exadev-eslint-config 2.26.0 → 2.27.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 +145 -2
- package/dist/index.cjs +1172 -61
- package/dist/index.d.cts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.js +1171 -62
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -169,6 +169,8 @@ 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 })` |
|
|
173
175
|
|
|
174
176
|
Every tri-state option above (`true`/`false`/`undefined`) is passed through the named `exadevConfig(options, ...userConfigs)` factory export:
|
|
@@ -299,7 +301,7 @@ Bundled into `exadevConfig()`'s default output the same way React/Next.js auto-d
|
|
|
299
301
|
| `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
302
|
| `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
303
|
| `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. |
|
|
304
|
+
| `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
305
|
| `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
306
|
| `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
307
|
| `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 +339,10 @@ Bundled into `exadevConfig()`'s default output the same way React/Next.js auto-d
|
|
|
337
339
|
| `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
340
|
| `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
341
|
| `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). |
|
|
342
|
+
| `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). |
|
|
343
|
+
| `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). |
|
|
344
|
+
| `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). |
|
|
345
|
+
| `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). |
|
|
340
346
|
|
|
341
347
|
## Barrel policy
|
|
342
348
|
|
|
@@ -443,6 +449,137 @@ Specifiers follow [Specifier patterns](#specifier-patterns). The rule is syntact
|
|
|
443
449
|
|
|
444
450
|
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
451
|
|
|
452
|
+
## Pure modules
|
|
453
|
+
|
|
454
|
+
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:
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
import { defineConfig } from 'eslint/config';
|
|
458
|
+
import { exadevConfig, pureModulesConfig } from '@exadev/eslint-config';
|
|
459
|
+
|
|
460
|
+
export default defineConfig(
|
|
461
|
+
...exadevConfig(),
|
|
462
|
+
...pureModulesConfig({
|
|
463
|
+
files: ['src/core/**', '!src/core/**/*.gen.ts'],
|
|
464
|
+
allowImports: ['node:stream'],
|
|
465
|
+
noControlFlow: true,
|
|
466
|
+
}),
|
|
467
|
+
);
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
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.
|
|
471
|
+
|
|
472
|
+
In the selected files the rule reports:
|
|
473
|
+
|
|
474
|
+
- 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;
|
|
475
|
+
- 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`;
|
|
476
|
+
- `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;
|
|
477
|
+
- an `async` function or method, `await`, and `for await`.
|
|
478
|
+
|
|
479
|
+
`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.
|
|
480
|
+
|
|
481
|
+
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.
|
|
482
|
+
|
|
483
|
+
### A complexity ceiling for logic-free modules
|
|
484
|
+
|
|
485
|
+
`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:
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
import { defineConfig } from 'eslint/config';
|
|
489
|
+
import { exadevConfig } from '@exadev/eslint-config';
|
|
490
|
+
|
|
491
|
+
export default defineConfig(
|
|
492
|
+
...exadevConfig(),
|
|
493
|
+
{
|
|
494
|
+
files: ['src/views/**/*.ts', 'src/main.ts'],
|
|
495
|
+
rules: { complexity: ['error', { max: 2 }] },
|
|
496
|
+
},
|
|
497
|
+
);
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
`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.
|
|
501
|
+
|
|
502
|
+
## Guard and conformance test hygiene
|
|
503
|
+
|
|
504
|
+
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:
|
|
505
|
+
|
|
506
|
+
```ts
|
|
507
|
+
import { defineConfig } from 'eslint/config';
|
|
508
|
+
import { exadevConfig } from '@exadev/eslint-config';
|
|
509
|
+
|
|
510
|
+
export default defineConfig(
|
|
511
|
+
...exadevConfig({
|
|
512
|
+
testHygiene: {
|
|
513
|
+
guardFiles: ['**/*.guard.test.ts'],
|
|
514
|
+
conformanceFiles: ['**/*conformance*.test.ts', 'packages/*/src/conformance.ts'],
|
|
515
|
+
assertFunctionNames: ['check*'],
|
|
516
|
+
skippableFiles: ['**/live.conformance.test.ts'],
|
|
517
|
+
},
|
|
518
|
+
}),
|
|
519
|
+
);
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
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.
|
|
523
|
+
|
|
524
|
+
| Field | Meaning |
|
|
525
|
+
| --- | --- |
|
|
526
|
+
| `guardFiles` | Guard test globs. Default `**/*.guard.test.ts`. These get the three vitest rules below, `exadev/injected-test-hygiene` and `exadev/non-vacuous-guard`. |
|
|
527
|
+
| `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`). |
|
|
528
|
+
| `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`). |
|
|
529
|
+
| `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 `**/`. |
|
|
530
|
+
|
|
531
|
+
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.
|
|
532
|
+
|
|
533
|
+
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.
|
|
534
|
+
|
|
535
|
+
`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:
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
{ rules: { 'exadev/test-file-kind': ['error', { kinds: ['unit', 'integration', 'e2e', 'guard', 'conformance'] }] } }
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### Non-vacuous guards
|
|
542
|
+
|
|
543
|
+
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:
|
|
544
|
+
|
|
545
|
+
- 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;
|
|
546
|
+
- 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;
|
|
547
|
+
- 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.
|
|
548
|
+
|
|
549
|
+
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.
|
|
550
|
+
|
|
551
|
+
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.
|
|
552
|
+
|
|
553
|
+
## Scoped first parameter
|
|
554
|
+
|
|
555
|
+
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:
|
|
556
|
+
|
|
557
|
+
```ts
|
|
558
|
+
// eslint.config.ts
|
|
559
|
+
export default defineConfig(
|
|
560
|
+
...exadevConfig(),
|
|
561
|
+
{
|
|
562
|
+
files: ['src/**/*.ts'],
|
|
563
|
+
plugins: { exadev: plugin },
|
|
564
|
+
rules: {
|
|
565
|
+
'exadev/scoped-first-parameter': ['error', { interfaces: 'Repository$|Store$', parameter: { name: 'scope', type: 'TenantScope' } }],
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
);
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
```ts
|
|
572
|
+
interface OrderRepository {
|
|
573
|
+
find(scope: TenantScope, id: OrderId): Promise<Order | undefined>; // ok
|
|
574
|
+
list(): Promise<Order[]>; // reported: takes no parameters
|
|
575
|
+
findAll(ids: OrderId[]): Promise<Order[]>; // reported: first parameter is OrderId[], not TenantScope
|
|
576
|
+
}
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
`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.
|
|
580
|
+
|
|
581
|
+
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.
|
|
582
|
+
|
|
446
583
|
## Filename patterns
|
|
447
584
|
|
|
448
585
|
```ts
|
|
@@ -850,13 +987,15 @@ pnpm build
|
|
|
850
987
|
- [`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
988
|
- [`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
989
|
- [`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.
|
|
990
|
+
- [`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.
|
|
991
|
+
- [`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.
|
|
853
992
|
- [`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
993
|
- `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
994
|
- [`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
995
|
- 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
996
|
- 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
997
|
- [`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.
|
|
998
|
+
- `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), and any trailing user configs.
|
|
860
999
|
- `defaultConfig` is `exadevConfig()` evaluated once, eagerly, at module load.
|
|
861
1000
|
- [`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
1001
|
- [`src/index.ts`](src/index.ts) is the entry point, still a pure re-export barrel:
|
|
@@ -864,8 +1003,12 @@ pnpm build
|
|
|
864
1003
|
export { defaultConfig as default, exadevConfig } from './create-config';
|
|
865
1004
|
export { importPolicyConfig } from './import-policy';
|
|
866
1005
|
export { publicPlugin as plugin } from './plugin';
|
|
1006
|
+
export { pureModulesConfig } from './pure-modules';
|
|
1007
|
+
export { testHygieneConfig } from './test-hygiene';
|
|
867
1008
|
export { turboConfig } from './turbo-config';
|
|
868
1009
|
export { workspaceArchitectureConfig } from './workspace-architecture';
|
|
1010
|
+
export type { PureModulesOptions } from './pure-modules';
|
|
1011
|
+
export type { TestHygieneOptions } from './test-hygiene';
|
|
869
1012
|
export type { ImportConfine, ImportDeny, ImportExceptEdge, ImportPolicy } from './rules/import-policy-options';
|
|
870
1013
|
export type { FilenamePatternEntry } from './rules/filename-pattern';
|
|
871
1014
|
export type { RequiredExportsEntry } from './rules/required-exports';
|