@soujvnunes/eslint-config 0.8.0 → 0.10.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @soujvnunes/eslint-config
2
2
 
3
- Shared flat ESLint config as factories. It bundles the plugin set (typescript-eslint, import-x, import-helpers, unused-imports, security, and for the Next preset react, react-hooks, jsx-a11y, `@next/next`), so you only bring `eslint` and `typescript`. The Next preset also bundles the TypeScript import resolver (`eslint-import-resolver-typescript`, wired via `import-x/resolver-next`), so `@/...` path aliases and `.d.ts` types resolve out of the box, with no extra install and no `settings` wiring.
3
+ Shared flat ESLint config as factories. It bundles the plugin set (typescript-eslint, import-x, import-helpers, unused-imports, security, and for the Next preset react, react-hooks, jsx-a11y, `@next/next`), so you only bring `eslint` and `typescript`. The Next preset also bundles the TypeScript import resolver (`eslint-import-resolver-typescript`, wired via `import-x/resolver-next`), so `@/...` path aliases and `.d.ts` types resolve out of the box, with no extra install and no `settings` wiring. The resolver is passed as an object, which sidesteps pnpm's bare-name resolution, and runs with `alwaysTryTypes`, so a value import resolves its `@types/*` package; it finds `tsconfig.json` from the working directory, and a repo with a tsconfig elsewhere appends its own resolver through `extend`. The base preset stays on import-x's built-in node resolver.
4
4
 
5
5
  ## Install
6
6
 
@@ -41,14 +41,26 @@ export default createBaseConfig()
41
41
 
42
42
  | Option | Default | Purpose |
43
43
  | --- | --- | --- |
44
- | `importGroups` | react, next, module, parent, sibling, index | Full import-order groups; insert your `@/...` paths |
44
+ | `importGroups` | react, next, module, parent, sibling, index | Full import-order groups, which replace the default list; insert your `@/...` paths |
45
45
  | `ignores` | (none) | Extra ignore globs, merged after the built-in defaults |
46
46
  | `tsconfigRootDir` | `process.cwd()` | Root for typescript-eslint's project service |
47
- | `tailwindEntryPoint` | (none) | Tailwind v4 CSS entry path. When set on the Next preset, wires `eslint-plugin-better-tailwindcss` correctness rules such as `no-unknown-classes`, which flags a class not registered in the theme |
47
+ | `tailwindEntryPoint` | (none) | Tailwind v4 CSS entry path: the file holding `@import "tailwindcss"` and `@theme`, such as `./app/tailwind.config.css`. When set on the Next preset, wires `eslint-plugin-better-tailwindcss` correctness rules such as `no-unknown-classes`, which flags a class not registered in the theme (a dead token neither `tsc` nor the build sees), and `no-restricted-classes`, which flags an arbitrary-value class such as `text-[11px]`. Left unset, the plugin stays off, since without the entry `no-unknown-classes` cannot resolve the theme and would flag every class. The stylistic rules stay off, since `prettier-plugin-tailwindcss` already owns class order |
48
+ | `allowArbitraryClasses` | `[]` | Utility prefixes exempt from the arbitrary-Tailwind-value ban, for a shape with no theme token (`['grid-cols']` for `grid-cols-[200px_1fr]`). Read only when `tailwindEntryPoint` is set |
49
+ | `classMergeName` | `'cn'` | The class-merge helper name a ternary passed straight to it is banned inside of |
50
+ | `nextConfigModules` | `[]` | Modules `next.config.*` loads, restricted to relative imports (`no-restricted-imports` on `['@/*']`) the same as a `next.config.ts`, `.mts` or `.cts` itself, on the Next preset |
51
+ | `strictExportGlobs` | `[]` | Globs wired to `soujvnunes/one-export-per-file`. With no globs the rule stays exported but off |
48
52
  | `extend` | `[]` | Extra flat-config objects appended at the end |
49
53
 
50
54
  Type-aware rules use typescript-eslint's **project service**, so no `parserOptions.project` wiring is needed. It discovers the nearest `tsconfig.json` per file.
51
55
 
56
+ ## Built-in exemptions
57
+
58
+ - A config file or script at the repo root (`*.{mjs,js,ts,mts,cts}`) may default-export, so `import-x/no-default-export` is off there. `no-restricted-syntax` stays on for everything that is not about export shape: the file still keeps the react-import bans, the enum ban, the lucide/next-font/cloneElement bans and, on the Next preset, the `cn()`-ternary ban. Only the two export-default selectors drop.
59
+ - On the Next preset, the file conventions Next requires to default-export (`page`, `layout`, `error`, `loading`, `not-found`, `proxy`, `middleware`, `sitemap`, `robots` and the rest) get the same treatment: the export-default selectors drop, every other `no-restricted-syntax` selector stays, which is why a `lucide-react` import that does not end in `Icon` is still caught inside `page.tsx`. `proxy` and `middleware` are both listed, since a repo can be on either name.
60
+ - `scripts/**/*.mjs` gets Node globals and `no-console` off, because printing is a script's job.
61
+ - The comment rules run in a block of their own on `**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}`, with their own `plugins`, since the main block's glob stops at `.js`, `.jsx`, `.ts` and `.tsx` and would never reach an `.mjs`, `.cjs`, `.mts` or `.cts` file.
62
+ - `**/*.test.*` and `**/copy/**` are exempt from `max-lines`, since a test file's assertions and a copy dictionary's strings are not the same kind of length as logic.
63
+
52
64
  ## Style rules worth knowing before you adopt
53
65
 
54
66
  These are the opinions most likely to surprise an existing codebase. All of them autofix except where noted.
@@ -57,6 +69,8 @@ These are the opinions most likely to surprise an existing codebase. All of them
57
69
 
58
70
  **No warning severity.** Every rule either fails or is not present. A deliberate exception is an `eslint-disable` comment rather than a warning, and `reportUnusedDisableDirectives` is on, so a disable comment that suppresses nothing is itself an error.
59
71
 
