Repository navigation
feat(init): name the ignore entries a project's formatter and linters need - #735
Conversation
… need After init, a detected prettier, eslint, biome, oxlint, ruff or black is told which entries keep it off .taskless/ (and, for prettier, the skill stubs), in its own syntax. Printed, never written; carried on --json as ignores. A tool whose config already mentions .taskless is left out. Refs #732
|
@claude /review |
1025427 to
2a945b4
Compare
|
Claude finished @aibex-agent[bot]'s task in 3m 0s —— View job Review completeReview mode: incremental — read 0 prior review thread(s) before reviewing. The
Findings (2 new, posted inline)
Everything else — the detection/skip logic for the other tools, the |
| tool: "eslint", | ||
| files: [...ESLINT_CONFIG_FILES, ".eslintignore"], | ||
| needle: ".taskless", | ||
| markdown: false, | ||
| location: (found) => | ||
| found === undefined || found === ".eslintignore" | ||
| ? "your ESLint config" | ||
| : found, | ||
| render: (patterns) => ({ | ||
| patterns: [...patterns], | ||
| // A config object holding only `ignores` is a global ignore in a flat | ||
| // config, which is what keeps typescript-eslint from type-checking a | ||
| // fixture no tsconfig includes. | ||
| snippet: `{ ignores: [${quoted(patterns)}] }`, | ||
| }), | ||
| }, |
There was a problem hiding this comment.
[New] The eslint target's files list reuses ESLINT_CONFIG_FILES, which includes the legacy configs (.eslintrc, .eslintrc.js/.cjs/.mjs/.json/.yml/.yaml) ahead of the flat configs in the array. But render always emits flat-config-only syntax: { ignores: [...] }.
If a project is detected as using eslint (e.g. only .eslintrc.json, or via eslintConfig in package.json/the eslint dependency with no config file at all) and has no flat eslint.config.*, location(found) will report that legacy file (or "your ESLint config") as where to add the snippet, but { ignores: [".taskless/"] } is not valid in a legacy .eslintrc* file — there is no ignores key in that schema, and pasting a bare object literal into .eslintrc.json isn't even valid JSON. The correct legacy mechanism is a .eslintignore file (gitignore syntax) or ignorePatterns in the config, not a flat-config ignore object.
Since detectRepository can mark eslint detected purely via the legacy configs or a bare dependency, this isn't an edge case — any project still on ESLint 8/legacy config (not yet migrated to flat config) will get a snippet that doesn't apply to its actual config format.
There was a problem hiding this comment.
Fixed in cc86297. A project with only a legacy .eslintrc* (or .eslintignore) is now pointed at .eslintignore with gitignore-style lines. The flat { ignores: [...] } object is used only when a flat eslint.config.* exists, or when no config file exists at all (only the dependency), since flat is ESLint 9's default. Flat configs are checked first, so a project in the middle of migrating gets the form ESLint 9 reads. Tests cover the legacy case and the both-present case, and the spec states the rule.
| { | ||
| tool: "ruff", | ||
| files: ["ruff.toml", ".ruff.toml", PYPROJECT], | ||
| needle: ".taskless", | ||
| markdown: false, | ||
| location: (found) => | ||
| found === undefined || found === PYPROJECT | ||
| ? `${PYPROJECT}, under [tool.ruff]` | ||
| : found, | ||
| render: (patterns) => { | ||
| const bare = patterns.map((pattern) => pattern.replace(/\/$/, "")); | ||
| return { | ||
| patterns: bare, | ||
| snippet: `extend-exclude = [${quoted(bare)}]`, | ||
| }; | ||
| }, | ||
| }, | ||
| { | ||
| tool: "black", | ||
| files: [PYPROJECT], | ||
| // black takes a regular expression, so its entry is the escaped form. | ||
| // ruff's plain `.taskless` in the same file does not count for black. | ||
| needle: String.raw`\.taskless`, | ||
| markdown: false, | ||
| location: () => `${PYPROJECT}, under [tool.black]`, | ||
| render: (patterns) => { | ||
| const expression = `/(${patterns | ||
| .map((pattern) => | ||
| pattern.replace(/\/$/, "").replaceAll(".", String.raw`\.`) | ||
| ) | ||
| .join("|")})/`; | ||
| return { | ||
| patterns: [expression], | ||
| snippet: `extend-exclude = '${expression}'`, | ||
| }; | ||
| }, | ||
| }, |
There was a problem hiding this comment.
[New] The already-handled check (lines 204-212) uses plain substring matching, which breaks in the other direction from the one the tests cover.
ruff's needle is the plain string .taskless. black's rendered entry in a shared pyproject.toml is the escaped regex form, e.g. extend-exclude = '/(\.taskless)/'. That string contains the substring .taskless (just drop the leading backslash), so if a project has only [tool.black] configured with that exclude and no [tool.ruff] exclude at all, findToolIgnores will read pyproject.toml for the ruff target, find .taskless as a substring of black's \.taskless entry, and mark ruff as already "handled" — even though ruff itself was never excluded.
The test added at packages/cli/test/tool-ignores.test.ts ("does not count ruff's entry as black's") only checks the direction where ruff is configured and black isn't; it doesn't check the reverse (black configured, ruff isn't), which is exactly the case that breaks here. Worth either using a less substring-prone check (e.g. a word/table-scoped match) or adding the reverse-direction test and fixing the false positive.
There was a problem hiding this comment.
Fixed in cc86297. The needles are now regexes. Every tool except black matches .taskless only when it isn't preceded by a backslash, so black's \.taskless no longer counts as ruff's entry. Black keeps matching the escaped form only. Added the reverse-direction test (black excluded, ruff not → ruff is named), and the spec now says black's entry doesn't count as another tool's.
…ry from counting for ruff Review findings on #735.
After
taskless init, a project's formatter and type-aware linter failed on files Taskless installed (.taskless/bin/cli.mjs,cli.lock.json,taskless.json, the skill file) and on rule fixtures under.taskless/rules, until the person excluded each one by hand. This is the first of the "two smaller things" in #732.What changes
init(batch and wizard) now names the ignore entries each detected formatter or linter still needs. It covers prettier, eslint, biome, oxlint, ruff and black, the toolsdetectrecognises that walk the whole tree:.taskless/. Prettier, which formats markdown, also gets each tool directory's Taskless skill stub..taskless(black needs the escaped\.taskless, so ruff's entry in a sharedpyproject.tomldoesn't count for it). The notice goes away once the project has handled it, so it doesn't repeat on everyinit.init --jsoncarries the same list asignores(always present). Theinitrecipe tells an agent to offer the edit in the same commit as the install, and to make it only when the user agrees.Why print rather than write
These are the person's configs. Several are code (
eslint.config.js,oxlint.config.ts) or JSON with comments, none is a fileinitowns, and outside.taskless/initwrites only its own skill stubs and permission rules. An agent working from the--jsonenvelope can apply the entries once the user agrees.detectis unchanged: it runs before anything is installed, so there are no Taskless files or stub paths to name yet.Checks
pnpm typecheck,pnpm lint, and the full cli suite (3424 passed). OpenSpec changeinit-tool-ignoresis archived in this PR (one ADDED requirement incli-init). Patch changeset.Refs #732