@soujvnunes/eslint-config 0.8.0 → 0.9.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 +60 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +643 -128
- package/package.json +1 -1
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
|
|
|
@@ -44,11 +44,23 @@ export default createBaseConfig()
|
|
|
44
44
|
| `importGroups` | react, next, module, parent, sibling, index | Full import-order groups; 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. 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, and `no-restricted-classes`, which flags an arbitrary-value class such as `text-[11px]`. 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 except two kinds. 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), `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. A JSDoc stays when it sits directly above an exported symbol (an `export * from` included, and a top-level declaration a later `export { X }`, `export default X` or `export = X` names, the shape every shadcn/ui primitive ends with, or that a CommonJS `module.exports = X`, `module.exports = { X }`, `exports.name = X` or `module.exports.name = X` names; such an assignment makes the file a module too), or above a declaration, member, property or signature whose parents reach an exported declaration before a statement boundary (a block, a function body, a non-exported top-level statement): a member of an exported class, interface, type or enum, index, call and construct signatures included, a key of an exported object, and a field of a type literal in a parameter, a generic argument or an array type. Everything inside a `declare global` block or a `declare module 'name'` block counts as exported, and so, in a file with no import or export, does every top-level declaration of a `.d.ts` file and every ambient one of any other file (a `declare const`, `function`, `class` or `namespace` with all it holds, an interface such as `interface Window`, a type alias), since those declarations are global. The rule reads the syntax, not the tsconfig: under `moduleDetection: "force"` (the Vite templates set it) or a `"type": "module"` package on `nodenext`, TypeScript treats every file as a module, so such a declaration is local there, and the rule keeps a doc it could report. In a module file a `declare namespace` is local to the file: its members count only when the namespace itself is exported. So does an `export` inside any namespace: it publishes the member only as far as the namespace is published. A factory documents what it returns on the members of an exported interface it declares as its return type: a JSDoc on a local binding the factory returns is reported, and TypeScript's declaration emit leaves it out of the inferred return type anyway. A JSDoc above anything else, 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. Six 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 misplaced JSDoc holding an `@` tag, a JSDoc holding an em dash, and a JSDoc that would reach an export only through an argument of a call or a `new`, such as a key in `export default defineConfig({ ... })`. The exported type there is the call's return type, which drops the doc for `defineConfig(config: UserConfig): UserConfig` and keeps it for `Object.freeze` or a generic identity helper, and the rule cannot see the signature, so it reports without a fix. `{ jsdoc: 'never' }` reports the exported JSDoc too. 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 JSDoc on an export 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.
|
|
@@ -69,3 +83,47 @@ These are the opinions most likely to surprise an existing codebase. All of them
|
|
|
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
|
|
|
71
85
|
Adopting this in an existing repo is usually one `eslint --fix` pass plus a short list of genuine fixes from the type-aware rules.
|
|
86
|
+
|
|
87
|
+
## Accessibility on the Next preset
|
|
88
|
+
|
|
89
|
+
`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.
|
|
90
|
+
|
|
91
|
+
## New `no-restricted-syntax` selectors, and why page.tsx still gets them
|
|
92
|
+
|
|
93
|
+
`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.
|
|
94
|
+
|
|
95
|
+
- **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.
|
|
96
|
+
- **Any import from `next/font/google`.** Self-hosted fonts only (`FONTS`).
|
|
97
|
+
- **`cloneElement`**, both as a named import from `react` and as `React.cloneElement`.
|
|
98
|
+
|
|
99
|
+
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`).
|
|
100
|
+
|
|
101
|
+
## Barrel files and feature roots, on the Next preset only
|
|
102
|
+
|
|
103
|
+
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:
|
|
104
|
+
|
|
105
|
+
- `**/index.{ts,tsx}` (outside `**/pages/**`) reports a barrel file outright: import each module by its own path instead of re-exporting through an aggregator.
|
|
106
|
+
- `**/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.
|
|
107
|
+
|
|
108
|
+
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.
|
|
109
|
+
|
|
110
|
+
## `cn()` ternary ban, on the Next preset
|
|
111
|
+
|
|
112
|
+
`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.
|
|
113
|
+
|
|
114
|
+
## Arbitrary Tailwind values, when `tailwindEntryPoint` is set
|
|
115
|
+
|
|
116
|
+
`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.
|
|
117
|
+
|
|
118
|
+
## Module boundaries
|
|
119
|
+
|
|
120
|
+
- `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.
|
|
121
|
+
- `**/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.
|
|
122
|
+
|
|
123
|
+
## `max-lines`: 300, skipping blank lines and comments
|
|
124
|
+
|
|
125
|
+
`**/*.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.
|
|
126
|
+
|
|
127
|
+
## `soujvnunes/one-export-per-file`, wired only through `strictExportGlobs`
|
|
128
|
+
|
|
129
|
+
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 {
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
3
|
|
|
3
|
-
declare const oneLineComments:
|
|
4
|
+
declare const oneLineComments: ESLintUtils.RuleModule<"block" | "orphanDoc" | "adjacent" | "paragraphs" | "notDoc", [], unknown, ESLintUtils.RuleListener>;
|
|
4
5
|
|
|
5
6
|
type CompatiblePlugin = {
|
|
6
7
|
meta: {
|
|
@@ -18,6 +19,14 @@ interface ConfigOptions {
|
|
|
18
19
|
tsconfigRootDir?: string;
|
|
19
20
|
/** 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
21
|
tailwindEntryPoint?: string;
|
|
22
|
+
/** Utility prefixes exempt from the arbitrary-Tailwind-value ban, for a shape with no theme token (e.g. `['grid-cols', 'grid-rows']` for `grid-cols-[200px_1fr]`). Only read when `tailwindEntryPoint` is set. */
|
|
23
|
+
allowArbitraryClasses?: string[];
|
|
24
|
+
/** The `cn()`-like helper name a ternary passed straight to it is banned inside of. */
|
|
25
|
+
classMergeName?: string;
|
|
26
|
+
/** Modules next.config.* loads, beside a next.config.ts, .mts or .cts itself (the .js and .mjs forms sit in the default ignores), restricted with the same repo's `no-restricted-imports` patterns (`['@/*']`) as the config file: relative imports only. */
|
|
27
|
+
nextConfigModules?: string[];
|
|
28
|
+
/** Globs wired to `soujvnunes/one-export-per-file`, the probe-only one-value-export-per-module rule. Unwired (no globs) leaves the rule exported but off. */
|
|
29
|
+
strictExportGlobs?: string[];
|
|
21
30
|
/** Extra flat-config objects appended at the end. */
|
|
22
31
|
extend?: Linter.Config[];
|
|
23
32
|
}
|
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) =>
|
|
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 =
|
|
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 =
|
|
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 ?
|
|
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(
|
|
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
|
|
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) =>
|
|
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:
|
|
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(
|
|
322
|
+
stable: both(classify2(node.left, position), classify2(node.right, position)).stable
|
|
323
323
|
};
|
|
324
324
|
case AST_NODE_TYPES11.LogicalExpression:
|
|
325
|
-
return both(
|
|
325
|
+
return both(classify2(node.left, position), classify2(node.right, position));
|
|
326
326
|
case AST_NODE_TYPES11.ConditionalExpression: {
|
|
327
|
-
const branches = both(
|
|
328
|
-
return { data: branches.data, stable: branches.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
|
|
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
|
|
344
|
+
return classify2(property.argument, position);
|
|
345
345
|
if (property.kind !== "init" || property.method) return NEVER;
|
|
346
|
-
const value =
|
|
347
|
-
return property.computed ? both(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
|
|
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) =>
|
|
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,461 @@ var needlessUseClient = ESLintUtils.RuleCreator.withoutDocs({
|
|
|
623
622
|
}
|
|
624
623
|
});
|
|
625
624
|
|
|
626
|
-
//
|
|
627
|
-
|
|
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 ===
|
|
632
|
-
var isDocShaped = (comment) => comment.type ===
|
|
633
|
-
var isBanner = (comment) => comment.type ===
|
|
662
|
+
var isComment = (token) => token?.type === AST_TOKEN_TYPES.Line || token?.type === AST_TOKEN_TYPES.Block;
|
|
663
|
+
var isDocShaped = (comment) => comment.type === AST_TOKEN_TYPES.Block && comment.value.startsWith("*");
|
|
664
|
+
var isBanner = (comment) => comment.type === AST_TOKEN_TYPES.Block && comment.value.startsWith("!");
|
|
634
665
|
var pragmaText = (comment) => comment.value.replace(/^\*+/u, "");
|
|
635
666
|
var isDirectiveText = (text) => DIRECTIVE.test(text) || ANNOTATION.test(text);
|
|
636
|
-
var isDirective = (comment) => isDirectiveText(pragmaText(comment)) || comment.type ===
|
|
637
|
-
var
|
|
638
|
-
|
|
667
|
+
var isDirective = (comment) => isDirectiveText(pragmaText(comment)) || comment.type === AST_TOKEN_TYPES.Block && (BLOCK_DIRECTIVE.test(comment.value) || !isDocShaped(comment) && BLOCK_ANNOTATION.test(comment.value));
|
|
668
|
+
var isToolDirective = (comment) => {
|
|
669
|
+
const text = pragmaText(comment);
|
|
670
|
+
return DIRECTIVE.test(text) || PRAGMA.test(text) || comment.type === AST_TOKEN_TYPES.Block && BLOCK_DIRECTIVE.test(comment.value);
|
|
671
|
+
};
|
|
672
|
+
var holdsTag = (comment) => /(?:^|\s)@\w/u.test(pragmaText(comment));
|
|
673
|
+
var isTypeAnnotation = (comment) => {
|
|
674
|
+
const text = pragmaText(comment);
|
|
675
|
+
const tag = isDocShaped(comment) ? /(?:^|\s)@(\w+)/u.exec(text) : null;
|
|
676
|
+
const shape = TYPE_TAGS.get(tag?.[1] ?? "");
|
|
677
|
+
return !!tag && !!shape && shape(text.slice(tag.index + tag[0].length));
|
|
678
|
+
};
|
|
679
|
+
var spansLines = (comment) => comment.loc.start.line !== comment.loc.end.line;
|
|
680
|
+
var followedOnLine = (comment, after) => !!after && after.loc.start.line === comment.loc.end.line;
|
|
681
|
+
var createCommentLookup = (sourceCode) => {
|
|
682
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
683
|
+
const nodeAt = (index) => {
|
|
684
|
+
const known = nodes.get(index);
|
|
685
|
+
if (known !== void 0) return known;
|
|
686
|
+
const node = sourceCode.getNodeByRangeIndex(index);
|
|
687
|
+
nodes.set(index, node);
|
|
688
|
+
return node;
|
|
689
|
+
};
|
|
690
|
+
const enclosingNode = (comment) => nodeAt(comment.range[0]);
|
|
691
|
+
const jsxContainer = (comment) => {
|
|
692
|
+
const node = enclosingNode(comment);
|
|
693
|
+
return node?.type === AST_NODE_TYPES13.JSXEmptyExpression ? node.parent : null;
|
|
694
|
+
};
|
|
695
|
+
const sidesOf = (span) => {
|
|
696
|
+
const { lines } = sourceCode;
|
|
697
|
+
return {
|
|
698
|
+
before: (lines[span.start.line - 1] ?? "").slice(0, span.start.column).trim() !== "",
|
|
699
|
+
after: (lines[span.end.line - 1] ?? "").slice(span.end.column).trim() !== ""
|
|
700
|
+
};
|
|
701
|
+
};
|
|
702
|
+
const sides = (comment) => sidesOf(jsxContainer(comment)?.loc ?? comment.loc);
|
|
703
|
+
const isOwnLine = (comment) => {
|
|
704
|
+
const side = comment.type === AST_TOKEN_TYPES.Line ? sidesOf(comment.loc) : sides(comment);
|
|
705
|
+
return !side.before && !side.after;
|
|
706
|
+
};
|
|
707
|
+
const isAllowMarker = (comment) => {
|
|
708
|
+
if (spansLines(comment) || !ALLOW_MARKER.test(comment.value)) return false;
|
|
709
|
+
const before = sourceCode.getTokenBefore(comment);
|
|
710
|
+
const after = sourceCode.getTokenAfter(comment);
|
|
711
|
+
return !!before && before.loc.end.line === comment.loc.start.line || !!after && after.loc.start.line === comment.loc.end.line;
|
|
712
|
+
};
|
|
713
|
+
return { nodeAt, enclosingNode, jsxContainer, sides, isOwnLine, isAllowMarker };
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
// noComments.ts
|
|
717
|
+
var EXPORTS = /* @__PURE__ */ new Set([
|
|
718
|
+
AST_NODE_TYPES14.ExportNamedDeclaration,
|
|
719
|
+
AST_NODE_TYPES14.ExportDefaultDeclaration,
|
|
720
|
+
AST_NODE_TYPES14.ExportAllDeclaration
|
|
721
|
+
]);
|
|
722
|
+
var DOCUMENTED = /* @__PURE__ */ new Set([
|
|
723
|
+
AST_NODE_TYPES14.ClassDeclaration,
|
|
724
|
+
AST_NODE_TYPES14.FunctionDeclaration,
|
|
725
|
+
AST_NODE_TYPES14.TSDeclareFunction,
|
|
726
|
+
AST_NODE_TYPES14.VariableDeclaration,
|
|
727
|
+
AST_NODE_TYPES14.TSInterfaceDeclaration,
|
|
728
|
+
AST_NODE_TYPES14.TSTypeAliasDeclaration,
|
|
729
|
+
AST_NODE_TYPES14.TSEnumDeclaration,
|
|
730
|
+
AST_NODE_TYPES14.TSModuleDeclaration,
|
|
731
|
+
AST_NODE_TYPES14.PropertyDefinition,
|
|
732
|
+
AST_NODE_TYPES14.MethodDefinition,
|
|
733
|
+
AST_NODE_TYPES14.TSAbstractPropertyDefinition,
|
|
734
|
+
AST_NODE_TYPES14.TSAbstractMethodDefinition,
|
|
735
|
+
AST_NODE_TYPES14.AccessorProperty,
|
|
736
|
+
AST_NODE_TYPES14.TSAbstractAccessorProperty,
|
|
737
|
+
AST_NODE_TYPES14.TSParameterProperty,
|
|
738
|
+
AST_NODE_TYPES14.TSIndexSignature,
|
|
739
|
+
AST_NODE_TYPES14.TSPropertySignature,
|
|
740
|
+
AST_NODE_TYPES14.TSMethodSignature,
|
|
741
|
+
AST_NODE_TYPES14.TSCallSignatureDeclaration,
|
|
742
|
+
AST_NODE_TYPES14.TSConstructSignatureDeclaration,
|
|
743
|
+
AST_NODE_TYPES14.TSEnumMember,
|
|
744
|
+
AST_NODE_TYPES14.Property
|
|
745
|
+
]);
|
|
746
|
+
var BOUNDARIES = /* @__PURE__ */ new Set([
|
|
747
|
+
AST_NODE_TYPES14.Program,
|
|
748
|
+
AST_NODE_TYPES14.BlockStatement,
|
|
749
|
+
AST_NODE_TYPES14.StaticBlock
|
|
750
|
+
]);
|
|
751
|
+
var MODULE_STATEMENTS = /* @__PURE__ */ new Set([
|
|
752
|
+
AST_NODE_TYPES14.ImportDeclaration,
|
|
753
|
+
AST_NODE_TYPES14.ExportNamedDeclaration,
|
|
754
|
+
AST_NODE_TYPES14.ExportDefaultDeclaration,
|
|
755
|
+
AST_NODE_TYPES14.ExportAllDeclaration,
|
|
756
|
+
AST_NODE_TYPES14.TSExportAssignment
|
|
757
|
+
]);
|
|
758
|
+
var MEMBER_OPENERS = /* @__PURE__ */ new Set(["{", ";", ","]);
|
|
759
|
+
var JS_FILE = /\.[cm]?jsx?$/u;
|
|
760
|
+
var DECLARATION_FILE = /\.d\.[cm]?ts$/u;
|
|
761
|
+
var EM_DASH = String.fromCodePoint(8212);
|
|
762
|
+
var identifierName = (node) => node?.type === AST_NODE_TYPES14.Identifier ? node.name : void 0;
|
|
763
|
+
var isModuleExports = (node) => node.type === AST_NODE_TYPES14.MemberExpression && identifierName(node.object) === "module" && identifierName(node.property) === "exports";
|
|
764
|
+
var commonJsExport = (statement) => {
|
|
765
|
+
if (statement.type !== AST_NODE_TYPES14.ExpressionStatement) return null;
|
|
766
|
+
const { expression } = statement;
|
|
767
|
+
if (expression.type !== AST_NODE_TYPES14.AssignmentExpression) return null;
|
|
768
|
+
const { left, right } = expression;
|
|
769
|
+
if (left.type !== AST_NODE_TYPES14.MemberExpression) return null;
|
|
770
|
+
const exported = isModuleExports(left) || identifierName(left.object) === "exports" || isModuleExports(left.object);
|
|
771
|
+
return exported ? right : null;
|
|
772
|
+
};
|
|
773
|
+
var deferredExports = (body) => {
|
|
774
|
+
const names = /* @__PURE__ */ new Set();
|
|
775
|
+
const add = (node) => {
|
|
776
|
+
const name = identifierName(node);
|
|
777
|
+
if (name) names.add(name);
|
|
778
|
+
};
|
|
779
|
+
for (const statement of body) {
|
|
780
|
+
const commonJs = commonJsExport(statement);
|
|
781
|
+
if (commonJs?.type === AST_NODE_TYPES14.ObjectExpression) {
|
|
782
|
+
for (const property of commonJs.properties) {
|
|
783
|
+
if (property.type === AST_NODE_TYPES14.Property) add(property.value);
|
|
784
|
+
}
|
|
785
|
+
} else add(commonJs);
|
|
786
|
+
if (statement.type === AST_NODE_TYPES14.ExportNamedDeclaration && !statement.source) {
|
|
787
|
+
for (const { local } of statement.specifiers) add(local);
|
|
788
|
+
}
|
|
789
|
+
if (statement.type === AST_NODE_TYPES14.ExportDefaultDeclaration) add(statement.declaration);
|
|
790
|
+
if (statement.type === AST_NODE_TYPES14.TSExportAssignment) add(statement.expression);
|
|
791
|
+
}
|
|
792
|
+
return names;
|
|
793
|
+
};
|
|
794
|
+
var declaredIds = (statement) => {
|
|
795
|
+
if (statement.type === AST_NODE_TYPES14.VariableDeclaration) {
|
|
796
|
+
return statement.declarations.map(({ id }) => id);
|
|
797
|
+
}
|
|
798
|
+
return "id" in statement ? [statement.id] : [];
|
|
799
|
+
};
|
|
800
|
+
var boundNames = (node) => {
|
|
801
|
+
if (node?.type === AST_NODE_TYPES14.Identifier) return [node.name];
|
|
802
|
+
if (node?.type === AST_NODE_TYPES14.ObjectPattern) {
|
|
803
|
+
return node.properties.flatMap(
|
|
804
|
+
(property) => boundNames(property.type === AST_NODE_TYPES14.RestElement ? property.argument : property.value)
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
if (node?.type === AST_NODE_TYPES14.ArrayPattern) {
|
|
808
|
+
return node.elements.flatMap((element) => boundNames(element));
|
|
809
|
+
}
|
|
810
|
+
if (node?.type === AST_NODE_TYPES14.AssignmentPattern) return boundNames(node.left);
|
|
811
|
+
if (node?.type === AST_NODE_TYPES14.RestElement) return boundNames(node.argument);
|
|
812
|
+
return [];
|
|
813
|
+
};
|
|
814
|
+
var isDeferred = (statement, deferred) => declaredIds(statement).some((id) => boundNames(id).some((name) => deferred.has(name)));
|
|
815
|
+
var isModuleFile = (program) => program.body.some(
|
|
816
|
+
(statement) => MODULE_STATEMENTS.has(statement.type) || commonJsExport(statement) !== null || statement.type === AST_NODE_TYPES14.TSImportEqualsDeclaration && statement.moduleReference.type === AST_NODE_TYPES14.TSExternalModuleReference
|
|
817
|
+
);
|
|
818
|
+
var isAmbient = (statement) => statement.type === AST_NODE_TYPES14.TSInterfaceDeclaration || statement.type === AST_NODE_TYPES14.TSTypeAliasDeclaration || "declare" in statement && statement.declare === true;
|
|
819
|
+
var ambience = (block) => {
|
|
820
|
+
let declared = false;
|
|
821
|
+
let node = block.parent;
|
|
822
|
+
while (node) {
|
|
823
|
+
if (node.type === AST_NODE_TYPES14.TSModuleDeclaration) {
|
|
824
|
+
if (node.kind === "global" || node.id.type === AST_NODE_TYPES14.Literal) return "public";
|
|
825
|
+
declared ||= node.declare;
|
|
826
|
+
}
|
|
827
|
+
node = node.parent;
|
|
828
|
+
}
|
|
829
|
+
return declared ? "declared" : "local";
|
|
830
|
+
};
|
|
831
|
+
var isBoundary = (node, child, walk) => BOUNDARIES.has(node.type) || node.type === AST_NODE_TYPES14.ArrowFunctionExpression && node.body === child || !walk.throughCalls && (node.type === AST_NODE_TYPES14.CallExpression || node.type === AST_NODE_TYPES14.NewExpression) && node.arguments.some((argument) => argument === child);
|
|
832
|
+
var isPublished = (statement, walk) => {
|
|
833
|
+
const { parent } = statement;
|
|
834
|
+
if (parent?.type !== AST_NODE_TYPES14.TSModuleBlock) return true;
|
|
835
|
+
return ambience(parent) === "public" || reachesExport(parent.parent, walk);
|
|
836
|
+
};
|
|
837
|
+
var reachesExport = (start, walk) => {
|
|
838
|
+
let child = start;
|
|
839
|
+
let node = start.parent;
|
|
840
|
+
while (node) {
|
|
841
|
+
if (EXPORTS.has(node.type)) return isPublished(node, walk);
|
|
842
|
+
if (node.type === AST_NODE_TYPES14.TSModuleBlock) {
|
|
843
|
+
const scope = ambience(node);
|
|
844
|
+
if (scope !== "declared") return scope === "public";
|
|
845
|
+
}
|
|
846
|
+
if (node.type === AST_NODE_TYPES14.Program) return walk.topLevel(child);
|
|
847
|
+
if (isBoundary(node, child, walk)) return false;
|
|
848
|
+
child = node;
|
|
849
|
+
node = node.parent;
|
|
850
|
+
}
|
|
851
|
+
return false;
|
|
852
|
+
};
|
|
853
|
+
var isExportedDoc = (comment, sourceCode, lookup, decorated, walk) => {
|
|
854
|
+
const before = sourceCode.getTokenBefore(comment);
|
|
855
|
+
if (before?.loc.end.line === comment.loc.start.line && !MEMBER_OPENERS.has(before.value)) {
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
858
|
+
const token = sourceCode.getTokenAfter(comment);
|
|
859
|
+
if (!token) return false;
|
|
860
|
+
const target = decorated.get(token.range[0]);
|
|
861
|
+
if (target?.type === AST_NODE_TYPES14.ClassDeclaration && reachesExport(target, walk)) {
|
|
862
|
+
return true;
|
|
863
|
+
}
|
|
864
|
+
let node = lookup.nodeAt(token.range[0]);
|
|
865
|
+
while (node?.range[0] === token.range[0]) {
|
|
866
|
+
if (EXPORTS.has(node.type)) return isPublished(node, walk);
|
|
867
|
+
if (DOCUMENTED.has(node.type)) return reachesExport(node, walk);
|
|
868
|
+
node = node.parent ?? null;
|
|
869
|
+
}
|
|
870
|
+
return false;
|
|
871
|
+
};
|
|
872
|
+
var isJsxNode = (node) => !!node && node.type.startsWith("JSX") && node.type !== AST_NODE_TYPES14.JSXExpressionContainer;
|
|
873
|
+
var classify = (comment, sourceCode, lookup, decorated, topLevel) => {
|
|
874
|
+
const node = lookup.enclosingNode(comment);
|
|
875
|
+
const inJsx = isJsxNode(node);
|
|
876
|
+
if (isToolDirective(comment) || lookup.isAllowMarker(comment)) {
|
|
877
|
+
return inJsx ? "jsxDirective" : "directive";
|
|
878
|
+
}
|
|
879
|
+
if (isBanner(comment)) return "banner";
|
|
880
|
+
if (inJsx) return node?.type === AST_NODE_TYPES14.JSXEmptyExpression ? "jsx" : "attribute";
|
|
881
|
+
if (isDocShaped(comment)) {
|
|
882
|
+
const reaches = (throughCalls) => isExportedDoc(comment, sourceCode, lookup, decorated, { topLevel, throughCalls });
|
|
883
|
+
if (reaches(false)) return "jsdoc";
|
|
884
|
+
return reaches(true) ? "argumentDoc" : "orphanDoc";
|
|
885
|
+
}
|
|
886
|
+
return comment.type === AST_TOKEN_TYPES2.Line ? "line" : "block";
|
|
887
|
+
};
|
|
888
|
+
var MESSAGES = {
|
|
889
|
+
line: "Comments are not allowed in code. Delete this `//` comment: a reason the code cannot carry belongs in the README. Only tool directives and a JSDoc on an exported symbol stay.",
|
|
890
|
+
block: "Comments are not allowed in code. Delete this block comment: a reason the code cannot carry belongs in the README. Only tool directives and a JSDoc on an exported symbol stay.",
|
|
891
|
+
orphanDoc: "A JSDoc is allowed only directly above an exported symbol, or a member of an exported class, interface, type or enum. Delete this one.",
|
|
892
|
+
argumentDoc: "This JSDoc sits in an argument of an exported call or `new`, so it is published only when the callee returns its argument's type, as `Object.freeze` or a generic identity helper does. The rule cannot see the signature: delete it unless the callee keeps it.",
|
|
893
|
+
jsdoc: "This config allows no JSDoc. Delete it.",
|
|
894
|
+
jsx: "Comments are not allowed in JSX. Delete this `{/* */}` container; only a tool directive stays.",
|
|
895
|
+
attribute: "Comments are not allowed inside a JSX tag. Delete this one.",
|
|
896
|
+
emDash: "This JSDoc holds an em dash. Write a comma, a colon, parentheses or two sentences instead."
|
|
897
|
+
};
|
|
898
|
+
var MESSAGE_IDS = {
|
|
899
|
+
directive: null,
|
|
900
|
+
banner: null,
|
|
901
|
+
jsxDirective: null,
|
|
902
|
+
jsdoc: "jsdoc",
|
|
903
|
+
orphanDoc: "orphanDoc",
|
|
904
|
+
argumentDoc: "argumentDoc",
|
|
905
|
+
jsx: "jsx",
|
|
906
|
+
attribute: "attribute",
|
|
907
|
+
line: "line",
|
|
908
|
+
block: "block"
|
|
909
|
+
};
|
|
910
|
+
var noComments = ESLintUtils2.RuleCreator.withoutDocs({
|
|
911
|
+
meta: {
|
|
912
|
+
type: "suggestion",
|
|
913
|
+
docs: {
|
|
914
|
+
description: "Disallow comments in code, except tool directives and a JSDoc directly above an exported symbol or a member of an exported class, interface, type or enum."
|
|
915
|
+
},
|
|
916
|
+
fixable: "code",
|
|
917
|
+
schema: [
|
|
918
|
+
{
|
|
919
|
+
type: "object",
|
|
920
|
+
properties: { jsdoc: { type: "string", enum: ["exports", "never"] } },
|
|
921
|
+
additionalProperties: false
|
|
922
|
+
}
|
|
923
|
+
],
|
|
924
|
+
messages: MESSAGES
|
|
925
|
+
},
|
|
926
|
+
defaultOptions: [{}],
|
|
927
|
+
create(context, [{ jsdoc }]) {
|
|
928
|
+
const sourceCode = context.sourceCode;
|
|
929
|
+
const { lines, text } = sourceCode;
|
|
930
|
+
const lookup = createCommentLookup(sourceCode);
|
|
931
|
+
const decorated = /* @__PURE__ */ new Map();
|
|
932
|
+
const program = sourceCode.ast;
|
|
933
|
+
const deferred = deferredExports(program.body);
|
|
934
|
+
const globalScope = !isModuleFile(program);
|
|
935
|
+
const declarationFile = DECLARATION_FILE.test(context.filename);
|
|
936
|
+
const topLevel = (statement) => isDeferred(statement, deferred) || globalScope && (declarationFile || isAmbient(statement));
|
|
937
|
+
const typedJs = JS_FILE.test(context.filename);
|
|
938
|
+
const lineStart = (line) => sourceCode.getIndexFromLoc({ line, column: 0 });
|
|
939
|
+
const lineEnd = (line) => lineStart(line) + (lines[line - 1]?.length ?? 0);
|
|
940
|
+
const wholeLines = (first, last) => {
|
|
941
|
+
if (last < lines.length) return [lineStart(first), lineStart(last + 1)];
|
|
942
|
+
if (first > 1) return [lineEnd(first - 1), text.length];
|
|
943
|
+
return [0, text.length];
|
|
944
|
+
};
|
|
945
|
+
const removal = (comment, kind) => {
|
|
946
|
+
if (kind === "attribute" || kind === "argumentDoc" || (kind === "orphanDoc" || kind === "jsdoc") && holdsTag(comment)) {
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
const span = lookup.jsxContainer(comment) ?? comment;
|
|
950
|
+
const side = lookup.sides(comment);
|
|
951
|
+
const { range, loc } = span;
|
|
952
|
+
const { before, after } = side;
|
|
953
|
+
if (!before && !after) {
|
|
954
|
+
const bounds = [loc.start.line, loc.end.line];
|
|
955
|
+
return { range: wholeLines(...bounds), text: "", lines: bounds };
|
|
956
|
+
}
|
|
957
|
+
if (kind === "jsx") return null;
|
|
958
|
+
const previousEnd = sourceCode.getTokenBefore(comment, { includeComments: true })?.range[1];
|
|
959
|
+
const nextStart = sourceCode.getTokenAfter(comment, { includeComments: true })?.range[0];
|
|
960
|
+
if (before && after) {
|
|
961
|
+
if (spansLines(comment) || previousEnd === void 0 || nextStart === void 0) return null;
|
|
962
|
+
return { range: [previousEnd, nextStart], text: " ", lines: null };
|
|
963
|
+
}
|
|
964
|
+
if (before) {
|
|
965
|
+
return previousEnd === void 0 ? null : { range: [previousEnd, range[1]], text: "", lines: null };
|
|
966
|
+
}
|
|
967
|
+
return nextStart === void 0 ? null : { range: [range[0], nextStart], text: "", lines: null };
|
|
968
|
+
};
|
|
969
|
+
return {
|
|
970
|
+
Decorator(decorator) {
|
|
971
|
+
const { parent } = decorator;
|
|
972
|
+
if ("decorators" in parent && parent.decorators[0] === decorator) {
|
|
973
|
+
decorated.set(decorator.range[0], parent);
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
"Program:exit"() {
|
|
977
|
+
const reports = [];
|
|
978
|
+
for (const comment of sourceCode.getAllComments().filter(isComment)) {
|
|
979
|
+
const kind = typedJs && isTypeAnnotation(comment) ? "directive" : classify(comment, sourceCode, lookup, decorated, topLevel);
|
|
980
|
+
if (kind === "jsdoc" && jsdoc !== "never") {
|
|
981
|
+
if (comment.value.includes(EM_DASH))
|
|
982
|
+
reports.push({ comment, messageId: "emDash", fix: null });
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
const messageId = MESSAGE_IDS[kind];
|
|
986
|
+
if (messageId) reports.push({ comment, messageId, fix: removal(comment, kind) });
|
|
987
|
+
}
|
|
988
|
+
const ownLine = reports.map(({ fix }) => fix).filter((fix) => !!fix?.lines).sort((a, b) => a.lines[0] - b.lines[0]);
|
|
989
|
+
let run = [];
|
|
990
|
+
const flush = () => {
|
|
991
|
+
const first = run[0];
|
|
992
|
+
const last = run[run.length - 1];
|
|
993
|
+
if (first && last) {
|
|
994
|
+
const range = wholeLines(first.lines[0], last.lines[1]);
|
|
995
|
+
for (const fix of run) fix.range = range;
|
|
996
|
+
}
|
|
997
|
+
run = [];
|
|
998
|
+
};
|
|
999
|
+
for (const fix of ownLine) {
|
|
1000
|
+
const previous = run[run.length - 1];
|
|
1001
|
+
if (previous && previous.lines[1] + 1 !== fix.lines[0]) flush();
|
|
1002
|
+
run.push(fix);
|
|
1003
|
+
}
|
|
1004
|
+
flush();
|
|
1005
|
+
for (const { comment, messageId, fix } of reports) {
|
|
1006
|
+
context.report({
|
|
1007
|
+
loc: comment.loc,
|
|
1008
|
+
messageId,
|
|
1009
|
+
fix: fix ? (fixer) => fixer.replaceTextRange(fix.range, fix.text) : null
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
// oneExportPerFile.ts
|
|
1018
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15, ESLintUtils as ESLintUtils3 } from "@typescript-eslint/utils";
|
|
1019
|
+
var isTypeOnlyDeclaration = (declaration) => declaration?.type === AST_NODE_TYPES15.TSInterfaceDeclaration || declaration?.type === AST_NODE_TYPES15.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES15.TSDeclareFunction;
|
|
1020
|
+
var declaratorEntries = (declaration) => declaration.declarations.map((declarator) => ({
|
|
1021
|
+
node: declarator,
|
|
1022
|
+
name: declarator.id.type === AST_NODE_TYPES15.Identifier ? declarator.id.name : "a destructured export"
|
|
1023
|
+
}));
|
|
1024
|
+
var declarationEntry = (declaration) => ({
|
|
1025
|
+
node: declaration,
|
|
1026
|
+
name: "id" in declaration && declaration.id?.type === AST_NODE_TYPES15.Identifier ? declaration.id.name : "default"
|
|
1027
|
+
});
|
|
1028
|
+
var namedEntries = (node) => {
|
|
1029
|
+
if (node.exportKind === "type") return [];
|
|
1030
|
+
const { declaration, specifiers } = node;
|
|
1031
|
+
if (declaration) {
|
|
1032
|
+
if (isTypeOnlyDeclaration(declaration)) return [];
|
|
1033
|
+
if (declaration.type === AST_NODE_TYPES15.VariableDeclaration) return declaratorEntries(declaration);
|
|
1034
|
+
return [declarationEntry(declaration)];
|
|
1035
|
+
}
|
|
1036
|
+
return specifiers.filter((specifier) => specifier.exportKind !== "type").map((specifier) => ({
|
|
1037
|
+
node: specifier,
|
|
1038
|
+
name: specifier.exported.type === AST_NODE_TYPES15.Identifier ? specifier.exported.name : specifier.exported.value
|
|
1039
|
+
}));
|
|
1040
|
+
};
|
|
1041
|
+
var exportEntries = (statement) => {
|
|
1042
|
+
if (statement.type === AST_NODE_TYPES15.ExportNamedDeclaration) return namedEntries(statement);
|
|
1043
|
+
if (statement.type === AST_NODE_TYPES15.ExportDefaultDeclaration)
|
|
1044
|
+
return statement.declaration.type === AST_NODE_TYPES15.TSDeclareFunction ? [] : [{ node: statement, name: "default" }];
|
|
1045
|
+
return [];
|
|
1046
|
+
};
|
|
1047
|
+
var oneExportPerFile = ESLintUtils3.RuleCreator.withoutDocs({
|
|
1048
|
+
meta: {
|
|
1049
|
+
type: "suggestion",
|
|
1050
|
+
docs: {
|
|
1051
|
+
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."
|
|
1052
|
+
},
|
|
1053
|
+
schema: [],
|
|
1054
|
+
messages: {
|
|
1055
|
+
multiple: "This module already exports `{{first}}`; give `{{name}}` its own module. A type export is free of this rule."
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
defaultOptions: [],
|
|
1059
|
+
create(context) {
|
|
1060
|
+
return {
|
|
1061
|
+
Program(program) {
|
|
1062
|
+
const [first, ...rest] = program.body.flatMap(exportEntries);
|
|
1063
|
+
if (!first || rest.length === 0) return;
|
|
1064
|
+
for (const entry of rest)
|
|
1065
|
+
context.report({
|
|
1066
|
+
node: entry.node,
|
|
1067
|
+
messageId: "multiple",
|
|
1068
|
+
data: { first: first.name, name: entry.name }
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
// oneLineComments.ts
|
|
1076
|
+
import { AST_TOKEN_TYPES as AST_TOKEN_TYPES3, ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
1077
|
+
var isBare = (comment) => comment.type === AST_TOKEN_TYPES3.Line && comment.value.trim() === "";
|
|
639
1078
|
var collapse = (text) => text.replace(/\s+/gu, " ").trim();
|
|
640
1079
|
var asLine = (body) => body ? `// ${body}` : null;
|
|
641
|
-
var followedOnLine = (comment, after) => !!after?.loc && !!comment.loc && after.loc.start.line === comment.loc.end.line;
|
|
642
1080
|
var blockLines = (comment) => comment.value.replace(/^!/u, "").split(/\r\n|[\r\n\u2028\u2029]/u).map(
|
|
643
1081
|
(line) => line.trim().replace(/^\*(?= |$)/u, "").trim()
|
|
644
1082
|
);
|
|
@@ -669,10 +1107,9 @@ var collapsedBlock = (comment, lines) => {
|
|
|
669
1107
|
};
|
|
670
1108
|
var isJsDoc = (comment, after) => {
|
|
671
1109
|
if (!isComment(after)) return true;
|
|
672
|
-
|
|
673
|
-
return isDirective(next) || isDocShaped(next) && /^\*+\s*@/u.test(comment.value);
|
|
1110
|
+
return isDirective(after) || isDocShaped(after) && /^\*+\s*@/u.test(comment.value);
|
|
674
1111
|
};
|
|
675
|
-
var oneLineComments = {
|
|
1112
|
+
var oneLineComments = ESLintUtils4.RuleCreator.withoutDocs({
|
|
676
1113
|
meta: {
|
|
677
1114
|
type: "layout",
|
|
678
1115
|
docs: {
|
|
@@ -688,34 +1125,16 @@ var oneLineComments = {
|
|
|
688
1125
|
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 `//`."
|
|
689
1126
|
}
|
|
690
1127
|
},
|
|
1128
|
+
defaultOptions: [],
|
|
691
1129
|
create(context) {
|
|
692
1130
|
const sourceCode = context.sourceCode;
|
|
693
1131
|
const comments = sourceCode.getAllComments().filter(isComment);
|
|
694
|
-
const
|
|
695
|
-
const
|
|
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
|
-
};
|
|
1132
|
+
const { enclosingNode, isOwnLine, isAllowMarker } = createCommentLookup(sourceCode);
|
|
1133
|
+
const insideJsx = (comment) => enclosingNode(comment)?.type.startsWith("JSX") ?? false;
|
|
715
1134
|
const breaksSemicolonInsertion = (comment, after) => {
|
|
716
1135
|
if (insideJsx(comment)) return false;
|
|
717
1136
|
const before = sourceCode.getTokenBefore(comment, { includeComments: true });
|
|
718
|
-
return !!before
|
|
1137
|
+
return !!before && before.loc.end.line === comment.loc.start.line && followedOnLine(comment, after);
|
|
719
1138
|
};
|
|
720
1139
|
const blockVerdict = (comment, after) => {
|
|
721
1140
|
const lines = blockLines(comment);
|
|
@@ -733,7 +1152,9 @@ var oneLineComments = {
|
|
|
733
1152
|
"Program:exit"() {
|
|
734
1153
|
const docs = /* @__PURE__ */ new Set();
|
|
735
1154
|
for (const comment of comments) {
|
|
736
|
-
if (comment.type !==
|
|
1155
|
+
if (comment.type !== AST_TOKEN_TYPES3.Block || isDirective(comment) || isAllowMarker(comment)) {
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
737
1158
|
const after = sourceCode.getTokenAfter(comment, { includeComments: true });
|
|
738
1159
|
if (spansLines(comment)) {
|
|
739
1160
|
const { messageId: messageId2, text: text2 } = blockVerdict(comment, after);
|
|
@@ -767,20 +1188,20 @@ var oneLineComments = {
|
|
|
767
1188
|
if (current.length < 2 || current.some(isDirective)) return;
|
|
768
1189
|
const first = current[0];
|
|
769
1190
|
const last = current[current.length - 1];
|
|
770
|
-
if (!first
|
|
771
|
-
const block = current.some((comment) => comment.type ===
|
|
1191
|
+
if (!first || !last) return;
|
|
1192
|
+
const block = current.some((comment) => comment.type === AST_TOKEN_TYPES3.Block);
|
|
772
1193
|
const texts = current.map((comment) => isBare(comment) ? "" : comment.value.trim() || " ");
|
|
773
1194
|
const paragraphs = proseParagraphs(texts, false) > 1;
|
|
774
1195
|
const text = asLine(collapse(texts.join(" ")));
|
|
775
1196
|
context.report({
|
|
776
1197
|
loc: { start: first.loc.start, end: last.loc.end },
|
|
777
1198
|
messageId: paragraphs ? "paragraphs" : "adjacent",
|
|
778
|
-
fix: paragraphs || block || !text ? null : (fixer) => fixer.replaceTextRange([first.range
|
|
1199
|
+
fix: paragraphs || block || !text ? null : (fixer) => fixer.replaceTextRange([first.range[0], last.range[1]], text)
|
|
779
1200
|
});
|
|
780
1201
|
};
|
|
781
1202
|
for (const comment of joinable) {
|
|
782
1203
|
const previous = run[run.length - 1];
|
|
783
|
-
const touching = previous &&
|
|
1204
|
+
const touching = previous && previous.loc.end.line + 1 === comment.loc.start.line;
|
|
784
1205
|
if (!touching) flush();
|
|
785
1206
|
run.push(comment);
|
|
786
1207
|
}
|
|
@@ -788,18 +1209,18 @@ var oneLineComments = {
|
|
|
788
1209
|
}
|
|
789
1210
|
};
|
|
790
1211
|
}
|
|
791
|
-
};
|
|
1212
|
+
});
|
|
792
1213
|
|
|
793
1214
|
// staticJsxInClient.ts
|
|
794
|
-
import { AST_NODE_TYPES as
|
|
1215
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16, AST_TOKEN_TYPES as AST_TOKEN_TYPES4, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
|
|
795
1216
|
var DISABLE_KEYWORDS = ["eslint-disable-next-line", "eslint-disable-line", "eslint-disable"];
|
|
796
|
-
var isJsx = (node) => node.type ===
|
|
1217
|
+
var isJsx = (node) => node.type === AST_NODE_TYPES16.JSXElement || node.type === AST_NODE_TYPES16.JSXFragment;
|
|
797
1218
|
var isRenderedByComponent = (node) => {
|
|
798
1219
|
let current = node.parent;
|
|
799
1220
|
while (current && !isFunctionNode(current)) current = current.parent;
|
|
800
1221
|
return !current || isComponentFunction(current);
|
|
801
1222
|
};
|
|
802
|
-
var staticJsxInClient =
|
|
1223
|
+
var staticJsxInClient = ESLintUtils5.RuleCreator.withoutDocs({
|
|
803
1224
|
meta: {
|
|
804
1225
|
type: "suggestion",
|
|
805
1226
|
docs: {
|
|
@@ -833,23 +1254,23 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
|
|
|
833
1254
|
const line = directive.loc.start.line;
|
|
834
1255
|
if (keyword === "eslint-disable-line") return covers && comment.loc.start.line === line;
|
|
835
1256
|
if (keyword === "eslint-disable-next-line") return covers && comment.loc.end.line === line - 1;
|
|
836
|
-
return covers && comment.type ===
|
|
1257
|
+
return covers && comment.type === AST_TOKEN_TYPES4.Block && comment.range[1] <= directive.range[0];
|
|
837
1258
|
});
|
|
838
1259
|
if (!needsClient(sourceCode) && !isDirectiveKept()) return {};
|
|
839
|
-
const { classify, classifyTag, positionOf } = createClassifier(sourceCode, true);
|
|
1260
|
+
const { classify: classify2, classifyTag, positionOf } = createClassifier(sourceCode, true);
|
|
840
1261
|
const isStatic = (node, position) => {
|
|
841
|
-
const verdict =
|
|
1262
|
+
const verdict = classify2(node, position);
|
|
842
1263
|
return verdict.data && verdict.stable;
|
|
843
1264
|
};
|
|
844
1265
|
const isStaticAttribute = (attribute, position) => {
|
|
845
|
-
if (attribute.type !==
|
|
846
|
-
const key = attribute.name.type ===
|
|
1266
|
+
if (attribute.type !== AST_NODE_TYPES16.JSXAttribute) return false;
|
|
1267
|
+
const key = attribute.name.type === AST_NODE_TYPES16.JSXIdentifier ? attribute.name.name : "";
|
|
847
1268
|
if (isFunctionAttribute(key)) return false;
|
|
848
1269
|
const { value } = attribute;
|
|
849
|
-
if (!value || value.type ===
|
|
850
|
-
return value.type ===
|
|
1270
|
+
if (!value || value.type === AST_NODE_TYPES16.Literal) return true;
|
|
1271
|
+
return value.type === AST_NODE_TYPES16.JSXExpressionContainer && isStatic(value.expression, position);
|
|
851
1272
|
};
|
|
852
|
-
const childPosition = (node) => node.type ===
|
|
1273
|
+
const childPosition = (node) => node.type === AST_NODE_TYPES16.JSXElement ? positionOf(node.openingElement) : "text";
|
|
853
1274
|
const verdicts2 = /* @__PURE__ */ new Map();
|
|
854
1275
|
const judge = (node) => {
|
|
855
1276
|
const cached = verdicts2.get(node);
|
|
@@ -857,7 +1278,7 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
|
|
|
857
1278
|
const position = childPosition(node);
|
|
858
1279
|
let isStaticNode = true;
|
|
859
1280
|
let count = 0;
|
|
860
|
-
if (node.type ===
|
|
1281
|
+
if (node.type === AST_NODE_TYPES16.JSXElement) {
|
|
861
1282
|
const { openingElement } = node;
|
|
862
1283
|
const tag = classifyTag(openingElement);
|
|
863
1284
|
isStaticNode = tag.data && tag.stable && openingElement.attributes.every((attribute) => isStaticAttribute(attribute, position));
|
|
@@ -868,9 +1289,9 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
|
|
|
868
1289
|
const verdict2 = judge(child);
|
|
869
1290
|
isStaticNode &&= verdict2.isStatic;
|
|
870
1291
|
count += verdict2.count;
|
|
871
|
-
} else if (child.type ===
|
|
1292
|
+
} else if (child.type === AST_NODE_TYPES16.JSXExpressionContainer)
|
|
872
1293
|
isStaticNode &&= isStatic(child.expression, position);
|
|
873
|
-
else if (child.type !==
|
|
1294
|
+
else if (child.type !== AST_NODE_TYPES16.JSXText) isStaticNode = false;
|
|
874
1295
|
}
|
|
875
1296
|
const verdict = { isStatic: isStaticNode, count };
|
|
876
1297
|
verdicts2.set(node, verdict);
|
|
@@ -899,9 +1320,9 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
|
|
|
899
1320
|
else if (isJsx(child)) {
|
|
900
1321
|
flush();
|
|
901
1322
|
visit(child);
|
|
902
|
-
} else if (child.type ===
|
|
1323
|
+
} else if (child.type === AST_NODE_TYPES16.JSXExpressionContainer && !isStatic(child.expression, position))
|
|
903
1324
|
flush();
|
|
904
|
-
else if (child.type ===
|
|
1325
|
+
else if (child.type === AST_NODE_TYPES16.JSXSpreadChild) flush();
|
|
905
1326
|
}
|
|
906
1327
|
flush();
|
|
907
1328
|
};
|
|
@@ -914,12 +1335,13 @@ var staticJsxInClient = ESLintUtils2.RuleCreator.withoutDocs({
|
|
|
914
1335
|
|
|
915
1336
|
// plugin.ts
|
|
916
1337
|
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
1338
|
meta: { name: "@soujvnunes/eslint-config" },
|
|
919
1339
|
rules: {
|
|
920
1340
|
"one-line-comments": oneLineComments,
|
|
1341
|
+
"no-comments": noComments,
|
|
921
1342
|
"no-needless-use-client": needlessUseClient,
|
|
922
|
-
"no-static-jsx-in-client": staticJsxInClient
|
|
1343
|
+
"no-static-jsx-in-client": staticJsxInClient,
|
|
1344
|
+
"one-export-per-file": oneExportPerFile
|
|
923
1345
|
}
|
|
924
1346
|
};
|
|
925
1347
|
var soujvnunesPlugin = plugin;
|
|
@@ -943,6 +1365,7 @@ var DEFAULT_IMPORT_GROUPS = [
|
|
|
943
1365
|
"sibling",
|
|
944
1366
|
"index"
|
|
945
1367
|
];
|
|
1368
|
+
var MAX_LINES = 300;
|
|
946
1369
|
var typescriptRules = {
|
|
947
1370
|
"@typescript-eslint/no-unused-vars": [
|
|
948
1371
|
"error",
|
|
@@ -967,7 +1390,6 @@ var typescriptRules = {
|
|
|
967
1390
|
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
968
1391
|
"no-shadow": "off",
|
|
969
1392
|
"@typescript-eslint/no-shadow": "error",
|
|
970
|
-
// Type-aware, so they need the project service wired below.
|
|
971
1393
|
"@typescript-eslint/no-floating-promises": "error",
|
|
972
1394
|
"@typescript-eslint/no-misused-promises": "error",
|
|
973
1395
|
"@typescript-eslint/await-thenable": "error",
|
|
@@ -1012,42 +1434,66 @@ var generalRules = {
|
|
|
1012
1434
|
"no-eval": "error",
|
|
1013
1435
|
"no-implied-eval": "error",
|
|
1014
1436
|
"no-script-url": "error",
|
|
1015
|
-
|
|
1016
|
-
"
|
|
1437
|
+
"padding-line-between-statements": ["error", { blankLine: "never", prev: "*", next: "*" }],
|
|
1438
|
+
"max-lines": ["error", { max: MAX_LINES, skipBlankLines: true, skipComments: true }]
|
|
1017
1439
|
};
|
|
1018
|
-
var
|
|
1019
|
-
|
|
1020
|
-
"
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
{
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1440
|
+
var RESTRICTED_SELECTORS = {
|
|
1441
|
+
exportDefaultFunction: {
|
|
1442
|
+
selector: "ExportDefaultDeclaration > FunctionDeclaration",
|
|
1443
|
+
message: "Avoid `export default function`; use `export const` instead for tree-shakeable modules."
|
|
1444
|
+
},
|
|
1445
|
+
exportNamedFunction: {
|
|
1446
|
+
selector: "ExportNamedDeclaration > FunctionDeclaration",
|
|
1447
|
+
message: "Use `export const` instead of `export function` for tree-shakeable modules."
|
|
1448
|
+
},
|
|
1449
|
+
tsEnum: {
|
|
1450
|
+
selector: "TSEnumDeclaration",
|
|
1451
|
+
message: "Avoid enums; use const assertions or union types instead."
|
|
1452
|
+
},
|
|
1453
|
+
reactDefaultImport: {
|
|
1454
|
+
selector: "ImportDeclaration[source.value='react'] > ImportDefaultSpecifier",
|
|
1455
|
+
message: "Do not import the React default. Use the ambient `React.*` namespace (the react-jsx runtime needs no React import)."
|
|
1456
|
+
},
|
|
1457
|
+
reactNamespaceImport: {
|
|
1458
|
+
selector: "ImportDeclaration[source.value='react'] > ImportNamespaceSpecifier",
|
|
1459
|
+
message: "Do not `import * as React`. Use the ambient `React.*` namespace."
|
|
1460
|
+
},
|
|
1461
|
+
reactTypeImportSpecifier: {
|
|
1462
|
+
selector: "ImportDeclaration[source.value='react'] > ImportSpecifier[importKind='type']",
|
|
1463
|
+
message: "Reference React types via the ambient `React.*` namespace, not a named `{ type X }` import from react."
|
|
1464
|
+
},
|
|
1465
|
+
reactTypeImportDeclaration: {
|
|
1466
|
+
selector: "ImportDeclaration[importKind='type'][source.value='react']",
|
|
1467
|
+
message: 'Reference React types via the ambient `React.*` namespace, not `import type \u2026 from "react"`.'
|
|
1468
|
+
},
|
|
1469
|
+
lucideIcon: {
|
|
1470
|
+
selector: "ImportDeclaration[source.value='lucide-react'][importKind!='type'] > ImportSpecifier[importKind!='type'][imported.name!=/Icon$/][imported.name!='createLucideIcon'][imported.name!='icons'][imported.name!='dynamicIconImports']",
|
|
1471
|
+
message: "Import the `*Icon` name from lucide-react, so a rename never lands on the plain word."
|
|
1472
|
+
},
|
|
1473
|
+
nextFontGoogle: {
|
|
1474
|
+
selector: "ImportDeclaration[source.value='next/font/google']",
|
|
1475
|
+
message: "Self-host fonts instead of fetching them from next/font/google."
|
|
1476
|
+
},
|
|
1477
|
+
cloneElementImport: {
|
|
1478
|
+
selector: "ImportDeclaration[source.value='react'] > ImportSpecifier[imported.name='cloneElement']",
|
|
1479
|
+
message: "Avoid cloneElement; pass data through props instead of mutating a child element."
|
|
1480
|
+
},
|
|
1481
|
+
cloneElementMember: {
|
|
1482
|
+
selector: "MemberExpression[object.name='React'][property.name='cloneElement']",
|
|
1483
|
+
message: "Avoid React.cloneElement; pass data through props instead of mutating a child element."
|
|
1484
|
+
}
|
|
1050
1485
|
};
|
|
1486
|
+
var ALL_SELECTOR_KEYS = Object.keys(RESTRICTED_SELECTORS);
|
|
1487
|
+
var EXPORT_DEFAULT_KEYS = ["exportDefaultFunction", "exportNamedFunction"];
|
|
1488
|
+
var NON_EXPORT_DEFAULT_KEYS = ALL_SELECTOR_KEYS.filter((key) => !EXPORT_DEFAULT_KEYS.includes(key));
|
|
1489
|
+
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}";
|
|
1490
|
+
var cnTernarySelector = (classMergeName) => ({
|
|
1491
|
+
selector: `CallExpression[callee.name='${classMergeName}'] > ConditionalExpression`,
|
|
1492
|
+
message: "Avoid a ternary inside `cn()`; use a cva variant or an object entry instead."
|
|
1493
|
+
});
|
|
1494
|
+
var restrictedSyntaxRule = (keys, extra = []) => ({
|
|
1495
|
+
"no-restricted-syntax": ["error", ...keys.map((key) => RESTRICTED_SELECTORS[key]), ...extra]
|
|
1496
|
+
});
|
|
1051
1497
|
var reactRules = {
|
|
1052
1498
|
"react/prop-types": "off",
|
|
1053
1499
|
"react/react-in-jsx-scope": "off",
|
|
@@ -1071,18 +1517,33 @@ var nextRules = {
|
|
|
1071
1517
|
"@next/next/no-html-link-for-pages": "error",
|
|
1072
1518
|
"@next/next/no-img-element": "error"
|
|
1073
1519
|
};
|
|
1520
|
+
var JSX_A11Y_COMPONENTS = {
|
|
1521
|
+
Link: "a",
|
|
1522
|
+
Image: "img",
|
|
1523
|
+
Button: "button",
|
|
1524
|
+
Input: "input"
|
|
1525
|
+
};
|
|
1074
1526
|
var importOrderRule = (groups) => ({
|
|
1075
1527
|
"import-helpers/order-imports": [
|
|
1076
1528
|
"error",
|
|
1077
1529
|
{ newlinesBetween: "never", groups, alphabetize: { order: "asc", ignoreCase: true } }
|
|
1078
1530
|
]
|
|
1079
1531
|
});
|
|
1532
|
+
var escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1533
|
+
var arbitraryTailwindValuePattern = (allow) => {
|
|
1534
|
+
const exempt = allow.length ? `(?!(?:${allow.map(escapeForRegExp).join("|")})-)` : "";
|
|
1535
|
+
return `(?:^|:)!?-?${exempt}[a-zA-Z][a-zA-Z0-9-]*-\\[[^\\]]+\\](?:/[a-zA-Z0-9.]+)?!?$`;
|
|
1536
|
+
};
|
|
1080
1537
|
var buildConfig = ({
|
|
1081
1538
|
next = false,
|
|
1082
1539
|
ignores = [],
|
|
1083
1540
|
importGroups = DEFAULT_IMPORT_GROUPS,
|
|
1084
1541
|
tsconfigRootDir = process.cwd(),
|
|
1085
1542
|
tailwindEntryPoint,
|
|
1543
|
+
allowArbitraryClasses = [],
|
|
1544
|
+
classMergeName = "cn",
|
|
1545
|
+
nextConfigModules = [],
|
|
1546
|
+
strictExportGlobs = [],
|
|
1086
1547
|
extend = []
|
|
1087
1548
|
} = {}) => {
|
|
1088
1549
|
const plugins = {
|
|
@@ -1096,7 +1557,7 @@ var buildConfig = ({
|
|
|
1096
1557
|
...importRules,
|
|
1097
1558
|
...securityRules,
|
|
1098
1559
|
...generalRules,
|
|
1099
|
-
...restrictedSyntaxRule,
|
|
1560
|
+
...restrictedSyntaxRule(ALL_SELECTOR_KEYS, next ? [cnTernarySelector(classMergeName)] : []),
|
|
1100
1561
|
...importOrderRule(importGroups)
|
|
1101
1562
|
};
|
|
1102
1563
|
const languageGlobals = { ...globals2.node, ...globals2.es2021 };
|
|
@@ -1108,7 +1569,7 @@ var buildConfig = ({
|
|
|
1108
1569
|
"react-hooks": reactHooks,
|
|
1109
1570
|
"jsx-a11y": jsxA11y
|
|
1110
1571
|
});
|
|
1111
|
-
Object.assign(rules, reactRules, nextRules);
|
|
1572
|
+
Object.assign(rules, reactRules, nextRules, jsxA11y.configs.recommended.rules);
|
|
1112
1573
|
Object.assign(languageGlobals, globals2.browser, {
|
|
1113
1574
|
React: "readonly",
|
|
1114
1575
|
JSX: "readonly",
|
|
@@ -1116,34 +1577,49 @@ var buildConfig = ({
|
|
|
1116
1577
|
});
|
|
1117
1578
|
settings.react = { version: "detect" };
|
|
1118
1579
|
settings["import-x/resolver-next"] = [createTypeScriptImportResolver({ alwaysTryTypes: true })];
|
|
1580
|
+
settings["jsx-a11y"] = { components: JSX_A11Y_COMPONENTS };
|
|
1119
1581
|
if (tailwindEntryPoint) {
|
|
1120
1582
|
plugins["better-tailwindcss"] = betterTailwind;
|
|
1121
1583
|
Object.assign(rules, {
|
|
1122
1584
|
"better-tailwindcss/no-unknown-classes": "error",
|
|
1123
1585
|
"better-tailwindcss/no-conflicting-classes": "error",
|
|
1124
|
-
"better-tailwindcss/no-concatenated-classes": "error"
|
|
1586
|
+
"better-tailwindcss/no-concatenated-classes": "error",
|
|
1587
|
+
"better-tailwindcss/no-restricted-classes": [
|
|
1588
|
+
"error",
|
|
1589
|
+
{
|
|
1590
|
+
restrict: [
|
|
1591
|
+
{
|
|
1592
|
+
pattern: arbitraryTailwindValuePattern(allowArbitraryClasses),
|
|
1593
|
+
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-[...])."
|
|
1594
|
+
}
|
|
1595
|
+
]
|
|
1596
|
+
}
|
|
1597
|
+
]
|
|
1125
1598
|
});
|
|
1126
1599
|
settings["better-tailwindcss"] = { entryPoint: tailwindEntryPoint };
|
|
1127
1600
|
}
|
|
1128
1601
|
}
|
|
1129
1602
|
const rootConfigOverride = {
|
|
1130
1603
|
files: ["*.{mjs,js,ts,mts,cts}"],
|
|
1131
|
-
rules: {
|
|
1604
|
+
rules: {
|
|
1605
|
+
"import-x/no-default-export": "off",
|
|
1606
|
+
...restrictedSyntaxRule(NON_EXPORT_DEFAULT_KEYS, next ? [cnTernarySelector(classMergeName)] : [])
|
|
1607
|
+
}
|
|
1132
1608
|
};
|
|
1133
1609
|
const nextFileConventionsOverride = {
|
|
1134
|
-
files: [
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1610
|
+
files: [NEXT_FILE_CONVENTIONS_GLOB],
|
|
1611
|
+
rules: {
|
|
1612
|
+
"import-x/no-default-export": "off",
|
|
1613
|
+
...restrictedSyntaxRule(NON_EXPORT_DEFAULT_KEYS, [cnTernarySelector(classMergeName)])
|
|
1614
|
+
}
|
|
1138
1615
|
};
|
|
1139
|
-
const
|
|
1616
|
+
const commentsOverride = {
|
|
1140
1617
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
|
|
1141
1618
|
plugins: { soujvnunes: soujvnunesPlugin },
|
|
1142
|
-
rules: { "soujvnunes/one-line-comments": "error" }
|
|
1619
|
+
rules: { "soujvnunes/one-line-comments": "error", "soujvnunes/no-comments": "error" }
|
|
1143
1620
|
};
|
|
1144
1621
|
const clientBoundaryOverride = {
|
|
1145
1622
|
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
1623
|
ignores: ["**/{error,global-error}.{jsx,tsx}"],
|
|
1148
1624
|
plugins: { soujvnunes: soujvnunesPlugin },
|
|
1149
1625
|
rules: {
|
|
@@ -1151,11 +1627,47 @@ var buildConfig = ({
|
|
|
1151
1627
|
"soujvnunes/no-static-jsx-in-client": "error"
|
|
1152
1628
|
}
|
|
1153
1629
|
};
|
|
1630
|
+
const programBanRule = (message) => restrictedSyntaxRule(ALL_SELECTOR_KEYS, [
|
|
1631
|
+
cnTernarySelector(classMergeName),
|
|
1632
|
+
{ selector: "Program", message }
|
|
1633
|
+
]);
|
|
1634
|
+
const barrelOverride = {
|
|
1635
|
+
files: ["**/index.{ts,tsx}"],
|
|
1636
|
+
ignores: ["**/pages/**"],
|
|
1637
|
+
rules: programBanRule("Avoid a barrel index file; import each module by its own path.")
|
|
1638
|
+
};
|
|
1639
|
+
const featureRootOverride = {
|
|
1640
|
+
files: ["**/features/*/*.{ts,tsx}"],
|
|
1641
|
+
ignores: ["**/*.test.{ts,tsx}", NEXT_FILE_CONVENTIONS_GLOB],
|
|
1642
|
+
rules: programBanRule("A feature root holds only subfolders; place this file inside one of them.")
|
|
1643
|
+
};
|
|
1154
1644
|
const scriptsOverride = {
|
|
1155
1645
|
files: ["scripts/**/*.mjs"],
|
|
1156
1646
|
languageOptions: { globals: { ...globals2.node } },
|
|
1157
1647
|
rules: { "no-console": "off" }
|
|
1158
1648
|
};
|
|
1649
|
+
const maxLinesExemptOverride = {
|
|
1650
|
+
files: ["**/*.test.*", "**/copy/**"],
|
|
1651
|
+
rules: { "max-lines": "off" }
|
|
1652
|
+
};
|
|
1653
|
+
const pureUtilsOverride = {
|
|
1654
|
+
files: ["**/utils/**"],
|
|
1655
|
+
rules: {
|
|
1656
|
+
"no-restricted-imports": [
|
|
1657
|
+
"error",
|
|
1658
|
+
{ patterns: ["server-only", "next/*", "react", "@/lib/*", "@/app/*"] }
|
|
1659
|
+
]
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
const nextConfigModulesOverride = {
|
|
1663
|
+
files: ["next.config.{ts,mts,cts}", ...nextConfigModules],
|
|
1664
|
+
rules: { "no-restricted-imports": ["error", { patterns: ["@/*"] }] }
|
|
1665
|
+
};
|
|
1666
|
+
const strictExportsOverride = {
|
|
1667
|
+
files: strictExportGlobs,
|
|
1668
|
+
plugins: { soujvnunes: soujvnunesPlugin },
|
|
1669
|
+
rules: { "soujvnunes/one-export-per-file": "error" }
|
|
1670
|
+
};
|
|
1159
1671
|
return [
|
|
1160
1672
|
{ ignores: [...DEFAULT_IGNORES, ...ignores] },
|
|
1161
1673
|
js.configs.recommended,
|
|
@@ -1163,7 +1675,6 @@ var buildConfig = ({
|
|
|
1163
1675
|
{
|
|
1164
1676
|
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
1165
1677
|
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
1678
|
linterOptions: { reportUnusedDisableDirectives: "error" },
|
|
1168
1679
|
languageOptions: {
|
|
1169
1680
|
parserOptions: {
|
|
@@ -1179,10 +1690,14 @@ var buildConfig = ({
|
|
|
1179
1690
|
rules
|
|
1180
1691
|
},
|
|
1181
1692
|
prettier,
|
|
1182
|
-
|
|
1693
|
+
commentsOverride,
|
|
1183
1694
|
rootConfigOverride,
|
|
1184
|
-
...next ? [nextFileConventionsOverride, clientBoundaryOverride] : [],
|
|
1695
|
+
...next ? [nextFileConventionsOverride, clientBoundaryOverride, barrelOverride, featureRootOverride] : [],
|
|
1696
|
+
maxLinesExemptOverride,
|
|
1697
|
+
pureUtilsOverride,
|
|
1185
1698
|
scriptsOverride,
|
|
1699
|
+
...next && nextConfigModules.length ? [nextConfigModulesOverride] : [],
|
|
1700
|
+
...strictExportGlobs.length ? [strictExportsOverride] : [],
|
|
1186
1701
|
...extend
|
|
1187
1702
|
];
|
|
1188
1703
|
};
|