Repository navigation
feat(detect): Improve existing linter detection #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
openspec/changes/archive/2026-10-21-improve-linter-detection/.openspec.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| schema: spec-driven | ||
| created: 2026-10-21 |
24 changes: 24 additions & 0 deletions
24
openspec/changes/archive/2026-10-21-improve-linter-detection/proposal.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| ## Why | ||
|
|
||
| `taskless detect` recognised a linter mostly by its dedicated config file. Most ecosystems install a linter as a dependency and run it on its defaults, or keep its config inside a manifest, so a repository could run a linter and still read as having none. Fifteen fixtures modelled on each ecosystem's common setup all came back with no linters: clippy configured in `Cargo.toml` or run in CI, rubocop or standard as a gem, phpstan, phpcs or pint as a Composer dev dependency, golangci-lint as a Go `tool`, SwiftLint as a SwiftPM plugin, flake8 configured in `setup.cfg` or `tox.ini`, ruff in a `requirements-dev.txt` or a pre-commit hook, and prettier or stylelint configured in `package.json`. #574 fixed the same problem for `pyproject.toml` dev dependencies; this change covers the rest. | ||
|
|
||
| ## What Changes | ||
|
|
||
| - **Every ecosystem's dependency manifest is read.** `Gemfile` gems for Ruby, `composer.json` `require` and `require-dev` for PHP, `go.mod` `require` and `tool` directives for Go (matched by module-path prefix, so `/v2/cmd/...` counts), and `Package.swift` package URLs for Swift. Python reads every pip requirements file (`requirements-dev.txt`, `dev-requirements.txt`, `requirements/*.txt`, and the `.in` sources pip-tools compiles), not only `requirements.txt`. | ||
| - **Config inside a manifest counts.** `[lints.clippy]` and `[workspace.lints.clippy]` in `Cargo.toml`, a `[flake8]` section in `setup.cfg` or `tox.ini`, and the `prettier` and `stylelint` keys in `package.json`, alongside the existing `[tool.*]` tables and `eslintConfig`. | ||
| - **A root CI or hook config that runs a linter is evidence**, read from the same root-only files `ci` and `hooks` report. Only commands count: the command fields of a YAML, JSON, or TOML config (`run`, `script`, `entry`, `uses`, `repo`, and the like) and the non-comment lines of a script, never a comment or a step's `name`. Evidence looks like `.github/workflows/ci.yml (cargo clippy)` or `.pre-commit-config.yaml (astral-sh/ruff-pre-commit)`. This is the only evidence for clippy run on its defaults, since clippy ships with the toolchain and is never a dependency. Being a Rust repository is not by itself evidence of clippy. | ||
| - **New linters**: `standard` (Ruby), `pint` and `php-cs-fixer` (PHP). | ||
| - **Missing config filenames**: `eslint.config.{mts,cts}`; prettier's `.prettierrc.{mjs,json5,toml,ts,mts,cts}` and `prettier.config.{ts,mts,cts}`; stylelint's `.stylelintrc.{mjs,ts}` and `stylelint.config.ts`. Each list was checked against the tool's own source (ESLint 9.39, Prettier 3.8.1, stylelint 17.16 via cosmiconfig 9). | ||
| - **Recipe**: `detect` (v4) describes the new evidence kinds. | ||
|
|
||
| The JSON shape is unchanged: these are new `evidence` strings and new `name` values. | ||
|
|
||
| ## Capabilities | ||
|
|
||
| ### Modified Capabilities | ||
|
|
||
| - `cli-detect`: adds "Detect recognizes a linter its ecosystem installs or runs by default". The existing requirements are unchanged. | ||
|
|
||
| ## Delivery Shape | ||
|
|
||
| **Stacked, merging forward**, on #574. Each PR only adds evidence `detect` reports, so either one is safe on `main` by itself. This is the tip, so it archives the change. |
49 changes: 49 additions & 0 deletions
49
...ec/changes/archive/2026-10-21-improve-linter-detection/specs/cli-detect/spec.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| ## ADDED Requirements | ||
|
|
||
| ### Requirement: Detect recognizes a linter its ecosystem installs or runs by default | ||
|
|
||
| `detect` SHALL report a linter that a repository installs as a dependency, configures inside a manifest, or runs from its CI or commit-hook configuration, even when the linter has no dedicated config file. A dependency SHALL be read from the manifests of the linter's own languages: `package.json` for JavaScript and TypeScript; `pyproject.toml` and every pip requirements file for Python; `Gemfile` for Ruby; `composer.json` `require` and `require-dev` for PHP; `go.mod` `require` and `tool` directives for Go, matched by module-path prefix; and `Package.swift` package URLs for Swift. | ||
|
|
||
| A CI or commit-hook configuration SHALL be read only from the root-level files that `ci` and `hooks` are detected from, and SHALL be evidence only when one of its commands runs the linter: a command field of a YAML, JSON, or TOML config, or a non-comment line of a script. A comment or a label such as a step's `name` SHALL NOT be evidence. Each match SHALL be reported as the file path followed by the matched command. | ||
|
|
||
| A linter that ships with a language toolchain rather than being declared as a dependency, such as clippy, SHALL NOT be reported merely because that language is present. | ||
|
|
||
| #### Scenario: clippy configured in Cargo.toml | ||
|
|
||
| - **WHEN** a `Cargo.toml` declares `[lints.clippy]` or `[workspace.lints.clippy]` | ||
| - **THEN** `detect --json` SHALL report `clippy` with evidence naming that manifest and table | ||
|
|
||
| #### Scenario: clippy run from CI | ||
|
|
||
| - **WHEN** a root GitHub Actions workflow runs `cargo clippy`, with or without a `+toolchain` argument | ||
| - **THEN** `detect --json` SHALL report `clippy` with evidence naming the workflow file and the command | ||
|
|
||
| #### Scenario: A Rust repository that never configures or runs clippy | ||
|
|
||
| - **WHEN** a repository has a `Cargo.toml` and nothing configures or runs clippy | ||
| - **THEN** `detect --json` SHALL report `Rust` among `languages` and SHALL NOT report `clippy` | ||
|
|
||
| #### Scenario: A linter declared as a dependency in its ecosystem's manifest | ||
|
|
||
| - **WHEN** `rubocop` is a gem in a `Gemfile`, `phpstan/phpstan` is in `composer.json` `require-dev`, `github.com/golangci/golangci-lint/v2/cmd/golangci-lint` is a `go.mod` `tool`, or `ruff` is listed in `requirements-dev.txt` | ||
| - **THEN** `detect --json` SHALL report that linter with a dependency marker naming the manifest | ||
|
|
||
| #### Scenario: Config inside a shared file | ||
|
|
||
| - **WHEN** `setup.cfg` or `tox.ini` has a `[flake8]` section, or `package.json` has a top-level `prettier` or `stylelint` key | ||
| - **THEN** `detect --json` SHALL report that linter with evidence naming the file and the section or key | ||
|
|
||
| #### Scenario: A linter run from a pre-commit hook | ||
|
|
||
| - **WHEN** a root `.pre-commit-config.yaml` uses `astral-sh/ruff-pre-commit` | ||
| - **THEN** `detect --json` SHALL report `ruff` with evidence naming `.pre-commit-config.yaml` | ||
|
|
||
| #### Scenario: A CI config below the root is not evidence | ||
|
|
||
| - **WHEN** the only command that runs a linter is in a CI config inside a sub-directory | ||
| - **THEN** `detect --json` SHALL NOT report that linter from it | ||
|
|
||
| #### Scenario: A mention that is not a command is not evidence | ||
|
|
||
| - **WHEN** a root CI or hook config names a linter only in a comment, a step's `name`, or another field that is not a command | ||
| - **THEN** `detect --json` SHALL NOT report that linter from it |
11 changes: 11 additions & 0 deletions
11
openspec/changes/archive/2026-10-21-improve-linter-detection/tasks.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## 1. Detection | ||
|
|
||
| - [x] 1.1 In `detect/scan.ts`, read dependencies from `Gemfile`, `composer.json`, `go.mod`, `Package.swift`, and every pip requirements file, keyed by the linter's languages. | ||
| - [x] 1.2 Generalize `pyprojectTables` to `manifestTables` (adding `Cargo.toml`), and add `iniSections`, `packageJsonKeys`, and `invocations` matched against the commands `automationCommands` extracts from the root `automationFiles`, never their comments or labels. | ||
| - [x] 1.3 Add `standard`, `pint`, and `php-cs-fixer`, and the missing ESLint, Prettier, and stylelint config filenames, checked against each tool's source. | ||
|
|
||
| ## 2. Recipe and tests | ||
|
|
||
| - [x] 2.1 `detect` recipe (v4), the evidence description in `schemas/detect.ts`, and the `DetectedLinter` doc. | ||
| - [x] 2.2 Tests: one case per new evidence source, plus clippy not inferred from Rust alone and no invocation read below the root. | ||
| - [x] 2.3 `pnpm typecheck`, `pnpm lint`, and the detect tests pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.