@kirill.konshin/lint 0.3.5 → 0.4.0

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.
Files changed (60) hide show
  1. package/README.md +135 -56
  2. package/dist/configs/base.d.ts +29 -0
  3. package/dist/configs/base.d.ts.map +1 -0
  4. package/{configs → dist/configs}/base.js +7 -25
  5. package/dist/configs/imports.d.ts +21 -0
  6. package/dist/configs/imports.d.ts.map +1 -0
  7. package/{configs → dist/configs}/imports.js +0 -10
  8. package/dist/configs/nx.d.ts +16 -0
  9. package/dist/configs/nx.d.ts.map +1 -0
  10. package/{configs → dist/configs}/nx.js +3 -8
  11. package/dist/configs/prettier.d.ts +17 -0
  12. package/dist/configs/prettier.d.ts.map +1 -0
  13. package/{configs → dist/configs}/prettier.js +0 -3
  14. package/dist/configs/promise.d.ts +6 -0
  15. package/dist/configs/promise.d.ts.map +1 -0
  16. package/{configs → dist/configs}/promise.js +0 -3
  17. package/dist/configs/react.d.ts +84 -0
  18. package/dist/configs/react.d.ts.map +1 -0
  19. package/{configs → dist/configs}/react.js +14 -41
  20. package/dist/configs/storybook.d.ts +14 -0
  21. package/dist/configs/storybook.d.ts.map +1 -0
  22. package/{configs → dist/configs}/storybook.js +3 -6
  23. package/dist/configs/tailwind.d.ts +29 -0
  24. package/dist/configs/tailwind.d.ts.map +1 -0
  25. package/{configs → dist/configs}/tailwind.js +9 -24
  26. package/dist/configs/testing.d.ts +22 -0
  27. package/dist/configs/testing.d.ts.map +1 -0
  28. package/{configs → dist/configs}/testing.js +11 -25
  29. package/dist/configs/turbo.d.ts +9 -0
  30. package/dist/configs/turbo.d.ts.map +1 -0
  31. package/{configs → dist/configs}/turbo.js +6 -6
  32. package/dist/configs/typescriptTypeAware.d.ts +20 -0
  33. package/dist/configs/typescriptTypeAware.d.ts.map +1 -0
  34. package/{configs → dist/configs}/typescriptTypeAware.js +10 -23
  35. package/dist/configs/unicorn.d.ts +10 -0
  36. package/dist/configs/unicorn.d.ts.map +1 -0
  37. package/{configs → dist/configs}/unicorn.js +0 -4
  38. package/dist/index.d.ts +80 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/{index.js → dist/index.js} +5 -54
  41. package/dist/lib.d.ts +116 -0
  42. package/dist/lib.d.ts.map +1 -0
  43. package/{lib.js → dist/lib.js} +69 -145
  44. package/dist/lintPrepare.d.ts +105 -0
  45. package/dist/lintPrepare.d.ts.map +1 -0
  46. package/{lintPrepare.js → dist/lintPrepare.js} +12 -67
  47. package/dist/yarn.cjs +117 -0
  48. package/dist/yarn.d.cts +8 -0
  49. package/dist/yarn.d.cts.map +1 -0
  50. package/package.json +42 -34
  51. package/rules/code-style.md +2 -0
  52. package/rules/github.md +17 -9
  53. package/rules/gitlab.md +68 -17
  54. package/rules/mui.md +1 -1
  55. package/rules/nextjs.md +1 -1
  56. package/rules/npm-yarn.md +51 -6
  57. package/rules/nx.md +6 -6
  58. package/rules/typescript.md +13 -7
  59. package/rules/webstorm.md +20 -0
  60. package/index.d.ts +0 -281
package/README.md CHANGED
@@ -5,9 +5,11 @@ ESLint + Prettier + lint-staged + Husky configuration, plus AI agent rules & ski
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- $ yarn add -D eslint prettier @kirill.konshin/lint husky lint-staged
8
+ $ yarn add -D eslint prettier @kirill.konshin/lint @yarnpkg/types husky lint-staged
9
9
  ```
10
10
 
11
+ Every project whose `packageManager` is Yarn must directly install `@yarnpkg/types`; Yarn PnP does not allow `yarn.config.cjs` to require a transitive dependency.
12
+
11
13
  ### PNPM
12
14
 
13
15
  https://eslint.org/docs/latest/use/getting-started#manual-set-up
@@ -17,6 +19,68 @@ auto-install-peers=true
17
19
  node-linker=hoisted
18
20
  ```
19
21
 
