exadev-eslint-config 2.26.0 → 2.28.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 +285 -4
- package/dist/index.cjs +2050 -77
- package/dist/index.d.cts +69 -1
- package/dist/index.d.ts +69 -1
- package/dist/index.js +2049 -79
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -169,7 +169,10 @@ export default tseslint.config(
|
|
|
169
169
|
| [Workspace architecture rules](#workspace-architecture) | Off unless given (no sensible default for `groups`) | `exadevConfig({ workspaceArchitecture })` / `workspaceArchitectureConfig(options)` |
|
|
170
170
|
| [Turbo rules](#turbo) | Off unless given (only a repository can say it uses turbo) | `exadevConfig({ turbo })` / `turboConfig(options)` |
|
|
171
171
|
| [Import policy](#import-policy) | Off unless given (only a repository can say which imports it forbids) | `exadevConfig({ importPolicies })` / `importPolicyConfig(policies)` |
|
|
172
|
+
| [Pure modules](#pure-modules) | Off unless given (only a repository can say which modules are a functional core) | `exadevConfig({ pureModules })` / `pureModulesConfig(options)` |
|
|
173
|
+
| [Guard and conformance test hygiene](#guard-and-conformance-test-hygiene) | Off unless given (only a repository can say which tests are guards); needs the optional peer `@vitest/eslint-plugin` | `exadevConfig({ testHygiene })` / `testHygieneConfig(options)` |
|
|
172
174
|
| [Turbo environment variable checking](#environment-variables-read-in-source) | Auto-detected: on if `eslint-plugin-turbo` is installed | `exadevConfig({ turboEnv })` |
|
|
175
|
+
| [Required Markdown headings](#required-markdown-headings) | Off unless given (only a repository can say which documents need which headings); needs the optional peer `@eslint/markdown` | `exadevConfig({ markdownHeadings })` / `markdownHeadingsConfig(options)` |
|
|
173
176
|
|
|
174
177
|
Every tri-state option above (`true`/`false`/`undefined`) is passed through the named `exadevConfig(options, ...userConfigs)` factory export:
|
|
175
178
|
|
|
@@ -201,7 +204,7 @@ React/hooks/a11y and Next.js rule blocks fold in automatically, with no separate
|
|
|
201
204
|
pnpm add -D @next/eslint-plugin-next # Next.js support
|
|
202
205
|
```
|
|
203
206
|
If none of these resolve, `@exadev/eslint-config`'s default export is byte-for-byte identical to the plain TypeScript ruleset — nothing about the base package changes.
|
|
204
|
-
2. **For React specifically, the file must actually be `.jsx`/`.tsx`.** The React/hooks/a11y rule block is scoped to `files: ['**/*.jsx', '**/*.tsx']`, so even if `eslint-plugin-react` is resolvable only incidentally (e.g. hoisted as a transitive dependency of something unrelated in a monorepo, with zero real JSX anywhere in the linted project), its rules never match a file that isn't JSX. `@next/eslint-plugin-next`'s block carries no such glob: its own presence is already an unambiguous signal (nothing installs it except a real Next.js project).
|
|
207
|
+
2. **For React specifically, the file must actually be `.jsx`/`.tsx`.** The React/hooks/a11y rule block is scoped to `files: ['**/*.jsx', '**/*.tsx']`, so even if `eslint-plugin-react` is resolvable only incidentally (e.g. hoisted as a transitive dependency of something unrelated in a monorepo, with zero real JSX anywhere in the linted project), its rules never match a file that isn't JSX. `@next/eslint-plugin-next`'s own block carries no such glob: its own presence is already an unambiguous signal (nothing installs it except a real Next.js project). The [server component boundary](#server-component-boundary) rules added beside it are scoped to the same JSX files.
|
|
205
208
|
|
|
206
209
|
React support pairs `eslint-plugin-react`'s `flat/recommended` with its own `flat/jsx-runtime` config, turning [`react/react-in-jsx-scope`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md) and [`react/jsx-uses-react`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md) back off. `flat/recommended` alone assumes the classic runtime, where every file using JSX needs `import React` in scope; the automatic JSX runtime (the default since React 17, and the only mode Next.js's own compiler supports) needs no such import. Without this pairing, a consumer on the automatic runtime would see `react/react-in-jsx-scope` fire on every JSX file.
|
|
207
210
|
|
|
@@ -236,6 +239,34 @@ React support pairs `eslint-plugin-react`'s `flat/recommended` with its own `fla
|
|
|
236
239
|
|
|
237
240
|
**Compatibility note:** a consumer who already has `eslint-plugin-react`/`@next/eslint-plugin-next` resolvable for unrelated reasons (e.g. hoisted in a monorepo) and writes `.jsx`/`.tsx` files may see new rule activity the moment they upgrade to a version of this package that ships React/Next.js support, with zero action on their part. This is the normal, widely-accepted ESLint-ecosystem convention that adding rules to a shared/recommended config is a minor bump even though it can newly trip an existing `--max-warnings 0` gate — not a breaking change. Use the `react`/`nextjs` options above to force it off explicitly if needed.
|
|
238
241
|
|
|
242
|
+
#### Server component boundary
|
|
243
|
+
|
|
244
|
+
Props a server component passes to a client component must be serialisable, and two easy mistakes surface only at runtime in a production build. The Next.js preset (auto-detected, `exadevConfig({ nextjs: true })` or `plugin.configs.nextjs`) therefore adds a block for `.jsx` and `.tsx` files enabling two rules. Both apply only to a file without a top-level `"use client"` directive, so a client file is never reported; neither needs type information.
|
|
245
|
+
|
|
246
|
+
- **`exadev/no-non-serialisable-server-prop`** reports a JSX attribute named in `names` (default `['component']`) whose value is not data. Data is a literal (not a regular expression), a template literal, object or array of data, `undefined`, a unary expression (`-x`, `!x`, `typeof x`, which always yields a primitive), or a JSX element, which React serialises. An identifier, member access, call, function, class, spread, or object member holding a function is reported, since it may be a function or component reference. Passing `component={Icon}` to a client component fails; passing a string key or `component={<Icon />}` does not.
|
|
247
|
+
- **`exadev/no-external-member-jsx-tag`** reports every member tag (`<Lib.Icon>`, `<Lib.Icons.Home>`) whose root identifier is bound by an import from a non-relative source, whether a namespace, default, named or `import x = require()` binding. Whether a library attaches statics after export cannot be worked out from one file, so the rule is deliberately over-broad. A relative import is the project's own code and is not reported; an alias to project code such as `@/ui` looks like a package, so list it in `allowSources`.
|
|
248
|
+
|
|
249
|
+
Both are approximations. They report a file without the directive that is only ever imported by client code (add the directive), a server-safe `<Ctx.Provider>` from an imported context (list it in `allowTags`), and a component passed to an element that is itself a server component (list the element in `allowElements`). Options, by rule:
|
|
250
|
+
|
|
251
|
+
| Rule | Option | Meaning |
|
|
252
|
+
| --- | --- | --- |
|
|
253
|
+
| `no-non-serialisable-server-prop` | `names` | Prop names whose value must be data. Replaces the default `['component']`. |
|
|
254
|
+
| `no-non-serialisable-server-prop` | `allowElements` | JSX element names as written (`Link`, `Lib.Icon`) whose props are not checked. |
|
|
255
|
+
| `no-external-member-jsx-tag` | `allowSources` | Import specifiers, in the [specifier pattern](#specifier-patterns) dialect (each also selects everything beneath it), whose member tags are not reported. |
|
|
256
|
+
| `no-external-member-jsx-tag` | `allowTags` | Tags as written (`Ctx.Provider`) that are not reported. |
|
|
257
|
+
|
|
258
|
+
The preset enables both at `error` with the defaults. To tune them, add a later block that sets the rule again for the same files:
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
{
|
|
262
|
+
files: ['**/*.tsx'],
|
|
263
|
+
rules: {
|
|
264
|
+
'exadev/no-non-serialisable-server-prop': ['error', { names: ['component', 'icon'], allowElements: ['Link'] }],
|
|
265
|
+
'exadev/no-external-member-jsx-tag': ['error', { allowSources: ['@/ui'], allowTags: ['ThemeCtx.Provider'] }],
|
|
266
|
+
},
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
239
270
|
### Gitignore-derived ignores
|
|
240
271
|
|
|
241
272
|
`exadevConfig()`'s default output includes an `ignores` block derived directly from your project's own `.gitignore` (via [`@eslint/config-helpers`](https://www.npmjs.com/package/@eslint/config-helpers)'s `includeIgnoreFile`), so a generated directory your `.gitignore` already knows about (`dist/`, `coverage/`, a tool's own report output) is never linted, without hand-duplicating that list in `eslint.config.ts` too. This closes a real gap: a `.gitignore`d directory that nothing previously linted broadly enough to reach could still get linted the moment a wide-reaching rule (this package's own bundled RFC 8785 JSON canonicalization, say) started matching every file its glob covers.
|
|
@@ -299,7 +330,7 @@ Bundled into `exadevConfig()`'s default output the same way React/Next.js auto-d
|
|
|
299
330
|
| `no-non-barrel-reexport` | ✓ | **Re-exports belong only in a barrel.** Catches the split form across two statements (`import { x } from './y'; export { x };` or `export default x;`) which no AST selector alone can match. Autofix deletes the export and the now-pointless import when it was the import's only use. Self-scopes away from any index file. |
|
|
300
331
|
| `no-side-effects-in-index` | | **A barrel may contain only re-export statements** — nothing that could execute at import time. Self-scopes to any index file. |
|
|
301
332
|
| `barrel-direct-siblings-only` | | **A barrel may re-export only from a direct sibling** (`./module`), never a nested path, parent, or bare package specifier (mode 3). |
|
|
302
|
-
| `no-control-flow` | | **Bans `if`/`switch`/loops/the ternary operator outright.** Not part of `recommended` or `barrel` — ordinary code legitimately needs control flow, so this is opt-in, wired via a consumer's own `files` glob for the specific packages that want it (a composition-root package selecting an adapter/strategy by a validated key, say): a lookup table replaces a branch, a declarative array method (`map`/`filter`/`some`/`every`/...) replaces a loop. Requires no type information. |
|
|
333
|
+
| `no-control-flow` | | **Bans `if`/`switch`/loops/the ternary operator outright.** Not part of `recommended` or `barrel` — ordinary code legitimately needs control flow, so this is opt-in, wired via a consumer's own `files` glob for the specific packages that want it (a composition-root package selecting an adapter/strategy by a validated key, say): a lookup table replaces a branch, a declarative array method (`map`/`filter`/`some`/`every`/...) replaces a loop. Requires no type information. See also [Pure modules](#pure-modules), which can add it to a block, and [a complexity ceiling](#a-complexity-ceiling-for-logic-free-modules) for a softer limit. |
|
|
303
334
|
| `no-pointless-reassignment` | ✓ | **Flags a `const` alias that adds no transformation** (`const foo = bar` where both sides are plain identifiers). Autofix rewrites every read to the original name and deletes the declaration. Still reported but deliberately not auto-fixable where collapsing the alias would change meaning: an explicit type annotation (`const exhaustive: never = item` — the annotation is the point), a read where the original name is shadowed, a read as a shorthand object property, more than one declarator in the statement, or a source that is written to anywhere. An alias that is itself part of the module's exported surface (`export const alias = original;`, a later `export { alias }`/`export { alias as other }`, or `export default alias;`) is neither reported nor fixed at all, since collapsing it would rename or delete a binding every importer of this module depends on. |
|
|
304
335
|
| `no-object-assign` | ✓/suggestion | **`Object.assign` skips the type-checking object spread gets** — it doesn't check a source object's properties against the target's declared types. A fresh object-literal target autofixes to `{ ...target, ...source }`; mutating an existing reassignable binding offers a suggestion only (changes the object's identity); a `const` binding or a non-statement call site gets a plain report with no fix. |
|
|
305
336
|
| `no-mutable-union-array-param` | ✓ | **A union-typed array parameter can be mutated with a value the caller's narrower array never declared.** A function parameter typed as an array of a union (`(string \| number)[]`) accepts a narrower caller array (`number[]`) by covariance; calling `push`/`unshift`/`splice`/`fill`/`copyWithin` on it can then insert a value the caller's own array was never declared to hold. Autofix marks the parameter `readonly`, turning the mutating call into a real compile error to resolve deliberately. Requires no type information. |
|
|
@@ -337,6 +368,15 @@ Bundled into `exadevConfig()`'s default output the same way React/Next.js auto-d
|
|
|
337
368
|
| `required-imports` | | **Files matching a glob must import, and optionally call, a module matching a specifier pattern.** See [File-level rules](#file-level-rules). |
|
|
338
369
|
| `import-policy` | | **Glob-scoped import policy:** deny lists, specifiers confined to named files, and exact exception edges, with a message that names the requirement. Wired by `importPolicyConfig`. See [Import policy](#import-policy). |
|
|
339
370
|
| `filename-pattern` | | **Filename conventions by glob:** a name regex, a required sibling file, and a naming scheme required once a file passes a line count. See [Filename patterns](#filename-patterns). |
|
|
371
|
+
| `pure-module` | | **Bans I/O, ambient state and `async` in the files it is wired onto:** imports of Node I/O modules, I/O and scheduling globals, argument-less `Date`, `Date.now`, `Math.random`, and `async`/`await`. Wired by `pureModulesConfig`. See [Pure modules](#pure-modules). |
|
|
372
|
+
| `scoped-first-parameter` | | **Every method of the configured repository-like interfaces takes a scope parameter first.** Checks the signature only, not that the scope is used or that tenants are isolated. Requires type information. Opt-in: needs its `interfaces` and `parameter` options. See [Scoped first parameter](#scoped-first-parameter). |
|
|
373
|
+
| `injected-test-hygiene` | | **A conformance kit's injected test functions get the same hygiene as imported ones:** no `.only`, no `.skip`, and an assertion in every test body, for the `describe` and `it` a kit receives as parameters, which `@vitest/eslint-plugin` skips. Wired by `testHygieneConfig`. See [Guard and conformance test hygiene](#guard-and-conformance-test-hygiene). |
|
|
374
|
+
| `non-vacuous-guard` | | **A guard test must show it can fail:** an unconditional lower bound on what it discovered, and its pattern checked against an input it must catch and one it must not. Wired by `testHygieneConfig`. See [Guard and conformance test hygiene](#guard-and-conformance-test-hygiene). |
|
|
375
|
+
| `no-multiline-template-literal` | ✓ | **An untagged template literal whose value spans several lines should be an array of lines joined with `\n`.** Autofixes only when the rewrite provably yields the same string. See [Multi-line template literals](#multi-line-template-literals). |
|
|
376
|
+
| `markdown-required-heading` | | **A Markdown document must contain each configured heading:** a `{ depth, text }` per required heading, matched on the text as it renders. A Markdown-language rule (`@eslint/markdown`). Wired by `markdownHeadingsConfig`. See [Required Markdown headings](#required-markdown-headings). |
|
|
377
|
+
| `timeout-aborts-request` | | **A `Promise.race` timeout must abort the request it raced against,** not only settle the race: the timer callback calls `.abort()` on an `AbortController` created in the same function, the timer id is cleared in a `finally`, and a `catch` returns early on `controller.signal.aborted`. Opt-in, needs no type information. See [Timeout races](#timeout-races). |
|
|
378
|
+
| `no-non-serialisable-server-prop` | | **A configured prop (default `component`) of a JSX element in a file without `"use client"` must be serialisable data.** A function or component reference cannot cross from a server component to a client component. Enabled by the Next.js preset. See [Server component boundary](#server-component-boundary). |
|
|
379
|
+
| `no-external-member-jsx-tag` | | **A member tag (`<Lib.Icon>`) rooted at an import from a package, in a file without `"use client"`, is reported.** Statics a library attaches after export may not survive the server component boundary. Enabled by the Next.js preset. See [Server component boundary](#server-component-boundary). |
|
|
340
380
|
|
|
341
381
|
## Barrel policy
|
|
342
382
|
|
|
@@ -443,6 +483,137 @@ Specifiers follow [Specifier patterns](#specifier-patterns). The rule is syntact
|
|
|
443
483
|
|
|
444
484
|
ESLint's core `no-restricted-imports` covers only the static forms (`import`, `export ... from`, `export * from` and `import x = require()`); it has no check for dynamic `import()`, `require()` or `import('x')` type queries, and `no-restricted-modules` is deprecated since ESLint 7. A preset compiled to `no-restricted-imports` blocks would also inherit flat config's rule-level override: when two policies select the same file, the later block's option list replaces the earlier one's, and an exception edge would have to restate every other restriction of the file. So the preset compiles to one block for a purpose-built rule instead, where every policy that selects a file applies to it. Files outside a policy's `files` are untouched.
|
|
445
485
|
|
|
486
|
+
## Pure modules
|
|
487
|
+
|
|
488
|
+
A functional core should not touch I/O, read the clock, roll dice or wait on anything. `pureModulesConfig` (or `exadevConfig({ pureModules })`) wires `exadev/pure-module` onto the files that must stay pure:
|
|
489
|
+
|
|
490
|
+
```ts
|
|
491
|
+
import { defineConfig } from 'eslint/config';
|
|
492
|
+
import { exadevConfig, pureModulesConfig } from '@exadev/eslint-config';
|
|
493
|
+
|
|
494
|
+
export default defineConfig(
|
|
495
|
+
...exadevConfig(),
|
|
496
|
+
...pureModulesConfig({
|
|
497
|
+
files: ['src/core/**', '!src/core/**/*.gen.ts'],
|
|
498
|
+
allowImports: ['node:stream'],
|
|
499
|
+
noControlFlow: true,
|
|
500
|
+
}),
|
|
501
|
+
);
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
The same object goes to `exadevConfig({ pureModules: { files: ['src/core/**'] } })`. `files` follows the [file glob dialect](#file-level-rules) used across this package, with a leading `!` excluding. Like any flat-config `files` list, a glob that ends in `/**` or `/*` selects files only alongside a block that names their extension, which `exadevConfig()` provides for JavaScript and TypeScript.
|
|
505
|
+
|
|
506
|
+
In the selected files the rule reports:
|
|
507
|
+
|
|
508
|
+
- an import of a Node I/O module (`child_process`, `fs`, `http`, `net`, `os`, `process`, `stream`, `worker_threads` and their kin, the full list being `BANNED_MODULES` in [`src/rules/pure-module-options.ts`](src/rules/pure-module-options.ts)), through any syntax `import-policy` recognises. Subpaths and the `node:` form are covered by the module name. A type-only import is left alone, since it is erased before the module runs;
|
|
509
|
+
- a read of an I/O, scheduling or environment global (`fetch`, `process`, `console`, `setTimeout`, `WebSocket`, `Worker`, `localStorage`, `document` and the rest of `BANNED_GLOBALS`), including through `globalThis`;
|
|
510
|
+
- `Date.now`, `Math.random`, `performance.now`, `crypto.randomUUID`, `crypto.getRandomValues`, and `Date()` or `new Date()` with no argument. `new Date(value)` is pure and passes. These are reported when reached through `globalThis` too (`globalThis.Date.now()`). Node's `crypto` module is not banned as a whole, since hashing is pure, but its sources of randomness and key generation (`randomUUID`, `randomBytes`, `randomInt`, `randomFillSync`, the `generate*` functions, `getRandomValues`, `webcrypto`; the full list is `NODE_CRYPTO_NONDETERMINISTIC` in the options file) are reported as named imports from it and as members of a default or namespace import of it;
|
|
511
|
+
- an `async` function or method, `await`, and `for await`.
|
|
512
|
+
|
|
513
|
+
`allowImports` lists specifiers, in the [specifier pattern](#specifier-patterns) dialect, exempted from the module ban. Every entry must select a banned module, so an entry that could never apply fails when the config is created. `noControlFlow: true` adds `exadev/no-control-flow` to the same block, for a module that should hold lookup tables and nothing else.
|
|
514
|
+
|
|
515
|
+
It is one rule under one name, not a `no-restricted-imports`, `no-restricted-globals` and `no-restricted-syntax` recipe, because flat config replaces a rule's options when a later block sets the same rule for the same files. A consumer's own `no-restricted-syntax` block over the pure files would silently drop a recipe's entries; it cannot drop these. The bans are syntactic. They keep a module from reaching for ambient state directly, and they do not follow an alias (`const { random } = Math`) or prove the module deterministic. A repository needing a different list writes its own `no-restricted-*` blocks.
|
|
516
|
+
|
|
517
|
+
### A complexity ceiling for logic-free modules
|
|
518
|
+
|
|
519
|
+
`exadev/no-control-flow` is all or nothing: a module either may branch or may not. For view adapters and thin entry points that should hold almost no logic, a scoped `complexity` ceiling is the softer statement, and needs no new rule. Set it in a block for those globs, placed after the shared config:
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
import { defineConfig } from 'eslint/config';
|
|
523
|
+
import { exadevConfig } from '@exadev/eslint-config';
|
|
524
|
+
|
|
525
|
+
export default defineConfig(
|
|
526
|
+
...exadevConfig(),
|
|
527
|
+
{
|
|
528
|
+
files: ['src/views/**/*.ts', 'src/main.ts'],
|
|
529
|
+
rules: { complexity: ['error', { max: 2 }] },
|
|
530
|
+
},
|
|
531
|
+
);
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
`complexity` counts each function on its own, starting at 1 and adding one per branch, so `max: 2` allows a single `if`, ternary or `&&` per function. Flat config keeps the last value a block sets for a rule, so a broader `complexity` setting that follows this block over the same files replaces the ceiling; keep the scoped block last.
|
|
535
|
+
|
|
536
|
+
## Guard and conformance test hygiene
|
|
537
|
+
|
|
538
|
+
Source-scanning guard tests and conformance suites are worth having only if they cannot silently stop running. A `.skip`, a stray `.only` or a test with no assertion leaves CI green while checking nothing, and so does a scan that discovers no files. `testHygieneConfig` (or `exadevConfig({ testHygiene })`) holds both kinds of file to that:
|
|
539
|
+
|
|
540
|
+
```ts
|
|
541
|
+
import { defineConfig } from 'eslint/config';
|
|
542
|
+
import { exadevConfig } from '@exadev/eslint-config';
|
|
543
|
+
|
|
544
|
+
export default defineConfig(
|
|
545
|
+
...exadevConfig({
|
|
546
|
+
testHygiene: {
|
|
547
|
+
guardFiles: ['**/*.guard.test.ts'],
|
|
548
|
+
conformanceFiles: ['**/*conformance*.test.ts', 'packages/*/src/conformance.ts'],
|
|
549
|
+
assertFunctionNames: ['check*'],
|
|
550
|
+
skippableFiles: ['**/live.conformance.test.ts'],
|
|
551
|
+
},
|
|
552
|
+
}),
|
|
553
|
+
);
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
Every field is optional and `{}` enables the defaults. The preset needs `@vitest/eslint-plugin`, an optional peer (`pnpm add -D @vitest/eslint-plugin`). Giving the option without it throws with the install command, as does an installed version that lacks `expect-expect`, `no-disabled-tests` or `no-focused-tests`. The plugin is registered under `vitest`, the namespace its own documentation uses.
|
|
557
|
+
|
|
558
|
+
| Field | Meaning |
|
|
559
|
+
| --- | --- |
|
|
560
|
+
| `guardFiles` | Guard test globs. Default `**/*.guard.test.ts`. These get the three vitest rules below, `exadev/injected-test-hygiene` and `exadev/non-vacuous-guard`. |
|
|
561
|
+
| `conformanceFiles` | Conformance suite globs. Default `**/*conformance*.test.ts`. These get the three vitest rules and `exadev/injected-test-hygiene`. A kit that is not named `*.test.ts` is listed by its own name (`conformance.ts`). |
|
|
562
|
+
| `assertFunctionNames` | Helper names counted as assertions, besides `expect` and `assert`, by `expect-expect` and by `exadev/injected-test-hygiene`. A kit that asserts by throwing from local helpers never calls `expect`. `*` matches any run of characters (`check*`), and a name also matches its members (`assert` matches `assert.equal`). |
|
|
563
|
+
| `skippableFiles` | Globs of files that are deliberately skipped, exempted from `no-disabled-tests` and from the `.skip` report of `exadev/injected-test-hygiene`, and nothing else. Flat-config globs, so a bare name needs `**/`. |
|
|
564
|
+
|
|
565
|
+
A leading `!` in `guardFiles` or `conformanceFiles` excludes, for that list only. All three vitest rules are set to `error`: `no-focused-tests`, `expect-expect` and `no-disabled-tests`. `describe.skipIf`, `describe.runIf` and `it.todo` are not reported by `no-disabled-tests`, so an opt-in project is written as `describe.skipIf(!process.env['LIVE'])` and needs no exemption; `skippableFiles` is for a file that is skipped unconditionally. Only vitest is supported: eslint-plugin-jest has rules of the same names, which a jest repository wires by hand, and `non-vacuous-guard` reads `expect` chains that both frameworks share.
|
|
566
|
+
|
|
567
|
+
A conformance kit usually takes its test functions as parameters (`runConformance({ describe, it })`, or `run(t)` calling `t.it(...)`) so that each adapter can run it under its own runner. `@vitest/eslint-plugin` resolves such a parameter as a local binding and reports nothing inside the function, so `expect-expect`, `no-disabled-tests` and `no-focused-tests` alone would pass a kit full of `.skip`, `.only` and assertion-free tests. `exadev/injected-test-hygiene` covers that shape, in the same files and with the same `assertFunctionNames` and `skippableFiles`: it reports `.only`, `.skip` (`.skipIf` is not reported) and a test body with no assertion, for a parameter of the enclosing function named `describe`, `suite`, `it` or `test` (directly, destructured, or renamed in the destructuring) and for those names read off any parameter (`t.it`). It is syntactic: a helper the kit calls counts as an assertion only when listed in `assertFunctionNames`, and an imported or global `it` is left to the vitest rules. A kit that is not named `*.test.ts` is listed in `conformanceFiles` by its own name so that both sets of rules reach it.
|
|
568
|
+
|
|
569
|
+
`guard` and `conformance` are test kinds to [`test-file-kind`](#rules), which by default accepts `unit`, `integration` and `e2e` only, so a repository using the default globs adds them:
|
|
570
|
+
|
|
571
|
+
```ts
|
|
572
|
+
{ rules: { 'exadev/test-file-kind': ['error', { kinds: ['unit', 'integration', 'e2e', 'guard', 'conformance'] }] } }
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### Non-vacuous guards
|
|
576
|
+
|
|
577
|
+
The vitest rules cannot catch the commonest way a guard goes quiet: a scan that discovers no files, or a pattern that matches nothing, passes every assertion with no skip, no focus and no assertion-free test. `exadev/non-vacuous-guard` requires each guard file to contain all three of:
|
|
578
|
+
|
|
579
|
+
- a lower bound on what it discovered: `toBeGreaterThan(n)` with `n` at least 0, `toBeGreaterThanOrEqual(n)` with `n` at least 1, `toHaveLength(n)` with `n` at least 1, or `not.toHaveLength(0)`, `not.toBe(0)`, `not.toEqual([])`. A bound written as a name (`MINIMUM_FILES`) is accepted, since its value cannot be read from the syntax;
|
|
580
|
+
- a check that its pattern flags an input it must: `toMatch`, or on a call subject `toBe(true)`, `toBeTruthy()`, `not.toBeNull()`, `toEqual([violation])` and the like, as in `expect(pattern.test(violation)).toBe(true)`. `toBeDefined()` and `toBeUndefined()` are not recognised, since a pattern match returns `null` and on a read they only state that a file exists. An assertion counts once: `not.toEqual([])` is the lower bound above and never also a check of the pattern;
|
|
581
|
+
- a check that it leaves alone an input it must not: `not.toMatch`, or on a call subject `toBe(false)`, `toBeFalsy()`, `toBeNull()`, `toEqual([])` and the like.
|
|
582
|
+
|
|
583
|
+
Only assertions that run unconditionally count. One inside a loop, a `forEach`/`map`/`filter` callback, the mapper of `Array.from`, the callback of an `it.each`, `describe.each` or `.for` table that may be empty (a table literal with a row always runs), a branch, a `switch` case or a `catch` never runs when what it iterates is empty, so `for (const file of files) expect(read(file)).not.toMatch(pattern)` is the scan itself and satisfies none of the three. A helper function that asserts counts, since whether it is called is not visible.
|
|
584
|
+
|
|
585
|
+
The rule is syntactic. It shows the guard file states each of the three, not that the pattern checked is the one the scan uses or that the discovered count is the scan's; a table-driven check whose expected values are variables (`toBe(expected)`) is not recognised, so write the catch and the pass as separate assertions.
|
|
586
|
+
|
|
587
|
+
## Scoped first parameter
|
|
588
|
+
|
|
589
|
+
In a multi-tenant codebase, every method of a repository or store interface should take the tenant scope first, so that a call cannot be written without one. `exadev/scoped-first-parameter` reports the methods that do not:
|
|
590
|
+
|
|
591
|
+
```ts
|
|
592
|
+
// eslint.config.ts
|
|
593
|
+
export default defineConfig(
|
|
594
|
+
...exadevConfig(),
|
|
595
|
+
{
|
|
596
|
+
files: ['src/**/*.ts'],
|
|
597
|
+
plugins: { exadev: plugin },
|
|
598
|
+
rules: {
|
|
599
|
+
'exadev/scoped-first-parameter': ['error', { interfaces: 'Repository$|Store$', parameter: { name: 'scope', type: 'TenantScope' } }],
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
);
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
```ts
|
|
606
|
+
interface OrderRepository {
|
|
607
|
+
find(scope: TenantScope, id: OrderId): Promise<Order | undefined>; // ok
|
|
608
|
+
list(): Promise<Order[]>; // reported: takes no parameters
|
|
609
|
+
findAll(ids: OrderId[]): Promise<Order[]>; // reported: first parameter is OrderId[], not TenantScope
|
|
610
|
+
}
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
`interfaces` is a regular expression tested against the name of each interface and type alias; only the members of a matching declaration are checked. `parameter.type` is the declared name of the type the first parameter must resolve to, and the optional `parameter.name` fixes the parameter's name. The annotation is followed through the checker to the declarations it names: an import rename, `import Scope = Auth.TenantScope` and a type alias of a type alias (`type Scope = TenantScope`) all lead back to `TenantScope`, and a scope declared as an alias of a generic instantiation (`type TenantScope = Readonly<{ id: string }>`) or of a primitive (`type TenantId = string`) is named by the alias that declares it. A type parameter constrained to the scope (`<S extends TenantScope>(scope: S)`) stands for the scope. A structurally identical type of another name does not count, and neither does a union that merely includes the scope, nor the scope wrapped in another type (`Readonly<TenantScope>`; declare the scope itself as the readonly alias instead). Only the members a matching interface or type alias declares are checked, not those it inherits through `extends` from a base that does not match `interfaces`. Method signatures and function-typed properties are both checked; an optional or rest first parameter is reported, since a call could then leave the scope out. TypeScript's `this` pseudo-parameter is skipped.
|
|
614
|
+
|
|
615
|
+
This checks signatures, not isolation. A method can accept a `TenantScope` and ignore it, or read across tenants anyway, so a clean run shows only that no call can be written without a scope. Showing that tenants are actually isolated takes conformance tests run against each implementation, which [`required-imports`](#required-imports) can require every adapter to wire in.
|
|
616
|
+
|
|
446
617
|
## Filename patterns
|
|
447
618
|
|
|
448
619
|
```ts
|
|
@@ -464,6 +635,106 @@ An entry applies to files matching `files` (and, with `overLines`, to those with
|
|
|
464
635
|
|
|
465
636
|
Why not a dependency: [`eslint-plugin-check-file`](https://github.com/dukeluo/eslint-plugin-check-file) (`filename-naming-convention`, `folder-match-with-fex`, `filename-blocklist`, `folder-naming-convention`, `no-index`) and [`unicorn/filename-case`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md) cover case styles and per-glob name patterns, and check-file also folder names and blocked names. Neither can express that another file must exist beside the linted one, or that a name depends on the file's line count, which are the two cases this rule exists for. The name-pattern case is the same as what check-file offers, so a project that already uses that plugin for case styles and folder layout can keep it alongside this rule.
|
|
466
637
|
|
|
638
|
+
## Multi-line template literals
|
|
639
|
+
|
|
640
|
+
`exadev/no-multiline-template-literal` reports an untagged template literal whose value contains a line feed, whether from a line break in the source or an `\n` escape, and rewrites it to an array of lines:
|
|
641
|
+
|
|
642
|
+
```ts
|
|
643
|
+
const prompt = `You are a reviewer.
|
|
644
|
+
Reply in ${language}.`;
|
|
645
|
+
|
|
646
|
+
// becomes
|
|
647
|
+
const prompt = [
|
|
648
|
+
'You are a reviewer.',
|
|
649
|
+
`Reply in ${language}.`
|
|
650
|
+
].join('\n');
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
A line with no substitution becomes a single-quoted string and a line with one stays a template literal on a single line. Substitutions are copied verbatim from the source, comments included, so their evaluation order and text do not change. The fix works on the template's raw source rather than its value: every escape carries over unchanged, since an escape means the same in a single-quoted string as in a template, and only an unescaped `'`, an escaped backtick and an escaped `$` are re-spelled for the literal that holds them. The array is indented one level deeper than the line the template starts on, using that line's own indentation style. Run the project's quote and trailing-comma rules afterwards if it prefers other styles.
|
|
654
|
+
|
|
655
|
+
The rule reports without offering a fix when it cannot show that the pieces join back to exactly the same value: a line continuation (a backslash before a line break), a carriage return or Unicode line separator in the source, a `\x` or `\u` escape that spells a line feed, or an octal-looking escape. A final check compares the line breaks it found with the line feeds in the cooked value, so a case the scanner mis-reads is refused rather than rewritten.
|
|
656
|
+
|
|
657
|
+
It also reports without a fix when the template sits where TypeScript needs its literal type, which the joined string (a plain `string`) does not have: under `as const`, `as`, `satisfies` or a type assertion (also through an enclosing array or object), as a string enum member's initialiser, or as the initialiser of a declaration with a type annotation. Without type information it cannot see the contextual type of a call argument or a return value, so those are still fixed.
|
|
658
|
+
|
|
659
|
+
A tagged template is never reported. The tag receives the literal's pieces, so joining them would change what it is called with, and multi-line `sql`, `css` or `markdown` templates are the point of the syntax. There is therefore no option listing tags to ignore. `allowFiles` takes globs in the [file glob dialect](#file-level-rules) for files whose multi-line strings are intended (fixtures, prompts):
|
|
660
|
+
|
|
661
|
+
```ts
|
|
662
|
+
'exadev/no-multiline-template-literal': ['error', { allowFiles: ['src/prompts/**', 'test/fixtures/**'] }]
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
The rule needs no type information and is not in `recommended`.
|
|
666
|
+
|
|
667
|
+
## Required Markdown headings
|
|
668
|
+
|
|
669
|
+
A documentation convention such as "every skill file has a `## Usage` heading" is otherwise enforced by a remark pipeline or by nothing. `@eslint/markdown` lets an ESLint rule visit the same heading nodes, so the check runs in the same lint as everything else. `markdownHeadingsConfig` (or `exadevConfig({ markdownHeadings })`) wires `exadev/markdown-required-heading` onto the Markdown files you name:
|
|
670
|
+
|
|
671
|
+
```ts
|
|
672
|
+
import { defineConfig } from 'eslint/config';
|
|
673
|
+
import { exadevConfig, markdownHeadingsConfig } from '@exadev/eslint-config';
|
|
674
|
+
|
|
675
|
+
export default defineConfig(
|
|
676
|
+
...exadevConfig(),
|
|
677
|
+
...markdownHeadingsConfig({
|
|
678
|
+
files: ['skills/**/SKILL.md'],
|
|
679
|
+
headings: [
|
|
680
|
+
{ depth: 2, text: 'Usage' },
|
|
681
|
+
{ depth: 2, text: 'Gotchas' },
|
|
682
|
+
],
|
|
683
|
+
}),
|
|
684
|
+
);
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
The preset needs `@eslint/markdown`, an optional peer (`pnpm add -D @eslint/markdown`), and throws with the install command when it cannot be resolved. It registers the plugin under `markdown` and sets the language to `markdown/gfm`. `files` follows the [file glob dialect](#file-level-rules) with a leading `!` excluding. Whether ESLint lints `**/*.md` at all is a repository-wide decision the preset cannot make: a `.gitignore`-derived or other `ignores` entry that hides those files still hides them.
|
|
688
|
+
|
|
689
|
+
Each entry is a `depth` from 1 to 6 (`#` to `######`) and the `text` of the heading. A document is missing an entry unless some heading of that depth has that text once the heading is flattened from its inline children and read the way a renderer shows it: emphasis, strong, links and code spans contribute their text, an image its alternative text, a hard break a space, and raw inline HTML nothing. The text is trimmed and each run of whitespace collapses to one space, on both sides, so a two-line Setext heading equals its one-line spelling. Matching is otherwise exact, case included. A heading anywhere in the document counts, inside a blockquote or a list as well. Each missing entry is reported once, at the top of the file, after the whole document has been read.
|
|
690
|
+
|
|
691
|
+
The entries are a list rather than a single `{ depth, text }` because flat config replaces a rule's options when a later block sets the same rule for the same files, so a second required heading could not be added by enabling the rule again.
|
|
692
|
+
|
|
693
|
+
Frontmatter is parsed as a node of its own (`yaml` by default, or `frontmatter: 'toml'` or `'json'`). Without that, a leading `---` block is read as a thematic break followed by a Setext heading made of the block's first line, which could satisfy or spoil a check; the preset always sets it. A repository that wires the rule by hand sets `languageOptions: { frontmatter: 'yaml' }` on its own block for the same reason. The frontmatter is never treated as a heading, so `title: Usage` does not satisfy a required `Usage`.
|
|
694
|
+
|
|
695
|
+
## Timeout races
|
|
696
|
+
|
|
697
|
+
A timeout that settles a `Promise.race` but leaves the request it raced against running is a leak: the caller moves on while the provider call keeps consuming budget and connections. `exadev/timeout-aborts-request` requires the shape that both settles the race and cancels the work:
|
|
698
|
+
|
|
699
|
+
```ts
|
|
700
|
+
async function complete(url: string): Promise<Response | undefined> {
|
|
701
|
+
const controller = new AbortController();
|
|
702
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
703
|
+
try {
|
|
704
|
+
return await Promise.race([
|
|
705
|
+
fetch(url, { signal: controller.signal }),
|
|
706
|
+
new Promise<never>((_, reject) => {
|
|
707
|
+
timer = setTimeout(() => {
|
|
708
|
+
controller.abort();
|
|
709
|
+
reject(new Error('timed out'));
|
|
710
|
+
}, TIMEOUT_MS);
|
|
711
|
+
}),
|
|
712
|
+
]);
|
|
713
|
+
} catch (error) {
|
|
714
|
+
if (controller.signal.aborted) return undefined;
|
|
715
|
+
throw error;
|
|
716
|
+
} finally {
|
|
717
|
+
clearTimeout(timer);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
For each `Promise.race([...])` with an arm that is a `new Promise(executor)` whose executor calls `setTimeout` (written in place or named by a `const` first), the rule reports:
|
|
723
|
+
|
|
724
|
+
- a timer callback that contains no `.abort()` call, including a callback it cannot read (an imported function, a bound method). Nothing aborts the request, so it keeps running after the race settles;
|
|
725
|
+
- an `.abort()` whose receiver is not a local `const controller = new AbortController()` of the function holding the race: a controller created at module level, in an outer function, received as a parameter or read off `this` is shared with other races or belongs to the caller, so aborting it cancels more than this request;
|
|
726
|
+
- a timer whose id is not kept in a variable and passed to `clearTimeout` in a `finally` around the race (a `try` statement's `finally`, or a `.finally(callback)` chained onto the race). A request that wins otherwise leaves the timer pending. A `try` counts only when it awaits the race, directly, through a type assertion or a chained `.then`, or through a `const` the race is stored in and later awaited inside the same block: a race that is returned or assigned without an await lets the `finally` run at once, clearing the timer before it can fire;
|
|
727
|
+
- a `catch` around the race (a `catch` clause, or a `.catch(callback)` chained onto it) that has no `if` testing `controller.signal.aborted` with a `return` in its consequent, so a timeout is handled apart from a failure of the request. The test must be `controller.signal.aborted` itself or an `&&` with that as one operand; its negation, or an `||`, is true without an abort. A `try` statement's `catch` counts only when the `try` block awaits the race, for the same reason as the `finally`;
|
|
728
|
+
- a controller that no other arm of the race refers to (directly or through a `const` the arm names), such as a request started with `other.signal`. The timer would abort a controller the raced request never received. The rule checks that the controller appears in the request's arm, not that a particular call forwards its signal to the underlying request.
|
|
729
|
+
|
|
730
|
+
The rule is syntactic and reads one function. It cannot see that a helper the race calls forwards `controller.signal` to the request, which is cross-file, and it does not check that a particular SDK call receives the signal, which is vendor-specific and belongs in the [import policy](#import-policy) or a recipe. A race over work that cannot be cancelled is a false positive; the escape hatch is a scoped block that turns the rule off for those files:
|
|
731
|
+
|
|
732
|
+
```ts
|
|
733
|
+
{ files: ['src/legacy/**'], rules: { 'exadev/timeout-aborts-request': 'off' } }
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
Off unless enabled (`'exadev/timeout-aborts-request': 'error'` with the plugin registered), and not in `recommended`, since a project chooses to adopt the shape.
|
|
737
|
+
|
|
467
738
|
## Workspace architecture
|
|
468
739
|
|
|
469
740
|
Six rules (`no-uphill-dependency`, `no-dependency-cycle`, `package-name-mirrors-path`, `package-has-files`, `dev-dependency-only`, `required-scripts`) share one options object, `WorkspaceArchitectureOptions`, describing a pnpm workspace's own dependency-direction rules (which package is allowed to depend on which other, checked directly against every `package.json`'s declared `dependencies`) and the per-package requirements layered on the same groups. The last four rules are opt-in within it: each does nothing unless its own option is given. Off by default, since `groups` has no sensible default; enable it either through `exadevConfig({ workspaceArchitecture })` (the full bundle) or the standalone `workspaceArchitectureConfig(options)` export (for a consumer building its own config from the lighter `plugin` export, e.g. one that isn't using `exadevConfig()` at all):
|
|
@@ -839,7 +1110,7 @@ pnpm build
|
|
|
839
1110
|
- `buildOptionalPluginConfig` is the builder shared by the presets that fold in a single plugin's flat config ([`src/nextjs.ts`](src/nextjs.ts), [`src/turbo-env.ts`](src/turbo-env.ts)): the package, the config path, the feature name for the error and an optional `files` scope go in, and the tri-state `enabled` behaviour comes out the same for each.
|
|
840
1111
|
- [`src/react.ts`](src/react.ts)/[`src/nextjs.ts`](src/nextjs.ts) each export a `build*Config(options)` function: resolve the relevant optional peer(s) via `tryRequire`, extract their real flat config via `readFlatConfig`, and return an array of 0-or-more config blocks.
|
|
841
1112
|
- `[]` if unresolvable and not explicitly forced on; a thrown `Error` if explicitly forced on (`enabled: true`) and still unresolvable.
|
|
842
|
-
- `react.ts`'s blocks are scoped to `files: ['**/*.jsx', '**/*.tsx']`; `nextjs.ts`'s is not (see [Optional React and Next.js support](#optional-react-and-nextjs-support) for why).
|
|
1113
|
+
- `react.ts`'s blocks are scoped to `files: ['**/*.jsx', '**/*.tsx']`; `nextjs.ts`'s upstream block is not (see [Optional React and Next.js support](#optional-react-and-nextjs-support) for why). `buildNextjsConfig` also takes this package's own plugin and adds the [server component boundary](#server-component-boundary) rule block after the upstream config, only when that resolves; the plugin is a parameter because `plugin.ts` builds `plugin.configs.nextjs` from `nextjs.ts`, and importing it back would make the two modules import each other.
|
|
843
1114
|
- [`src/json-language-config.ts`](src/json-language-config.ts) is the shared groundwork for every rule that lints JSON files through `@eslint/json`, an optional peer.
|
|
844
1115
|
- `tryResolveJsonPlugin` and `requireJsonPlugin` are the silent and the throwing resolution paths, the second naming the feature that needs the peer and the install command.
|
|
845
1116
|
- `buildJsonLanguageBlock` assembles the `exadev` and `json` plugin registration for a `files` list under `json/json` or `json/jsonc`; the `json/jsonc` form also admits trailing commas, matching the JSONC config in [`src/json-canonical.ts`](src/json-canonical.ts). `JSONC_FILE_GLOBS` (`tsconfig*.json`, `turbo.json`, `*.jsonc`) lists the files that carry comments, so a rule targeting them must be wired under `json/jsonc`, and a rule meant for both languages declares both in `meta.languages`.
|
|
@@ -850,24 +1121,34 @@ pnpm build
|
|
|
850
1121
|
- [`src/rules/file-entry.ts`](src/rules/file-entry.ts) is the shared option handling for the per-file rules (`required-exports`, `required-imports`, `import-policy`, `filename-pattern`): `createEntryScope` widens a glob without a `/` to any depth on top of `createFileScope`, and the `read*` helpers validate entries and reject unknown keys.
|
|
851
1122
|
- [`src/rules/specifier-match.ts`](src/rules/specifier-match.ts) matches import specifiers against patterns for `required-imports` and `import-policy`, reusing the path matcher `createPathMatcher` in `file-scope.ts`.
|
|
852
1123
|
- [`src/import-policy.ts`](src/import-policy.ts) builds the `importPolicyConfig` block from the validated policies in [`src/rules/import-policy-options.ts`](src/rules/import-policy-options.ts), which the rule reads with the same reader.
|
|
1124
|
+
- [`src/pure-modules.ts`](src/pure-modules.ts) builds the `pureModulesConfig` block: `files` becomes the block's `files` and `ignores`, and the rule options are read by [`src/rules/pure-module-options.ts`](src/rules/pure-module-options.ts), which also holds the ban lists. [`src/rules/pure-module.ts`](src/rules/pure-module.ts) reuses `moduleReferenceOf` from `import-policy.ts` so every import syntax is recognised the same way.
|
|
1125
|
+
- [`src/test-hygiene.ts`](src/test-hygiene.ts) builds the `testHygieneConfig` blocks: it resolves the optional `@vitest/eslint-plugin` through `tryRequire`, checks the three rules it relies on exist, and emits the vitest rules and `exadev/injected-test-hygiene` per list of globs, plus `exadev/non-vacuous-guard` for guard files. Tests supply a plugin through `assembleTestHygieneConfig`, so the public options carry no resolver seam. [`src/config-globs.ts`](src/config-globs.ts) turns a validated glob list into a block's `files` and `ignores`, shared with the pure-module builder.
|
|
1126
|
+
- [`src/markdown-headings.ts`](src/markdown-headings.ts) builds the `markdownHeadingsConfig` block. It resolves the optional `@eslint/markdown` through [`src/markdown-plugin.ts`](src/markdown-plugin.ts), which unwraps the ES module namespace `require()` returns the way `json-plugin.ts` does for `@eslint/json`, and fixes the language and the frontmatter option the rule depends on. [`src/rules/markdown-required-heading.ts`](src/rules/markdown-required-heading.ts) is typed against `@eslint/markdown`'s own rule definition, like the JSON rules.
|
|
853
1127
|
- [`src/rules/file-reference.ts`](src/rules/file-reference.ts) is the option shape for a rule that reads another file: `{ path, relativeTo? }`, resolved against the linted file's directory (`file`, the default) or the workspace root (`root`, found the way the workspace architecture rules find it).
|
|
854
1128
|
- `readReferencedJson` parses the target as JSONC through [`src/rules/jsonc.ts`](src/rules/jsonc.ts) (comments, trailing commas and a leading byte order mark), returning `undefined` for a missing file and throwing, naming the path, for one that does not parse.
|
|
855
1129
|
- [`src/turbo-config.ts`](src/turbo-config.ts) builds the turbo blocks (`buildTurboConfig` internally, `turboConfig` publicly) from the one shared options object in [`src/rules/turbo-options.ts`](src/rules/turbo-options.ts).
|
|
856
1130
|
- The pure decisions live in [`src/rules/turbo-checks.ts`](src/rules/turbo-checks.ts), independent of ESLint, so they are tested against plain maps; the rules are thin visitors over them. [`src/rules/turbo-json.ts`](src/rules/turbo-json.ts) reads the parts of a `turbo.json` the rules need and finds the root one, [`src/rules/turbo-workspace.ts`](src/rules/turbo-workspace.ts) lists the packages and their scripts, and [`src/rules/turbo-commands.ts`](src/rules/turbo-commands.ts) reads a script command for a delegation, the tasks it invokes, or a boundaries run.
|
|
857
1131
|
- Rules that read sibling and ancestor files take a `WorkspaceFs` through their factory, and their tests use [`src/rules/memory-fs.ts`](src/rules/memory-fs.ts), an in-memory implementation, rather than fixture trees on disk.
|
|
858
1132
|
- [`src/create-config.ts`](src/create-config.ts) is config assembly's single source of truth.
|
|
859
|
-
- `exadevConfig(options, ...userConfigs)` concatenates, in order: `buildGitignoreConfig`, `recommendedTypeChecked`, `jsdocAndTsdoc`, `jsonCanonicalConfig`, `stylisticCommentsConfig`, `buildReactConfig`, `buildNextjsConfig`, `buildPackageJsonKeyOrderConfig` (each tri-state builder fed its matching option), `buildWorkspaceArchitectureConfig` (only when `workspaceArchitecture` is given; there is no auto-detected default), `buildTurboConfig` (only when `turbo` is given, likewise), `buildImportPolicyConfig` (only when `importPolicies` is given, likewise), and any trailing user configs.
|
|
1133
|
+
- `exadevConfig(options, ...userConfigs)` concatenates, in order: `buildGitignoreConfig`, `recommendedTypeChecked`, `jsdocAndTsdoc`, `jsonCanonicalConfig`, `stylisticCommentsConfig`, `buildReactConfig`, `buildNextjsConfig`, `buildPackageJsonKeyOrderConfig` (each tri-state builder fed its matching option), `buildWorkspaceArchitectureConfig` (only when `workspaceArchitecture` is given; there is no auto-detected default), `buildTurboConfig` (only when `turbo` is given, likewise), `buildImportPolicyConfig` (only when `importPolicies` is given, likewise), `buildPureModulesConfig` (only when `pureModules` is given, likewise), `buildTestHygieneConfig` (only when `testHygiene` is given, likewise), `buildMarkdownHeadingsConfig` (only when `markdownHeadings` is given, likewise), and any trailing user configs.
|
|
860
1134
|
- `defaultConfig` is `exadevConfig()` evaluated once, eagerly, at module load.
|
|
861
1135
|
- [`src/stylistic-comments.ts`](src/stylistic-comments.ts) builds `stylisticCommentsConfig`: the hand-picked `@stylistic/eslint-plugin` rules plus this package's own `exadev/prefer-doc-comment`, in two blocks (one scoped to every JS/TS file, one scoped to JSX files only for the three JSX-specific rules). See [Stylistic comment, class-member and JSX rules](#stylistic-comment-class-member-and-jsx-rules).
|
|
862
1136
|
- [`src/index.ts`](src/index.ts) is the entry point, still a pure re-export barrel:
|
|
863
1137
|
```ts
|
|
864
1138
|
export { defaultConfig as default, exadevConfig } from './create-config';
|
|
865
1139
|
export { importPolicyConfig } from './import-policy';
|
|
1140
|
+
export { markdownHeadingsConfig } from './markdown-headings';
|
|
866
1141
|
export { publicPlugin as plugin } from './plugin';
|
|
1142
|
+
export { pureModulesConfig } from './pure-modules';
|
|
1143
|
+
export { testHygieneConfig } from './test-hygiene';
|
|
867
1144
|
export { turboConfig } from './turbo-config';
|
|
868
1145
|
export { workspaceArchitectureConfig } from './workspace-architecture';
|
|
1146
|
+
export type { MarkdownFrontmatter, MarkdownHeadingsOptions } from './markdown-headings';
|
|
1147
|
+
export type { PureModulesOptions } from './pure-modules';
|
|
1148
|
+
export type { TestHygieneOptions } from './test-hygiene';
|
|
869
1149
|
export type { ImportConfine, ImportDeny, ImportExceptEdge, ImportPolicy } from './rules/import-policy-options';
|
|
870
1150
|
export type { FilenamePatternEntry } from './rules/filename-pattern';
|
|
1151
|
+
export type { RequiredHeading } from './rules/markdown-required-heading';
|
|
871
1152
|
export type { RequiredExportsEntry } from './rules/required-exports';
|
|
872
1153
|
export type { RequiredImportsEntry } from './rules/required-imports';
|
|
873
1154
|
export type { GroupSpec, NamingOptions, RankRule, RankSkipOptions, SliceSpec, WorkspaceArchitectureOptions } from './rules/workspace-options';
|