From 783ec71689244e29085f16be3a39cde7acbe0249 Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sun, 29 Nov 2026 14:12:50 -0800 Subject: [PATCH 1/2] feat(route): guide golangci-lint through forbidigo and depguard detect has recognized golangci-lint since v0.10.0, but route named it only as a tool with no guide of its own, so an agent in a Go repository had to work out golangci-lint's catch-alls and its v1/v2 config layout by hand. Add a create-legacy-rule recipe and a route paragraph for it, and pin detection for each config spelling and for v1 and v2 configs. --- .changeset/detect-golangci-lint-guide.md | 5 + .../proposal.md | 37 +++++++ .../specs/cli-legacy-rule-recipes/spec.md | 41 +++++++ .../specs/cli-rule-routing/spec.md | 43 ++++++++ .../tasks.md | 17 +++ .../specs/cli-legacy-rule-recipes/spec.md | 12 ++ openspec/specs/cli-rule-routing/spec.md | 6 + .../agent/create-legacy-rule.golangci-lint.md | 104 ++++++++++++++++++ packages/cli/src/prompts/recipes.ts | 7 ++ packages/cli/test/agent-extensions.test.ts | 33 +++--- packages/cli/test/detect.test.ts | 42 ++++++- packages/cli/test/legacy-ladder.test.ts | 34 +++++- packages/cli/test/prompts.test.ts | 11 ++ 13 files changed, 369 insertions(+), 23 deletions(-) create mode 100644 .changeset/detect-golangci-lint-guide.md create mode 100644 openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/proposal.md create mode 100644 openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-legacy-rule-recipes/spec.md create mode 100644 openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-rule-routing/spec.md create mode 100644 openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/tasks.md create mode 100644 packages/cli/src/agent/create-legacy-rule.golangci-lint.md diff --git a/.changeset/detect-golangci-lint-guide.md b/.changeset/detect-golangci-lint-guide.md new file mode 100644 index 000000000..22fef3acc --- /dev/null +++ b/.changeset/detect-golangci-lint-guide.md @@ -0,0 +1,5 @@ +--- +"@taskless/cli": patch +--- + +golangci-lint now has its own `create-legacy-rule` recipe and a paragraph in `route`, naming `forbidigo` and `depguard` as the catch-alls to check first and saying where settings go in a v1 and a v2 config. Detection itself was already in place; an agent in a Go repository previously got only the generic recipe for it. diff --git a/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/proposal.md b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/proposal.md new file mode 100644 index 000000000..6dfc89292 --- /dev/null +++ b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/proposal.md @@ -0,0 +1,37 @@ +## Why + +taskless/cli#712 reports that `detect --json` found no linter in a Go repository configured with golangci-lint v2, so the legacy ladder was skipped and had to be re-derived by hand. The detection half does not reproduce: `LINTER_SIGNALS` has carried a `golangci-lint` entry (all four config spellings, the `go.mod` dependency, and the `golangci-lint` invocation) since v0.10.0, and both v0.13.7 and HEAD report it for the issue's exact repository. + +What does reproduce is the second half. `route` names golangci-lint only on its "also detected, with no guide of their own" line and sends the agent to the generic `create-legacy-rule` recipe, which names catch-all rules for ESLint, Ruff, Biome and pylint, and none for Go. An agent following it has to work out for itself that `forbidigo` and `depguard` are golangci-lint's catch-alls, and that settings live in different places in a v1 and a v2 config. That is the "re-derived by hand" in the report. + +## What Changes + +- A `create-legacy-rule.golangci-lint.md` recipe: check `forbidigo` and `depguard` first, then find a bundled linter with `golangci-lint help linters`, confirm with `golangci-lint linters`, write settings in the config's own version (`linters.settings` for v2, `linters-settings` for v1) without migrating it, and verify with `golangci-lint config verify`. `detect` counts no golangci-lint custom rules, so the recipe never authors a `ruleguard` rule or a module plugin. +- A golangci-lint paragraph in `route`'s per-linter passage, naming both catch-alls. +- Detection tests for each config spelling, for the issue's v2 config and its v1 form, and for a Go repository with no golangci-lint config. + +Every claim in the recipe was checked against golangci-lint's own documentation (configuration file, CLI, linter settings, migration guide). Two corrected an assumption: `forbidigo` has a default pattern list, and `depguard` with no rules allows only the standard library, so the recipe says neither is a no-op when left unconfigured. + +Nothing here is **BREAKING**. Pre-1.0, a new recipe variant is a `patch`. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `cli-legacy-rule-recipes`: "Legacy recipes use what a tool ships before anything is written" gains the golangci-lint check and two scenarios. +- `cli-rule-routing`: "Route describes each detected linter" gains a scenario for the golangci-lint paragraph. + +## Impact + +- `packages/cli/src/agent/create-legacy-rule.golangci-lint.md`: new. +- `packages/cli/src/prompts/recipes.ts`: one `LEGACY_LINTER_GUIDE` entry. +- `packages/cli/test/{detect,prompts,legacy-ladder,agent-extensions}.test.ts`: new cases. +- `packages/cli/src/detect/scan.ts`: untouched; the catalog entry already existed. + +## Delivery shape + +**Single PR.** One recipe, one paragraph, their tests, the spec deltas and the archive fit one reviewable diff. diff --git a/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-legacy-rule-recipes/spec.md b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-legacy-rule-recipes/spec.md new file mode 100644 index 000000000..1a6715a33 --- /dev/null +++ b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-legacy-rule-recipes/spec.md @@ -0,0 +1,41 @@ +## MODIFIED Requirements + +### Requirement: Legacy recipes use what a tool ships before anything is written + +Every `create-legacy-rule` recipe, generic or per-tool, SHALL direct the agent to first establish whether a rule the tool already ships solves the request, including the tool's configurable catch-all rules. A recipe SHALL name the catch-all rules for its tool explicitly, because a search for the request's subject does not surface a catch-all rule. + +A per-tool recipe SHALL state the check its tool always performs first: + +- Ruff: whether `banned-api` (TID251) covers the request. +- ESLint: whether a core rule covers it, with `no-restricted-syntax` and `no-restricted-imports` (and their `@typescript-eslint/` counterparts) named as the catch-alls, before any plugin. +- Biome: whether an existing rule makes the problem go away, with `noRestrictedImports` and `noRestrictedGlobals` named as the catch-alls. +- Oxlint: whether an existing rule makes the problem go away, with `no-restricted-imports` and `no-restricted-globals` named as the catch-alls. The recipe SHALL state that Oxlint has no `no-restricted-syntax`. +- pylint: whether a shipped message or the `deprecated-modules`, `preferred-modules`, or `bad-functions` options cover it. +- flake8: whether `banned-modules` from `flake8-tidy-imports` covers it. The flake8 recipe SHALL NOT include a discovery step. +- golangci-lint: whether `forbidigo` or `depguard` covers it. The recipe SHALL state that neither is a no-op when unconfigured, and SHALL direct the agent to write settings in the config version the file already uses: `linters.settings` for a `version: "2"` config, `linters-settings` otherwise. + +#### Scenario: Ruff tries banned-api first + +- **WHEN** the agent follows the Ruff recipe for a request to forbid an API +- **THEN** the recipe SHALL direct it to check `banned-api` before any other step + +#### Scenario: ESLint tries a core rule before a plugin + +- **WHEN** the agent follows the ESLint recipe +- **THEN** it SHALL check core rules and the named catch-alls before considering any plugin from the curated list + +#### Scenario: flake8 goes straight to its catch-all + +- **WHEN** the agent follows the flake8 recipe +- **THEN** it SHALL be directed to `banned-modules` without a rule-discovery step + +#### Scenario: golangci-lint tries its catch-alls first + +- **WHEN** the agent follows the golangci-lint recipe +- **THEN** it SHALL check `forbidigo` and `depguard` before searching the bundled linters for one that fits + +#### Scenario: A golangci-lint config keeps its version + +- **WHEN** the repository's golangci-lint config has no `version: "2"` key +- **THEN** the agent SHALL write the linter's settings under `linters-settings` +- **AND** SHALL NOT migrate the config to v2 as a side effect diff --git a/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-rule-routing/spec.md b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-rule-routing/spec.md new file mode 100644 index 000000000..836625d73 --- /dev/null +++ b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/specs/cli-rule-routing/spec.md @@ -0,0 +1,43 @@ +## MODIFIED Requirements + +### Requirement: Route describes each detected linter + +The `route` recipe SHALL include, for each linter `detect` reports that can host a legacy rule, one paragraph saying what the tool is for, what the agent always checks first in it, and the recipe command to fetch for it. The paragraphs SHALL be rendered when the recipe is served, and SHALL appear only for linters detected in the repository. + +A detected tool that can host a legacy rule and has no paragraph SHALL be named in the recipe with the command to fetch the generic recipe for it, and the recipe SHALL state that steps 1 and 2 of the legacy ladder still apply to it. `route` SHALL NOT state or imply that a linter `detect` reported is absent. Formatters and Taskless's own engines are not legacy hosts and SHALL NOT be named this way. + +When the recipe is rendered from a scan, it SHALL state that `detect` recognizes a fixed list of tools, so the repository may run others. + +#### Scenario: Only detected linters are described + +- **WHEN** `detect` reports Ruff and no other linter +- **THEN** the served `route` recipe SHALL contain the Ruff paragraph +- **AND** SHALL NOT contain a paragraph for any other linter + +#### Scenario: A tool with no legacy recipe gets no paragraph + +- **WHEN** `detect` reports only `prettier` +- **THEN** the served `route` recipe SHALL contain no linter paragraph + +#### Scenario: Oxlint is described when detected + +- **WHEN** `detect` reports `oxlint` and no other linter +- **THEN** the served `route` recipe SHALL contain the Oxlint paragraph +- **AND** SHALL NOT say that no linter was found + +#### Scenario: A detected linter with no paragraph is still named + +- **WHEN** `detect` reports `eslint` and `stylelint` +- **THEN** the served `route` recipe SHALL contain the ESLint paragraph +- **AND** SHALL name `stylelint` with the command to fetch `create-legacy-rule` for it + +#### Scenario: A formatter is not offered as a legacy destination + +- **WHEN** `detect` reports `eslint` and `prettier` +- **THEN** the served `route` recipe SHALL NOT name `prettier` as a linter to fetch a recipe for + +#### Scenario: golangci-lint is described when detected + +- **WHEN** `detect` reports `golangci-lint` and no other linter +- **THEN** the served `route` recipe SHALL contain the golangci-lint paragraph, naming `forbidigo` and `depguard` as its catch-alls +- **AND** SHALL NOT list golangci-lint among the tools with no guide of their own diff --git a/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/tasks.md b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/tasks.md new file mode 100644 index 000000000..81f4a1d73 --- /dev/null +++ b/openspec/changes/archive/2026-11-29-golangci-lint-legacy-recipe/tasks.md @@ -0,0 +1,17 @@ +## 1. Implementation + +- [x] 1.1 Reproduce #712 with the built CLI against the issue's repository, and confirm the `golangci-lint` catalog entry exists in v0.13.7 and HEAD. +- [x] 1.2 Confirm the recipe's golangci-lint claims against golangci-lint's documentation. +- [x] 1.3 Add `packages/cli/src/agent/create-legacy-rule.golangci-lint.md`. +- [x] 1.4 Add the golangci-lint entry to `LEGACY_LINTER_GUIDE` in `packages/cli/src/prompts/recipes.ts`. +- [x] 1.5 Add tests: each config spelling, v2 and v1 configs, a Go repository with no config, the `route` paragraph, and the recipe's catch-all order. +- [x] 1.6 Add a `patch` changeset. + +## 2. Spec + +- [x] 2.1 Write both deltas, restating each requirement in full with every existing scenario. +- [x] 2.2 `pnpm openspec validate --strict`, the dry-run archive scenario check, then archive. + +## 3. Verification + +- [x] 3.1 `pnpm typecheck`, `pnpm lint`, and the CLI test suite pass. diff --git a/openspec/specs/cli-legacy-rule-recipes/spec.md b/openspec/specs/cli-legacy-rule-recipes/spec.md index 523277908..85e40964e 100644 --- a/openspec/specs/cli-legacy-rule-recipes/spec.md +++ b/openspec/specs/cli-legacy-rule-recipes/spec.md @@ -18,6 +18,7 @@ A per-tool recipe SHALL state the check its tool always performs first: - Oxlint: whether an existing rule makes the problem go away, with `no-restricted-imports` and `no-restricted-globals` named as the catch-alls. The recipe SHALL state that Oxlint has no `no-restricted-syntax`. - pylint: whether a shipped message or the `deprecated-modules`, `preferred-modules`, or `bad-functions` options cover it. - flake8: whether `banned-modules` from `flake8-tidy-imports` covers it. The flake8 recipe SHALL NOT include a discovery step. +- golangci-lint: whether `forbidigo` or `depguard` covers it. The recipe SHALL state that neither is a no-op when unconfigured, and SHALL direct the agent to write settings in the config version the file already uses: `linters.settings` for a `version: "2"` config, `linters-settings` otherwise. #### Scenario: Ruff tries banned-api first @@ -34,6 +35,17 @@ A per-tool recipe SHALL state the check its tool always performs first: - **WHEN** the agent follows the flake8 recipe - **THEN** it SHALL be directed to `banned-modules` without a rule-discovery step +#### Scenario: golangci-lint tries its catch-alls first + +- **WHEN** the agent follows the golangci-lint recipe +- **THEN** it SHALL check `forbidigo` and `depguard` before searching the bundled linters for one that fits + +#### Scenario: A golangci-lint config keeps its version + +- **WHEN** the repository's golangci-lint config has no `version: "2"` key +- **THEN** the agent SHALL write the linter's settings under `linters-settings` +- **AND** SHALL NOT migrate the config to v2 as a side effect + ### Requirement: Rule discovery is confirmed against the installed version Where a tool's rule set is too large to match a request against locally, the recipe SHALL direct the agent to find candidate rules on the tool's rules page by web search or fetch, then confirm each candidate against the installed version with the tool's own command before enabling it. The Ruff recipe SHALL use `ruff rule `, the Biome recipe `biome explain `, and the Oxlint recipe `oxlint --rules --format default`. diff --git a/openspec/specs/cli-rule-routing/spec.md b/openspec/specs/cli-rule-routing/spec.md index f2df2da7b..370032e62 100644 --- a/openspec/specs/cli-rule-routing/spec.md +++ b/openspec/specs/cli-rule-routing/spec.md @@ -373,6 +373,12 @@ When the recipe is rendered from a scan, it SHALL state that `detect` recognizes - **WHEN** `detect` reports `eslint` and `prettier` - **THEN** the served `route` recipe SHALL NOT name `prettier` as a linter to fetch a recipe for +#### Scenario: golangci-lint is described when detected + +- **WHEN** `detect` reports `golangci-lint` and no other linter +- **THEN** the served `route` recipe SHALL contain the golangci-lint paragraph, naming `forbidigo` and `depguard` as its catch-alls +- **AND** SHALL NOT list golangci-lint among the tools with no guide of their own + ### Requirement: Route asks the user only when the ladder does not decide The `route` recipe SHALL present the viable options to the user with their diff --git a/packages/cli/src/agent/create-legacy-rule.golangci-lint.md b/packages/cli/src/agent/create-legacy-rule.golangci-lint.md new file mode 100644 index 000000000..68e175831 --- /dev/null +++ b/packages/cli/src/agent/create-legacy-rule.golangci-lint.md @@ -0,0 +1,104 @@ +# Topic: create-legacy-rule (golangci-lint) (CLI v%(CLI_VERSION)s / topic v1) + +%(ONE_COMMAND_PER_CALL)s + +## You are here +This is `create-legacy-rule` for golangci-lint. It solves a request by +enabling or configuring a linter golangci-lint already bundles. When +nothing here fits, re-run `%(TASKLESS_CLI)s agent route` and continue from +step 3 of its legacy ladder. + +## Goal +Find the bundled linter that makes the problem go away, confirm it in the +installed version, and enable it in the repository's golangci-lint +configuration, in the config version that file already uses. + +## Preconditions +- `%(TASKLESS_CLI)s detect --json` reports `golangci-lint`. +- No auth required. + +## Steps + +1. **Always check the catch-all linters first.** They take your own list, + and a search for the request's subject will not surface them: + - `forbidigo`: bans identifiers matched by a regular expression, each + with its own message, through `forbid` entries of `pattern` and + `msg`. With `analyze-types: true`, a `pkg` pattern matches the + import path, so `^v1.Dump$` can mean one package's `Dump` and not + another's. It covers most "never call X" requests. + - `depguard`: bans imports, each with a reason, through named `rules` + whose `deny` entries are `pkg` and `desc`, scoped with `files`. + It covers "never import X" and "use Y instead of X". + + Neither is a no-op when left unconfigured. `forbidigo`'s default list + bans `fmt.Print*`, `print` and `println`, so a repo that enables it with + no `forbid` list relies on that default: keep those patterns when you + add yours. `depguard` with no `rules` allows only the standard library, + so never enable it without writing the rule. + +2. **Otherwise, find a bundled linter.** golangci-lint bundles many + linters, each with its own checks. `golangci-lint help linters` lists + every linter the installed build has, and the docs describe each one's + settings at https://golangci-lint.run/docs/linters/configuration/. + There is no `llms.txt` index for this site. + +3. **Confirm against the installed version and config.** Run + `golangci-lint linters`, which lists the linters the current config + enables and disables. In a v2 config, read `linters.default` before + `linters.enable`: it sets the starting set (`standard`, `all`, `none`, + or `fast`), so a linter can already be on without being listed. + +4. **Edit the config golangci-lint actually reads, in its own version.** + It reads `.golangci.yml`, `.golangci.yaml`, `.golangci.toml`, or + `.golangci.json`, searching from the directory of the first analyzed + path up to the root. `golangci-lint config path` prints the one in use. + - **`version: "2"`:** settings go under `linters.settings.`, + and the linter is named in `linters.enable`: + ```yaml + version: "2" + linters: + enable: + - forbidigo + - depguard + settings: + forbidigo: + forbid: + - pattern: ^fmt\.Print.*$ + msg: Use the logger in internal/log. + depguard: + rules: + main: + deny: + - pkg: github.com/pkg/errors + desc: Use the standard errors package. + ``` + - **No `version` key (a v1 config):** settings go under the top-level + `linters-settings.` instead, with the same keys below it. + Do not migrate the file to v2 as a side effect: `golangci-lint migrate` + rewrites the whole config and drops its comments, so it is the + user's decision. + + Then run `golangci-lint config verify`, which checks the file against + golangci-lint's JSON schema. + +5. **No bundled linter fits: return to `route`.** `detect` does not count + golangci-lint custom rules, so the repository's own rules can never + reach the threshold here. Do not write a `ruleguard` rule or build a + module plugin. Return to `%(TASKLESS_CLI)s agent route` and continue to + step 3 of its legacy ladder, a Taskless rule. + +6. **Report, and say who runs it.** Show the file you changed and the + command that shows the linter firing, e.g. `golangci-lint run ./...`. + `%(TASKLESS_CLI)s check` does NOT run golangci-lint. + +## Important Notes + +- Do not invent linter settings from memory: confirm each key against the + linter's section of the configuration docs before writing it. +- A linter the installed build does not list is not available, however + current the docs are. Upgrading golangci-lint is the user's decision. + +## See Also + +- `%(TASKLESS_CLI)s agent route`: continue down the legacy ladder when no bundled linter fits +- `%(TASKLESS_CLI)s agent create-sg-rule`: ast-grep parses Go, for the Taskless rule diff --git a/packages/cli/src/prompts/recipes.ts b/packages/cli/src/prompts/recipes.ts index 76312f858..dfb5fb658 100644 --- a/packages/cli/src/prompts/recipes.ts +++ b/packages/cli/src/prompts/recipes.ts @@ -704,6 +704,13 @@ check them first, with the \`deprecated-modules\`, from \`flake8-tidy-imports\` first, which bans a module with a message. It is a plugin package, so the repo may need to add it.`, ], + [ + "golangci-lint", + `**golangci-lint** runs a bundle of Go linters from one config. Always +check \`forbidigo\` (bans identifiers by pattern, each with a message) +and \`depguard\` (bans imports, each with a reason) first: they are the +catch-alls, and a search for the request's subject will not surface them.`, + ], ]; /** diff --git a/packages/cli/test/agent-extensions.test.ts b/packages/cli/test/agent-extensions.test.ts index 2e9c13081..310c14768 100644 --- a/packages/cli/test/agent-extensions.test.ts +++ b/packages/cli/test/agent-extensions.test.ts @@ -637,20 +637,25 @@ describe("taskless agent --tool (variant lookup)", () => { await rm(cwd, { recursive: true, force: true }); }); - it.each(["ruff", "eslint", "biome", "oxlint", "pylint", "flake8"])( - "serves the %s variant of create-legacy-rule", - async (tool) => { - const result = await runCli([ - "agent", - "create-legacy-rule", - `--tool=${tool}`, - "-d", - cwd, - ]); - expect(result.exitCode).toBe(0); - expect(result.stdout).toContain(`# Topic: create-legacy-rule (${tool})`); - } - ); + it.each([ + "ruff", + "eslint", + "biome", + "oxlint", + "pylint", + "flake8", + "golangci-lint", + ])("serves the %s variant of create-legacy-rule", async (tool) => { + const result = await runCli([ + "agent", + "create-legacy-rule", + `--tool=${tool}`, + "-d", + cwd, + ]); + expect(result.exitCode).toBe(0); + expect(result.stdout).toContain(`# Topic: create-legacy-rule (${tool})`); + }); it("takes the value as a separate argument, not as a second topic", async () => { const result = await runCli([ diff --git a/packages/cli/test/detect.test.ts b/packages/cli/test/detect.test.ts index e38f232f9..101febbe3 100644 --- a/packages/cli/test/detect.test.ts +++ b/packages/cli/test/detect.test.ts @@ -135,11 +135,47 @@ describe("taskless detect", () => { expect(result.languages).toContain("Ruby"); }); - it("detects golangci-lint for a Go repo", async () => { + it.each([ + ".golangci.yml", + ".golangci.yaml", + ".golangci.toml", + ".golangci.json", + ])("detects golangci-lint from %s in a Go repo", async (config) => { + await writeFile(join(cwd, "go.mod"), "module example.com/x\n", "utf8"); + await writeFile(join(cwd, config), "", "utf8"); + const result = await detect(cwd); + expect( + result.linters.find((linter) => linter.name === "golangci-lint")?.evidence + ).toEqual([config]); + expect(result.languages).toContain("Go"); + }); + + // taskless/cli#712: the survey's repository, a golangci-lint v2 config. + it.each([ + ["v2", 'version: "2"\nlinters:\n enable:\n - forbidigo\n - gosec\n'], + ["v1", "linters:\n enable:\n - forbidigo\n - gosec\n"], + ])( + "detects golangci-lint from a %s config, with no custom-rule count", + async (_version, config) => { + await writeFile( + join(cwd, "go.mod"), + "module example.com/x\n\ngo 1.24\n", + "utf8" + ); + await writeFile(join(cwd, ".golangci.yml"), config, "utf8"); + const result = await detect(cwd); + const golangci = result.linters.find( + (linter) => linter.name === "golangci-lint" + ); + expect(golangci?.evidence).toEqual([".golangci.yml"]); + expect(golangci?.customRules).toBeUndefined(); + } + ); + + it("reports no linter for a Go repo with no golangci config", async () => { await writeFile(join(cwd, "go.mod"), "module example.com/x\n", "utf8"); - await writeFile(join(cwd, ".golangci.yml"), "", "utf8"); const result = await detect(cwd); - expect(linterNames(result)).toContain("golangci-lint"); + expect(result.linters).toEqual([]); expect(result.languages).toContain("Go"); }); diff --git a/packages/cli/test/legacy-ladder.test.ts b/packages/cli/test/legacy-ladder.test.ts index c47b19f96..b566fad2e 100644 --- a/packages/cli/test/legacy-ladder.test.ts +++ b/packages/cli/test/legacy-ladder.test.ts @@ -223,18 +223,40 @@ describe("the per-tool legacy recipes", () => { ); }); + it("has golangci-lint check its catch-alls in the config's own version", () => { + const golangci = tool("golangci-lint"); + const catchAll = golangci.indexOf( + "**Always check the catch-all linters first.**" + ); + expect(catchAll).toBeGreaterThan(-1); + expect(catchAll).toBeLessThan( + golangci.indexOf("**Otherwise, find a bundled linter.**") + ); + expect(golangci).toContain("`forbidigo`"); + expect(golangci).toContain("`depguard`"); + expect(golangci).toContain("`golangci-lint help linters`"); + expect(golangci).toContain("`linters.settings.`"); + expect(golangci).toContain("`linters-settings.`"); + expect(golangci).toContain("Do not write a `ruleguard` rule"); + }); + it("sends flake8 straight to banned-modules with no discovery step", () => { const flake8 = tool("flake8"); expect(flake8).toContain("**Use `banned-modules`.**"); expect(flake8).not.toContain("--list"); }); - it.each(["ruff", "eslint", "biome", "oxlint", "pylint", "flake8"])( - "has the %s recipe say Taskless does not run the linter", - (name) => { - expect(tool(name)).toMatch(/check` does NOT run /); - } - ); + it.each([ + "ruff", + "eslint", + "biome", + "oxlint", + "pylint", + "flake8", + "golangci-lint", + ])("has the %s recipe say Taskless does not run the linter", (name) => { + expect(tool(name)).toMatch(/check` does NOT run /); + }); }); describe("the custom-rule threshold", () => { diff --git a/packages/cli/test/prompts.test.ts b/packages/cli/test/prompts.test.ts index 720b7e40f..33c65adde 100644 --- a/packages/cli/test/prompts.test.ts +++ b/packages/cli/test/prompts.test.ts @@ -676,6 +676,7 @@ describe("route's per-linter passage", () => { "**Ruff**", "**pylint**", "**flake8**", + "**golangci-lint**", ]; it("describes only the linters it is told were detected", () => { @@ -702,6 +703,16 @@ describe("route's per-linter passage", () => { expect(route).not.toContain("found no linter here"); }); + it("describes golangci-lint and its catch-alls when detected", () => { + const route = getPrompt("route", { linters: ["golangci-lint"] }); + expect(route).toContain("**golangci-lint**"); + expect(route).toContain("`forbidigo`"); + expect(route).toContain("`depguard`"); + expect(route).toContain("create-legacy-rule --tool=golangci-lint`."); + expect(route).not.toContain("with no guide of their own"); + expect(route).not.toContain("found no linter here"); + }); + it("never drops a detected linter that has no guide of its own", () => { const route = getPrompt("route", { linters: ["eslint", "stylelint"] }); expect(route).toContain("**ESLint**"); From d81147d68dc6b3685c04e8484d941b861a903eed Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sun, 29 Nov 2026 14:16:47 -0800 Subject: [PATCH 2/2] fix(recipe): escape the dot in the forbidigo pkg example --- packages/cli/src/agent/create-legacy-rule.golangci-lint.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/agent/create-legacy-rule.golangci-lint.md b/packages/cli/src/agent/create-legacy-rule.golangci-lint.md index 68e175831..6487723d2 100644 --- a/packages/cli/src/agent/create-legacy-rule.golangci-lint.md +++ b/packages/cli/src/agent/create-legacy-rule.golangci-lint.md @@ -24,7 +24,7 @@ configuration, in the config version that file already uses. - `forbidigo`: bans identifiers matched by a regular expression, each with its own message, through `forbid` entries of `pattern` and `msg`. With `analyze-types: true`, a `pkg` pattern matches the - import path, so `^v1.Dump$` can mean one package's `Dump` and not + import path, so `^v1\.Dump$` can mean one package's `Dump` and not another's. It covers most "never call X" requests. - `depguard`: bans imports, each with a reason, through named `rules` whose `deny` entries are `pkg` and `desc`, scoped with `files`.