22
+ ## Yarn constraints
23
+
24
+ `yarn.config.cjs`:
25
+
26
+ ```js
27
+ /** @type {import('@yarnpkg/types')} */
28
+ const { defineConfig } = require('@yarnpkg/types');
29
+ const { defineYarnConfig } = require('@kirill.konshin/lint/yarn');
30
+
31
+ module.exports = defineConfig(defineYarnConfig());
32
+ ```
33
+
34
+ `defineYarnConfig` reads the root `overrides` and `resolutions`. Each named non-peer dependency in a leaf package must use the root override reference or resolution range; `overrides` wins when both fields name the same package. Nested npm overrides and `$dependency` references are supported.
35
+
36
+ When the root has no `overrides` field, `@types/node`, `@types/react`, `@types/react-dom`, `next`, `eslint`, `typescript`, and `vite` must each use one range across the workspace. The root declaration wins; otherwise the first leaf path supplies the range. Run `yarn constraints --fix` to apply unambiguous changes.
37
+
38
+ ## `.gitignore`
39
+
40
+ ```gitignore
41
+ .DS_Store
42
+ *.tsbuildinfo
43
+ .tscache
44
+ .turbo
45
+ .nx
46
+ .next
47
+ build
48
+ coverage
49
+ dist
50
+ dist-*
51
+ node_modules
52
+ npm-debug*
53
+ out
54
+ *storybook.log
55
+ yarn-error*
56
+ .yarnrc.local.yml
57
+
58
+ # https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
59
+ .pnp.*
60
+ .yarn/*
61
+ !.yarn/patches
62
+ !.yarn/plugins
63
+ !.yarn/releases
64
+ !.yarn/sdks
65
+ !.yarn/versions
66
+ ```
67
+
68
+ List need to be verified, especially `build`, `coverage`, `dist` must be verified not to exclude legit folders.
69
+
70
+ ## `.prettierignore`
71
+
72
+ Create `.prettierignore` file:
73
+
74
+ ```gitignore
75
+ .idea
76
+ .husky
77
+ .yarn
78
+ ```
79
+
80
+ https://prettier.io/docs/ignore:
81
+
82
+ > Prettier will also follow rules specified in the ".gitignore" file if it exists in the same directory from which it is run.
83
+
20
84
  ## ESLint
21
85
 
22
86
  `eslint.config.mjs`:
@@ -24,20 +88,24 @@ node-linker=hoisted
24
88
  Every tool integration — Next.js, Nx, Turborepo, Storybook, Jest, Vitest, Tailwind — is auto-detected (the detection results are exported as `has*` booleans for debugging). Pass options (JSDoc-typed, see `LintOptions` in `index.js`) to force any of them on/off or to supply tool-specific settings:
25
89
 
26
90
  ```js
91
+ import { defineConfig } from 'eslint/config';
27
92
  import { defineLintConfig } from '@kirill.konshin/lint';
28
93
 
29
94
  // every tool integration auto-detected
30
- export default defineLintConfig({
31
- defaultIgnore: { importMetaUrl: import.meta.url }, // .gitignore + .prettierignore as ESLint ignores
32
- });
95
+ export default defineConfig(
96
+ await defineLintConfig({
97
+ defaultIgnore: { importMetaUrl: import.meta.url }, // .gitignore + .prettierignore as ESLint ignores
98
+ }),
99
+ );
33
100
  ```
34
101
 
35
102
  Config can be extended, `defineLintConfig` returns a `Promise` (natively awaited by ESLint), to compose with your own blocks, `await` it:
36
103
 
37
104
  ```js
105
+ import { defineConfig } from 'eslint/config';
38
106
  import { defineLintConfig, includeIgnoreFile } from '@kirill.konshin/lint';
39
107
 
40
- export default [
108
+ export default defineConfig([
41
109
  ...(await defineLintConfig({ defaultIgnore: { importMetaUrl: import.meta.url } })),
42
110
  {
43
111
  name: 'Custom rules',
@@ -46,7 +114,7 @@ export default [
46
114
  },
47
115
  },
48
116
  includeIgnoreFile(import.meta.url, '.customignore'), // extra ignore files beyond defaultIgnore
49
- ];
117
+ ]);
50
118
  ```
51
119
 
52
120
  ### Full Config Example
