@shivaedev/quality 0.11.1 → 0.13.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/CHANGELOG.md +15 -0
- package/README.md +10 -3
- package/dist/imports/fences/evaluate.d.ts.map +1 -1
- package/dist/imports/fences/evaluate.js +2 -1
- package/dist/imports/fences/evaluate.js.map +1 -1
- package/dist/naming/testName.d.ts +1 -0
- package/dist/naming/testName.d.ts.map +1 -1
- package/dist/naming/testName.js +4 -0
- package/dist/naming/testName.js.map +1 -1
- package/dist/rules/imports/fences.d.ts.map +1 -1
- package/dist/rules/imports/fences.js +1 -1
- package/dist/rules/imports/fences.js.map +1 -1
- package/dist/rules/max-lines.js +4 -4
- package/dist/rules/max-lines.js.map +1 -1
- package/dist/rules/suppressions/no-inline.js +2 -2
- package/dist/rules/suppressions/no-inline.js.map +1 -1
- package/package.json +3 -2
- package/src/imports/fences/evaluate.ts +2 -1
- package/src/naming/testName.ts +6 -0
- package/src/rules/imports/fences.ts +2 -1
- package/src/rules/max-lines.ts +4 -4
- package/src/rules/suppressions/no-inline.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0 - 2026-10-05
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Test code has one definition: a test file, as the `tests/*` rules read the name, or any file under a `test-support/` folder. `test-support/` is the one folder name for test helpers, and every rule that checks shipped code skips it. `tests/follow` and `tests/colocated` still read only test files.
|
|
8
|
+
- `imports/fences` skips files under `test-support/` too, beside test and spec files, so a harness may import what the tests need.
|
|
9
|
+
- `structure/max-lines` gives test code the test limit without configuration. `testFiles` now adds further folders, such as a Playwright suite in `e2e/`, and is empty by default: `*.test.*` and `*.spec.*` count without it, and a helper in a `test/`, `tests/` or `__tests__/` folder is source until it moves to `test-support/` or the option names its folder. A config that listed the old defaults keeps working.
|
|
10
|
+
|
|
11
|
+
## 0.12.0 - 2026-10-05
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- `imports/fences` skips test files: a file the `tests/*` rules read as a test, `*.test.ts` or `*.spec.ts` with any environment, is never a module a fence holds, so a test beside shipped code may import what it needs. Fences guard shipped code, and a test ships nowhere. Nothing turns this off.
|
|
16
|
+
- `suppressions/no-inline` allows `@ts-expect-error` in `*.typecheck.spec.ts` files too, the type test of a behaviour, exactly as in `*.typecheck.test.ts`.
|
|
17
|
+
|
|
3
18
|
## 0.11.1 - 2026-10-05
|
|
4
19
|
|
|
5
20
|
### Changed
|
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ The config is typed: an unknown rule id, a misspelled option or an option of the
|
|
|
56
56
|
|
|
57
57
|
## Rules
|
|
58
58
|
|
|
59
|
-
`structure/max-lines` keeps each module to one job: a source file may have 150 lines and
|
|
59
|
+
`structure/max-lines` keeps each module to one job: a source file may have 150 lines and [test code](#test-code) 300, counted the way an editor numbers them. Declaration files are exempt. Its options are `source` and `test` (the limits) and `testFiles`, `.gitignore` patterns of further folders whose files count as tests, such as a Playwright suite in `e2e/` (none by default). A file over its limit counts one violation for each line above it: 168 lines under a limit of 150 count 18.
|
|
60
60
|
|
|
61
61
|
### Comments
|
|
62
62
|
|
|
@@ -124,7 +124,7 @@ Coverage hints (`c8 ignore`, `v8 ignore`, `istanbul ignore`) are allowed: they l
|
|
|
124
124
|
|
|
125
125
|
#### Type tests
|
|
126
126
|
|
|
127
|
-
A type test proves that an API rejects what its types forbid, and TypeScript asserts a compile error only through `@ts-expect-error`, which fails as soon as the error it expects goes away. So `@ts-expect-error`, and no other directive, is allowed in a type test: a file named `*.typecheck.test.ts` or `typecheck.test.ts` (or `.tsx`). The compiler checks these files; [Vitest projects](#vitest-projects) never run them. `@ts-ignore`, `@ts-nocheck` and every linter and formatter directive stay reported in them. A test that must pass a rejected value at run time, to prove the runtime refuses it too, calls the API through `Reflect.apply` instead of a directive.
|
|
127
|
+
A type test proves that an API rejects what its types forbid, and TypeScript asserts a compile error only through `@ts-expect-error`, which fails as soon as the error it expects goes away. So `@ts-expect-error`, and no other directive, is allowed in a type test: a file named `*.typecheck.test.ts`, `*.typecheck.spec.ts` or `typecheck.test.ts` (or `.tsx`). The compiler checks these files; [Vitest projects](#vitest-projects) never run them. `@ts-ignore`, `@ts-nocheck` and every linter and formatter directive stay reported in them. A test that must pass a rejected value at run time, to prove the runtime refuses it too, calls the API through `Reflect.apply` instead of a directive.
|
|
128
128
|
|
|
129
129
|
`suppressions/no-double-cast` finds casts with the TypeScript parser, through parentheses and in either assertion syntax. A single cast is left to the linter, and `as const` is not a cast.
|
|
130
130
|
|
|
@@ -217,7 +217,7 @@ Each import resolves the way the compiler resolves it, with the options of the n
|
|
|
217
217
|
- A module that resolves into `node_modules` or outside the root is external, and its package is the one it resolves into, whatever alias the import uses. A `@types` package counts as the package it describes: `@types/hast` is `hast`, `@types/scope__name` is `@scope/name`.
|
|
218
218
|
|
|
219
219
|
```ts
|
|
220
|
-
"imports/resolvable": { options: { generated: ["packages/db/test/generated"] } },
|
|
220
|
+
"imports/resolvable": { options: { generated: ["packages/db/src/test-support/generated"] } },
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
`imports/cycles` reports each group of modules that import each other at run time once, at the alphabetically first of them, with one loop through the group. Its count is the number of modules in the group. `import type`, `export type`, type references and imports in declaration files are left out; `import { type X }` stays a runtime import. Dynamic `import()` and `require()` count; `require.resolve()` does not. It takes no registry exceptions. Each finding of `imports/resolvable` has the import as its subject.
|
|
@@ -274,6 +274,8 @@ Targets are `packages(...)` (workspace packages by name, with or without their s
|
|
|
274
274
|
|
|
275
275
|
The config does not compile without `demonstratedBy`, and the rule checks the examples against the policy: each is a chain of imports from a file of the repository, which may end in `external(name)`. The illegal example must cross this fence and no other; the legal example must cross none. Every name a fence uses must exist: a package, a folder that holds checked files, a checked file, a subject of the unit. Two fences may not share a name, and each needs a reason. A policy that breaks any of this stops the run. Fences count type imports too.
|
|
276
276
|
|
|
277
|
+
Fences guard shipped code, and [test code](#test-code) ships nowhere, so a fence never holds it: a test file or a file under `test-support/` may import across every fence. There is no option to check them.
|
|
278
|
+
|
|
277
279
|
A finding has its fence's name as its subject, so a registry entry with that subject excuses one file from one fence.
|
|
278
280
|
|
|
279
281
|
### Manifests
|
|
@@ -496,6 +498,7 @@ A test sits beside the code it covers, and its name says what it covers and wher
|
|
|
496
498
|
| `cart/Basket.dom.test.tsx` | `cart/Basket.tsx`, in a DOM | Yes |
|
|
497
499
|
| `cart/checkoutFlow.spec.ts` | A behaviour of the `cart/` folder as a whole, such as a flow across several files | Yes |
|
|
498
500
|
| `cart/checkoutFlow.dom.spec.tsx` | The same, in a DOM | Yes |
|
|
501
|
+
| `cart/checkoutFlow.typecheck.spec.ts` | The types of that behaviour, checked by the compiler | Yes |
|
|
499
502
|
| `cart/totals.test.ts` | No `cart/totals.ts` beside it | No: a `.test` follows a file, and a test of the folder is a `.spec` |
|
|
500
503
|
| `cart/cart.spec.ts` | | No: a `.spec` names a behaviour, so it may not share a stem with a file beside it |
|
|
501
504
|
| `cart/cart.hydration.test.ts` | | No: an aspect gets its own file in the module's folder, or a `.spec` |
|
|
@@ -508,6 +511,10 @@ A test sits beside the code it covers, and its name says what it covers and wher
|
|
|
508
511
|
|
|
509
512
|
Both rules take a `suites` option, `.gitignore` patterns of folders that hold tests with their own layout, such as tests across several packages or a Playwright suite, whose `.spec.ts` files mean something else. The rules skip those folders.
|
|
510
513
|
|
|
514
|
+
### Test code
|
|
515
|
+
|
|
516
|
+
Test code is a test file, as `tests/follow` reads the name (`*.test.ts` or `*.spec.ts`, with any environment), or any file under a folder named `test-support/`. `test-support/` is the one folder name for the fixtures, harnesses and generated clients that tests share. Test code ships nowhere, so the rules that check shipped code skip it: `imports/fences` never holds it, and `structure/max-lines` gives it the test limit. The test rules still read only test files: a file under `test-support/` is not a test, so `tests/follow` and `tests/colocated` leave it alone.
|
|
517
|
+
|
|
511
518
|
## Vitest projects
|
|
512
519
|
|
|
513
520
|
`@shivaedev/quality/vitest.ts` sets up the tests of a package by file name, so no test file sets its environment with a pragma. It needs `vitest`, and `happy-dom` for DOM tests.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../../src/imports/fences/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../../src/imports/fences/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,KAAK,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIxC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC;AAEhE,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,SAAS,OAAO,EAAE,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACtB;AAgDD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,aAAa,CAY5E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isTestCode } from "#naming/testName.ts";
|
|
1
2
|
import { compile } from "./match.js";
|
|
2
3
|
import { labelOf, outgoing, reachedFrom } from "./reach.js";
|
|
3
4
|
import { compileVocabulary } from "./vocabulary.js";
|
|
@@ -43,7 +44,7 @@ export function compileFence(compiler, fence) {
|
|
|
43
44
|
const where = `fence "${fence.name}"`;
|
|
44
45
|
const from = compile(compiler, fence.from, `${where}.from`);
|
|
45
46
|
function importer(path) {
|
|
46
|
-
return from({ kind: "file", path });
|
|
47
|
+
return !isTestCode(path) && from({ kind: "file", path });
|
|
47
48
|
}
|
|
48
49
|
const prohibition = fence.prohibition;
|
|
49
50
|
if (prohibition.kind === "vocabulary") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../../src/imports/fences/evaluate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../../src/imports/fences/evaluate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAiB,OAAO,EAAgB,MAAM,YAAY,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAmB,MAAM,iBAAiB,CAAC;AAWrE,SAAS,MAAM,CAAC,KAAY;IAC3B,OAAO,qBAAqB,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC;AAC/D,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAY,EAAE,UAAsB,EAAE,QAA2B,EAAE,IAAgB;IAC7G,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9C,IAAI,OAAO,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,OAAO,EAAE,CAAC;IACX,CAAC;IACD,MAAM,OAAO,GAAG,YAAY,OAAO,QAAQ,UAAU,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACjH,OAAO,CAAC,EAAE,IAAI,EAAE,I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,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACtC,IAAI,WAAW,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACvC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;IAClF,CAAC;IACD,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,EAAE,GAAG,KAAK,KAAK,CAAC,CAAC;IAC5D,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;AACtI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testName.d.ts","sourceRoot":"","sources":["../../src/naming/testName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,uCAAwC,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAID,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAQ3D"}
|
|
1
|
+
{"version":3,"file":"testName.d.ts","sourceRoot":"","sources":["../../src/naming/testName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,uCAAwC,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAID,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAQ3D;AAID,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD"}
|
package/dist/naming/testName.js
CHANGED
|
@@ -10,4 +10,8 @@ export function testName(path) {
|
|
|
10
10
|
const [stem = "", ...modifiers] = groups.base.split(".");
|
|
11
11
|
return { extension: groups.extension, folder: posix.dirname(path), kind, modifiers, stem };
|
|
12
12
|
}
|
|
13
|
+
const TEST_SUPPORT = "test-support";
|
|
14
|
+
export function isTestCode(path) {
|
|
15
|
+
return testName(path) !== undefined || posix.dirname(path).split("/").includes(TEST_SUPPORT);
|
|
16
|
+
}
|
|
13
17
|
//# sourceMappingURL=testName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testName.js","sourceRoot":"","sources":["../../src/naming/testName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAU,CAAC;AAYlE,MAAM,SAAS,GAAG,gEAAgE,CAAC;AAEnF,MAAM,UAAU,QAAQ,CAAC,IAAY;IACpC,MAAM,MAAM,GAAG,SAAS,C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AC;IACD,MAAM,CAAC,IAAI,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzD,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC5F,CAAC;AAED,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fences.d.ts","sourceRoot":"","sources":["../../../src/rules/imports/fences.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAatD,eAAO,MAAM,YAAY;;
|
|
1
|
+
{"version":3,"file":"fences.d.ts","sourceRoot":"","sources":["../../../src/rules/imports/fences.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAatD,eAAO,MAAM,YAAY;;EAavB,CAAC"}
|
|
@@ -17,7 +17,7 @@ export const importFences = defineRule({
|
|
|
17
17
|
const policy = compilePolicy(options.fences, { files: inputs.files, packages: graph.packages });
|
|
18
18
|
return policy.flatMap((compiled) => compiled.evaluate(graph));
|
|
19
19
|
},
|
|
20
|
-
description: "Imports respect the fences the repository declares. Move the code to the side of the fence its imports belong to.",
|
|
20
|
+
description: "Imports of shipped code respect the fences the repository declares; a test file ships nowhere, so no fence holds it. Move the code to the side of the fence its imports belong to.",
|
|
21
21
|
id: "imports/fences",
|
|
22
22
|
options: Schema.toStandardSchemaV1(FencesOptions, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
|
|
23
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fences.js","sourceRoot":"","sources":["../../../src/rules/imports/fences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,SAAS,OAAO,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;AACjG,CAAC;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,2BAA2B,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;CAChJ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACtC,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE;QACvC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAA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xC,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChG,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC;IACD,WAAW,EACV,oLAAoL;IACrL,EAAE,EAAE,gBAAgB;IACpB,OAAO,EAAE,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC;CACjH,CAAC,CAAC"}
|
package/dist/rules/max-lines.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import ignore from "ignore";
|
|
3
|
+
import { isTestCode } from "#naming/testName.ts";
|
|
3
4
|
import { defineRule } from "#rule.ts";
|
|
4
|
-
const DEFAULT_TEST_FILES = ["*.test.*", "*.spec.*", "test/", "tests/", "__tests__/"];
|
|
5
5
|
const DECLARATION = /\.d\.[cm]?ts$/u;
|
|
6
6
|
const Limit = Schema.Int.check(Schema.isGreaterThan(0));
|
|
7
7
|
const MaxLinesOptions = Schema.Struct({
|
|
8
8
|
source: Limit.pipe(Schema.withDecodingDefaultKey(Effect.succeed(150))),
|
|
9
9
|
test: Limit.pipe(Schema.withDecodingDefaultKey(Effect.succeed(300))),
|
|
10
|
-
testFiles: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed(
|
|
10
|
+
testFiles: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
|
|
11
11
|
});
|
|
12
12
|
const oversized = (file, limit) => file.lines.length <= limit
|
|
13
13
|
? []
|
|
@@ -21,10 +21,10 @@ const oversized = (file, limit) => file.lines.length <= limit
|
|
|
21
21
|
];
|
|
22
22
|
export const maxLines = defineRule({
|
|
23
23
|
check: ({ options, sources }) => {
|
|
24
|
-
const
|
|
24
|
+
const suites = ignore().add([...options.testFiles]);
|
|
25
25
|
return sources
|
|
26
26
|
.filter((file) => !DECLARATION.test(file.path))
|
|
27
|
-
.flatMap((file) => oversized(file,
|
|
27
|
+
.flatMap((file) => oversized(file, isTestCode(file.path) || suites.ignores(file.path) ? options.test : options.source));
|
|
28
28
|
},
|
|
29
29
|
description: "Keep each module to one job. Split a long file along its responsibilities; never golf it under the limit.",
|
|
30
30
|
id: "structure/max-lines",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"max-lines.js","sourceRoot":"","sources":["../../src/rules/max-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"max-lines.js","sourceRoot":"","sources":["../../src/rules/max-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAiC,MAAM,UAAU,CAAC;AAErE,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAExD,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,IAAI,EAAE,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AAC,CAAC;IAC1H,CAAC;IACD,WAAW,EAAE,2GAA2G;IACxH,EAAE,EAAE,qBAAqB;IACzB,OAAO,EAAE,MAAM,CAAC,kBAAkB,CAAC,eAAe,EAAE,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC;CACnH,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { defineRule } from "#rule.ts";
|
|
|
2
2
|
import { scanComments } from "#rules/comments/scan.ts";
|
|
3
3
|
import { suppressionIn } from "./directives.js";
|
|
4
4
|
import { STYLESHEET, stylesheetComments } from "./stylesheet-comments.js";
|
|
5
|
-
const TYPE_TEST = /(
|
|
5
|
+
const TYPE_TEST = /(?:(?:^|\/)typecheck\.test|\.typecheck\.(?:test|spec))\.[cm]?[jt]sx?$/u;
|
|
6
6
|
const TYPE_TEST_DIRECTIVE = "@ts-expect-error";
|
|
7
7
|
const sitesIn = (file, comments) => comments.flatMap((comment) => {
|
|
8
8
|
const directive = suppressionIn(comment);
|
|
@@ -18,7 +18,7 @@ function allowed(site) {
|
|
|
18
18
|
}
|
|
19
19
|
export const noInline = defineRule({
|
|
20
20
|
check: async (inputs) => [...inputs.sources.flatMap((file) => sitesIn(file.path, scanComments(file))), ...(await stylesheetSites(inputs))].filter((site) => !allowed(site)),
|
|
21
|
-
description: "A suppression silences a check at one site instead of fixing the cause. Fix the code; where a lint rule truly cannot apply, turn it off for that scope in the Biome config and declare it under suppressions/biome-overrides. A type test asserts a compile error with @ts-expect-error in a *.typecheck.test.ts file.",
|
|
21
|
+
description: "A suppression silences a check at one site instead of fixing the cause. Fix the code; where a lint rule truly cannot apply, turn it off for that scope in the Biome config and declare it under suppressions/biome-overrides. A type test asserts a compile error with @ts-expect-error in a *.typecheck.test.ts or *.typecheck.spec.ts file.",
|
|
22
22
|
id: "suppressions/no-inline",
|
|
23
23
|
registrable: false,
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-inline.js","sourceRoot":"","sources":["../../../src/rules/suppressions/no-inline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiC,MAAM,UAAU,CAAC;AACrE,OAAO,EAAsB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE1E,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"no-inline.js","sourceRoot":"","sources":["../../../src/rules/suppressions/no-inline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiC,MAAM,UAAU,CAAC;AACrE,OAAO,EAAsB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE1E,MAAM,SAAS,GAAG,wEAAwE,CAAC;AAE3F,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAM/C,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,QAAkC,EAAmB,EAAE,CACrF,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IAC5B,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,wBAAwB,SAAS,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;AAC1I,CAAC,CAAC,CAAC;AAEJ,MAAM,eAAe,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAc,EAA4B,EAAE;IACpG,MAAM,IAAI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AAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/quality",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Repository quality gate with typed rules, a baseline of existing debt and a registry of reasoned exceptions",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/quality#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"type": "module",
|
|
17
17
|
"imports": {
|
|
18
|
-
"#test/*": "./test/*",
|
|
18
|
+
"#test/*": "./src/test-support/*",
|
|
19
19
|
"#*.ts": {
|
|
20
20
|
"source": "./src/*.ts",
|
|
21
21
|
"types": "./dist/*.d.ts",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"src",
|
|
44
44
|
"!src/**/*.test.ts",
|
|
45
45
|
"!src/**/*.spec.ts",
|
|
46
|
+
"!src/**/test-support",
|
|
46
47
|
"tsconfig",
|
|
47
48
|
"CHANGELOG.md",
|
|
48
49
|
"README.md"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ImportEdge, ImportGraph } from "#imports/graph.ts";
|
|
2
|
+
import { isTestCode } from "#naming/testName.ts";
|
|
2
3
|
import type { Finding } from "#rule.ts";
|
|
3
4
|
import { type Compiler, compile, type Matcher } from "./match.ts";
|
|
4
5
|
import type { Fence } from "./model.ts";
|
|
@@ -64,7 +65,7 @@ export function compileFence(compiler: Compiler, fence: Fence): CompiledFence {
|
|
|
64
65
|
const where = `fence "${fence.name}"`;
|
|
65
66
|
const from = compile(compiler, fence.from, `${where}.from`);
|
|
66
67
|
function importer(path: string): boolean {
|
|
67
|
-
return from({ kind: "file", path });
|
|
68
|
+
return !isTestCode(path) && from({ kind: "file", path });
|
|
68
69
|
}
|
|
69
70
|
const prohibition = fence.prohibition;
|
|
70
71
|
if (prohibition.kind === "vocabulary") {
|
package/src/naming/testName.ts
CHANGED
|
@@ -23,3 +23,9 @@ export function testName(path: string): TestName | undefined {
|
|
|
23
23
|
const [stem = "", ...modifiers] = groups.base.split(".");
|
|
24
24
|
return { extension: groups.extension, folder: posix.dirname(path), kind, modifiers, stem };
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
const TEST_SUPPORT = "test-support";
|
|
28
|
+
|
|
29
|
+
export function isTestCode(path: string): boolean {
|
|
30
|
+
return testName(path) !== undefined || posix.dirname(path).split("/").includes(TEST_SUPPORT);
|
|
31
|
+
}
|
|
@@ -21,7 +21,8 @@ export const importFences = defineRule({
|
|
|
21
21
|
const policy = compilePolicy(options.fences, { files: inputs.files, packages: graph.packages });
|
|
22
22
|
return policy.flatMap((compiled) => compiled.evaluate(graph));
|
|
23
23
|
},
|
|
24
|
-
description:
|
|
24
|
+
description:
|
|
25
|
+
"Imports of shipped code respect the fences the repository declares; a test file ships nowhere, so no fence holds it. Move the code to the side of the fence its imports belong to.",
|
|
25
26
|
id: "imports/fences",
|
|
26
27
|
options: Schema.toStandardSchemaV1(FencesOptions, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
|
|
27
28
|
});
|
package/src/rules/max-lines.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import ignore from "ignore";
|
|
3
|
+
import { isTestCode } from "#naming/testName.ts";
|
|
3
4
|
import { defineRule, type Finding, type SourceFile } from "#rule.ts";
|
|
4
5
|
|
|
5
|
-
const DEFAULT_TEST_FILES: readonly string[] = ["*.test.*", "*.spec.*", "test/", "tests/", "__tests__/"];
|
|
6
6
|
const DECLARATION = /\.d\.[cm]?ts$/u;
|
|
7
7
|
|
|
8
8
|
const Limit = Schema.Int.check(Schema.isGreaterThan(0));
|
|
@@ -10,7 +10,7 @@ const Limit = Schema.Int.check(Schema.isGreaterThan(0));
|
|
|
10
10
|
const MaxLinesOptions = Schema.Struct({
|
|
11
11
|
source: Limit.pipe(Schema.withDecodingDefaultKey(Effect.succeed(150))),
|
|
12
12
|
test: Limit.pipe(Schema.withDecodingDefaultKey(Effect.succeed(300))),
|
|
13
|
-
testFiles: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed(
|
|
13
|
+
testFiles: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const oversized = (file: SourceFile, limit: number): readonly Finding[] =>
|
|
@@ -27,10 +27,10 @@ const oversized = (file: SourceFile, limit: number): readonly Finding[] =>
|
|
|
27
27
|
|
|
28
28
|
export const maxLines = defineRule({
|
|
29
29
|
check: ({ options, sources }) => {
|
|
30
|
-
const
|
|
30
|
+
const suites = ignore().add([...options.testFiles]);
|
|
31
31
|
return sources
|
|
32
32
|
.filter((file) => !DECLARATION.test(file.path))
|
|
33
|
-
.flatMap((file) => oversized(file,
|
|
33
|
+
.flatMap((file) => oversized(file, isTestCode(file.path) || suites.ignores(file.path) ? options.test : options.source));
|
|
34
34
|
},
|
|
35
35
|
description: "Keep each module to one job. Split a long file along its responsibilities; never golf it under the limit.",
|
|
36
36
|
id: "structure/max-lines",
|
|
@@ -3,7 +3,7 @@ import { type SourceComment, scanComments } from "#rules/comments/scan.ts";
|
|
|
3
3
|
import { suppressionIn } from "./directives.ts";
|
|
4
4
|
import { STYLESHEET, stylesheetComments } from "./stylesheet-comments.ts";
|
|
5
5
|
|
|
6
|
-
const TYPE_TEST = /(
|
|
6
|
+
const TYPE_TEST = /(?:(?:^|\/)typecheck\.test|\.typecheck\.(?:test|spec))\.[cm]?[jt]sx?$/u;
|
|
7
7
|
|
|
8
8
|
const TYPE_TEST_DIRECTIVE = "@ts-expect-error";
|
|
9
9
|
|
|
@@ -33,7 +33,7 @@ export const noInline = defineRule({
|
|
|
33
33
|
(site) => !allowed(site),
|
|
34
34
|
),
|
|
35
35
|
description:
|
|
36
|
-
"A suppression silences a check at one site instead of fixing the cause. Fix the code; where a lint rule truly cannot apply, turn it off for that scope in the Biome config and declare it under suppressions/biome-overrides. A type test asserts a compile error with @ts-expect-error in a *.typecheck.test.ts file.",
|
|
36
|
+
"A suppression silences a check at one site instead of fixing the cause. Fix the code; where a lint rule truly cannot apply, turn it off for that scope in the Biome config and declare it under suppressions/biome-overrides. A type test asserts a compile error with @ts-expect-error in a *.typecheck.test.ts or *.typecheck.spec.ts file.",
|
|
37
37
|
id: "suppressions/no-inline",
|
|
38
38
|
registrable: false,
|
|
39
39
|
});
|