@kirill.konshin/lint 0.3.6 → 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 (58) hide show
  1. package/README.md +135 -57
  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} +11 -65
  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/mui.md +1 -1
  53. package/rules/nextjs.md +1 -1
  54. package/rules/npm-yarn.md +36 -6
  55. package/rules/nx.md +6 -6
  56. package/rules/typescript.md +13 -7
  57. package/rules/webstorm.md +20 -0
  58. package/index.d.ts +0 -281
@@ -0,0 +1,84 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { NextOptions } from '../index.js';
3
+ export declare const nextPlugin: typeof import("@next/eslint-plugin-next") | null;
4
+ /**
5
+ * Auto-find Next.js app roots below the workspace root (scanned like the Tailwind entry - see
6
+ * `scanWorkspace`). `next.config.*` is optional in Next.js, so any of three signals marks an app
7
+ * root:
8
+ * - a `next.config.*` file
9
+ * - a `package.json` depending on `next` (see {@link dependsOnNext})
10
+ * - a `src/app` or `src/pages` directory - the reported root is the directory CONTAINING `src`,
11
+ * because the plugin resolves both layouts (`pages`/`app` and `src/pages`/`src/app`) from the
12
+ * package root itself; the bare root-level dir names are too generic to scan for, but such apps
13
+ * are caught by the other two signals
14
+ *
15
+ * Returns absolute directories, deduplicated (one app usually shows several signals) and sorted
16
+ * so the emitted settings block is deterministic across filesystems.
17
+ */
18
+ export declare function findNextRoots(ignores: string[]): string[];
19
+ /**
20
+ * Next.js blocks: the whole `eslint-config-next` flat config, plus `settings.next.rootDir`.
21
+ *
22
+ * `rootDir` is auto-detected via {@link findNextRoots} when omitted: zero apps found → no settings
23
+ * block (the setting is optional and the plugin works without it - NOT an error, unlike the
24
+ * Tailwind entry); one or several → ALL of them (`settings.next.rootDir` accepts an array -
25
+ * pointing at just one app would break linting of the others).
26
+ *
27
+ * `eslint-config-next`'s own parser module does `require('next/dist/compiled/babel/eslint-parser')` -
28
+ * a file INSIDE the `next` package itself - so merely *importing* `eslint-config-next` crashes if
29
+ * `next` isn't installed at all (verified empirically: it throws "Cannot find module
30
+ * 'next/dist/compiled/babel/eslint-parser'" the instant the module loads). Hence the lazy import
31
+ * here; when the block is forced on without `next` around, that error IS the failure mode.
32
+ *
33
+ */
34
+ export declare function nextBaseConfig({ rootDir }?: NextOptions): Promise<Linter.Config[]>;
35
+ /**
36
+ * Non-Next React projects - this config is also used for Vite+React apps - still want React/React
37
+ * Hooks/jsx-a11y linting, which `eslint-config-next` normally provides but only via the Next-specific
38
+ * parser. Cover the same ground directly instead, with whatever parser is already active
39
+ * (typescript-eslint for .ts/.tsx via typescriptConfig, the default parser otherwise).
40
+ *
41
+ */
42
+ export declare function reactBaseConfig(): Linter.Config[];
43
+ /**
44
+ * Composite: {@link nextBaseConfig} when Next is enabled, the {@link reactBaseConfig} fallback
45
+ * otherwise. Full evidence-based gate (see `toolGate` in lib.js), mirroring Tailwind: app-root
46
+ * evidence (see {@link findNextRoots} - `next.config.*`, a `package.json` depending on `next`, a
47
+ * `src/app`/`src/pages` tree) marks a Next repo even when the `next` package is installed only in
48
+ * a leaf app (invisible to `hasNext`) - and because `eslint-config-next` `require`s files INSIDE
49
+ * the `next` package, `next` must be resolvable from the workspace root (hoisted); a leaf-only
50
+ * install is a hard error with hoisting guidance (see `toolGate` in lib.js).
51
+ *
52
+ */
53
+ export declare function nextConfig(option?: boolean | NextOptions, strict?: boolean): Promise<Linter.Config[]>;
54
+ /**
55
+ * TypeScript blocks - lives here because the wiring stems from `eslint-config-next/typescript`
56
+ * (typescript-eslint recommended setup, useful with or without Next itself) + deliberate overrides
57
+ * of its rule set.
58
+ *
59
+ */
60
+ export declare function typescriptOverridesConfig(): Linter.Config[];
61
+ /**
62
+ * Overrides of rules set by `eslint-config-next`. Always applied (not gated on Next): the
63
+ * jsx-a11y/react entries matter for {@link reactBaseConfig} consumers too, and turning off rules of an
64
+ * unregistered plugin is harmless.
65
+ *
66
+ */
67
+ export declare function nextOverridesConfig(): Linter.Config[];
68
+ /**
69
+ * FIXME ESLint 10 + Next fix
70
+ * https://github.com/vercel/next.js/issues/89764
71
+ * https://gist.github.com/OscarGauss/1f305edf5b7c103bb2ee32ba479f4261
72
+ *
73
+ */
74
+ export declare function reactSettingsConfig(): Linter.Config[];
75
+ /**
76
+ * The whole React family in its load-bearing order: {@link nextConfig} (Next when enabled, plain
77
+ * React otherwise - Next is just a shortcut to an opinionated React/TypeScript setup), then
78
+ * {@link typescriptOverridesConfig}, {@link nextOverridesConfig} and {@link reactSettingsConfig} -
79
+ * which apply NO MATTER whether Next or plain React won, so composing them individually risks
80
+ * ordering mistakes; defineLintConfig uses this composite.
81
+ *
82
+ */
83
+ export declare function reactConfig(option?: boolean | NextOptions, strict?: boolean): Promise<Linter.Config[]>;
84
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/configs/react.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,UAAU,kDAAsE,CAAC;AAe9F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,EAAE,OAAuC,EAAE,GAAE,WAAgB,GAAG,OAAO,CACxG,MAAM,CAAC,MAAM,EAAE,CAClB,CAOA;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,CAOjD;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CA6BzG;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAAC,MAAM,EAAE,CAmD3D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,CAarD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,CAQrD;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAO1G"}
@@ -5,30 +5,22 @@ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
5
5
  import reactPlugin from 'eslint-plugin-react';