@@ -59,40 +127,43 @@ Default behavior in the comments, all tools are optional (see [Detection](#detec
59
127
  - `{ /* tool options *./ }` — object configuration implies `enabled: true` even if omitted; set `enabled: false` to force OFF while keeping the other options in place, see example
60
128
 
61
129
  ```js
130
+ import { defineConfig } from 'eslint/config';
62
131
  import { defineLintConfig, scanWorkspace } from '@kirill.konshin/lint';
63
132
 
64
133
  // function form shown
65
- export default defineLintConfig(() => ({
66
- // enabled (default true) = tools are ON unless said otherwise;
67
- // strict (default false) = same-scope package probes only, no workspace evidence scans
68
- // `{ enabled: false, strict: true }` is ideal for per-package configs
69
- detection: { enabled: true, strict: false }, // default
70
-
71
- // ON by default; app roots auto-detected (next.config.*, package.json depending on next, src/{app,pages}/);
72
- // can be force OFF; several apps auto-detect as array; pass the package root, not src
73
- next: { rootDir: 'apps/web' }, // string or array
74
-
75
- storybook: true, // force ON if detection failed
76
- turbo: false, // force OFF
77
- nx: true,
78
- jest: false,
79
- vitest: { enabled: true }, // object form implies ON; { enabled: false, ... } turns OFF keeping options
80
-
81
- // ON by default; auto-detected single entry CSS; explicit path always wins over the scan
82
- tailwind: { cssConfigPath: 'apps/web/src/app/index.css' },
83
-
84
- // OFF by default
85
- defaultIgnore: {
86
- importMetaUrl: import.meta.url, // required, error if turned on via `defaultIgnore: true`
87
- },
134
+ export default defineConfig(
135
+ await defineLintConfig({
136
+ // enabled (default true) = tools are ON unless said otherwise;
137
+ // strict (default false) = same-scope package probes only, no workspace evidence scans
138
+ // `{ enabled: false, strict: true }` is ideal for per-package configs
139
+ detection: { enabled: true, strict: false }, // default
140
+
141
+ // ON by default; app roots auto-detected (next.config.*, package.json depending on next, src/{app,pages}/);
142
+ // can be force OFF; several apps auto-detect as array; pass the package root, not src
143
+ next: { rootDir: 'apps/web' }, // string or array
144
+
145
+ storybook: true, // force ON if detection failed
146
+ turbo: false, // force OFF
147
+ nx: true,
148
+ jest: false,
149
+ vitest: { enabled: true }, // object form implies ON; { enabled: false, ... } turns OFF keeping options
150
+
151
+ // ON by default; auto-detected single entry CSS; explicit path always wins over the scan
152
+ tailwind: { cssConfigPath: 'apps/web/src/app/index.css' },
153
+
154
+ // OFF by default
155
+ defaultIgnore: {
156
+ importMetaUrl: import.meta.url, // required, error if turned on via `defaultIgnore: true`
157
+ },
88
158
 
89
- // OFF by default (slow) - see "Type-aware rules"
90
- typeAware: {
91
- allowDefaultProject: scanWorkspace('{vite,vitest}.config.ts'), // no default; absolute paths are relativized; ** globs are not supported
92
- maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 50, // defaults to the list length, (default 8), set it explicitly only when supplying multi-match globs
93
- tsconfigRootDir: process.cwd(), // defaults to the detected workspace root
94
- },
95
- }));
159
+ // OFF by default (slow) - see "Type-aware rules"
160
+ typeAware: {
161
+ allowDefaultProject: scanWorkspace('{vite,vitest}.config.ts'), // no default; absolute paths are relativized; ** globs are not supported
162
+ maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 50, // defaults to the list length, (default 8), set it explicitly only when supplying multi-match globs
163
+ tsconfigRootDir: process.cwd(), // defaults to the detected workspace root
164
+ },
165
+ }),
166
+ );
96
167
  ```
97
168
 
98
169
  ### Per-package configs (monorepo)
@@ -101,23 +172,27 @@ ESLint 10 resolves the config **per linted file**: the nearest `eslint.config.mj
101
172
 
102
173
  ```js
103
174
  // apps/web/eslint.config.mjs
175
+ import { defineConfig } from 'eslint/config';
104
176
  import rootConfig from '../../eslint.config.mjs';
105
177
 
106
- export default [...(await rootConfig), { rules: { 'tailwindcss/no-custom-classname': 'off' } }];
178
+ export default defineConfig([...(await rootConfig), { rules: { 'tailwindcss/no-custom-classname': 'off' } }]);
107
179
  ```
108
180
 
109
181
  …or simply call `defineLintConfig` again with the options this app needs:
110
182
 
111
183
  ```js
112
184
  // apps/web/eslint.config.mjs
185
+ import { defineConfig } from 'eslint/config';
113
186
  import { fileURLToPath } from 'node:url';
114
187
  import { defineLintConfig } from '@kirill.konshin/lint';
115
188
 
116
- export default defineLintConfig({
117
- detection: { enabled: false, strict: true }, // fully explicit: this config only sees its own scope
118
- // do not use workspace-wide auto-scan, provide exactly ONE from THIS leaf package
119
- tailwind: { cssConfigPath: fileURLToPath(new URL('src/app/index.css', import.meta.url)) },
120
- });
189
+ export default defineConfig(
190
+ await defineLintConfig({
191
+ detection: { enabled: false, strict: true }, // fully explicit: this config only sees its own scope
192
+ // do not use workspace-wide auto-scan, provide exactly ONE from THIS leaf package
193
+ tailwind: { cssConfigPath: fileURLToPath(new URL('src/app/index.css', import.meta.url)) },
194
+ }),
195
+ );
121
196
  ```
122
197
 
123
198
  ⚠️ Nearest-wins means root-only blocks (e.g. `defaultIgnore`, custom rules) do NOT apply to the subtree unless inherited or re-declared.
@@ -157,6 +232,9 @@ trim_trailing_whitespace = true
157
232
  insert_final_newline = false
158
233
  max_line_length = 120
159
234
 
235
+ [*.md]
236
+ max_line_length = 99999
237
+
160
238
  [*.{js,jsx,ts,tsx,cjs,cts,mjs,mts,md,mdx,htm,html,vue}]
161
239
  indent_size = 4
162
240
 
@@ -298,7 +376,7 @@ export default [
298
376
  - **`tailwindEntry` const removed** → call the exported `findTailwindEntry(ignores)` when needed
299
377
  - **New:** every block is a composable exported `*Config()` function; gated ones accept `true` / `false` / an options object with optional `enabled` (defaults to `true` in the object form); `typeAware: true` enables the (slow) type-aware rules
300
378
  - **`prettier` is now a declared (required) peer dependency** — it was always required by the setup, so no action needed in practice
301
- - **TypeScript consumers get real types** — `index.d.ts` ships with the package (`LintOptions` and friends)
379
+ - **TypeScript consumers get generated declarations** — `LintOptions` and all public exports are typed from source
302
380
  - **Hoisting** if tools can't find packages, fix it once in the package manager config: keep default hoisting (drop `installConfig.hoistingLimits`/`nohoist`), on pnpm add `public-hoist-pattern[]=<pkg>` to `.npmrc`, or add the tool to root `devDependencies`. Run eslint with `LINT_DEBUG=1` to trace detection.
303
381
  - **Scans follow the declared workspace.** `scanWorkspace` (also used by all evidence scans) now covers the root directory plus the real `workspaces`/`pnpm-workspace.yaml` packages via `@manypkg/get-packages` instead of a blind ≤5-level glob — config files in directories that are not declared workspace members are only found via the root scan, and the depth limit is gone.
304
382
  - `has*` probes are anchored at the **workspace root** (via `local-pkg`) instead of this package's install location — identical for standard root installs.
@@ -307,15 +385,15 @@ Everything else — `prettier`, `listStaged`, extension lists (`tsExts`, …), `
307
385
 
308
386
  ## Development
309
387
 
310
- ### Why raw JS (no build)
388
+ ### Incremental TypeScript build
311
389
 
312
- Deliberately plain ESM, **no TypeScript build**: the config is loaded by `eslint.config.mjs` and pre-commit `lint:staged` before anything is built, so a `dist/` `main` would force a build before the repo could lint — not worth it for a config package.
390
+ The package compiles ESM and declarations from `src/*.ts`, plus the CommonJS Yarn entry from `src/yarn.cts`, with `tsc --build`. Build state is cached in `.tscache/tsconfig.tsbuildinfo`; consumers load `dist`, and this monorepo builds lint first in its root `postinstall` before running `lint-prepare`.
313
391
 
314
392
  ### Eslint
315
393
 
316
- The package ships hand-written types (`index.d.ts`) that pull real types from the underlying packages — `Linter.Config` from `eslint`, `PluginSettings` from `eslint-plugin-tailwindcss`, `prettier`'s `Config`, `lint-staged`'s `Configuration` — so `defineLintConfig` options and all exports are fully typed in `eslint.config.mjs` (via editor inference) and `eslint.config.ts`.
394
+ Declarations are generated from the TypeScript source and retain the underlying package types — `Linter.Config`, Tailwind plugin settings, Prettier `Config`, and lint-staged `Configuration`.
317
395
 
318
- **Every** block lives in a themed `configs/*.js` file and is exported as a standalone function for manual composition (and easy testing/mocking), in the order `defineLintConfig` applies them: `baseConfig` (JS recommended + global ignores + globals + core-rule overrides), `defaultIgnoreConfig`, `reactConfig` (the whole React family, see below), `prettierConfig`, `storybookConfig`, `typeAwareConfig` (off by default; ordered before the import blocks so its naming-convention rule loses to the default-export relaxation), `importXConfig` (includes the default-export relaxation for conventional files), `importSortConfig`, `unusedImportsConfig`, `promiseConfig`, `unicornConfig`, `turboConfig`, `tailwindConfig`, `nxConfig`, `jestConfig`, `vitestConfig`, `testConfig`.
396
+ **Every** block lives in a themed `src/configs/*.ts` file and is exported as a standalone function for manual composition (and easy testing/mocking), in the order `defineLintConfig` applies them: `baseConfig` (JS recommended + global ignores + globals + core-rule overrides), `defaultIgnoreConfig`, `reactConfig` (the whole React family, see below), `prettierConfig`, `storybookConfig`, `typeAwareConfig` (off by default; ordered before the import blocks so its naming-convention rule loses to the default-export relaxation), `importXConfig` (includes the default-export relaxation for conventional files), `importSortConfig`, `unusedImportsConfig`, `promiseConfig`, `unicornConfig`, `turboConfig`, `tailwindConfig`, `nxConfig`, `jestConfig`, `vitestConfig`, `testConfig`.
319
397
 
320
398
  Tool-gated functions take the same value as their `defineLintConfig` flag and gate themselves (`tailwindConfig(true)`, `nxConfig(false)` → `[]`, `tailwindConfig({ cssConfigPath })`). `reactConfig(nextFlag, strict)` is the whole family in its load-bearing order — Next is just a shortcut to an opinionated React/TypeScript setup, so the TS wiring, overrides and settings apply no matter whether Next or plain React won: `nextConfig` (chooser: `nextBaseConfig` when Next is enabled, `reactBaseConfig` fallback otherwise) → `typescriptOverridesConfig` → `nextOverridesConfig` → `reactSettingsConfig` — all exported individually too.
321
399
 
@@ -328,15 +406,15 @@ Due to limitations package visibility between leaf and root this package has to
328
406
  3. **Hoisting, not bridging** — the plugins need the tool's package resolvable from the workspace root; a tool that is evidently in use (2) but not resolvable there (1) is a **hard error** with hoisting guidance (keep default hoisting, pnpm `public-hoist-pattern`, or a root devDependency — see the error text) instead of a silent skip or a cryptic plugin crash. Fix it once in the package manager config; nothing is symlinked at lint time.
329
407
  4. **Yarn Berry PnP** — there is no hoisting to configure; declare the tools at the workspace root as well, keeping versions in sync with the leaves (e.g. the `"vitest": "$vitest"` version-alias hack); `next` documents its own monorepo ESLint setup.
330
408
 
331
- | Option | Package | Evidence glob | When zero / many found |
332
- | ----------- | ---------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
333
- | `tailwind` | `tailwindcss`¹ | `*.css` with `@import "tailwindcss"` | needs exactly **one**: zero → off (forced → error), several → **always** error; set `cssConfigPath` |
334
- | `next` | `next`¹ | `next.config.*`, `package.json` depending on `next`, `src/{app,pages}/` dir | zero → no `rootDir` (optional); many → all as array; or set `rootDir` (the package root, not `src`) |
335
- | `storybook` | `storybook`¹ | `.storybook/main.*` | presence is enough |
336
- | `jest` | `jest`¹ | `jest.config.*` | presence is enough |
337
- | `vitest` | `vitest`¹ | `{vitest,vite}.config.*` | presence is enough |
338
- | `nx` | (plugin bundled) | `nx.json` at the workspace root | — |
339
- | `turbo` | `turbo` | package probe only | — |
409
+ | Option | Package | Evidence glob | When zero / many found |
410
+ | --- | --- | --- | --- |
411
+ | `tailwind` | `tailwindcss`¹ | `*.css` with `@import "tailwindcss"` | needs exactly **one**: zero → off (forced → error), several → **always** error; set `cssConfigPath` |
412
+ | `next` | `next`¹ | `next.config.*`, `package.json` depending on `next`, `src/{app,pages}/` dir | zero → no `rootDir` (optional); many → all as array; or set `rootDir` (the package root, not `src`) |
413
+ | `storybook` | `storybook`¹ | `.storybook/main.*` | presence is enough |
414
+ | `jest` | `jest`¹ | `jest.config.*` | presence is enough |
415
+ | `vitest` | `vitest`¹ | `{vitest,vite}.config.*` | presence is enough |
416
+ | `nx` | (plugin bundled) | `nx.json` at the workspace root | — |
417
+ | `turbo` | `turbo` | package probe only | — |
340
418
 
341
419
  ¹ the plugins need the tool's package resolvable at lint time (`tailwindcss` for the theme-loading workers, `next` for `eslint-config-next`'s internal `require`s, `storybook` for its plugin's static import, `jest` for version sniffing) — resolvable from the workspace root, or the hard error of step 3 fires.
342
420
 
@@ -374,6 +452,7 @@ paths:
374
452
  - [ ] Yarn 1 (classic) — root detection now delegates to `@manypkg/find-root` (workspace-manifest walk); unverified since the switch
375
453
  - [ ] pnpm — root detection via `@manypkg/find-root` (`pnpm-workspace.yaml`); `public-hoist-pattern` guidance unverified in a real pnpm workspace
376
454
  - [ ] npm — env fast-path (`npm_config_local_prefix`) verified previously; `@manypkg/find-root` fallback unverified since the switch
455
+ - [x] Yarn [constraints](https://yarnpkg.com/features/constraints) helper enforces root overrides/resolutions or default dependency consistency
377
456
  - ESLint 9
378
457
  - [x] https://github.com/microsoft/rushstack/issues/4635 Failed to patch ESLint because the calling module was not recognized
379
458
  - [x] https://github.com/microsoft/rushstack/issues/4965 Failed to patch ESLint because the calling module was not recognized
@@ -0,0 +1,29 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { DefaultIgnoreOptions } from '../index.js';
3
+ /**
4
+ * Core JS recommended rules, global ignores, browser + Node globals, and overrides of core ESLint
5
+ * rules.
6
+ *
7
+ * `eslint-config-next` already ignores `next-env.d.ts`, but only as a bare pattern ('next-env.d.ts'),
8
+ * which only matches at the config's own root - not when the Next app (and its generated
9
+ * next-env.d.ts) lives in a subdirectory, like demo/web-static/ here. It's auto-generated and
10
+ * explicitly marked "should not be edited", so exclude it recursively instead of just working
11
+ * around individual rules (its `///` reference directives otherwise trip multiline-comment-style,
12
+ * which would corrupt them if autofixed into a `/* *\/` block).
13
+ */
14
+ export declare function baseConfig(): Linter.Config[];
15
+ /**
16
+ * Convert an ignore file (`.gitignore`, `.prettierignore`, ...) into an ESLint ignores block,
17
+ * resolved next to the consumer's config file.
18
+ */
19
+ export declare function includeIgnoreFile(importMetaUrl: string, ignoreFile: string): Linter.Config;
20
+ /**
21
+ * The conventional ignore setup of this toolkit: `.gitignore` + `.prettierignore` next to the
22
+ * consumer's config file, both converted into ESLint ignores via {@link includeIgnoreFile} (both
23
+ * files must exist - the prettier scripts in README use the same two).
24
+ *
25
+ * There is nothing to auto-detect here - the consumer's config file location can't be known - so
26
+ * the flag is off by default and enabling it without `importMetaUrl` is a hard error.
27
+ */
28
+ export declare function defaultIgnoreConfig(option?: boolean | DefaultIgnoreOptions): Linter.Config[];
29
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/configs/base.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAmC5C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAG1F;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,CAa5F"}
@@ -1,11 +1,9 @@
1
1
  import { dirname, resolve } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
- import { includeIgnoreFile as includeIgnoreFileCompat } from '@eslint/compat';
3
+ import { includeIgnoreFile as includeIgnoreFileConfig } from '@eslint/config-helpers';
4
4
  import js from '@eslint/js';
5
5
  import globals from 'globals';
6
-
7
6
  import { asOptions, GLOBAL_IGNORES } from '../lib.js';
8
-
9
7
  /**
10
8
  * Core JS recommended rules, global ignores, browser + Node globals, and overrides of core ESLint
11
9
  * rules.
@@ -16,8 +14,6 @@ import { asOptions, GLOBAL_IGNORES } from '../lib.js';
16
14
  * explicitly marked "should not be edited", so exclude it recursively instead of just working
17
15
  * around individual rules (its `///` reference directives otherwise trip multiline-comment-style,
18
16
  * which would corrupt them if autofixed into a `/* *\/` block).
19
- *
20
- * @returns {import('eslint').Linter.Config[]}
21
17
  */
22
18
  export function baseConfig() {
23
19
  return [
@@ -55,22 +51,14 @@ export function baseConfig() {
55
51
  },
56
52
  ];
57
53
  }
58
-
59
54
  /**
60
55
  * Convert an ignore file (`.gitignore`, `.prettierignore`, ...) into an ESLint ignores block,
61
56
  * resolved next to the consumer's config file.
62
- *
63
- * @param {string} importMetaUrl `import.meta.url` of the consumer's `eslint.config.mjs`
64
- * @param {string} ignoreFile
65
- * @returns {import('eslint').Linter.Config}
66
57
  */
67
58
  export function includeIgnoreFile(importMetaUrl, ignoreFile) {
68
59
  // @see https://blog.linotte.dev/eslint-9-next-js-935c2b6d0371
69
- return includeIgnoreFileCompat(resolve(dirname(fileURLToPath(importMetaUrl)), ignoreFile));
60
+ return includeIgnoreFileConfig(resolve(dirname(fileURLToPath(importMetaUrl)), ignoreFile));
70
61
  }
71
-
72
- /** @typedef {import('../index.js').DefaultIgnoreOptions} DefaultIgnoreOptions Defined in index.d.ts. */
73
-
74
62
  /**
75
63
  * The conventional ignore setup of this toolkit: `.gitignore` + `.prettierignore` next to the
76
64
  * consumer's config file, both converted into ESLint ignores via {@link includeIgnoreFile} (both
@@ -78,21 +66,15 @@ export function includeIgnoreFile(importMetaUrl, ignoreFile) {
78
66
  *
79
67
  * There is nothing to auto-detect here - the consumer's config file location can't be known - so
80
68
  * the flag is off by default and enabling it without `importMetaUrl` is a hard error.
81
- *
82
- * @param {boolean | DefaultIgnoreOptions} [option] the defineLintConfig `defaultIgnore` flag
83
- * @returns {import('eslint').Linter.Config[]}
84
69
  */
85
70
  export function defaultIgnoreConfig(option) {
86
71
  const { enabled = false, importMetaUrl } = asOptions(option);
87
- if (!enabled) return [];
88
-
72
+ if (!enabled)
73
+ return [];
89
74
  if (!importMetaUrl) {
90
- throw new Error(
91
- '[@kirill.konshin/lint] `defaultIgnore` was enabled, but `importMetaUrl` was not provided - the ' +
92
- 'location of the consumer config file cannot be auto-detected. ' +
93
- 'Pass `defaultIgnore: { importMetaUrl: import.meta.url }`.',
94
- );
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 }`.');
95
78
  }
96
-
97
79
  return [includeIgnoreFile(importMetaUrl, '.gitignore'), includeIgnoreFile(importMetaUrl, '.prettierignore')];
98
80
  }
@@ -0,0 +1,21 @@
1
+ import type { Linter } from 'eslint';
2
+ /**
3
+ * Import linting via eslint-plugin-import-x: recommended rules + overrides + the default-export
4
+ * relaxation for files that legitimately default-export (framework/tooling conventions) - the
5
+ * latter makes no sense without `import-x/no-default-export`, so it is not a separate block.
6
+ *
7
+ * eslint-config-next already registers `eslint-plugin-import` under the 'import' key, and ESLint 10
8
+ * hard-errors ("Cannot redefine plugin") if a later config tries to reuse that same key with a
9
+ * different plugin instance. eslint-plugin-import-x is a drop-in replacement, registered under its
10
+ * own 'import-x' key instead (its own recommended config does this registration for us).
11
+ */
12
+ export declare function importXConfig(): Linter.Config[];
13
+ /**
14
+ * Deterministic import ordering.
15
+ */
16
+ export declare function importSortConfig(): Linter.Config[];
17
+ /**
18
+ * Autofixable removal of unused imports.
19
+ */
20
+ export declare function unusedImportsConfig(): Linter.Config[];
21
+ //# sourceMappingURL=imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/configs/imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQrC;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,CA8E/C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,CAmClD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,CAerD"}
@@ -2,9 +2,7 @@ import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescrip
2
2
  import importXPlugin, { createNodeResolver } from 'eslint-plugin-import-x';
3
3
  import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
4
4
  import unusedImportsPlugin from 'eslint-plugin-unused-imports';
5
-
6
5
  import { tsExts } from '../lib.js';
7
-
8
6
  /**
9
7
  * Import linting via eslint-plugin-import-x: recommended rules + overrides + the default-export
10
8
  * relaxation for files that legitimately default-export (framework/tooling conventions) - the
@@ -14,8 +12,6 @@ import { tsExts } from '../lib.js';
14
12
  * hard-errors ("Cannot redefine plugin") if a later config tries to reuse that same key with a
15
13
  * different plugin instance. eslint-plugin-import-x is a drop-in replacement, registered under its
16
14
  * own 'import-x' key instead (its own recommended config does this registration for us).
17
- *
18
- * @returns {import('eslint').Linter.Config[]}
19
15
  */
20
16
  export function importXConfig() {
21
17
  return [
@@ -96,11 +92,8 @@ export function importXConfig() {
96
92
  },
97
93
  ];
98
94
  }
99
-
100
95
  /**
101
96
  * Deterministic import ordering.
102
- *
103
- * @returns {import('eslint').Linter.Config[]}
104
97
  */
105
98
  export function importSortConfig() {
106
99
  return [
@@ -138,11 +131,8 @@ export function importSortConfig() {
138
131
  },
139
132
  ];
140
133
  }
141
-
142
134
  /**
143
135
  * Autofixable removal of unused imports.
144
- *
145
- * @returns {import('eslint').Linter.Config[]}
146
136
  */
147
137
  export function unusedImportsConfig() {
148
138
  return [
@@ -0,0 +1,16 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { ToggleOptions } from '../index.js';
3
+ export declare const nxPlugin: typeof import("@nx/eslint-plugin") | null;
4
+ /**
5
+ * Nx blocks: plugin registration + `@nx/dependency-checks` on every `package.json`.
6
+ *
7
+ * Only `flat/base` (registers the '@nx' plugin, no rules of its own).
8
+ *
9
+ * `flat/typescript`/`flat/javascript` were deliberately NOT used - same call as with eslint-plugin-unicorn's
10
+ * recommended: they bundle the ENTIRE @stylistic plugin (hundreds of formatting rules - indent, quotes,
11
+ * semi, comma-dangle, ...) which would directly fight Prettier, plus a second full copy of
12
+ * @typescript-eslint/recommended that would relitigate rules already configured deliberately here.
13
+ *
14
+ */
15
+ export declare function nxConfig(option?: boolean | ToggleOptions, strict?: boolean): Promise<Linter.Config[]>;
16
+ //# sourceMappingURL=nx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx.d.ts","sourceRoot":"","sources":["../../src/configs/nx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,eAAO,MAAM,QAAQ,2CAA6D,CAAC;AAEnF;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAuBzG"}
@@ -1,13 +1,10 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
- import jsoncParser from 'jsonc-eslint-parser';
4
-
3
+ import * as jsoncParser from 'jsonc-eslint-parser';
5
4
  import { hasNx, toolGate } from '../lib.js';
6
-
7
5
  // lazy so consumers without Nx don't pay the load cost (it drags in a large part of nx itself) -
8
6
  // re-exported from index.js
9
7
  export const nxPlugin = hasNx ? (await import('@nx/eslint-plugin')).default : null;
10
-
11
8
  /**
12
9
  * Nx blocks: plugin registration + `@nx/dependency-checks` on every `package.json`.
13
10
  *
@@ -18,9 +15,6 @@ export const nxPlugin = hasNx ? (await import('@nx/eslint-plugin')).default : nu
18
15
  * semi, comma-dangle, ...) which would directly fight Prettier, plus a second full copy of
19
16
  * @typescript-eslint/recommended that would relitigate rules already configured deliberately here.
20
17
  *
21
- * @param {boolean | import('../index.js').ToggleOptions} [option] the defineLintConfig `nx` flag; auto-detected (workspace `nx.json`) when omitted
22
- * @param {boolean} [strict] same-scope detection only: `nx.json` at cwd instead of the workspace root (defineLintConfig `detection.strict`)
23
- * @returns {Promise<import('eslint').Linter.Config[]>}
24
18
  */
25
19
  export async function nxConfig(option, strict = false) {
26
20
  const { enabled } = toolGate(option, strict, {
@@ -29,7 +23,8 @@ export async function nxConfig(option, strict = false) {
29
23
  // hasNx is the one non-strict `has*` (a workspace-root file check) - strict stays at cwd
30
24
  strictHas: strict && existsSync(resolve(process.cwd(), 'nx.json')),
31
25
  });
32
- if (!enabled) return [];
26
+ if (!enabled)
27
+ return [];
33
28
  const nx = (await import('@nx/eslint-plugin')).default;
34
29
  return [
35
30
  ...nx.configs['flat/base'],
@@ -0,0 +1,17 @@
1
+ import type { Linter } from 'eslint';
2
+ /**
3
+ * Prettier compatibility: turns off all rules that would fight the formatter.
4
+ *
5
+ * @see https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#arrow-body-style-and-prefer-arrow-callback-issue
6
+ * Plugin is not recommended by Prettier, they suggest to just use config, and disable all the rules, except for
7
+ * these two in plugin last since they disable some previously set rules:
8
+ * import prettierConfigRecommended from 'eslint-plugin-prettier/recommended';
9
+ * 'arrow-body-style': 'off'
10
+ * 'prefer-arrow-callback': 'off',
11
+ *
12
+ * @see https://nextjs.org/docs/app/api-reference/config/eslint#with-prettier
13
+ * Note the `/flat` suffix here, the difference from default entry is that `/flat` added `name` property to the
14
+ * exported object to improve https://eslint.org/blog/2024/04/eslint-config-inspector/ experience.
15
+ */
16
+ export declare function prettierConfig(): Linter.Config[];
17
+ //# sourceMappingURL=prettier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../../src/configs/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,CAEhD"}
@@ -1,5 +1,4 @@
1
1
  import prettierFlat from 'eslint-config-prettier/flat';
2
-
3
2
  /**
4
3
  * Prettier compatibility: turns off all rules that would fight the formatter.
5
4
  *
@@ -13,8 +12,6 @@ import prettierFlat from 'eslint-config-prettier/flat';
13
12
  * @see https://nextjs.org/docs/app/api-reference/config/eslint#with-prettier
14
13
  * Note the `/flat` suffix here, the difference from default entry is that `/flat` added `name` property to the
15
14
  * exported object to improve https://eslint.org/blog/2024/04/eslint-config-inspector/ experience.
16
- *
17
- * @returns {import('eslint').Linter.Config[]}
18
15
  */
19
16
  export function prettierConfig() {
20
17
  return [prettierFlat];
@@ -0,0 +1,6 @@
1
+ import type { Linter } from 'eslint';
2
+ /**
3
+ * Promise rules: recommended + overrides.
4
+ */
5
+ export declare function promiseConfig(): Linter.Config[];
6
+ //# sourceMappingURL=promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/configs/promise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,CAa/C"}
@@ -1,9 +1,6 @@
1
1
  import promisePlugin from 'eslint-plugin-promise';
2
-
3
2
  /**
4
3
  * Promise rules: recommended + overrides.
5
- *
6
- * @returns {import('eslint').Linter.Config[]}
7
4
  */
8
5
  export function promiseConfig() {
9
6
  return [