72
+ **No comments in code: `soujvnunes/no-comments`.** It reports every comment in a JS or TS file, JSDoc included, except a tool directive. A tool directive that does work stays, matched by name: `eslint-disable`, `@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`, `prettier-ignore`, `biome-ignore`, a coverage pragma (`istanbul`, `c8`, `v8`, `node:coverage`), a minifier annotation (`@__PURE__`, `#__NO_SIDE_EFFECTS__` and the rest of the `__NAME__` family), a `webpack` or `turbopack` magic comment, `@vite-ignore`, `//# sourceMappingURL`, a triple-slash reference, `/* global */`, `@jsx` with its `Frag`, `ImportSource` and `Runtime` forms, `@vitest-environment`, `@jest-environment`, `@refresh reset`, `@license`, `@preserve`, `@format`, `@prettier`, `@internal` standing alone (read by TypeScript's `stripInternal`; with prose after it, it is a JSDoc like any other), a JSDoc whose only content is a `@deprecated` tag with or without its sentence, on one line or several (read by editors and by `@typescript-eslint/no-deprecated`; another tag after it, or the same text in a `//` line, reports, while a scoped package name such as `@scope/pkg` in its sentence is not a tag, and an em dash in its sentence reports without a fix), `gitleaks:allow` anywhere in a one-line comment that shares its line with code, before it or after it (gitleaks reads it only on the line of the finding), the `/*!` banner and the `#!` line. Any other comment that opens with `@` or `#`, such as `// @todo`, is prose and reports. In a `.js`, `.mjs`, `.cjs` or `.jsx` file a JSDoc whose first tag is a type annotation `checkJs` reads (`@type`, `@typedef`, `@callback`, `@satisfies`, `@template`, `@param`, `@returns`, `@import`, `@enum`, `@extends`, `@augments`, `@implements`, `@this`, `@overload`) and carries the type the tag takes (a `{Type}` after `@type`, `@param`, `@returns`, `@return`, `@satisfies`, `@enum` and `@this`; a `{Type}` or a name that ends its line after `@typedef` and `@callback`; a `{constraint}` or a comma list of names that ends its line after `@template`; a `{Type}` or a type that ends its line after `@extends`, `@augments` and `@implements`; an `import` clause with its `from` after `@import`; a typed `@param` or `@returns` later in the same comment after `@overload`), stays as well, wherever it sits, since deleting it removes the type check. Every other JSDoc reports wherever it sits: above an exported symbol, on a member of an exported class, interface, type or enum, on a key of an exported object, in a `declare global` block and in a `.d.ts` file alike. The rule used to keep those and took a `jsdoc` option to report them; the option is gone, so passing it is a config error and a config that set `{ jsdoc: 'never' }` drops it. A `{/* */}` in JSX and a comment inside a JSX tag are reported like any other comment. The fix deletes the comment: its whole line when it stands alone, back to the code when it trails, and one space when code sits on both sides. Five cases are left to the author: a JSX container between text, a comment inside a tag, a multi-line comment with code on both of its edges (deleting it could join two lines that semicolon insertion keeps apart), a JSDoc holding an `@` tag, and a comment that is all a block holds, since deleting it would leave an empty block that `no-empty` reports (a function body is not such a block, since `no-empty` never reports one, so its lone comment is deleted). A reason the code cannot carry belongs in the README. Both presets turn it on at error, beside `soujvnunes/one-line-comments`, which still collapses a multi-line `@deprecated` JSDoc to one line.
73
+
60
74
  **Type-aware rules are enabled**, including `no-floating-promises`, `no-misused-promises`, `await-thenable`, `no-deprecated` and `no-unnecessary-type-assertion`. These need the project service, which is wired by default (see above). They are the rules most likely to surface real findings in a codebase adopting this config, and most are not autofixable.
61
75
 
62
76
  **`security/detect-object-injection` is not included.** It predates TypeScript narrowing and reports every `obj[key]`, including keys already narrowed to a literal union and plain array indexes. Use `noUncheckedIndexedAccess` and an own-key (`Object.hasOwn`) guard instead.
@@ -68,4 +82,50 @@ These are the opinions most likely to surprise an existing codebase. All of them
68
82
 
69
83
  Measured on a Next app with 77 client files, with the TypeScript parser and browser globals the preset uses: the first rule found the 3 wrappers around a Radix primitive and `cn()` that were known to be needless, and nothing else once `error` files were exempt; the second found 16 static subtrees in 8 files, every one a block of labels and inputs or a heading a server parent could render. A threshold of two elements found 43, most of them label and input pairs that are not worth a refactor.
70
84
 
85
+ This package's tests run every client-boundary case under two settings, espree with no globals and the Next preset's TypeScript parser with browser globals, since a global the config or a TypeScript lib declares resolves differently from an undeclared one.
86
+
71
87
  Adopting this in an existing repo is usually one `eslint --fix` pass plus a short list of genuine fixes from the type-aware rules.
88
+
89
+ ## Accessibility on the Next preset
90
+
91
+ `jsx-a11y`'s recommended rules run at error, not just registered with zero rules. `settings['jsx-a11y'].components` maps `Link` to `a`, `Image` to `img`, `Button` to `button` and `Input` to `input`, so a rule such as `anchor-is-valid` or `alt-text` reads through the wrapper to the native element it renders. Measured on a Next app with 676 source files: 7 real findings across 5 rules (`no-autofocus`, `click-events-have-key-events`, `no-noninteractive-element-interactions`, `no-static-element-interactions`, `anchor-has-content`), one of which is a component that forwards `children` only through `{...props}`, which the rule cannot see through; everything else was a genuine finding.
92
+
93
+ ## New `no-restricted-syntax` selectors, and why page.tsx still gets them
94
+
95
+ `no-restricted-syntax` selectors now live in a keyed record composed per file convention, rather than one hardcoded array turned fully off on `page.tsx`, `layout.tsx` and root config files. Those two overrides now drop only the two export-default selectors (`page.tsx` and `next.config.ts` both need to default-export) and keep everything else: the enum ban, the react-import bans, and the three additions below. This is what makes a `lucide-react` import inside `page.tsx` still get caught.
96
+
97
+ - **A `lucide-react` import whose name does not end in `Icon`.** `import { Home } from 'lucide-react'` is reported; `import { HomeIcon } from 'lucide-react'` is not. `createLucideIcon`, `icons` and `dynamicIconImports` are exempt, since none of them is itself an icon, and a type-only import (`import type` or `{ type X }`) is exempt too. The check is on the imported name, not the local alias, so `import { Home as MyIcon }` still reports.
98
+ - **Any import from `next/font/google`.** Self-hosted fonts only (`FONTS`).
99
+ - **`cloneElement`**, both as a named import from `react` and as `React.cloneElement`.
100
+
101
+ Measured on a Next app: `lucide-react` and `cloneElement` both read 0 (the app already imports the `*Icon` names and never touches `cloneElement`), `next/font/google` read 1 (`src/app/layout.tsx`).
102
+
103
+ ## Barrel files and feature roots, on the Next preset only
104
+
105
+ Two more `no-restricted-syntax` overrides, each adding a `Program` selector to the full selector list, so every matching file reports once whatever it contains, and the enum, react-import, `lucide-react`, `next/font/google`, `cloneElement` and `cn()` ternary bans still apply inside it:
106
+
107
+ - `**/index.{ts,tsx}` (outside `**/pages/**`) reports a barrel file outright: import each module by its own path instead of re-exporting through an aggregator.
108
+ - `**/features/*/*.{ts,tsx}` (outside its own `*.test.{ts,tsx}`) reports a file sitting loose at a feature's root: place it inside one of the feature's subfolders.
109
+
110
+ Both are Next-preset only, since a plain TypeScript library's `index.ts` is its npm entry point, not the barrel the Next convention (`MODULARITY`) warns about; `createBaseConfig` never sees either override, which is why this very package's own `eslint-config/index.ts` is not flagged by its own rule.
111
+
112
+ ## `cn()` ternary ban, on the Next preset
113
+
114
+ `CallExpression[callee.name='cn'] > ConditionalExpression` is its own entry in the same selector composition, so the file-convention overrides above cannot drop it independently of the export-default filtering: it rides along with every other selector wherever `no-restricted-syntax` is set. The callee name comes from `classMergeName` (default `'cn'`), for a repo whose merge helper is named `clsx` or something else. Use a `cva` variant or an object entry instead of `cn(base, condition ? 'a' : 'b')`. Measured on a Next app: 16 sites across 9 files, 8 of them in one badge component.
115
+
116
+ ## Arbitrary Tailwind values, when `tailwindEntryPoint` is set
117
+
118
+ `better-tailwindcss/no-restricted-classes` bans a bracketed value on a utility (`text-[11px]`, `tracking-[0.08em]`, `bg-[#000]/50`) while leaving a bracketed **variant** alone (`data-[state=open]:`, `group-data-[state=open]:`, `peer-data-[checked]:`, `supports-[display:grid]:`, `[&_>_svg]:`), since those precede a colon and the ban only matches the class's own trailing bracket. `allowArbitraryClasses` exempts a utility prefix that has no theme-token shape at all, such as `grid-cols` for `grid-cols-[200px_1fr]`. Measured on a Next app: 28 distinct values at 52 sites, mostly `text-[Npx]` and `tracking-[Nem]`, none of which has a matching theme token today.
119
+
120
+ ## Module boundaries
121
+
122
+ - `nextConfigModules` restricts a `next.config.ts`, `.mts` or `.cts` and the modules it names to relative imports only (`no-restricted-imports` on `['@/*']`), on the Next preset. A `next.config.js` or `.mjs` is not linted at all, since `*.config.js` and `*.config.mjs` are in the default ignores; the modules it names still are. A config file that imports through the `@/...` alias resolves it differently at build time than the app does, so anything the config loads stays relative.
123
+ - `**/utils/**` restricts `server-only`, `next/*`, `react`, `@/lib/*` and `@/app/*` on both presets: a pure helper module takes data in and data out, never a server-only boundary or a framework import.
124
+
125
+ ## `max-lines`: 300, skipping blank lines and comments
126
+
127
+ `**/*.test.*` and `**/copy/**` are exempt (a copy dictionary's length is strings, not logic). Probed on a Next app at 200 (28 hits), 250 (13 hits) and 300 (9 hits); 300 is the threshold this config ships, since it is the only one under 10.
128
+
129
+ ## `soujvnunes/one-export-per-file`, wired only through `strictExportGlobs`
130
+
131
+ One value export per module; an interface, a type alias, or a type-only named export is free of the count. The rule is always exported from the plugin, so a consumer can wire it with `strictExportGlobs` once its own codebase is ready, but no preset turns it on by default. Probed on a read-only Next app with many small named constants and phase helpers grouped into a couple of files: 1,419 sites across 27 files, two files alone (a game-constants module and a phase-utilities module) accounting for 65 of them. That is well over the 20-file bar for adopting it by default, so it stays unwired there; a repo with smaller, more atomic modules already can wire it per folder with `strictExportGlobs`.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Rule, Linter } from 'eslint';
1
+ import { Linter } from 'eslint';
2
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
3
 
3
- declare const oneLineComments: Rule.RuleModule;
4
+ declare const oneLineComments: ESLintUtils.RuleModule<"block" | "adjacent" | "paragraphs" | "notDoc" | "orphanDoc", [], unknown, ESLintUtils.RuleListener>;
4
5
 
5
6
  type CompatiblePlugin = {
6
7
  meta: {
@@ -10,20 +11,17 @@ type CompatiblePlugin = {
10
11
  declare const soujvnunesPlugin: CompatiblePlugin;
11
12
 
12
13
  interface ConfigOptions {
13
- /** Extra ignore globs, merged after the defaults. */
14
14
  ignores?: string[];
15
- /** Full import-order groups (replaces the default skeleton). */
16
15
  importGroups?: (string | string[])[];
17
- /** Root for typescript-eslint's project service. Defaults to cwd. */
18
16
  tsconfigRootDir?: string;
19
- /** Path to the Tailwind v4 CSS entry (the file with `@import "tailwindcss"` + `@theme`, e.g. `./app/tailwind.config.css`). When set on the Next preset, it wires the bundled `eslint-plugin-better-tailwindcss` correctness rules, chiefly `no-unknown-classes`, which flags a class not registered in the theme (a dead token `tsc`/build cannot see; see DESIGN-TOKENS). Leave it unset and the plugin stays off, since without the entry the rule cannot resolve the theme and would flag every class. */
20
17
  tailwindEntryPoint?: string;
21
- /** Extra flat-config objects appended at the end. */
18
+ allowArbitraryClasses?: string[];
19
+ classMergeName?: string;
20
+ nextConfigModules?: string[];
21
+ strictExportGlobs?: string[];
22
22
  extend?: Linter.Config[];
23
23
  }
24
- /** Base config for TypeScript libraries (no React/Next layers). */
25
24
  declare const createBaseConfig: (options?: ConfigOptions) => any[];
26
- /** Full config for Next.js apps: base plus React, React Hooks, jsx-a11y and Next plugins. */
27
25
  declare const createNextConfig: (options?: ConfigOptions) => any[];
28
26
 
29
27
  export { type ConfigOptions, createBaseConfig, createNextConfig, oneLineComments, soujvnunesPlugin };
package/dist/index.js CHANGED
@@ -208,7 +208,7 @@ var createClassifier = (sourceCode, importMembersAreData) => {
208
208
  const memo = /* @__PURE__ */ new Map();
209
209
  const resolving = /* @__PURE__ */ new Set();
210
210
  let cycled = false;
211
- const withDefault = (name, verdict) => all([verdict, ...patternDefaults(name).map((fallback) => classify(fallback, "prop"))]);
211
+ const withDefault = (name, verdict) => all([verdict, ...patternDefaults(name).map((fallback) => classify2(fallback, "prop"))]);
212
212
  const written = /* @__PURE__ */ new Map();
213
213
  const isWritten = (variable, kind) => {
214
214
  const cached = written.get(variable);
@@ -235,7 +235,7 @@ var createClassifier = (sourceCode, importMembersAreData) => {
235
235
  return DECLARATION;
236
236
  if (def.type !== DefinitionType3.Variable || !def.node.init) return NEVER;
237
237
  if (isWritten(variable, def.parent.kind)) return NEVER;
238
- const init = classify(def.node.init, "prop");
238
+ const init = classify2(def.node.init, "prop");
239
239
  return withDefault(def.name, {
240
240
  data: init.data,
241
241
  stable: init.stable && MODULE_SCOPES.has(variable.scope.type) && def.parent.kind === "const"
@@ -269,7 +269,7 @@ var createClassifier = (sourceCode, importMembersAreData) => {
269
269
  const propertyName = isProperty ? keyName(property.key, property.computed) : void 0;
270
270
  const isMatch = name !== void 0 && propertyName === name;
271
271
  if (isMatch || name === void 0 || propertyName === void 0) {
272
- const value = classify(isProperty ? property.value : property.argument, position);
272
+ const value = classify2(isProperty ? property.value : property.argument, position);
273
273
  verdict = verdict ? both(verdict, value) : value;
274
274
  if (isMatch) break;
275
275
  }
@@ -282,9 +282,9 @@ var createClassifier = (sourceCode, importMembersAreData) => {
282
282
  const ofMember = (node, position) => {
283
283
  const name = keyName(node.property, node.computed);
284
284
  const isMethod = name !== void 0 && METHOD_NAMES.has(name);
285
- const key = node.computed ? classify(node.property, position) : ALWAYS;
285
+ const key = node.computed ? classify2(node.property, position) : ALWAYS;
286
286
  if (node.object.type !== AST_NODE_TYPES11.Identifier)
287
- return isMethod ? NEVER : both(classify(node.object, position), key);
287
+ return isMethod ? NEVER : both(classify2(node.object, position), key);
288
288
  const variable = variableOf(node.object, node.object.name);
289
289
  if (isImport(variable)) return both(ofImport(position, !isNamespaceImport(variable)), key);
290
290
  const [def] = variable?.defs ?? [];
@@ -302,7 +302,7 @@ var createClassifier = (sourceCode, importMembersAreData) => {
302
302
  return name === "length" ? { data: true, stable: binding.stable } : NEVER;
303
303
  return isMethod ? NEVER : both(binding, key);
304
304
  };
305
- const classify = (node, position) => {
305
+ const classify2 = (node, position) => {
306
306
  if (!node) return NEVER;
307
307
  switch (node.type) {
308
308
  case AST_NODE_TYPES11.Literal:
@@ -312,26 +312,26 @@ var createClassifier = (sourceCode, importMembersAreData) => {
312
312
  case AST_NODE_TYPES11.TemplateLiteral:
313
313
  return {
314
314
  data: true,
315
- stable: all(node.expressions.map((part) => classify(part, position))).stable
315
+ stable: all(node.expressions.map((part) => classify2(part, position))).stable
316
316
  };
317
317
  case AST_NODE_TYPES11.UnaryExpression:
318
- return { data: true, stable: classify(node.argument, position).stable };
318
+ return { data: true, stable: classify2(node.argument, position).stable };
319
319
  case AST_NODE_TYPES11.BinaryExpression:
320
320
  return {
321
321
  data: true,
322
- stable: both(classify(node.left, position), classify(node.right, position)).stable
322
+ stable: both(classify2(node.left, position), classify2(node.right, position)).stable
323
323
  };
324
324
  case AST_NODE_TYPES11.LogicalExpression:
325
- return both(classify(node.left, position), classify(node.right, position));
325
+ return both(classify2(node.left, position), classify2(node.right, position));
326
326
  case AST_NODE_TYPES11.ConditionalExpression: {
327
- const branches = both(classify(node.consequent, position), classify(node.alternate, position));
328
- return { data: branches.data, stable: branches.stable && classify(node.test, position).stable };
327
+ const branches = both(classify2(node.consequent, position), classify2(node.alternate, position));
328
+ return { data: branches.data, stable: branches.stable && classify2(node.test, position).stable };
329
329
  }
330
330
  case AST_NODE_TYPES11.ArrayExpression:
331
331
  return all(
332
332
  node.elements.map((element) => {
333
333
  if (!element) return ALWAYS;
334
- return classify(
334
+ return classify2(
335
335
  element.type === AST_NODE_TYPES11.SpreadElement ? element.argument : element,
336
336
  position
337
337
  );
@@ -341,10 +341,10 @@ var createClassifier = (sourceCode, importMembersAreData) => {
341
341
  return all(
342
342
  node.properties.map((property) => {
343
343
  if (property.type === AST_NODE_TYPES11.SpreadElement)
344
- return classify(property.argument, position);
344
+ return classify2(property.argument, position);
345
345
  if (property.kind !== "init" || property.method) return NEVER;
346
- const value = classify(property.value, position);
347
- return property.computed ? both(value, classify(property.key, position)) : value;
346
+ const value = classify2(property.value, position);
347
+ return property.computed ? both(value, classify2(property.key, position)) : value;
348
348
  })
349
349
  );
350
350
  case AST_NODE_TYPES11.MemberExpression:
@@ -353,7 +353,7 @@ var createClassifier = (sourceCode, importMembersAreData) => {
353
353
  case AST_NODE_TYPES11.TSAsExpression:
354
354
  case AST_NODE_TYPES11.TSSatisfiesExpression:
355
355
  case AST_NODE_TYPES11.TSNonNullExpression:
356
- return classify(node.expression, position);
356
+ return classify2(node.expression, position);
357
357
  case AST_NODE_TYPES11.JSXElement:
358
358
  case AST_NODE_TYPES11.JSXFragment:
359
359
  return PER_RENDER;
@@ -404,7 +404,7 @@ var createClassifier = (sourceCode, importMembersAreData) => {
404
404
  return name.object.type === AST_NODE_TYPES11.JSXIdentifier && isNamespaceImport(variableOf(element, name.object.name)) ? ALWAYS : NEVER;
405
405
  };
406
406
  const positionOf = (element) => element.name.type === AST_NODE_TYPES11.JSXIdentifier && INTRINSIC.test(element.name.name) ? "text" : "prop";
407
- return { classify, classifyTag, positionOf, variableOf };
407
+ return { classify: classify2, classifyTag, positionOf, variableOf };
408
408
  };
409
409
 
410
410
  // isEventHandler.ts
@@ -472,8 +472,8 @@ var BROWSER_GLOBALS = /* @__PURE__ */ new Set([
472
472
  var isValueReference = (reference) => reference.isValueReference !== false;
473
473
  var verdicts = /* @__PURE__ */ new WeakMap();
474
474
  var analyze = (sourceCode) => {
475
- const { classify, classifyTag, positionOf, variableOf } = createClassifier(sourceCode, false);
476
- const isData = (node) => classify(node, "prop").data;
475
+ const { classify: classify2, classifyTag, positionOf, variableOf } = createClassifier(sourceCode, false);
476
+ const isData = (node) => classify2(node, "prop").data;
477
477
  const isComponentBinding = (identifier) => {
478
478
  const variable = variableOf(identifier, identifier.name);
479
479
  const isNamedLikeComponent = isComponentName(variable?.name);
@@ -574,7 +574,6 @@ var analyze = (sourceCode) => {
574
574
  return (isTag ? isFunctionAttribute(key) : key !== "className") && !isData(value.expression);
575
575
  });
576
576
  }
577
- // A child of a component is its `children` prop, which can carry a function; a child of a tag or a fragment renders in place and cannot.
578
577
  case AST_NODE_TYPES12.JSXExpressionContainer:
579
578
  return node.parent.type === AST_NODE_TYPES12.JSXElement && positionOf(node.parent.openingElement) === "prop" && !isData(node.expression);
580
579
  default:
@@ -623,22 +622,300 @@ var needlessUseClient = ESLintUtils.RuleCreator.withoutDocs({
623
622
  }
624
623
  });
625
624
 
626
- // oneLineComments.ts
627
- var DIRECTIVE = /^\s*(?:eslint-disable\b|eslint-enable\b|\/\s*<|prettier-ignore|biome-ignore|(?:istanbul|c8|v8)\s+ignore\b|webpack[A-Z])/u;
625
+ // noComments.ts
626
+ import { AST_NODE_TYPES as AST_NODE_TYPES14, AST_TOKEN_TYPES as AST_TOKEN_TYPES2, ESLintUtils as ESLintUtils2 } from "@typescript-eslint/utils";
627
+
628
+ // commentKinds.ts
629
+ import { AST_NODE_TYPES as AST_NODE_TYPES13, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
630
+ var DIRECTIVE = /^\s*(?:eslint-disable\b|eslint-enable\b|\/\s*<|prettier-ignore|biome-ignore|(?:istanbul|c8|v8)\s+ignore\b|(?:webpack|turbopack)[A-Z]|@vitest-environment\b)/u;
631
+ var ALLOW_MARKER = /\bgitleaks:allow\b/u;
628
632
  var BLOCK_DIRECTIVE = /^\s*(?:eslint\s|eslint-env\b|global\s|globals\s|exported\s)/u;
633
+ var PRAGMA = /^\s*(?:@ts-(?:expect-error|ignore|nocheck|check)\b|@jsx(?:Frag|ImportSource|Runtime)?\b|[@#]__[A-Z_]+__|[@#]\s*source(?:Mapping)?URL=|@jest-environment\b|@vite-ignore\b|@refresh\s+reset\b|@license\b|@preserve\b|@format\b|@prettier\b|@internal\s*$|node:coverage\s)/u;
634
+ var TYPED = /^\s*\{/u;
635
+ var NAME = /^[\w$]+$/u;
636
+ var IMPORT_CLAUSE = /^\s*(?:\{[^}]*\}|\*\s*as\s+[\w$]+|[\w$]+)\s+from\s+['"]/u;
637
+ var TYPED_TAG = /(?:^|\s)@(?:param|returns?)\s*\{/u;
638
+ var firstLine = (rest) => (rest.split(/\r?\n/u)[0] ?? "").trim();
639
+ var typed = (rest) => TYPED.test(rest);
640
+ var named = (rest) => typed(rest) || NAME.test(firstLine(rest));
641
+ var nameList = (rest) => typed(rest) || firstLine(rest).split(",").every((part) => NAME.test(part.trim()));
642
+ var heritage = (rest) => typed(rest) || /^[\w$.]+$/u.test(firstLine(rest).replace(/<.*>$/u, ""));
643
+ var TYPE_TAGS = /* @__PURE__ */ new Map([
644
+ ["type", typed],
645
+ ["param", typed],
646
+ ["returns", typed],
647
+ ["return", typed],
648
+ ["satisfies", typed],
649
+ ["enum", typed],
650
+ ["this", typed],
651
+ ["typedef", named],
652
+ ["callback", named],
653
+ ["template", nameList],
654
+ ["extends", heritage],
655
+ ["augments", heritage],
656
+ ["implements", heritage],
657
+ ["import", (rest) => IMPORT_CLAUSE.test(rest)],
658
+ ["overload", (rest) => TYPED_TAG.test(rest)]
659
+ ]);
629
660
  var ANNOTATION = /^\s*[@#]/u;
630
661
  var BLOCK_ANNOTATION = /^\s*[\w-]+:\S/u;
631
- var isComment = (token) => token?.type === "Line" || token?.type === "Block";
632
- var isDocShaped = (comment) => comment.type === "Block" && comment.value.startsWith("*");
633
- var isBanner = (comment) => comment.type === "Block" && comment.value.startsWith("!");
662
+ var DEPRECATION = /^@deprecated(?![\w-])/u;
663
+ var LATER_TAG = /\s@\w[\w-]*(?![\w/-])/u;
664
+ var isComment = (token) => token?.type === AST_TOKEN_TYPES.Line || token?.type === AST_TOKEN_TYPES.Block;
665
+ var isDocShaped = (comment) => comment.type === AST_TOKEN_TYPES.Block && comment.value.startsWith("*");
666
+ var isBanner = (comment) => comment.type === AST_TOKEN_TYPES.Block && comment.value.startsWith("!");
634
667
  var pragmaText = (comment) => comment.value.replace(/^\*+/u, "");
668
+ var docText = (comment) => comment.value.split(/\r?\n/u).map((line) => line.trim().replace(/^\*+/u, "").trim()).filter(Boolean).join(" ");
669
+ var isDeprecation = (comment) => {
670
+ if (!isDocShaped(comment)) return false;
671
+ const text = docText(comment);
672
+ return DEPRECATION.test(text) && !LATER_TAG.test(text);
673
+ };
635
674
  var isDirectiveText = (text) => DIRECTIVE.test(text) || ANNOTATION.test(text);
636
- var isDirective = (comment) => isDirectiveText(pragmaText(comment)) || comment.type === "Block" && (BLOCK_DIRECTIVE.test(comment.value) || !isDocShaped(comment) && BLOCK_ANNOTATION.test(comment.value));
637
- var spansLines = (comment) => (comment.loc?.start.line ?? 0) !== (comment.loc?.end.line ?? 0);
638
- var isBare = (comment) => comment.type === "Line" && comment.value.trim() === "";
675
+ var isDirective = (comment) => isDirectiveText(pragmaText(comment)) || comment.type === AST_TOKEN_TYPES.Block && (BLOCK_DIRECTIVE.test(comment.value) || !isDocShaped(comment) && BLOCK_ANNOTATION.test(comment.value));
676
+ var isToolDirective = (comment) => {
677
+ const text = pragmaText(comment);
678
+ return DIRECTIVE.test(text) || PRAGMA.test(text) || isDeprecation(comment) || comment.type === AST_TOKEN_TYPES.Block && BLOCK_DIRECTIVE.test(comment.value);
679
+ };
680
+ var holdsTag = (comment) => /(?:^|\s)@\w/u.test(pragmaText(comment));
681
+ var isTypeAnnotation = (comment) => {
682
+ const text = pragmaText(comment);
683
+ const tag = isDocShaped(comment) ? /(?:^|\s)@(\w+)/u.exec(text) : null;
684
+ const shape = TYPE_TAGS.get(tag?.[1] ?? "");
685
+ return !!tag && !!shape && shape(text.slice(tag.index + tag[0].length));
686
+ };
687
+ var spansLines = (comment) => comment.loc.start.line !== comment.loc.end.line;
688
+ var followedOnLine = (comment, after) => !!after && after.loc.start.line === comment.loc.end.line;
689
+ var createCommentLookup = (sourceCode) => {
690
+ const nodes = /* @__PURE__ */ new Map();
691
+ const nodeAt = (index) => {
692
+ const known = nodes.get(index);
693
+ if (known !== void 0) return known;
694
+ const node = sourceCode.getNodeByRangeIndex(index);
695
+ nodes.set(index, node);
696
+ return node;
697
+ };
698
+ const enclosingNode = (comment) => nodeAt(comment.range[0]);
699
+ const jsxContainer = (comment) => {
700
+ const node = enclosingNode(comment);
701
+ return node?.type === AST_NODE_TYPES13.JSXEmptyExpression ? node.parent : null;
702
+ };
703
+ const sidesOf = (span) => {
704
+ const { lines } = sourceCode;
705
+ return {
706
+ before: (lines[span.start.line - 1] ?? "").slice(0, span.start.column).trim() !== "",
707
+ after: (lines[span.end.line - 1] ?? "").slice(span.end.column).trim() !== ""
708
+ };
709
+ };
710
+ const sides = (comment) => sidesOf(jsxContainer(comment)?.loc ?? comment.loc);
711
+ const isOwnLine = (comment) => {
712
+ const side = comment.type === AST_TOKEN_TYPES.Line ? sidesOf(comment.loc) : sides(comment);
713
+ return !side.before && !side.after;
714
+ };
715
+ const isAllowMarker = (comment) => {
716
+ if (spansLines(comment) || !ALLOW_MARKER.test(comment.value)) return false;
717
+ const before = sourceCode.getTokenBefore(comment);
718
+ const after = sourceCode.getTokenAfter(comment);
719
+ return !!before && before.loc.end.line === comment.loc.start.line || !!after && after.loc.start.line === comment.loc.end.line;
720
+ };
721
+ return { nodeAt, enclosingNode, jsxContainer, sides, isOwnLine, isAllowMarker };
722
+ };
723
+
724
+ // noComments.ts
725
+ var JS_FILE = /\.[cm]?jsx?$/u;
726
+ var EM_DASH = String.fromCodePoint(8212);
727
+ var isJsxNode = (node) => !!node && node.type.startsWith("JSX") && node.type !== AST_NODE_TYPES14.JSXExpressionContainer;
728
+ var FUNCTION_NODES = /* @__PURE__ */ new Set([
729
+ AST_NODE_TYPES14.FunctionDeclaration,
730
+ AST_NODE_TYPES14.FunctionExpression,
731
+ AST_NODE_TYPES14.ArrowFunctionExpression
732
+ ]);
733
+ var isEmptyBlock = (node) => {
734
+ if (node?.type === AST_NODE_TYPES14.SwitchStatement) return node.cases.length === 0;
735
+ if (node?.type === AST_NODE_TYPES14.StaticBlock) return node.body.length === 0;
736
+ return node?.type === AST_NODE_TYPES14.BlockStatement && node.body.length === 0 && !FUNCTION_NODES.has(node.parent.type);
737
+ };
738
+ var classify = (comment, lookup) => {
739
+ const node = lookup.enclosingNode(comment);
740
+ const inJsx = isJsxNode(node);
741
+ if (isToolDirective(comment) || lookup.isAllowMarker(comment)) {
742
+ return inJsx ? "jsxDirective" : "directive";
743
+ }
744
+ if (isBanner(comment)) return "banner";
745
+ if (inJsx) return node?.type === AST_NODE_TYPES14.JSXEmptyExpression ? "jsx" : "attribute";
746
+ if (isDocShaped(comment)) return "jsdoc";
747
+ return comment.type === AST_TOKEN_TYPES2.Line ? "line" : "block";
748
+ };
749
+ var KEPT = "Only a tool directive stays, such as `eslint-disable`, `@ts-expect-error`, a type annotation in a JS file, a lone `@internal` or a JSDoc holding only `@deprecated`.";
750
+ var MESSAGES = {
751
+ line: `Comments are not allowed in code. Delete this \`//\` comment: a reason the code cannot carry belongs in the README. ${KEPT}`,
752
+ block: `Comments are not allowed in code. Delete this block comment: a reason the code cannot carry belongs in the README. ${KEPT}`,
753
+ jsdoc: `Comments are not allowed in code, JSDoc included. Delete this JSDoc: a reason the code cannot carry belongs in the README. ${KEPT}`,
754
+ jsx: "Comments are not allowed in JSX. Delete this `{/* */}` container; only a tool directive stays.",
755
+ attribute: "Comments are not allowed inside a JSX tag. Delete this one.",
756
+ emDash: "This `@deprecated` JSDoc holds an em dash. Write a comma, a colon, parentheses or two sentences instead."
757
+ };
758
+ var MESSAGE_IDS = {
759
+ directive: null,
760
+ banner: null,
761
+ jsxDirective: null,
762
+ jsdoc: "jsdoc",
763
+ jsx: "jsx",
764
+ attribute: "attribute",
765
+ line: "line",
766
+ block: "block"
767
+ };
768
+ var noComments = ESLintUtils2.RuleCreator.withoutDocs({
769
+ meta: {
770
+ type: "suggestion",
771
+ docs: {
772
+ description: "Disallow comments in code, JSDoc included, except tool directives, a type-annotation JSDoc in a JS file, a lone `@internal` and a JSDoc holding only `@deprecated`."
773
+ },
774
+ fixable: "code",
775
+ schema: [],
776
+ messages: MESSAGES
777
+ },
778
+ defaultOptions: [],
779
+ create(context) {
780
+ const sourceCode = context.sourceCode;
781
+ const { lines, text } = sourceCode;
782
+ const lookup = createCommentLookup(sourceCode);
783
+ const typedJs = JS_FILE.test(context.filename);
784
+ const lineStart = (line) => sourceCode.getIndexFromLoc({ line, column: 0 });
785
+ const lineEnd = (line) => lineStart(line) + (lines[line - 1]?.length ?? 0);
786
+ const wholeLines = (first, last) => {
787
+ if (last < lines.length) return [lineStart(first), lineStart(last + 1)];
788
+ if (first > 1) return [lineEnd(first - 1), text.length];
789
+ return [0, text.length];
790
+ };
791
+ const removal = (comment, kind) => {
792
+ if (kind === "attribute" || kind === "jsdoc" && holdsTag(comment) || isEmptyBlock(lookup.enclosingNode(comment))) {
793
+ return null;
794
+ }
795
+ const span = lookup.jsxContainer(comment) ?? comment;
796
+ const side = lookup.sides(comment);
797
+ const { range, loc } = span;
798
+ const { before, after } = side;
799
+ if (!before && !after) {
800
+ const bounds = [loc.start.line, loc.end.line];
801
+ return { range: wholeLines(...bounds), text: "", lines: bounds };
802
+ }
803
+ if (kind === "jsx") return null;
804
+ const previousEnd = sourceCode.getTokenBefore(comment, { includeComments: true })?.range[1];
805
+ const nextStart = sourceCode.getTokenAfter(comment, { includeComments: true })?.range[0];
806
+ if (before && after) {
807
+ if (spansLines(comment) || previousEnd === void 0 || nextStart === void 0) return null;
808
+ return { range: [previousEnd, nextStart], text: " ", lines: null };
809
+ }
810
+ if (before) {
811
+ return previousEnd === void 0 ? null : { range: [previousEnd, range[1]], text: "", lines: null };
812
+ }
813
+ return nextStart === void 0 ? null : { range: [range[0], nextStart], text: "", lines: null };
814
+ };
815
+ return {
816
+ "Program:exit"() {
817
+ const reports = [];
818
+ for (const comment of sourceCode.getAllComments().filter(isComment)) {
819
+ const kind = typedJs && isTypeAnnotation(comment) ? "directive" : classify(comment, lookup);
820
+ if (isDeprecation(comment) && comment.value.includes(EM_DASH)) {
821
+ reports.push({ comment, messageId: "emDash", fix: null });
822
+ continue;
823
+ }
824
+ const messageId = MESSAGE_IDS[kind];
825
+ if (messageId) reports.push({ comment, messageId, fix: removal(comment, kind) });
826
+ }
827
+ const ownLine = reports.map(({ fix }) => fix).filter((fix) => !!fix?.lines).sort((a, b) => a.lines[0] - b.lines[0]);
828
+ let run = [];
829
+ const flush = () => {
830
+ const first = run[0];
831
+ const last = run[run.length - 1];
832
+ if (first && last) {
833
+ const range = wholeLines(first.lines[0], last.lines[1]);
834
+ for (const fix of run) fix.range = range;
835
+ }
836
+ run = [];
837
+ };
838
+ for (const fix of ownLine) {
839
+ const previous = run[run.length - 1];
840
+ if (previous && previous.lines[1] + 1 !== fix.lines[0]) flush();
841
+ run.push(fix);
842
+ }
843
+ flush();
844
+ for (const { comment, messageId, fix } of reports) {
845
+ context.report({
846
+ loc: comment.loc,
847
+ messageId,
848
+ fix: fix ? (fixer) => fixer.replaceTextRange(fix.range, fix.text) : null
849
+ });
850
+ }
851
+ }
852
+ };
853
+ }
854
+ });
855
+
856
+ // oneExportPerFile.ts
857
+ import { AST_NODE_TYPES as AST_NODE_TYPES15, ESLintUtils as ESLintUtils3 } from "@typescript-eslint/utils";
858
+ var isTypeOnlyDeclaration = (declaration) => declaration?.type === AST_NODE_TYPES15.TSInterfaceDeclaration || declaration?.type === AST_NODE_TYPES15.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES15.TSDeclareFunction;
859
+ var declaratorEntries = (declaration) => declaration.declarations.map((declarator) => ({
860
+ node: declarator,
861
+ name: declarator.id.type === AST_NODE_TYPES15.Identifier ? declarator.id.name : "a destructured export"
862
+ }));
863
+ var declarationEntry = (declaration) => ({
864
+ node: declaration,
865
+ name: "id" in declaration && declaration.id?.type === AST_NODE_TYPES15.Identifier ? declaration.id.name : "default"
866
+ });
867
+ var namedEntries = (node) => {
868
+ if (node.exportKind === "type") return [];
869
+ const { declaration, specifiers } = node;
870
+ if (declaration) {
871
+ if (isTypeOnlyDeclaration(declaration)) return [];
872
+ if (declaration.type === AST_NODE_TYPES15.VariableDeclaration) return declaratorEntries(declaration);
873
+ return [declarationEntry(declaration)];
874
+ }
875
+ return specifiers.filter((specifier) => specifier.exportKind !== "type").map((specifier) => ({
876
+ node: specifier,
877
+ name: specifier.exported.type === AST_NODE_TYPES15.Identifier ? specifier.exported.name : specifier.exported.value
878
+ }));
879
+ };
880
+ var exportEntries = (statement) => {
881
+ if (statement.type === AST_NODE_TYPES15.ExportNamedDeclaration) return namedEntries(statement);
882
+ if (statement.type === AST_NODE_TYPES15.ExportDefaultDeclaration)
883
+ return statement.declaration.type === AST_NODE_TYPES15.TSDeclareFunction ? [] : [{ node: statement, name: "default" }];
884
+ return [];
885
+ };
886
+ var oneExportPerFile = ESLintUtils3.RuleCreator.withoutDocs({
887
+ meta: {
888
+ type: "suggestion",
889
+ docs: {
890
+ description: "Disallow more than one value export per module. A type export (an interface, a type alias, or a type-only named export) is free of the count."
891
+ },
892
+ schema: [],
893
+ messages: {
894
+ multiple: "This module already exports `{{first}}`; give `{{name}}` its own module. A type export is free of this rule."
895
+ }
896
+ },
897
+ defaultOptions: [],
898
+ create(context) {
899
+ return {
900
+ Program(program) {
901
+ const [first, ...rest] = program.body.flatMap(exportEntries);
902
+ if (!first || rest.length === 0) return;
903
+ for (const entry of rest)
904
+ context.report({
905
+ node: entry.node,
906
+ messageId: "multiple",
907
+ data: { first: first.name, name: entry.name }
908
+ });
909
+ }
910
+ };
911
+ }
912
+ });
913
+
914
+ // oneLineComments.ts
915
+ import { AST_TOKEN_TYPES as AST_TOKEN_TYPES3, ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
916
+ var isBare = (comment) => comment.type === AST_TOKEN_TYPES3.Line && comment.value.trim() === "";
639
917
  var collapse = (text) => text.replace(/\s+/gu, " ").trim();
640
918
  var asLine = (body) => body ? `// ${body}` : null;
641
- var followedOnLine = (comment, after) => !!after?.loc && !!comment.loc && after.loc.start.line === comment.loc.end.line;
642
919
  var blockLines = (comment) => comment.value.replace(/^!/u, "").split(/\r\n|[\r\n\u2028\u2029]/u).map(
643
920
  (line) => line.trim().replace(/^\*(?= |$)/u, "").trim()
644
921
  );
@@ -669,10 +946,9 @@ var collapsedBlock = (comment, lines) => {
669
946
  };
670
947
  var isJsDoc = (comment, after) => {
671
948
  if (!isComment(after)) return true;
672
- const next = after;
673
- return isDirective(next) || isDocShaped(next) && /^\*+\s*@/u.test(comment.value);
949
+ return isDirective(after) || isDocShaped(after) && /^\*+\s*@/u.test(comment.value);
674
950
  };
675
- var oneLineComments = {
951
+ var oneLineComments = ESLintUtils4.RuleCreator.withoutDocs({
676
952
  meta: {
677
953
  type: "layout",
678
954
  docs: {
@@ -683,39 +959,21 @@ var oneLineComments = {
683
959
  messages: {
684
960
  adjacent: "Two comment lines are touching. A comment is one line, however long it runs: join them, or write one line per fact beside the code it describes.",
685
961
  paragraphs: "A paragraph break inside a comment, a bare `//` between comment lines or an empty line inside a block, makes it a set of comments rather than one wrapped line, and joining it would bury every fact but the first. Write one line per fact beside the code it describes, or move the rationale to the README or the project MANIFEST.",
686
- block: "This block comment spans lines. A comment is one line, however long it runs: collapse it to one `//` line, or to one `/** \u2026 */` line when it is JSDoc, or move the rationale to the README or the project MANIFEST.",
962
+ block: "This block comment spans lines. A comment is one line, however long it runs: collapse it to one `//` line, or to one `/** \u2026 */` line when a tool reads it as JSDoc, or move the rationale to the README or the project MANIFEST.",
687
963
  notDoc: "A block comment is for JSDoc and JSX only. Write this one as `//`, on its own line or at the end of one, or delete it if it is empty.",
688
- orphanDoc: "`/**` is JSDoc, and JSDoc sits directly above the code it documents. Move it there, join it with the doc under it, or write it as `//`."
964
+ orphanDoc: "`/**` opens a JSDoc, which a tool reads only directly above the code it applies to. Move it there when a tool reads it, and delete it otherwise."
689
965
  }
690
966
  },
967
+ defaultOptions: [],
691
968
  create(context) {
692
969
  const sourceCode = context.sourceCode;
693
970
  const comments = sourceCode.getAllComments().filter(isComment);
694
- const enclosing = /* @__PURE__ */ new Map();
695
- const enclosingNode = (comment) => {
696
- const known = enclosing.get(comment);
697
- if (known !== void 0) return known;
698
- const node = sourceCode.getNodeByRangeIndex(comment.range?.[0] ?? 0);
699
- enclosing.set(comment, node);
700
- return node;
701
- };
702
- const insideJsx = (comment) => enclosingNode(comment)?.type?.startsWith("JSX") ?? false;
703
- const jsxContainer = (comment) => {
704
- const node = comment.type === "Block" ? enclosingNode(comment) : null;
705
- return node?.type === "JSXEmptyExpression" ? node.parent ?? null : null;
706
- };
707
- const isOwnLine = (comment) => {
708
- const span = jsxContainer(comment)?.loc ?? comment.loc;
709
- if (!span) return false;
710
- const lines = sourceCode.getLines();
711
- const before = (lines[span.start.line - 1] ?? "").slice(0, span.start.column);
712
- const after = (lines[span.end.line - 1] ?? "").slice(span.end.column);
713
- return before.trim() === "" && after.trim() === "";
714
- };
971
+ const { enclosingNode, isOwnLine, isAllowMarker } = createCommentLookup(sourceCode);
972
+ const insideJsx = (comment) => enclosingNode(comment)?.type.startsWith("JSX") ?? false;
715
973
  const breaksSemicolonInsertion = (comment, after) => {
716
974
  if (insideJsx(comment)) return false;
717
975
  const before = sourceCode.getTokenBefore(comment, { includeComments: true });
718
- return !!before?.loc && before.loc.end.line === comment.loc?.start.line && followedOnLine(comment, after);
976
+ return !!before && before.loc.end.line === comment.loc.start.line && followedOnLine(comment, after);
719
977
  };
720
978
  const blockVerdict = (comment, after) => {
721
979
  const lines = blockLines(comment);
@@ -733,7 +991,9 @@ var oneLineComments = {
733
991
  "Program:exit"() {
734
992
  const docs = /* @__PURE__ */ new Set();
735
993
  for (const comment of comments) {
736
- if (comment.type !== "Block" || isDirective(comment)) continue;
994
+ if (comment.type !== AST_TOKEN_TYPES3.Block || isDirective(comment) || isAllowMarker(comment)) {
995
+ continue;
996
+ }
737
997
  const after = sourceCode.getTokenAfter(comment, { includeComments: true });
738
998
  if (spansLines(comment)) {
739
999
  const { messageId: messageId2, text: text2 } = blockVerdict(comment, after);
@@ -767,20 +1027,20 @@ var oneLineComments = {
767
1027
  if (current.length < 2 || current.some(isDirective)) return;
768
1028
  const first = current[0];
769
1029
  const last = current[current.length - 1];
770
- if (!first?.loc || !last?.loc) return;
771
- const block = current.some((comment) => comment.type === "Block");
1030
+ if (!first || !last) return;
1031
+ const block = current.some((comment) => comment.type === AST_TOKEN_TYPES3.Block);
772
1032
  const texts = current.map((comment) => isBare(comment) ? "" : comment.value.trim() || " ");
773
1033
  const paragraphs = proseParagraphs(texts, false) > 1;
774
1034
  const text = asLine(collapse(texts.join(" ")));
775
1035
  context.report({
776
1036
  loc: { start: first.loc.start, end: last.loc.end },
777
1037
  messageId: paragraphs ? "paragraphs" : "adjacent",
778
- fix: paragraphs || block || !text ? null : (fixer) => fixer.replaceTextRange([first.range?.[0] ?? 0, last.range?.[1] ?? 0], text)
1038
+ fix: paragraphs || block || !text ? null : (fixer) => fixer.replaceTextRange([first.range[0], last.range[1]], text)
779
1039
  });
780
1040
  };
781
1041
  for (const comment of joinable) {
782
1042
  const previous = run[run.length - 1];
783
- const touching = previous && (previous.loc?.end.line ?? 0) + 1 === (comment.loc?.start.line ?? 0);
1043
+ const touching = previous && previous.loc.end.line + 1 === comment.loc.start.line;
784
1044
  if (!touching) flush();
785
1045
  run.push(comment);
786
1046
  }
@@ -788,18 +1048,18 @@ var oneLineComments = {
788
1048
  }
789
1049
  };
790
1050
  }
791
- };
1051
+ });
792
1052
 
793
1053
  // staticJsxInClient.ts
794
- import { AST_NODE_TYPES as AST_NODE_TYPES13, AST_TOKEN_TYPES, ESLintUtils as ESLintUtils2 } from "@typescript-eslint/utils";
1054
+ import { AST_NODE_TYPES as AST_NODE_TYPES16, AST_TOKEN_TYPES as AST_TOKEN_TYPES4, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
795
1055
  var DISABLE_KEYWORDS = ["eslint-disable-next-line", "eslint-disable-line", "eslint-disable"];
796
- var isJsx = (node) => node.type === AST_NODE_TYPES13.JSXElement || node.type === AST_NODE_TYPES13.JSXFragment;
1056
+ var isJsx = (node) => node.type === AST_NODE_TYPES16.JSXElement || node.type === AST_NODE_TYPES16.JSXFragment;
797
1057
  var isRenderedByComponent = (node) => {
798
1058
  let current = node.parent;
799
1059
  while (current && !isFunctionNode(current)) current = current.parent;
800
1060
  return !current || isComponentFunction(current);
801
1061
  };
802
- var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
1062
+ var staticJsxInClient = ESLintUtils5.RuleCreator.withoutDocs({
803
1063
  meta: {
804
1064
  type: "suggestion",
805
1065
  docs: {
@@ -833,23 +1093,23 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
833
1093
  const line = directive.loc.start.line;
834
1094
  if (keyword === "eslint-disable-line") return covers && comment.loc.start.line === line;
835
1095
  if (keyword === "eslint-disable-next-line") return covers && comment.loc.end.line === line - 1;
836
- return covers && comment.type === AST_TOKEN_TYPES.Block && comment.range[1] <= directive.range[0];
1096
+ return covers && comment.type === AST_TOKEN_TYPES4.Block && comment.range[1] <= directive.range[0];
837
1097
  });
838
1098
  if (!needsClient(sourceCode) && !isDirectiveKept()) return {};
839
- const { classify, classifyTag, positionOf } = createClassifier(sourceCode, true);
1099
+ const { classify: classify2, classifyTag, positionOf } = createClassifier(sourceCode, true);
840
1100
  const isStatic = (node, position) => {
841
- const verdict = classify(node, position);
1101
+ const verdict = classify2(node, position);
842
1102
  return verdict.data && verdict.stable;
843
1103
  };
844
1104
  const isStaticAttribute = (attribute, position) => {
845
- if (attribute.type !== AST_NODE_TYPES13.JSXAttribute) return false;
846
- const key = attribute.name.type === AST_NODE_TYPES13.JSXIdentifier ? attribute.name.name : "";
1105
+ if (attribute.type !== AST_NODE_TYPES16.JSXAttribute) return false;
1106
+ const key = attribute.name.type === AST_NODE_TYPES16.JSXIdentifier ? attribute.name.name : "";
847
1107
  if (isFunctionAttribute(key)) return false;
848
1108
  const { value } = attribute;
849
- if (!value || value.type === AST_NODE_TYPES13.Literal) return true;
850
- return value.type === AST_NODE_TYPES13.JSXExpressionContainer && isStatic(value.expression, position);
1109
+ if (!value || value.type === AST_NODE_TYPES16.Literal) return true;
1110
+ return value.type === AST_NODE_TYPES16.JSXExpressionContainer && isStatic(value.expression, position);
851
1111
  };
852
- const childPosition = (node) => node.type === AST_NODE_TYPES13.JSXElement ? positionOf(node.openingElement) : "text";
1112
+ const childPosition = (node) => node.type === AST_NODE_TYPES16.JSXElement ? positionOf(node.openingElement) : "text";
853
1113
  const verdicts2 = /* @__PURE__ */ new Map();
854
1114
  const judge = (node) => {
855
1115
  const cached = verdicts2.get(node);
@@ -857,7 +1117,7 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
857
1117
  const position = childPosition(node);
858
1118
  let isStaticNode = true;
859
1119
  let count = 0;
860
- if (node.type === AST_NODE_TYPES13.JSXElement) {
1120
+ if (node.type === AST_NODE_TYPES16.JSXElement) {
861
1121
  const { openingElement } = node;
862
1122
  const tag = classifyTag(openingElement);
863
1123
  isStaticNode = tag.data && tag.stable && openingElement.attributes.every((attribute) => isStaticAttribute(attribute, position));
@@ -868,9 +1128,9 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
868
1128
  const verdict2 = judge(child);
869
1129
  isStaticNode &&= verdict2.isStatic;
870
1130
  count += verdict2.count;
871
- } else if (child.type === AST_NODE_TYPES13.JSXExpressionContainer)
1131
+ } else if (child.type === AST_NODE_TYPES16.JSXExpressionContainer)
872
1132
  isStaticNode &&= isStatic(child.expression, position);
873
- else if (child.type !== AST_NODE_TYPES13.JSXText) isStaticNode = false;
1133
+ else if (child.type !== AST_NODE_TYPES16.JSXText) isStaticNode = false;
874
1134
  }
875
1135
  const verdict = { isStatic: isStaticNode, count };
876
1136
  verdicts2.set(node, verdict);
@@ -899,9 +1159,9 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
899
1159
  else if (isJsx(child)) {
900
1160
  flush();
901
1161
  visit(child);
902
- } else if (child.type === AST_NODE_TYPES13.JSXExpressionContainer && !isStatic(child.expression, position))
1162
+ } else if (child.type === AST_NODE_TYPES16.JSXExpressionContainer && !isStatic(child.expression, position))
903
1163
  flush();
904
- else if (child.type === AST_NODE_TYPES13.JSXSpreadChild) flush();
1164
+ else if (child.type === AST_NODE_TYPES16.JSXSpreadChild) flush();
905
1165
  }
906
1166
  flush();
907
1167
  };
@@ -914,12 +1174,13 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
914
1174
 
915
1175
  // plugin.ts
916
1176
  var plugin = {
917
- // No `version`: it feeds ESLint's cache key, and a hardcoded one drifts from package.json and serves stale cached results after a behaviour change.
918
1177
  meta: { name: "@soujvnunes/eslint-config" },
919
1178
  rules: {
920
1179
  "one-line-comments": oneLineComments,
1180
+ "no-comments": noComments,
921
1181
  "no-needless-use-client": needlessUseClient,
922
- "no-static-jsx-in-client": staticJsxInClient
1182
+ "no-static-jsx-in-client": staticJsxInClient,
1183
+ "one-export-per-file": oneExportPerFile
923
1184
  }
924
1185
  };
925
1186
  var soujvnunesPlugin = plugin;
@@ -943,6 +1204,7 @@ var DEFAULT_IMPORT_GROUPS = [
943
1204
  "sibling",
944
1205
  "index"
945
1206
  ];
1207
+ var MAX_LINES = 300;
946
1208
  var typescriptRules = {
947
1209
  "@typescript-eslint/no-unused-vars": [
948
1210
  "error",
@@ -967,7 +1229,6 @@ var typescriptRules = {
967
1229
  "@typescript-eslint/prefer-nullish-coalescing": "error",
968
1230
  "no-shadow": "off",
969
1231
  "@typescript-eslint/no-shadow": "error",
970
- // Type-aware, so they need the project service wired below.
971
1232
  "@typescript-eslint/no-floating-promises": "error",
972
1233
  "@typescript-eslint/no-misused-promises": "error",
973
1234
  "@typescript-eslint/await-thenable": "error",
@@ -1012,42 +1273,66 @@ var generalRules = {
1012
1273
  "no-eval": "error",
1013
1274
  "no-implied-eval": "error",
1014
1275
  "no-script-url": "error",
1015
- // Blank lines between statements are stripped, not required, with no exceptions. Import-group separators go too, so `import-helpers/order-imports` runs with `newlinesBetween: 'never'` and `import-x/newline-after-import` is off; grouping and order still hold, they are just not spelled with whitespace.
1016
- "padding-line-between-statements": ["error", { blankLine: "never", prev: "*", next: "*" }]
1276
+ "padding-line-between-statements": ["error", { blankLine: "never", prev: "*", next: "*" }],
1277
+ "max-lines": ["error", { max: MAX_LINES, skipBlankLines: true, skipComments: true }]
1017
1278
  };
1018
- var restrictedSyntaxRule = {
1019
- "no-restricted-syntax": [
1020
- "error",
1021
- {
1022
- selector: "ExportDefaultDeclaration > FunctionDeclaration",
1023
- message: "Avoid `export default function`; use `export const` instead for tree-shakeable modules."
1024
- },
1025
- {
1026
- selector: "ExportNamedDeclaration > FunctionDeclaration",
1027
- message: "Use `export const` instead of `export function` for tree-shakeable modules."
1028
- },
1029
- {
1030
- selector: "TSEnumDeclaration",
1031
- message: "Avoid enums; use const assertions or union types instead."
1032
- },
1033
- {
1034
- selector: "ImportDeclaration[source.value='react'] > ImportDefaultSpecifier",
1035
- message: "Do not import the React default. Use the ambient `React.*` namespace (the react-jsx runtime needs no React import)."
1036
- },
1037
- {
1038
- selector: "ImportDeclaration[source.value='react'] > ImportNamespaceSpecifier",
1039
- message: "Do not `import * as React`. Use the ambient `React.*` namespace."
1040
- },
1041
- {
1042
- selector: "ImportDeclaration[source.value='react'] > ImportSpecifier[importKind='type']",
1043
- message: "Reference React types via the ambient `React.*` namespace, not a named `{ type X }` import from react."
1044
- },
1045
- {
1046
- selector: "ImportDeclaration[importKind='type'][source.value='react']",
1047
- message: 'Reference React types via the ambient `React.*` namespace, not `import type \u2026 from "react"`.'
1048
- }
1049
- ]
1279
+ var RESTRICTED_SELECTORS = {
1280
+ exportDefaultFunction: {
1281
+ selector: "ExportDefaultDeclaration > FunctionDeclaration",
1282
+ message: "Avoid `export default function`; use `export const` instead for tree-shakeable modules."
1283
+ },
1284
+ exportNamedFunction: {
1285
+ selector: "ExportNamedDeclaration > FunctionDeclaration",
1286
+ message: "Use `export const` instead of `export function` for tree-shakeable modules."
1287
+ },
1288
+ tsEnum: {
1289
+ selector: "TSEnumDeclaration",
1290
+ message: "Avoid enums; use const assertions or union types instead."
1291
+ },
1292
+ reactDefaultImport: {
1293
+ selector: "ImportDeclaration[source.value='react'] > ImportDefaultSpecifier",
1294
+ message: "Do not import the React default. Use the ambient `React.*` namespace (the react-jsx runtime needs no React import)."
1295
+ },
1296
+ reactNamespaceImport: {
1297
+ selector: "ImportDeclaration[source.value='react'] > ImportNamespaceSpecifier",
1298
+ message: "Do not `import * as React`. Use the ambient `React.*` namespace."
1299
+ },
1300
+ reactTypeImportSpecifier: {
1301
+ selector: "ImportDeclaration[source.value='react'] > ImportSpecifier[importKind='type']",
1302
+ message: "Reference React types via the ambient `React.*` namespace, not a named `{ type X }` import from react."
1303
+ },
1304
+ reactTypeImportDeclaration: {
1305
+ selector: "ImportDeclaration[importKind='type'][source.value='react']",
1306
+ message: 'Reference React types via the ambient `React.*` namespace, not `import type \u2026 from "react"`.'
1307
+ },
1308
+ lucideIcon: {
1309
+ selector: "ImportDeclaration[source.value='lucide-react'][importKind!='type'] > ImportSpecifier[importKind!='type'][imported.name!=/Icon$/][imported.name!='createLucideIcon'][imported.name!='icons'][imported.name!='dynamicIconImports']",
1310
+ message: "Import the `*Icon` name from lucide-react, so a rename never lands on the plain word."
1311
+ },
1312
+ nextFontGoogle: {
1313
+ selector: "ImportDeclaration[source.value='next/font/google']",
1314
+ message: "Self-host fonts instead of fetching them from next/font/google."
1315
+ },
1316
+ cloneElementImport: {
1317
+ selector: "ImportDeclaration[source.value='react'] > ImportSpecifier[imported.name='cloneElement']",
1318
+ message: "Avoid cloneElement; pass data through props instead of mutating a child element."
1319
+ },
1320
+ cloneElementMember: {
1321
+ selector: "MemberExpression[object.name='React'][property.name='cloneElement']",
1322
+ message: "Avoid React.cloneElement; pass data through props instead of mutating a child element."
1323
+ }
1050
1324
  };
1325
+ var ALL_SELECTOR_KEYS = Object.keys(RESTRICTED_SELECTORS);
1326
+ var EXPORT_DEFAULT_KEYS = ["exportDefaultFunction", "exportNamedFunction"];
1327
+ var NON_EXPORT_DEFAULT_KEYS = ALL_SELECTOR_KEYS.filter((key) => !EXPORT_DEFAULT_KEYS.includes(key));
1328
+ var NEXT_FILE_CONVENTIONS_GLOB = "**/{default,page,layout,error,loading,forbidden,not-found,template,unauthorized,icon,apple-icon,manifest,opengraph-image,twitter-image,global-error,proxy,middleware,sitemap,robots}.{ts,tsx}";
1329
+ var cnTernarySelector = (classMergeName) => ({
1330
+ selector: `CallExpression[callee.name='${classMergeName}'] > ConditionalExpression`,
1331
+ message: "Avoid a ternary inside `cn()`; use a cva variant or an object entry instead."
1332
+ });
1333
+ var restrictedSyntaxRule = (keys, extra = []) => ({
1334
+ "no-restricted-syntax": ["error", ...keys.map((key) => RESTRICTED_SELECTORS[key]), ...extra]
1335
+ });
1051
1336
  var reactRules = {
1052
1337
  "react/prop-types": "off",
1053
1338
  "react/react-in-jsx-scope": "off",
@@ -1071,18 +1356,33 @@ var nextRules = {
1071
1356
  "@next/next/no-html-link-for-pages": "error",
1072
1357
  "@next/next/no-img-element": "error"
1073
1358
  };
1359
+ var JSX_A11Y_COMPONENTS = {
1360
+ Link: "a",
1361
+ Image: "img",
1362
+ Button: "button",
1363
+ Input: "input"
1364
+ };
1074
1365
  var importOrderRule = (groups) => ({
1075
1366
  "import-helpers/order-imports": [
1076
1367
  "error",
1077
1368
  { newlinesBetween: "never", groups, alphabetize: { order: "asc", ignoreCase: true } }
1078
1369
  ]
1079
1370
  });
1371
+ var escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1372
+ var arbitraryTailwindValuePattern = (allow) => {
1373
+ const exempt = allow.length ? `(?!(?:${allow.map(escapeForRegExp).join("|")})-)` : "";
1374
+ return `(?:^|:)!?-?${exempt}[a-zA-Z][a-zA-Z0-9-]*-\\[[^\\]]+\\](?:/[a-zA-Z0-9.]+)?!?$`;
1375
+ };
1080
1376
  var buildConfig = ({
1081
1377
  next = false,
1082
1378
  ignores = [],
1083
1379
  importGroups = DEFAULT_IMPORT_GROUPS,
1084
1380
  tsconfigRootDir = process.cwd(),
1085
1381
  tailwindEntryPoint,
1382
+ allowArbitraryClasses = [],
1383
+ classMergeName = "cn",
1384
+ nextConfigModules = [],
1385
+ strictExportGlobs = [],
1086
1386
  extend = []
1087
1387
  } = {}) => {
1088
1388
  const plugins = {
@@ -1096,7 +1396,7 @@ var buildConfig = ({
1096
1396
  ...importRules,
1097
1397
  ...securityRules,
1098
1398
  ...generalRules,
1099
- ...restrictedSyntaxRule,
1399
+ ...restrictedSyntaxRule(ALL_SELECTOR_KEYS, next ? [cnTernarySelector(classMergeName)] : []),
1100
1400
  ...importOrderRule(importGroups)
1101
1401
  };
1102
1402
  const languageGlobals = { ...globals2.node, ...globals2.es2021 };
@@ -1108,7 +1408,7 @@ var buildConfig = ({
1108
1408
  "react-hooks": reactHooks,
1109
1409
  "jsx-a11y": jsxA11y
1110
1410
  });
1111
- Object.assign(rules, reactRules, nextRules);
1411
+ Object.assign(rules, reactRules, nextRules, jsxA11y.configs.recommended.rules);
1112
1412
  Object.assign(languageGlobals, globals2.browser, {
1113
1413
  React: "readonly",
1114
1414
  JSX: "readonly",
@@ -1116,34 +1416,49 @@ var buildConfig = ({
1116
1416
  });
1117
1417
  settings.react = { version: "detect" };
1118
1418
  settings["import-x/resolver-next"] = [createTypeScriptImportResolver({ alwaysTryTypes: true })];
1419
+ settings["jsx-a11y"] = { components: JSX_A11Y_COMPONENTS };
1119
1420
  if (tailwindEntryPoint) {
1120
1421
  plugins["better-tailwindcss"] = betterTailwind;
1121
1422
  Object.assign(rules, {
1122
1423
  "better-tailwindcss/no-unknown-classes": "error",
1123
1424
  "better-tailwindcss/no-conflicting-classes": "error",
1124
- "better-tailwindcss/no-concatenated-classes": "error"
1425
+ "better-tailwindcss/no-concatenated-classes": "error",
1426
+ "better-tailwindcss/no-restricted-classes": [
1427
+ "error",
1428
+ {
1429
+ restrict: [
1430
+ {
1431
+ pattern: arbitraryTailwindValuePattern(allowArbitraryClasses),
1432
+ message: "Avoid an arbitrary Tailwind value ($0); use a theme token, or list its prefix in allowArbitraryClasses when it has none (e.g. grid-cols-[...])."
1433
+ }
1434
+ ]
1435
+ }
1436
+ ]
1125
1437
  });
1126
1438
  settings["better-tailwindcss"] = { entryPoint: tailwindEntryPoint };
1127
1439
  }
1128
1440
  }
1129
1441
  const rootConfigOverride = {
1130
1442
  files: ["*.{mjs,js,ts,mts,cts}"],
1131
- rules: { "import-x/no-default-export": "off", "no-restricted-syntax": "off" }
1443
+ rules: {
1444
+ "import-x/no-default-export": "off",
1445
+ ...restrictedSyntaxRule(NON_EXPORT_DEFAULT_KEYS, next ? [cnTernarySelector(classMergeName)] : [])
1446
+ }
1132
1447
  };
1133
1448
  const nextFileConventionsOverride = {
1134
- files: [
1135
- "**/{default,page,layout,error,loading,forbidden,not-found,template,unauthorized,icon,apple-icon,manifest,opengraph-image,twitter-image,global-error,proxy,middleware,sitemap,robots}.{ts,tsx}"
1136
- ],
1137
- rules: { "import-x/no-default-export": "off", "no-restricted-syntax": "off" }
1449
+ files: [NEXT_FILE_CONVENTIONS_GLOB],
1450
+ rules: {
1451
+ "import-x/no-default-export": "off",
1452
+ ...restrictedSyntaxRule(NON_EXPORT_DEFAULT_KEYS, [cnTernarySelector(classMergeName)])
1453
+ }
1138
1454
  };
1139
- const oneLineCommentsOverride = {
1455
+ const commentsOverride = {
1140
1456
  files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
1141
1457
  plugins: { soujvnunes: soujvnunesPlugin },
1142
- rules: { "soujvnunes/one-line-comments": "error" }
1458
+ rules: { "soujvnunes/one-line-comments": "error", "soujvnunes/no-comments": "error" }
1143
1459
  };
1144
1460
  const clientBoundaryOverride = {
1145
1461
  files: ["**/*.{jsx,tsx}"],
1146
- // Next requires these two conventions to be client components and hands them functions, so the directive is never needless and no server parent exists to take their markup.
1147
1462
  ignores: ["**/{error,global-error}.{jsx,tsx}"],
1148
1463
  plugins: { soujvnunes: soujvnunesPlugin },
1149
1464
  rules: {
@@ -1151,11 +1466,47 @@ var buildConfig = ({
1151
1466
  "soujvnunes/no-static-jsx-in-client": "error"
1152
1467
  }
1153
1468
  };
1469
+ const programBanRule = (message) => restrictedSyntaxRule(ALL_SELECTOR_KEYS, [
1470
+ cnTernarySelector(classMergeName),
1471
+ { selector: "Program", message }
1472
+ ]);
1473
+ const barrelOverride = {
1474
+ files: ["**/index.{ts,tsx}"],
1475
+ ignores: ["**/pages/**"],
1476
+ rules: programBanRule("Avoid a barrel index file; import each module by its own path.")
1477
+ };
1478
+ const featureRootOverride = {
1479
+ files: ["**/features/*/*.{ts,tsx}"],
1480
+ ignores: ["**/*.test.{ts,tsx}", NEXT_FILE_CONVENTIONS_GLOB],
1481
+ rules: programBanRule("A feature root holds only subfolders; place this file inside one of them.")
1482
+ };
1154
1483
  const scriptsOverride = {
1155
1484
  files: ["scripts/**/*.mjs"],
1156
1485
  languageOptions: { globals: { ...globals2.node } },
1157
1486
  rules: { "no-console": "off" }
1158
1487
  };
1488
+ const maxLinesExemptOverride = {
1489
+ files: ["**/*.test.*", "**/copy/**"],
1490
+ rules: { "max-lines": "off" }
1491
+ };
1492
+ const pureUtilsOverride = {
1493
+ files: ["**/utils/**"],
1494
+ rules: {
1495
+ "no-restricted-imports": [
1496
+ "error",
1497
+ { patterns: ["server-only", "next/*", "react", "@/lib/*", "@/app/*"] }
1498
+ ]
1499
+ }
1500
+ };
1501
+ const nextConfigModulesOverride = {
1502
+ files: ["next.config.{ts,mts,cts}", ...nextConfigModules],
1503
+ rules: { "no-restricted-imports": ["error", { patterns: ["@/*"] }] }
1504
+ };
1505
+ const strictExportsOverride = {
1506
+ files: strictExportGlobs,
1507
+ plugins: { soujvnunes: soujvnunesPlugin },
1508
+ rules: { "soujvnunes/one-export-per-file": "error" }
1509
+ };
1159
1510
  return [
1160
1511
  { ignores: [...DEFAULT_IGNORES, ...ignores] },
1161
1512
  js.configs.recommended,
@@ -1163,7 +1514,6 @@ var buildConfig = ({
1163
1514
  {
1164
1515
  files: ["**/*.{js,jsx,ts,tsx}"],
1165
1516
  plugins,
1166
- // Every rule here is an error, never a warning: a rule worth keeping is worth failing on, and a deliberate exception is an `eslint-disable` comment, which records the decision where the code is. `reportUnusedDisableDirectives` closes the loop by failing on a disable comment that suppresses nothing.
1167
1517
  linterOptions: { reportUnusedDisableDirectives: "error" },
1168
1518
  languageOptions: {
1169
1519
  parserOptions: {
@@ -1179,10 +1529,14 @@ var buildConfig = ({
1179
1529
  rules
1180
1530
  },
1181
1531
  prettier,
1182
- oneLineCommentsOverride,
1532
+ commentsOverride,
1183
1533
  rootConfigOverride,
1184
- ...next ? [nextFileConventionsOverride, clientBoundaryOverride] : [],
1534
+ ...next ? [nextFileConventionsOverride, clientBoundaryOverride, barrelOverride, featureRootOverride] : [],
1535
+ maxLinesExemptOverride,
1536
+ pureUtilsOverride,
1185
1537
  scriptsOverride,
1538
+ ...next && nextConfigModules.length ? [nextConfigModulesOverride] : [],
1539
+ ...strictExportGlobs.length ? [strictExportsOverride] : [],
1186
1540
  ...extend
1187
1541
  ];
1188
1542
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soujvnunes/eslint-config",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Shared flat ESLint config factories (base + Next.js).",
5
5
  "license": "MIT",
6
6
  "author": "soujvnunes",