6
6
  import reactHooksPlugin from 'eslint-plugin-react-hooks';
7
7
  import { globSync } from 'glob';
8
-
9
8
  import { findWorkspaceRoot, GLOBAL_IGNORES, hasNext, scanWorkspace, toolGate, tsExts } from '../lib.js';
10
-
11
9
  // lazy so consumers without Next don't pay the load cost - re-exported from index.js
12
10
  export const nextPlugin = hasNext ? (await import('@next/eslint-plugin-next')).default : null;
13
-
14
- /** @typedef {import('../index.js').NextOptions} NextOptions Defined in index.d.ts. */
15
-
16
11
  /**
17
12
  * Does this `package.json` declare `next` as a dependency? Peer/optional declarations are
18
13
  * deliberately ignored - they mark component libraries, not apps.
19
- *
20
- * @param {string} file absolute path of a `package.json`
21
- * @returns {boolean}
22
14
  */
23
15
  function dependsOnNext(file) {
24
16
  try {
25
17
  const { dependencies, devDependencies } = JSON.parse(readFileSync(file, 'utf-8'));
26
18
  return Boolean(dependencies?.next ?? devDependencies?.next);
27
- } catch {
19
+ }
20
+ catch {
28
21
  return false; // unreadable / malformed - not evidence
29
22
  }
30
23
  }
31
-
32
24
  /**
33
25
  * Auto-find Next.js app roots below the workspace root (scanned like the Tailwind entry - see
34
26
  * `scanWorkspace`). `next.config.*` is optional in Next.js, so any of three signals marks an app
@@ -40,9 +32,8 @@ function dependsOnNext(file) {
40
32
  * package root itself; the bare root-level dir names are too generic to scan for, but such apps
41
33
  * are caught by the other two signals
42
34
  *
43
- * @param {string[]} ignores glob patterns to skip
44
- * @returns {string[]} absolute directories, deduplicated (one app usually shows several signals) and
45
- * sorted so the emitted settings block is deterministic across filesystems
35
+ * Returns absolute directories, deduplicated (one app usually shows several signals) and sorted
36
+ * so the emitted settings block is deterministic across filesystems.
46
37
  */
47
38
  export function findNextRoots(ignores) {
48
39
  return [
@@ -56,7 +47,6 @@ export function findNextRoots(ignores) {
56
47
  ]),
57
48
  ].sort();
58
49
  }
59
-
60
50
  /**
61
51
  * Next.js blocks: the whole `eslint-config-next` flat config, plus `settings.next.rootDir`.
62
52
  *
@@ -71,8 +61,6 @@ export function findNextRoots(ignores) {
71
61
  * 'next/dist/compiled/babel/eslint-parser'" the instant the module loads). Hence the lazy import
72
62
  * here; when the block is forced on without `next` around, that error IS the failure mode.
73
63
  *
74
- * @param {NextOptions} [options]
75
- * @returns {Promise<import('eslint').Linter.Config[]>}
76
64
  */
