@kirill.konshin/lint 0.5.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -3
- package/commands/spec-author.md +39 -0
- package/dist/configs/base.d.ts +4 -3
- package/dist/configs/base.js +61 -74
- package/dist/configs/imports.d.ts +3 -2
- package/dist/configs/imports.js +95 -146
- package/dist/configs/nx.d.ts +4 -3
- package/dist/configs/nx.js +31 -41
- package/dist/configs/prettier.d.ts +3 -2
- package/dist/configs/prettier.js +19 -16
- package/dist/configs/promise.d.ts +3 -2
- package/dist/configs/promise.js +16 -16
- package/dist/configs/react.d.ts +4 -3
- package/dist/configs/react.js +178 -217
- package/dist/configs/storybook.d.ts +4 -3
- package/dist/configs/storybook.js +22 -22
- package/dist/configs/tailwind.d.ts +4 -3
- package/dist/configs/tailwind.js +67 -91
- package/dist/configs/testing.d.ts +7 -6
- package/dist/configs/testing.js +112 -146
- package/dist/configs/turbo.d.ts +4 -3
- package/dist/configs/turbo.js +19 -27
- package/dist/configs/typescriptTypeAware.d.ts +4 -3
- package/dist/configs/typescriptTypeAware.js +99 -95
- package/dist/configs/unicorn.d.ts +3 -2
- package/dist/configs/unicorn.js +34 -41
- package/dist/exts.d.ts +2 -1
- package/dist/exts.js +10 -11
- package/dist/index.d.ts +44 -42
- package/dist/index.js +53 -85
- package/dist/lib.d.ts +21 -21
- package/dist/lib.js +262 -301
- package/dist/lintPrepare.d.ts +20 -17
- package/dist/lintPrepare.js +341 -371
- package/dist/lintStaged.d.ts +4 -3
- package/dist/lintStaged.js +25 -22
- package/dist/prettier.d.ts +4 -3
- package/dist/prettier.js +16 -17
- package/dist/restrictions.d.ts +11 -10
- package/dist/restrictions.js +18 -22
- package/dist/yarn.cjs +79 -98
- package/dist/yarn.d.cts +3 -2
- package/package.json +22 -8
- package/rules/agent.md +2 -0
- package/rules/openspec.md +1 -1
- package/skills/spec-steward/SKILL.md +4 -12
- package/skills/spec-steward/references/audit.md +18 -43
- package/skills/spec-steward/references/contract.md +9 -9
- package/skills/spec-steward/references/criteria.md +4 -4
- package/skills/spec-steward/references/review-format.md +6 -6
- package/skills/spec-steward/references/wiring.md +2 -2
- package/skills/spec-steward/references/worker.md +67 -0
- package/skills/spec-steward/sweeps.json +49 -0
- package/skills/spec-tools/SKILL.md +48 -0
- package/skills/spec-tools/references/contract.md +111 -0
- package/skills/spec-tools/references/gitlab.md +120 -0
- package/skills/spec-tools/scripts/cli.js +8129 -0
- package/skills/spec-verify/SKILL.md +153 -0
- package/dist/configs/base.d.ts.map +0 -1
- package/dist/configs/imports.d.ts.map +0 -1
- package/dist/configs/nx.d.ts.map +0 -1
- package/dist/configs/prettier.d.ts.map +0 -1
- package/dist/configs/promise.d.ts.map +0 -1
- package/dist/configs/react.d.ts.map +0 -1
- package/dist/configs/storybook.d.ts.map +0 -1
- package/dist/configs/tailwind.d.ts.map +0 -1
- package/dist/configs/testing.d.ts.map +0 -1
- package/dist/configs/turbo.d.ts.map +0 -1
- package/dist/configs/typescriptTypeAware.d.ts.map +0 -1
- package/dist/configs/unicorn.d.ts.map +0 -1
- package/dist/exts.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib.d.ts.map +0 -1
- package/dist/lintPrepare.d.ts.map +0 -1
- package/dist/lintStaged.d.ts.map +0 -1
- package/dist/prettier.d.ts.map +0 -1
- package/dist/restrictions.d.ts.map +0 -1
- package/dist/yarn.d.cts.map +0 -1
- package/skills/spec-steward/scripts/lib/align.mjs +0 -127
- package/skills/spec-steward/scripts/lib/checks.mjs +0 -589
- package/skills/spec-steward/scripts/lib/citations.mjs +0 -156
- package/skills/spec-steward/scripts/lib/corpus.mjs +0 -256
- package/skills/spec-steward/scripts/lib/coverage.mjs +0 -123
- package/skills/spec-steward/scripts/lib/evidence.mjs +0 -334
- package/skills/spec-steward/scripts/lib/git.mjs +0 -138
- package/skills/spec-steward/scripts/lib/review.mjs +0 -347
- package/skills/spec-steward/scripts/lib/scan.mjs +0 -364
- package/skills/spec-steward/scripts/lib/util.mjs +0 -161
- package/skills/spec-steward/scripts/lib/wire.mjs +0 -331
- package/skills/spec-steward/scripts/steward.mjs +0 -350
- package/skills/spec-steward/workflows/audit.js +0 -539
package/README.md
CHANGED
|
@@ -335,11 +335,46 @@ The generated `AGENTS.md` has a `# Custom Rules` section at the bottom — add p
|
|
|
335
335
|
In the project root, `lint-prepare`:
|
|
336
336
|
|
|
337
337
|
- Creates real `rules/`, `commands/` and `skills/` directories in `.agents/` (canonical, cross-tool) and `.claude/` (Claude Code), and only ever symlinks files into them.
|
|
338
|
-
- Links every `rules/*.md` and every skill folder (`skills/<name>/` with all its files, plus this `README.md` next to `SKILL.md` unless the skill ships one, so a skill can reference `@README.md`) into all three — e.g. `lint-repo`, which sets up the tooling above and audits the repo against the rules. Links point straight at the installed package's real location (`node_modules/@kirill.konshin/lint`, or the workspace package).
|
|
338
|
+
- Links every `rules/*.md`, every `commands/*.md` and every skill folder (`skills/<name>/` with all its files, plus this `README.md` next to `SKILL.md` unless the skill ships one, so a skill can reference `@README.md`) into all three — e.g. `lint-repo`, which sets up the tooling above and audits the repo against the rules. Links point straight at the installed package's real location (`node_modules/@kirill.konshin/lint`, or the workspace package).
|
|
339
339
|
- Mirrors your own files from `.agents/{rules,commands,skills}/` into `.claude/`; a file of yours wins over the package file at the same path.
|
|
340
340
|
- Removes dead links (e.g. after renaming a file) and the links it placed before but no longer needs. Each directory gets a generated `.gitignore` listing its links, so your own files stay tracked.
|
|
341
341
|
- Generates `AGENTS.md` for other assistants (Codex, Cursor, Copilot, …) with a `# Rules` section — one entry per rule (the package's and yours): its title, frontmatter `description`, the `paths` it is scoped to and a plain link to its `.agents/rules/<file>` entry — and symlinks `CLAUDE.md` to it. The links are never `@` imports: Claude Code loads `.claude/rules` itself and honours each rule's `paths`, while an import would load every rule into every session.
|
|
342
342
|
|
|
343
|
+
### OpenSpec
|
|
344
|
+
|
|
345
|
+
For a repository specified with [OpenSpec](https://github.com/Fission-AI/OpenSpec) the package ships one bin, `spec-tools` — a single self-contained file, `skills/spec-tools/scripts/cli.js` — three skills and a command:
|
|
346
|
+
|
|
347
|
+
- `spec-tools steward` and the `spec-steward` skill — the corpus gate (citations, binding, the scenario ratchet), the edit hook, corpus-quality audits and review rounds.
|
|
348
|
+
- `spec-tools` and its skill — the change gates, the workflow-evidence gate, the requirement-level specification diff, the code-conformance audit, and the glue a CI pipeline runs around a headless AI review (verdict gate, merge-request comment, HTML reports).
|
|
349
|
+
- `spec-verify` — the skill every audit worker loads.
|
|
350
|
+
- `/spec-author` — the command that writes or edits a specification in place, the default direct-edit path.
|
|
351
|
+
|
|
352
|
+
Which to reach for:
|
|
353
|
+
|
|
354
|
+
| Question | Tool | Outcome |
|
|
355
|
+
| --- | --- | --- |
|
|
356
|
+
| How do I write or change a rule? | `/spec-author` | The specification edited in place, with the code and tests that prove it |
|
|
357
|
+
| Do citations resolve, is every new scenario bound, did a rule weaken? | `spec-tools steward check` (the gate, the edit hook) | Fails the merge request on an error |
|
|
358
|
+
| Are these the right rules — placement, REQUIRED or ⚠️ ADVISORY, wording, evidence, duplicates, drift across repositories? | the `spec-steward` skill (audit on the `spec-tools` engine, review rounds, align) | A review file of proposals; the owner decides, steward applies; never a build failure |
|
|
359
|
+
| Does the code do exactly what the rules say, and do the bound tests assert them? | the `spec-verify` skill, run by `spec-tools` | Graded, quote-proved findings; PASS / FAIL / INCOMPLETE gates CI |
|
|
360
|
+
| Is the change finished, what did it change, how does CI run the audit? | `spec-tools` (gates, evidence, diff, tier, workers, verdict, comment, html) | Gates and reports for the pipeline |
|
|
361
|
+
|
|
362
|
+
Where each runs:
|
|
363
|
+
|
|
364
|
+
| What | In CI | Locally |
|
|
365
|
+
| --- | --- | --- |
|
|
366
|
+
| `spec-tools steward check` | `spec-tools gates`, every merge request: an error fails it | the edit hook on every edit Claude makes, and `spec-tools gates` before handing back |
|
|
367
|
+
| `spec-tools steward coverage`, `spec-tools steward evidence --json` | the coverage report, and the evidence `spec-tools scope` builds the spec-verify audit from | on demand |
|
|
368
|
+
| spec-steward's corpus audit, review rounds, `align` | never — it is heavy and its outcome is the owner's | on the owner's request: `spec-tools audit --audit spec-steward [--context <decisions file>]`, then the review rounds, where the accepted answers are applied |
|
|
369
|
+
| `spec-verify` | the reading jobs and the judge job: its verdict gates merge requests and the release | `spec-tools audit`, and `/spec-verify changed` before handing back a spec edit |
|
|
370
|
+
| `spec-tools gates`, `evidence`, `diff` | their own jobs | before handing back |
|
|
371
|
+
|
|
372
|
+
Specifications change only by hand, or when the steward skill applies the owner's accepted review answers; `spec-tools steward check --fix` makes the only mechanical repairs. No audit edits code or specifications.
|
|
373
|
+
|
|
374
|
+
The audits share their principles: `spec-verify`'s checks 2–5 are spec-steward's criteria 10, 9, 11 and 5, worded identically — steward asks whether the rule should change, `spec-verify` whether the code or the rule has diverged.
|
|
375
|
+
|
|
376
|
+
Setup and the GitLab pipeline are in the `spec-tools` skill.
|
|
377
|
+
|
|
343
378
|
### Safety checks
|
|
344
379
|
|
|
345
380
|
Only the files `lint-prepare` knows (package files and mirrors of yours) and dead links are touched: real files are never overwritten (e.g. your own `.claude/rules/*.md`) and nothing is written through a symlinked directory. `.codex/` is not touched: Codex reads `.agents/skills` and `AGENTS.md`, and the links earlier versions placed in `.codex/` stay until you delete them. `init`/`update` refuse to run if `CLAUDE.md` isn't a symlink. If `AGENTS.md` exists and wasn't generated by this tool, `init` skips it; use `update` to force regeneration.
|
|
@@ -400,9 +435,9 @@ Everything else — `prettier`, `listStaged`, extension lists (`tsExts`, …), `
|
|
|
400
435
|
|
|
401
436
|
## Development
|
|
402
437
|
|
|
403
|
-
###
|
|
438
|
+
### Build
|
|
404
439
|
|
|
405
|
-
|
|
440
|
+
`tsdown` builds two things (`tsdown.config.ts`): the library — ESM and declarations from `src/*.ts`, one file per module, plus the CommonJS Yarn entry from `src/yarn.cts` — into `dist`, and the `spec-tools` CLI — spec-steward included — into one self-contained file, `skills/spec-tools/scripts/cli.js`, which the skills and CI jobs name. `yarn typecheck` (`tsc --noEmit`) checks types; the build does not. Consumers load `dist`, and this monorepo builds lint first in its root `postinstall` before running `lint-prepare`.
|
|
406
441
|
|
|
407
442
|
### Eslint
|
|
408
443
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Spec author
|
|
3
|
+
description: Write or edit a capability specification in openspec/specs — the default direct-edit path
|
|
4
|
+
allowed-tools: Bash(openspec:*), Bash(spec-tools:*), Bash(spec-steward:*), Bash(yarn openspec:*), Bash(yarn spec-tools:*), Bash(yarn spec-steward:*), Bash(npx openspec:*), Bash(npx spec-tools:*), Bash(npx spec-steward:*), Bash(git diff*), Bash(git log*), Read, Edit, Write, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Write or edit a capability specification in place. This is the **default** path for specification work; the `/opsx:*` commands drive the full delta flow and run only when the user asks for them.
|
|
8
|
+
|
|
9
|
+
How a specification is written is the spec-steward model, [`references/model.md`](../skills/spec-steward/references/model.md), and what the gate checks is its [`references/contract.md`](../skills/spec-steward/references/contract.md); the rest of the tooling's contract is the spec-tools skill's [`references/contract.md`](../skills/spec-tools/references/contract.md); the change paths and who commits are in the root `AGENTS.md`. Read them; this file only sequences the work.
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. **Ask about scope first.** A workspace or branch, or the current tree? A direct edit, or a change folder because the work needs a written plan? Wait for an answer unless the user already gave one. The full delta flow is never yours to choose: take it only when the user names it.
|
|
14
|
+
|
|
15
|
+
2. **Find the capability.** `openspec list --specs`. Edit the existing `openspec/specs/<capability>/spec.md` that owns the behaviour; a new capability is a decision to raise out loud. A pattern that works system-wide earns its own folder.
|
|
16
|
+
|
|
17
|
+
3. **Read the neighbours.** A rule lives in the capability that owns it — cite a neighbour rather than restating it. If the new behaviour contradicts an existing requirement, surface it and let the user decide; do not paper over it in either place.
|
|
18
|
+
|
|
19
|
+
4. **If the user chose a change folder**: `openspec new change <name>`, set `skip_specs: true` in its `.openspec.yaml`, write `proposal.md`, `design.md` and `tasks.md`. The behaviour still lands as a direct edit — the folder carries the plan, never deltas. Set `skip_specs` yourself when the change is plainly simple (a bugfix, a small feature); ask when in doubt. The folder is archived inside the merge or pull request, on the user's word.
|
|
20
|
+
|
|
21
|
+
5. **Write it.** Name the observable failure the rule prevents and the cheapest evidence that catches it; if there is none, mark the requirement `**⚠️ Advisory:** <why review is its evidence>`, and record what is knowingly missing as `**⚠️ Known gap (<tracker>):** <what is missing>`. Write a new or edited statement in EARS (`When <trigger>, the <system> SHALL <response>`, `While <state>, …`, `If <condition>, then …`, or `The <system> SHALL …`), keeping the RFC 2119 keyword in capitals, and each new or edited scenario in Given/When/Then, one case each, Given only where a precondition matters; leave untouched text as it is. Scenario names are unique within the file:
|
|
22
|
+
|
|
23
|
+
```markdown
|
|
24
|
+
### Requirement: <name>
|
|
25
|
+
|
|
26
|
+
When <trigger>, the <system> SHALL <response>.
|
|
27
|
+
|
|
28
|
+
#### Scenario: <name>
|
|
29
|
+
|
|
30
|
+
- **GIVEN** <precondition, only where it matters>
|
|
31
|
+
- **WHEN** <trigger>
|
|
32
|
+
- **THEN** <observable outcome>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
A test that proves a scenario cites its anchor on its `describe`/`it`/`test` block; a code citation is optional and only has to resolve (the spec-steward contract).
|
|
36
|
+
|
|
37
|
+
6. **Verify**: run the checks the root `AGENTS.md` lists; where it lists none, `openspec validate --strict --all` and `spec-tools gates`.
|
|
38
|
+
|
|
39
|
+
7. **Hand back.** Say what changed and show the `spec-tools diff` first line. Do not commit, push, or archive; end with the decisions the user has to make.
|
package/dist/configs/base.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { DefaultIgnoreOptions } from "../index.js";
|
|
2
|
+
import { Linter } from "eslint";
|
|
3
|
+
//#region src/configs/base.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Core JS recommended rules, global ignores, browser + Node globals, and overrides of core ESLint
|
|
5
6
|
* rules.
|
|
@@ -26,4 +27,4 @@ export declare function includeIgnoreFile(importMetaUrl: string, ignoreFile: str
|
|
|
26
27
|
* the flag is off by default and enabling it without `importMetaUrl` is a hard error.
|
|
27
28
|
*/
|
|
28
29
|
export declare function defaultIgnoreConfig(option?: boolean | DefaultIgnoreOptions): Linter.Config[];
|
|
29
|
-
//#
|
|
30
|
+
//#endregion
|
package/dist/configs/base.js
CHANGED
|
@@ -1,80 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { GLOBAL_IGNORES, asOptions } from "../lib.js";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { includeIgnoreFile as includeIgnoreFile$1 } from "@eslint/config-helpers";
|
|
5
|
+
import js from "@eslint/js";
|
|
6
|
+
import globals from "globals";
|
|
7
|
+
//#region src/configs/base.ts
|
|
7
8
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
message: 'Please use next/navigation instead of next/router',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
// 'multiline-comment-style': ['warn', 'starred-block'],
|
|
49
|
-
'multiline-comment-style': 'off',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
];
|
|
9
|
+
* Core JS recommended rules, global ignores, browser + Node globals, and overrides of core ESLint
|
|
10
|
+
* rules.
|
|
11
|
+
*
|
|
12
|
+
* `eslint-config-next` already ignores `next-env.d.ts`, but only as a bare pattern ('next-env.d.ts'),
|
|
13
|
+
* which only matches at the config's own root - not when the Next app (and its generated
|
|
14
|
+
* next-env.d.ts) lives in a subdirectory, like demo/web-static/ here. It's auto-generated and
|
|
15
|
+
* explicitly marked "should not be edited", so exclude it recursively instead of just working
|
|
16
|
+
* around individual rules (its `///` reference directives otherwise trip multiline-comment-style,
|
|
17
|
+
* which would corrupt them if autofixed into a `/* *\/` block).
|
|
18
|
+
*/
|
|
19
|
+
function baseConfig() {
|
|
20
|
+
return [
|
|
21
|
+
js.configs.recommended,
|
|
22
|
+
{
|
|
23
|
+
name: "Global Ignores",
|
|
24
|
+
ignores: GLOBAL_IGNORES
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "Globals",
|
|
28
|
+
languageOptions: { globals: {
|
|
29
|
+
...globals.browser,
|
|
30
|
+
...globals.node
|
|
31
|
+
} }
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "ESLint overrides",
|
|
35
|
+
rules: {
|
|
36
|
+
"no-restricted-imports": ["error", { paths: [{
|
|
37
|
+
name: "next/router",
|
|
38
|
+
message: "Please use next/navigation instead of next/router"
|
|
39
|
+
}] }],
|
|
40
|
+
"multiline-comment-style": "off"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
];
|
|
53
44
|
}
|
|
54
45
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return includeIgnoreFileConfig(resolve(dirname(fileURLToPath(importMetaUrl)), ignoreFile));
|
|
46
|
+
* Convert an ignore file (`.gitignore`, `.prettierignore`, ...) into an ESLint ignores block,
|
|
47
|
+
* resolved next to the consumer's config file.
|
|
48
|
+
*/
|
|
49
|
+
function includeIgnoreFile(importMetaUrl, ignoreFile) {
|
|
50
|
+
return includeIgnoreFile$1(resolve(dirname(fileURLToPath(importMetaUrl)), ignoreFile));
|
|
61
51
|
}
|
|
62
52
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
throw new Error('[@kirill.konshin/lint] `defaultIgnore` was enabled, but `importMetaUrl` was not provided - the ' +
|
|
76
|
-
'location of the consumer config file cannot be auto-detected. ' +
|
|
77
|
-
'Pass `defaultIgnore: { importMetaUrl: import.meta.url }`.');
|
|
78
|
-
}
|
|
79
|
-
return [includeIgnoreFile(importMetaUrl, '.gitignore'), includeIgnoreFile(importMetaUrl, '.prettierignore')];
|
|
53
|
+
* The conventional ignore setup of this toolkit: `.gitignore` + `.prettierignore` next to the
|
|
54
|
+
* consumer's config file, both converted into ESLint ignores via {@link includeIgnoreFile} (both
|
|
55
|
+
* files must exist - the prettier scripts in README use the same two).
|
|
56
|
+
*
|
|
57
|
+
* There is nothing to auto-detect here - the consumer's config file location can't be known - so
|
|
58
|
+
* the flag is off by default and enabling it without `importMetaUrl` is a hard error.
|
|
59
|
+
*/
|
|
60
|
+
function defaultIgnoreConfig(option) {
|
|
61
|
+
const { enabled = false, importMetaUrl } = asOptions(option);
|
|
62
|
+
if (!enabled) return [];
|
|
63
|
+
if (!importMetaUrl) throw new Error("[@kirill.konshin/lint] `defaultIgnore` was enabled, but `importMetaUrl` was not provided - the location of the consumer config file cannot be auto-detected. Pass `defaultIgnore: { importMetaUrl: import.meta.url }`.");
|
|
64
|
+
return [includeIgnoreFile(importMetaUrl, ".gitignore"), includeIgnoreFile(importMetaUrl, ".prettierignore")];
|
|
80
65
|
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { baseConfig, defaultIgnoreConfig, includeIgnoreFile };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
|
+
//#region src/configs/imports.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Import linting via eslint-plugin-import-x: recommended rules + overrides + the default-export
|
|
4
5
|
* relaxation for files that legitimately default-export (framework/tooling conventions) - the
|
|
@@ -18,4 +19,4 @@ export declare function importSortConfig(): Linter.Config[];
|
|
|
18
19
|
* Autofixable removal of unused imports.
|
|
19
20
|
*/
|
|
20
21
|
export declare function unusedImportsConfig(): Linter.Config[];
|
|
21
|
-
//#
|
|
22
|
+
//#endregion
|
package/dist/configs/imports.js
CHANGED
|
@@ -1,152 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { tsExts } from "../exts.js";
|
|
2
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
3
|
+
import importXPlugin, { createNodeResolver } from "eslint-plugin-import-x";
|
|
4
|
+
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
5
|
+
import unusedImportsPlugin from "eslint-plugin-unused-imports";
|
|
6
|
+
//#region src/configs/imports.ts
|
|
6
7
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
`**/page.${tsExts}`,
|
|
71
|
-
`**/template.${tsExts}`,
|
|
72
|
-
`**/unauthorized.${tsExts}`,
|
|
73
|
-
`**/apple-icon.${tsExts}`,
|
|
74
|
-
`**/icon.${tsExts}`,
|
|
75
|
-
`**/manifest.${tsExts}`,
|
|
76
|
-
`**/opengraph-image.${tsExts}`,
|
|
77
|
-
`**/robots.${tsExts}`,
|
|
78
|
-
`**/sitemap.${tsExts}`,
|
|
79
|
-
`**/twitter-image.${tsExts}`,
|
|
80
|
-
],
|
|
81
|
-
rules: {
|
|
82
|
-
/*
|
|
83
|
-
* Stories always default-export `meta`, and story exports (`Default`, `WithArgs`, ...) are PascalCase by
|
|
84
|
-
* Storybook's own convention, which the general rules disallow. The stray naming-convention entry is
|
|
85
|
-
* deliberately out of place here - the rule itself lives in typescriptTypeAware.js, which
|
|
86
|
-
* defineLintConfig orders BEFORE this block precisely so this exemption wins (flat config is
|
|
87
|
-
* last-wins).
|
|
88
|
-
*/
|
|
89
|
-
'import-x/no-default-export': 'off',
|
|
90
|
-
'@typescript-eslint/naming-convention': 'off',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
];
|
|
8
|
+
* Import linting via eslint-plugin-import-x: recommended rules + overrides + the default-export
|
|
9
|
+
* relaxation for files that legitimately default-export (framework/tooling conventions) - the
|
|
10
|
+
* latter makes no sense without `import-x/no-default-export`, so it is not a separate block.
|
|
11
|
+
*
|
|
12
|
+
* eslint-config-next already registers `eslint-plugin-import` under the 'import' key, and ESLint 10
|
|
13
|
+
* hard-errors ("Cannot redefine plugin") if a later config tries to reuse that same key with a
|
|
14
|
+
* different plugin instance. eslint-plugin-import-x is a drop-in replacement, registered under its
|
|
15
|
+
* own 'import-x' key instead (its own recommended config does this registration for us).
|
|
16
|
+
*/
|
|
17
|
+
function importXConfig() {
|
|
18
|
+
return [
|
|
19
|
+
importXPlugin.configs["flat/recommended"],
|
|
20
|
+
{
|
|
21
|
+
name: "eslint-plugin-import-x overrides",
|
|
22
|
+
settings: { "import-x/resolver-next": [createTypeScriptImportResolver(), createNodeResolver()] },
|
|
23
|
+
rules: {
|
|
24
|
+
"import-x/no-unresolved": "off",
|
|
25
|
+
"import-x/named": "off",
|
|
26
|
+
"import-x/namespace": "off",
|
|
27
|
+
"import-x/default": "off",
|
|
28
|
+
"import-x/export": "off",
|
|
29
|
+
"import-x/no-named-as-default": "off",
|
|
30
|
+
"import-x/no-named-as-default-member": "off",
|
|
31
|
+
"import-x/no-default-export": "warn"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "Default export overrides",
|
|
36
|
+
files: [
|
|
37
|
+
"**/*.config.*",
|
|
38
|
+
`**/*.stories.${tsExts}`,
|
|
39
|
+
`**/.storybook/main.${tsExts}`,
|
|
40
|
+
`**/.storybook/preview.${tsExts}`,
|
|
41
|
+
"**/.lintstagedrc*",
|
|
42
|
+
"**/.prettierrc*",
|
|
43
|
+
`**/App.${tsExts}`,
|
|
44
|
+
`**/index.${tsExts}`,
|
|
45
|
+
`**/main.${tsExts}`,
|
|
46
|
+
"**/*.d.ts",
|
|
47
|
+
`**/default.${tsExts}`,
|
|
48
|
+
`**/error.${tsExts}`,
|
|
49
|
+
`**/forbidden.${tsExts}`,
|
|
50
|
+
`**/global-error.${tsExts}`,
|
|
51
|
+
`**/layout.${tsExts}`,
|
|
52
|
+
`**/loading.${tsExts}`,
|
|
53
|
+
`**/not-found.${tsExts}`,
|
|
54
|
+
`**/page.${tsExts}`,
|
|
55
|
+
`**/template.${tsExts}`,
|
|
56
|
+
`**/unauthorized.${tsExts}`,
|
|
57
|
+
`**/apple-icon.${tsExts}`,
|
|
58
|
+
`**/icon.${tsExts}`,
|
|
59
|
+
`**/manifest.${tsExts}`,
|
|
60
|
+
`**/opengraph-image.${tsExts}`,
|
|
61
|
+
`**/robots.${tsExts}`,
|
|
62
|
+
`**/sitemap.${tsExts}`,
|
|
63
|
+
`**/twitter-image.${tsExts}`
|
|
64
|
+
],
|
|
65
|
+
rules: {
|
|
66
|
+
"import-x/no-default-export": "off",
|
|
67
|
+
"@typescript-eslint/naming-convention": "off"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
];
|
|
94
71
|
}
|
|
95
72
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
'error',
|
|
113
|
-
{
|
|
114
|
-
groups: [
|
|
115
|
-
// 1. Polyfills - side-effect imports that must run first
|
|
116
|
-
['^\\u0000.*(polyfill|core-js|regenerator-runtime|whatwg-fetch|@vitest/web-worker)'],
|
|
117
|
-
// 2. React
|
|
118
|
-
['^react(-dom)?(/|$)'],
|
|
119
|
-
// 3. Third-party packages (node: builtins + npm packages)
|
|
120
|
-
['^node:', '^@?\\w'],
|
|
121
|
-
// 4. Local imports - path aliases then relative
|
|
122
|
-
['^@/', '^\\.'],
|
|
123
|
-
// 5. CSS/styles from libraries (side-effect, package path)
|
|
124
|
-
['^\\u0000@?\\w'],
|
|
125
|
-
// 6. Local CSS/styles (side-effect, relative path)
|
|
126
|
-
['^\\u0000'],
|
|
127
|
-
],
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
];
|
|
73
|
+
* Deterministic import ordering.
|
|
74
|
+
*/
|
|
75
|
+
function importSortConfig() {
|
|
76
|
+
return [{
|
|
77
|
+
name: "eslint-plugin-simple-import-sort",
|
|
78
|
+
files: [`**/*.${tsExts}`],
|
|
79
|
+
plugins: { "simple-import-sort": simpleImportSortPlugin },
|
|
80
|
+
rules: { "simple-import-sort/imports": ["error", { groups: [
|
|
81
|
+
["^\\u0000.*(polyfill|core-js|regenerator-runtime|whatwg-fetch|@vitest/web-worker)"],
|
|
82
|
+
["^react(-dom)?(/|$)"],
|
|
83
|
+
["^node:", "^@?\\w"],
|
|
84
|
+
["^@/", "^\\."],
|
|
85
|
+
["^\\u0000@?\\w"],
|
|
86
|
+
["^\\u0000"]
|
|
87
|
+
] }] }
|
|
88
|
+
}];
|
|
133
89
|
}
|
|
134
90
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
/*
|
|
144
|
-
* Unlike `@typescript-eslint/no-unused-vars/core` `no-unused-vars`, this rule is
|
|
145
|
-
* autofixable - `--fix` deletes the unused import specifier (or the whole import
|
|
146
|
-
* statement if nothing from it is used) instead of just reporting it.
|
|
147
|
-
*/
|
|
148
|
-
'unused-imports/no-unused-imports': 'error',
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
];
|
|
91
|
+
* Autofixable removal of unused imports.
|
|
92
|
+
*/
|
|
93
|
+
function unusedImportsConfig() {
|
|
94
|
+
return [{
|
|
95
|
+
name: "eslint-plugin-unused-imports",
|
|
96
|
+
plugins: { "unused-imports": unusedImportsPlugin },
|
|
97
|
+
rules: { "unused-imports/no-unused-imports": "error" }
|
|
98
|
+
}];
|
|
152
99
|
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { importSortConfig, importXConfig, unusedImportsConfig };
|
package/dist/configs/nx.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ToggleOptions } from "../index.js";
|
|
2
|
+
import { Linter } from "eslint";
|
|
3
|
+
//#region src/configs/nx.d.ts
|
|
3
4
|
export declare const nxPlugin: typeof import("@nx/eslint-plugin") | null;
|
|
4
5
|
/**
|
|
5
6
|
* Nx blocks: plugin registration + `@nx/dependency-checks` on every `package.json`.
|
|
@@ -13,4 +14,4 @@ export declare const nxPlugin: typeof import("@nx/eslint-plugin") | null;
|
|
|
13
14
|
*
|
|
14
15
|
*/
|
|
15
16
|
export declare function nxConfig(option?: boolean | ToggleOptions, strict?: boolean): Promise<Linter.Config[]>;
|
|
16
|
-
//#
|
|
17
|
+
//#endregion
|
package/dist/configs/nx.js
CHANGED
|
@@ -1,43 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolve } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const nxPlugin = hasNx ? (await import('@nx/eslint-plugin')).default : null;
|
|
1
|
+
import { hasNx, toolGate } from "../lib.js";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import * as jsoncParser from "jsonc-eslint-parser";
|
|
5
|
+
//#region src/configs/nx.ts
|
|
6
|
+
const nxPlugin = hasNx ? (await import("@nx/eslint-plugin")).default : null;
|
|
8
7
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
name: '@nx/dependency-checks',
|
|
33
|
-
files: ['**/package.json'],
|
|
34
|
-
languageOptions: {
|
|
35
|
-
parser: jsoncParser,
|
|
36
|
-
},
|
|
37
|
-
rules: {
|
|
38
|
-
// https://nx.dev/docs/technologies/eslint/eslint-plugin/guides/dependency-checks
|
|
39
|
-
'@nx/dependency-checks': 'error',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
];
|
|
8
|
+
* Nx blocks: plugin registration + `@nx/dependency-checks` on every `package.json`.
|
|
9
|
+
*
|
|
10
|
+
* Only `flat/base` (registers the '@nx' plugin, no rules of its own).
|
|
11
|
+
*
|
|
12
|
+
* `flat/typescript`/`flat/javascript` were deliberately NOT used - same call as with eslint-plugin-unicorn's
|
|
13
|
+
* recommended: they bundle the ENTIRE @stylistic plugin (hundreds of formatting rules - indent, quotes,
|
|
14
|
+
* semi, comma-dangle, ...) which would directly fight Prettier, plus a second full copy of
|
|
15
|
+
* @typescript-eslint/recommended that would relitigate rules already configured deliberately here.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
async function nxConfig(option, strict = false) {
|
|
19
|
+
const { enabled } = toolGate(option, strict, {
|
|
20
|
+
tool: "nx",
|
|
21
|
+
has: hasNx,
|
|
22
|
+
strictHas: strict && existsSync(resolve(process.cwd(), "nx.json"))
|
|
23
|
+
});
|
|
24
|
+
if (!enabled) return [];
|
|
25
|
+
return [...(await import("@nx/eslint-plugin")).default.configs["flat/base"], {
|
|
26
|
+
name: "@nx/dependency-checks",
|
|
27
|
+
files: ["**/package.json"],
|
|
28
|
+
languageOptions: { parser: jsoncParser },
|
|
29
|
+
rules: { "@nx/dependency-checks": "error" }
|
|
30
|
+
}];
|
|
43
31
|
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { nxConfig, nxPlugin };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
|
+
//#region src/configs/prettier.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Prettier compatibility: turns off all rules that would fight the formatter.
|
|
4
5
|
*
|
|
@@ -14,4 +15,4 @@ import type { Linter } from 'eslint';
|
|
|
14
15
|
* exported object to improve https://eslint.org/blog/2024/04/eslint-config-inspector/ experience.
|
|
15
16
|
*/
|
|
16
17
|
export declare function prettierConfig(): Linter.Config[];
|
|
17
|
-
//#
|
|
18
|
+
//#endregion
|