77
65
  export async function nextBaseConfig({ rootDir = findNextRoots(GLOBAL_IGNORES) } = {}) {
78
66
  const next = (await import('eslint-config-next')).default;
@@ -82,14 +70,12 @@ export async function nextBaseConfig({ rootDir = findNextRoots(GLOBAL_IGNORES) }
82
70
  ...(rootDir?.length ? [{ name: '@next/eslint-plugin-next settings', settings: { next: { rootDir } } }] : []),
83
71
  ];
84
72
  }
85
-
86
73
  /**
87
74
  * Non-Next React projects - this config is also used for Vite+React apps - still want React/React
88
75
  * Hooks/jsx-a11y linting, which `eslint-config-next` normally provides but only via the Next-specific
89
76
  * parser. Cover the same ground directly instead, with whatever parser is already active
90
77
  * (typescript-eslint for .ts/.tsx via typescriptConfig, the default parser otherwise).
91
78
  *
92
- * @returns {import('eslint').Linter.Config[]}
93
79
  */
94
80
  export function reactBaseConfig() {
95
81
  return [
@@ -99,7 +85,6 @@ export function reactBaseConfig() {
99
85
  jsxA11yPlugin.flatConfigs.recommended,
100
86
  ];
101
87
  }
102
-
103
88
  /**
104
89
  * Composite: {@link nextBaseConfig} when Next is enabled, the {@link reactBaseConfig} fallback
105
90
  * otherwise. Full evidence-based gate (see `toolGate` in lib.js), mirroring Tailwind: app-root
@@ -109,9 +94,6 @@ export function reactBaseConfig() {
109
94
  * the `next` package, `next` must be resolvable from the workspace root (hoisted); a leaf-only
110
95
  * install is a hard error with hoisting guidance (see `toolGate` in lib.js).
111
96
  *
112
- * @param {boolean | NextOptions} [option] the defineLintConfig `next` flag
113
- * @param {boolean} [strict] same-scope detection only - no `next.config.*` scan (defineLintConfig `detection.strict`)
114
- * @returns {Promise<import('eslint').Linter.Config[]>}
115
97
  */
116
98
  export async function nextConfig(option, strict = false) {
117
99
  const { enabled, options, files } = toolGate(option, strict, {
@@ -126,28 +108,27 @@ export async function nextConfig(option, strict = false) {
126
108
  * anchor (harmless - resolution just walks up from there). The probes resolve from each
127
109
  * app's package.json.
128
110
  */
129
- absolutizeOptions: ({ rootDir }) =>
130
- (Array.isArray(rootDir) ? rootDir : [rootDir]).filter(Boolean).flatMap((dir) => {
131
- const pattern = isAbsolute(dir) ? dir : resolve(findWorkspaceRoot(), dir);
132
- // trailing slash = directories only; backslash normalization mirrors the plugin
133
- const dirs = globSync(`${pattern.replace(/\\/g, '/').replace(/\/+$/, '')}/`, { absolute: true });
134
- return (dirs.length > 0 ? dirs : [pattern]).map((appDir) => join(appDir, 'package.json'));
135
- }),
111
+ absolutizeOptions: ({ rootDir }) => (Array.isArray(rootDir) ? rootDir : [rootDir])
112
+ .filter((dir) => Boolean(dir))
113
+ .flatMap((dir) => {
114
+ const pattern = isAbsolute(dir) ? dir : resolve(findWorkspaceRoot(), dir);
115
+ // trailing slash = directories only; backslash normalization mirrors the plugin
116
+ const dirs = globSync(`${pattern.replace(/\\/g, '/').replace(/\/+$/, '')}/`, { absolute: true });
117
+ return (dirs.length > 0 ? dirs : [pattern]).map((appDir) => join(appDir, 'package.json'));
118
+ }),
136
119
  scan: () => findNextRoots(GLOBAL_IGNORES).map((dir) => join(dir, 'package.json')),
137
120
  });
138
- if (!enabled) return reactBaseConfig();
139
-
121
+ if (!enabled)
122
+ return reactBaseConfig();
140
123
  // explicit rootDir is passed through in the consumer's own notation; auto-detected roots are
141
124
  // the evidence dirs (absolute; empty under strict → no settings block, the setting is optional)
142
125
  return nextBaseConfig({ ...options, rootDir: options.rootDir ?? files.map((file) => dirname(file)) });
143
126
  }
144
-
145
127
  /**
146
128
  * TypeScript blocks - lives here because the wiring stems from `eslint-config-next/typescript`
147
129
  * (typescript-eslint recommended setup, useful with or without Next itself) + deliberate overrides
148
130
  * of its rule set.
149
131
  *
150
- * @returns {import('eslint').Linter.Config[]}
151
132
  */
152
133
  export function typescriptOverridesConfig() {
153
134
  return [
@@ -201,13 +182,11 @@ export function typescriptOverridesConfig() {
201
182
  },
202
183
  ];
203
184
  }
204
-
205
185
  /**
206
186
  * Overrides of rules set by `eslint-config-next`. Always applied (not gated on Next): the
207
187
  * jsx-a11y/react entries matter for {@link reactBaseConfig} consumers too, and turning off rules of an
208
188
  * unregistered plugin is harmless.
209
189
  *
210
- * @returns {import('eslint').Linter.Config[]}
211
190
  */
212
191
  export function nextOverridesConfig() {
213
192
  return [
@@ -223,13 +202,11 @@ export function nextOverridesConfig() {
223
202
  },
224
203
  ];
225
204
  }
226
-
227
205
  /**
228
206
  * FIXME ESLint 10 + Next fix
229
207
  * https://github.com/vercel/next.js/issues/89764
230
208
  * https://gist.github.com/OscarGauss/1f305edf5b7c103bb2ee32ba479f4261
231
209
  *
232
- * @returns {import('eslint').Linter.Config[]}
233
210
  */
234
211
  export function reactSettingsConfig() {
235
212
  return [
@@ -240,7 +217,6 @@ export function reactSettingsConfig() {
240
217
  },
241
218
  ];
242
219
  }
243
-
244
220
  /**
245
221
  * The whole React family in its load-bearing order: {@link nextConfig} (Next when enabled, plain
246
222
  * React otherwise - Next is just a shortcut to an opinionated React/TypeScript setup), then
@@ -248,9 +224,6 @@ export function reactSettingsConfig() {
248
224
  * which apply NO MATTER whether Next or plain React won, so composing them individually risks
249
225
  * ordering mistakes; defineLintConfig uses this composite.
250
226
  *
251
- * @param {boolean | NextOptions} [option] the defineLintConfig `next` flag
252
- * @param {boolean} [strict] same-scope detection only (defineLintConfig `detection.strict`)
253
- * @returns {Promise<import('eslint').Linter.Config[]>}
254
227
  */
255
228
  export async function reactConfig(option, strict = false) {
256
229
  return [
@@ -0,0 +1,14 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { ToggleOptions } from '../index.js';
3
+ /**
4
+ * Storybook recommended rules. Full evidence-based gate (see `toolGate` in lib.js), mirroring
5
+ * Tailwind: a `.storybook/main.*` marks a Storybook repo even when the `storybook` package is
6
+ * installed only in a leaf package (invisible to `hasStorybook`) - and because
7
+ * `eslint-plugin-storybook` statically imports the `storybook` package itself, `storybook` must
8
+ * be resolvable from the workspace root (hoisted); a leaf-only install is a hard error with
9
+ * hoisting guidance (see `toolGate` in lib.js). The plugin stays lazily imported so consumers
10
+ * without Storybook never pay for it.
11
+ *
12
+ */
13
+ export declare function storybookConfig(option?: boolean | ToggleOptions, strict?: boolean): Promise<Linter.Config[]>;
14
+ //# sourceMappingURL=storybook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook.d.ts","sourceRoot":"","sources":["../../src/configs/storybook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAYhH"}
@@ -1,5 +1,4 @@
1
1
  import { GLOBAL_IGNORES, hasStorybook, scanWorkspace, toolGate } from '../lib.js';
2
-
3
2
  /**
4
3
  * Storybook recommended rules. Full evidence-based gate (see `toolGate` in lib.js), mirroring
5
4
  * Tailwind: a `.storybook/main.*` marks a Storybook repo even when the `storybook` package is
@@ -9,9 +8,6 @@ import { GLOBAL_IGNORES, hasStorybook, scanWorkspace, toolGate } from '../lib.js
9
8
  * hoisting guidance (see `toolGate` in lib.js). The plugin stays lazily imported so consumers
10
9
  * without Storybook never pay for it.
11
10
  *
12
- * @param {boolean | import('../index.js').ToggleOptions} [option] the defineLintConfig `storybook` flag; auto-detected when omitted
13
- * @param {boolean} [strict] same-scope detection only - no `.storybook` scan (defineLintConfig `detection.strict`)
14
- * @returns {Promise<import('eslint').Linter.Config[]>}
15
11
  */
16
12
  export async function storybookConfig(option, strict = false) {
17
13
  const { enabled } = toolGate(option, strict, {
@@ -20,8 +16,9 @@ export async function storybookConfig(option, strict = false) {
20
16
  packageName: 'storybook',
21
17
  scan: () => scanWorkspace('.storybook/main.*', GLOBAL_IGNORES, { dot: true }),
22
18
  });
23
- if (!enabled) return [];
24
-
19
+ if (!enabled)
20
+ return [];
25
21
  const storybookPlugin = (await import('eslint-plugin-storybook')).default;
22
+ // Storybook still publishes ESLint 9 rule types; the runtime flat configs are valid in ESLint 10.
26
23
  return storybookPlugin.configs['flat/recommended'];
27
24
  }
@@ -0,0 +1,29 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { TailwindOptions } from '../index.js';
3
+ /**
4
+ * Auto-find THE Tailwind v4 entry CSS ({@link findTailwindEntries} narrowed to exactly one).
5
+ *
6
+ * eslint-plugin-tailwindcss v4 loads the entry (`settings.tailwindcss.cssConfigPath`) and
7
+ * HARD-CRASHES with ENOENT when it can't, so {@link tailwindConfig} only enables the plugin when
8
+ * exactly one entry is found (`allowMultiple: false` in its gate spec); with zero or several the
9
+ * consumer must configure `cssConfigPath` manually (MANDATORY for the plugin; several candidates
10
+ * are a hard error) - see README "Detection".
11
+ *
12
+ */
13
+ export declare function findTailwindEntry(ignores: string[]): string | null;
14
+ /**
15
+ * Tailwind recommended rules (warnings + `no-contradicting-classname` as error) as a standalone
16
+ * block (simple to override wholesale).
17
+ *
18
+ * Auto-detection is driven by the entry CSS (see {@link findTailwindEntries}), not by the package
19
+ * probe: explicit `cssConfigPath` wins, otherwise auto-find. Zero entries stays inert in auto mode
20
+ * (nothing marks the repo as Tailwind) but fails loudly when Tailwind was FORCED on (`true` /
21
+ * options object). SEVERAL entries fail loudly even in auto mode: they prove the repo uses
22
+ * Tailwind, the right one cannot be guessed, and a silent skip would be hard to detect - pass
23
+ * `cssConfigPath` to pick one. `tailwindcss` must be resolvable from the workspace root (where
24
+ * the plugin's theme-loading workers resolve it); a leaf-only install is a hard error with
25
+ * hoisting guidance (see `toolGate` in lib.js).
26
+ *
27
+ */
28
+ export declare function tailwindConfig(option?: boolean | TailwindOptions, strict?: boolean): Promise<Linter.Config[]>;
29
+ //# sourceMappingURL=tailwind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../src/configs/tailwind.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmBnD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAGlE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,eAAe,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAsDjH"}
@@ -1,26 +1,22 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { isAbsolute, resolve } from 'node:path';
3
-
4
3
  import { findWorkspaceRoot, GLOBAL_IGNORES, hasTailwind, packageDirOf, scanWorkspace, toolGate } from '../lib.js';
5
-
6
4
  /**
7
5
  * All Tailwind v4 entry CSS candidates: every `*.css` across the workspace (see `scanWorkspace` -
8
6
  * the root plus every workspace package, `.gitignore`- and build-output-aware) containing the
9
7
  * Tailwind v4 marker `@import "tailwindcss"`.
10
8
  *
11
- * @param {string[]} ignores glob patterns to skip
12
- * @returns {string[]} absolute paths
13
9
  */
14
10
  function findTailwindEntries(ignores) {
15
11
  return scanWorkspace('*.css', ignores).filter((file) => {
16
12
  try {
17
13
  return /@import\s+['"]tailwindcss['"]/.test(readFileSync(file, 'utf-8'));
18
- } catch {
14
+ }
15
+ catch {
19
16
  return false;
20
17
  }
21
18
  });
22
19
  }
23
-
24
20
  /**
25
21
  * Auto-find THE Tailwind v4 entry CSS ({@link findTailwindEntries} narrowed to exactly one).
26
22
  *
@@ -30,16 +26,11 @@ function findTailwindEntries(ignores) {
30
26
  * consumer must configure `cssConfigPath` manually (MANDATORY for the plugin; several candidates
31
27
  * are a hard error) - see README "Detection".
32
28
  *
33
- * @param {string[]} ignores glob patterns to skip
34
- * @returns {string | null} absolute path of the single entry, or null when zero or several were found
35
29
  */
36
30
  export function findTailwindEntry(ignores) {
37
31
  const entries = findTailwindEntries(ignores);
38
32
  return entries.length === 1 ? entries[0] : null;
39
33
  }
40
-
41
- /** @typedef {import('../index.js').TailwindOptions} TailwindOptions Defined in index.d.ts. */
42
-
43
34
  /**
44
35
  * Tailwind recommended rules (warnings + `no-contradicting-classname` as error) as a standalone
45
36
  * block (simple to override wholesale).
@@ -53,9 +44,6 @@ export function findTailwindEntry(ignores) {
53
44
  * the plugin's theme-loading workers resolve it); a leaf-only install is a hard error with
54
45
  * hoisting guidance (see `toolGate` in lib.js).
55
46
  *
56
- * @param {boolean | TailwindOptions} [option] the defineLintConfig `tailwind` flag; auto-detected when omitted
57
- * @param {boolean} [strict] same-scope detection only - no entry scan, no bridge (defineLintConfig `detection.strict`)
58
- * @returns {Promise<import('eslint').Linter.Config[]>}
59
47
  */
60
48
  export async function tailwindConfig(option, strict = false) {
61
49
  /*
@@ -70,26 +58,23 @@ export async function tailwindConfig(option, strict = false) {
70
58
  packageName: 'tailwindcss',
71
59
  needs: {
72
60
  what: 'entry CSS',
73
- detail:
74
- 'single Tailwind v4 entry CSS (a *.css containing `@import "tailwindcss"`, scanned across ' +
61
+ detail: 'single Tailwind v4 entry CSS (a *.css containing `@import "tailwindcss"`, scanned across ' +
75
62
  'the workspace root and every workspace package)',
76
63
  hint: '`tailwind: { cssConfigPath }`',
77
64
  },
78
65
  // the plugin takes exactly ONE entry - several scan candidates are a hard error
79
66
  allowMultiple: false,
80
67
  // option paths may be relative; the resolution probe needs an absolute file context
81
- absolutizeOptions: ({ cssConfigPath }) =>
82
- cssConfigPath
83
- ? [isAbsolute(cssConfigPath) ? cssConfigPath : resolve(findWorkspaceRoot(), cssConfigPath)]
84
- : [],
68
+ absolutizeOptions: ({ cssConfigPath }) => cssConfigPath
69
+ ? [isAbsolute(cssConfigPath) ? cssConfigPath : resolve(findWorkspaceRoot(), cssConfigPath)]
70
+ : [],
85
71
  scan: () => findTailwindEntries(GLOBAL_IGNORES),
86
72
  });
87
- if (!enabled) return [];
88
-
73
+ if (!enabled)
74
+ return [];
89
75
  // an explicit path is passed through in the consumer's own notation (the absolutized copy only
90
76
  // served the probes); an auto-found entry is the absolute evidence file
91
77
  const cssConfigPath = options.cssConfigPath ?? files[0];
92
-
93
78
  /*
94
79
  * The entry CSS pins down the ONE package that uses Tailwind, so by default the block is
95
80
  * scoped to it via `basePath` (ESLint >= 9.30, absolute paths supported) instead of flagging
@@ -101,10 +86,10 @@ export async function tailwindConfig(option, strict = false) {
101
86
  const { scoped = true } = options;
102
87
  const packageDir = scoped ? packageDirOf(files[0]) : null;
103
88
  const basePath = packageDir && packageDir !== findWorkspaceRoot() ? { basePath: packageDir } : {};
104
-
105
89
  const tailwindPlugin = (await import('eslint-plugin-tailwindcss')).default;
106
90
  return [
107
91
  {
92
+ // The plugin still publishes @typescript-eslint's ESLint 9 config types.
108
93
  ...tailwindPlugin.configs.recommended,
109
94
  ...basePath,
110
95
  settings: { tailwindcss: { cssConfigPath } },
@@ -0,0 +1,22 @@
1
+ import vitestPlugin from '@vitest/eslint-plugin';
2
+ import type { Linter } from 'eslint';
3
+ import jestPlugin from 'eslint-plugin-jest';
4
+ import type { ToggleOptions } from '../index.js';
5
+ export { jestPlugin, vitestPlugin };
6
+ /**
7
+ * Jest recommended rules, scoped to test files.
8
+ *
9
+ */
10
+ export declare function jestConfig(option?: boolean | ToggleOptions, strict?: boolean): Linter.Config[];
11
+ /**
12
+ * Vitest recommended rules + globals, scoped to test files.
13
+ *
14
+ */
15
+ export declare function vitestConfig(option?: boolean | ToggleOptions, strict?: boolean): Linter.Config[];
16
+ /**
17
+ * Runner-agnostic test rules: pure AST/call-name checking, needs neither jest nor vitest installed
18
+ * to work correctly, so it applies regardless of which one (if either) is present.
19
+ *
20
+ */
21
+ export declare function testConfig(): Linter.Config[];
22
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/configs/testing.ts"],"names":[],"mappings":"AAYA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAC3C,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AA6DpC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAgB5F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,EAAE,MAAM,UAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAsB9F;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAmB5C"}
@@ -12,11 +12,8 @@ import fs from 'node:fs';
12
12
  import path from 'node:path';
13
13
  import vitestPlugin from '@vitest/eslint-plugin';
14
14
  import jestPlugin from 'eslint-plugin-jest';
15
-
16
15
  import { GLOBAL_IGNORES, hasJest, hasVitest, scanWorkspace, toolGate, tsExts, tsExtsRaw } from '../lib.js';
17
-
18
16
  export { jestPlugin, vitestPlugin };
19
-
20
17
  /*
21
18
  * Both runners use the evidence-based `toolGate` (see lib.js): a runner config file marks the repo
22
19
  * even when the runner is installed only in a leaf package (invisible to the `has*` probe), and
@@ -25,11 +22,9 @@ export { jestPlugin, vitestPlugin };
25
22
  * plugin-crashing tools (next/storybook/tailwind) the rules are pure AST checks that work without
26
23
  * the runner, so forcing a runner on never throws (`requirePackage: false`).
27
24
  */
28
-
29
25
  // derived from the shared extension list - one source of truth with the lint file globs
30
26
  const SOURCE_EXTS = tsExtsRaw.split(',').map((ext) => `.${ext}`);
31
27
  const TEST_SUFFIX = new RegExp(`\\.test\\.(${tsExtsRaw.replaceAll(',', '|')})$`);
32
-
33
28
  /**
34
29
  * Custom rule (registered as `local/test-colocation` by {@link testConfig}). Only `*.test.*` is
35
30
  * checked, not `*.spec.*` - per testing.md, spec files cover e2e/integration flows that don't map
@@ -43,27 +38,24 @@ const testColocation = {
43
38
  },
44
39
  schema: [],
45
40
  messages: {
46
- missingSibling:
47
- "No sibling source file found for '{{testFile}}'. Expected e.g. '{{expected}}' in the same directory, not a separate __tests__/ folder.",
41
+ missingSibling: "No sibling source file found for '{{testFile}}'. Expected e.g. '{{expected}}' in the same directory, not a separate __tests__/ folder.",
48
42
  },
49
43
  },
50
44
  create(context) {
51
45
  const base = path.basename(context.filename);
52
46
  const match = base.match(TEST_SUFFIX);
53
-
54
- if (!match) return {};
55
-
47
+ if (!match)
48
+ return {};
56
49
  const stem = base.slice(0, -match[0].length);
57
-
58
50
  let siblings;
59
51
  try {
60
52
  siblings = fs.readdirSync(path.dirname(context.filename));
61
- } catch {
53
+ }
54
+ catch {
62
55
  return {}; // virtual filename (stdin, editor buffer) - no directory to check against
63
56
  }
64
-
65
- if (SOURCE_EXTS.some((ext) => siblings.includes(`${stem}${ext}`))) return {};
66
-
57
+ if (SOURCE_EXTS.some((ext) => siblings.includes(`${stem}${ext}`)))
58
+ return {};
67
59
  return {
68
60
  Program(node) {
69
61
  context.report({
@@ -75,12 +67,9 @@ const testColocation = {
75
67
  };
76
68
  },
77
69
  };
78
-
79
70
  /**
80
71
  * Jest recommended rules, scoped to test files.
81
72
  *
82
- * @param {boolean | import('../index.js').ToggleOptions} [option] the defineLintConfig `jest` flag; auto-detected when omitted
83
- * @returns {import('eslint').Linter.Config[]}
84
73
  */
85
74
  export function jestConfig(option, strict = false) {
86
75
  const { enabled } = toolGate(option, strict, {
@@ -90,7 +79,8 @@ export function jestConfig(option, strict = false) {
90
79
  requirePackage: false,
91
80
  scan: () => scanWorkspace('jest.config.*', GLOBAL_IGNORES),
92
81
  });
93
- if (!enabled) return [];
82
+ if (!enabled)
83
+ return [];
94
84
  return [
95
85
  {
96
86
  ...jestPlugin.configs['flat/recommended'],
@@ -99,12 +89,9 @@ export function jestConfig(option, strict = false) {
99
89
  },
100
90
  ];
101
91
  }
102
-
103
92
  /**
104
93
  * Vitest recommended rules + globals, scoped to test files.
105
94
  *
106
- * @param {boolean | import('../index.js').ToggleOptions} [option] the defineLintConfig `vitest` flag; auto-detected when omitted
107
- * @returns {import('eslint').Linter.Config[]}
108
95
  */
109
96
  export function vitestConfig(option, strict = false) {
110
97
  const { enabled } = toolGate(option, strict, {
@@ -115,7 +102,8 @@ export function vitestConfig(option, strict = false) {
115
102
  // vitest is often configured inside vite.config.* - both count as evidence
116
103
  scan: () => scanWorkspace('{vitest,vite}.config.*', GLOBAL_IGNORES),
117
104
  });
118
- if (!enabled) return [];
105
+ if (!enabled)
106
+ return [];
119
107
  return [
120
108
  {
121
109
  ...vitestPlugin.configs.recommended,
@@ -129,12 +117,10 @@ export function vitestConfig(option, strict = false) {
129
117
  },
130
118
  ];
131
119
  }
132
-
133
120
  /**
134
121
  * Runner-agnostic test rules: pure AST/call-name checking, needs neither jest nor vitest installed
135
122
  * to work correctly, so it applies regardless of which one (if either) is present.
136
123
  *
137
- * @returns {import('eslint').Linter.Config[]}
138
124
  */
139
125
  export function testConfig() {
140
126
  return [
@@ -0,0 +1,9 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { ToggleOptions } from '../index.js';
3
+ export declare const turboPlugin: typeof import("eslint-plugin-turbo") | null;
4
+ /**
5
+ * Turborepo rules. Probe-only gate (see `toolGate` in lib.js) - no evidence scan, no bridge.
6
+ *
7
+ */
8
+ export declare function turboConfig(option?: boolean | ToggleOptions): Promise<Linter.Config[]>;
9
+ //# sourceMappingURL=turbo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turbo.d.ts","sourceRoot":"","sources":["../../src/configs/turbo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,eAAO,MAAM,WAAW,6CAAkE,CAAC;AAE3F;;;GAGG;AACH,wBAAsB,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAoB5F"}
@@ -1,20 +1,20 @@
1
1
  import { hasTurbo, toolGate } from '../lib.js';
2
-
3
2
  // lazy so consumers without Turbo don't pay the load cost - re-exported from index.js
4
3
  export const turboPlugin = hasTurbo ? (await import('eslint-plugin-turbo')).default : null;
5
-
6
4
  /**
7
5
  * Turborepo rules. Probe-only gate (see `toolGate` in lib.js) - no evidence scan, no bridge.
8
6
  *
9
- * @param {boolean | import('../index.js').ToggleOptions} [option] the defineLintConfig `turbo` flag; auto-detected when omitted
10
- * @returns {Promise<import('eslint').Linter.Config[]>}
11
7
  */
12
8
  export async function turboConfig(option) {
13
9
  const { enabled } = toolGate(option, false, { tool: 'turbo', has: hasTurbo });
14
- if (!enabled) return [];
10
+ if (!enabled)
11
+ return [];
15
12
  const turbo = (await import('eslint-plugin-turbo')).default;
13
+ const recommended = turbo.configs?.['flat/recommended'];
14
+ // Turbo's declaration permits both legacy and flat shapes; this entry is flat at runtime.
15
+ const base = (Array.isArray(recommended) ? recommended : [recommended ?? {}]);
16
16
  return [
17
- turbo.configs['flat/recommended'],
17
+ ...base,
18
18
  {
19
19
  name: 'eslint-plugin-turbo overrides',
20
20
  rules: {
@@ -0,0 +1,20 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { TypeAwareOptions } from '../index.js';
3
+ /**
4
+ * Type-aware rules. Off by default (FIXME: does not perform) - enable via
5
+ * `defineLintConfig({ typeAware: true })` or by composing this block manually; it is self-contained
6
+ * (wires typescript-eslint's projectService itself).
7
+ *
8
+ * Config files like vite.config.ts and .storybook/{main,preview}.ts sit at the package root or in
9
+ * a dotfolder, outside their tsconfig.json `include` - projectService has no tsconfig to attach
10
+ * them to. `allowDefaultProject` falls back to a synthetic single-file program for these instead
11
+ * of erroring; it has NO default (the layout is project-specific and its patterns may not contain
12
+ * `**` - see README "Type-aware rules" for how to generate the list).
13
+ * `maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING` defaults to the length of
14
+ * `allowDefaultProject` when that list is given (upstream default is 8), and `tsconfigRootDir`
15
+ * defaults to the detected workspace root.
16
+ *
17
+ * There is nothing to auto-detect, so only an explicit `true` or options object enables the block.
18
+ */
19
+ export declare function typeAwareConfig(option?: boolean | TypeAwareOptions, strict?: boolean): Linter.Config[];
20
+ //# sourceMappingURL=typescriptTypeAware.d.ts.map