@shivaedev/quality 0.72.2 → 0.73.1
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 +12 -0
- package/README.md +14 -2
- package/dist/adapters/asciiFindings.d.ts +12 -4
- package/dist/adapters/asciiFindings.d.ts.map +1 -1
- package/dist/adapters/asciiFindings.js +31 -1
- package/dist/adapters/asciiFindings.js.map +1 -1
- package/dist/adapters/databaseUrlFindings.d.ts +5 -0
- package/dist/adapters/databaseUrlFindings.d.ts.map +1 -1
- package/dist/cli/fixAscii.d.ts +6 -0
- package/dist/cli/fixAscii.d.ts.map +1 -0
- package/dist/cli/fixAscii.js +27 -0
- package/dist/cli/fixAscii.js.map +1 -0
- package/dist/cli/fixRule.d.ts.map +1 -1
- package/dist/cli/fixRule.js +20 -14
- package/dist/cli/fixRule.js.map +1 -1
- package/dist/rule.d.ts +5 -0
- package/dist/rule.d.ts.map +1 -1
- package/dist/rule.js.map +1 -1
- package/dist/rules/builtIn.d.ts +1 -3
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/files/ascii.d.ts +2 -3
- package/dist/rules/files/ascii.d.ts.map +1 -1
- package/dist/rules/files/ascii.js +23 -3
- package/dist/rules/files/ascii.js.map +1 -1
- package/package.json +3 -3
- package/src/adapters/asciiFindings.ts +47 -6
- package/src/cli/fixAscii.ts +29 -0
- package/src/cli/fixRule.ts +26 -20
- package/src/rule.ts +1 -0
- package/src/rules/files/ascii.ts +29 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.73.1 - 2026-11-07
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Update `@shivaedev/test-story` from 0.45.3 to 0.45.4.
|
|
8
|
+
|
|
9
|
+
## 0.73.0 - 2026-11-07
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Let `files/ascii` select forbidden Unicode code points and ranges, with optional replacement fixes and custom messages.
|
|
14
|
+
|
|
3
15
|
## 0.72.2 - 2026-11-07
|
|
4
16
|
|
|
5
17
|
### Changed
|
package/README.md
CHANGED
|
@@ -78,16 +78,28 @@ Import `ImportCompiler` from `@shivaedev/quality/adapters/import-compiler/servic
|
|
|
78
78
|
|
|
79
79
|
`manifests/dependency-pins` checks dependencies, development dependencies, optional dependencies and peers in every inventoried package manifest. External dependencies use exact versions, including npm aliases. Workspace dependencies use `workspace:`. Replace `file:` and `link:` dependencies with npm versions or workspace/catalog references in both published and private packages. Quality finds the nearest `pnpm-workspace.yaml` at or above its config folder. When that workspace declares a default or named catalog, external dependencies use `catalog:` or `catalog:<name>`, and the referenced catalog must contain that dependency. Catalog entries themselves use exact versions. Write catalogs as indented block mappings; inline mappings and YAML aliases receive findings instead of escaping the check.
|
|
80
80
|
|
|
81
|
-
`files/ascii` is opt-in by file selection. It checks the bytes of selected text files, including a UTF-8 BOM, and reports each line containing non-ASCII bytes.
|
|
81
|
+
`files/ascii` is opt-in by file selection. It checks the bytes of selected text files, including a UTF-8 BOM, and reports each line containing non-ASCII bytes. Set `forbidden` to check only named Unicode code points or inclusive ranges instead. An entry can replace its character during `quality fix --rule files/ascii`, or give a message for a manual rewrite. Other files are left alone:
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
84
|
export default defineConfig({
|
|
85
85
|
rules: {
|
|
86
|
-
|
|
86
|
+
// Replace curly quotes and ask for a manual rewrite of em dashes.
|
|
87
|
+
"files/ascii": {
|
|
88
|
+
options: {
|
|
89
|
+
files: ["src/game/**/*.ts"],
|
|
90
|
+
forbidden: [
|
|
91
|
+
{ codePoint: 0x201c, replacement: '"' },
|
|
92
|
+
{ codePoint: 0x201d, replacement: '"' },
|
|
93
|
+
{ codePoint: 0x2014, message: "Reword this sentence without an em dash." },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
87
97
|
},
|
|
88
98
|
});
|
|
89
99
|
```
|
|
90
100
|
|
|
101
|
+
An entry may use `range: [0x200B, 0x200B]` in place of `codePoint`. When `forbidden` is absent, the rule retains its strict non-ASCII byte check.
|
|
102
|
+
|
|
91
103
|
`docs/repository-paths` checks paths in backticks in Markdown prose. Explicit `./` and `../` paths resolve from the document; `./` may also name a path from the repository root, as in a command run there. Other paths with a file extension or trailing slash are checked when their first folder belongs to the repository inventory; they may resolve from the repository root or the document’s folder. Prefix an extensionless repository file with `./` or `../` to distinguish it from a rule id or other identifier. Line suffixes and heading fragments are removed before checking existence. Commands, URLs, package specifiers, installed `node_modules` paths, globs, placeholders, fenced examples and released changelogs are left alone. Use a placeholder such as `<app>/src/main.ts` when describing a consumer's example rather than a path in this repository.
|
|
92
104
|
|
|
93
105
|
`docs/agent-links` requires each inventoried `AGENTS.md` to have a `CLAUDE.md` symlink beside it and each inventoried `CLAUDE.md`, including dangling links, to point to an existing sibling `AGENTS.md`. Create a missing link with `ln -s AGENTS.md CLAUDE.md` from that folder, and keep the instructions in `AGENTS.md`.
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { Effect, FileSystem } from "effect";
|
|
2
|
-
import type { RuleContext } from "#rule.ts";
|
|
3
|
-
export
|
|
2
|
+
import type { Finding, RuleContext } from "#rule.ts";
|
|
3
|
+
export interface ForbiddenCharacter {
|
|
4
|
+
readonly codePoint?: number | undefined;
|
|
5
|
+
readonly message?: string | undefined;
|
|
6
|
+
readonly range?: readonly [number, number] | undefined;
|
|
7
|
+
readonly replacement?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface AsciiOptions {
|
|
4
10
|
readonly files: readonly string[];
|
|
5
|
-
|
|
11
|
+
readonly forbidden?: readonly ForbiddenCharacter[] | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare const asciiFindings: (args_0: RuleContext<AsciiOptions>) => Effect.Effect<(Finding | {
|
|
6
14
|
file: string;
|
|
7
15
|
line: number;
|
|
8
16
|
message: string;
|
|
9
|
-
}[], import("effect/PlatformError").PlatformError, FileSystem.FileSystem>;
|
|
17
|
+
})[], import("effect/PlatformError").PlatformError, FileSystem.FileSystem>;
|
|
10
18
|
//# sourceMappingURL=asciiFindings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asciiFindings.d.ts","sourceRoot":"","sources":["../../src/adapters/asciiFindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"asciiFindings.d.ts","sourceRoot":"","sources":["../../src/adapters/asciiFindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,kBAAkB,EAAE,GAAG,SAAS,CAAC;CAC/D;AA8CD,eAAO,MAAM,aAAa;;;;0EAkBxB,CAAC"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { Effect, FileSystem } from "effect";
|
|
3
3
|
import { globMatcher } from "#imports/globMatcher.ts";
|
|
4
|
+
function forbiddenLines(text, forbidden, file) {
|
|
5
|
+
const findings = [];
|
|
6
|
+
let line = 1;
|
|
7
|
+
let offset = 0;
|
|
8
|
+
for (const character of text) {
|
|
9
|
+
const codePoint = character.codePointAt(0);
|
|
10
|
+
if (codePoint === undefined) {
|
|
11
|
+
offset += character.length;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const entry = forbidden.find(({ codePoint: point, range }) => point === codePoint || (range !== undefined && codePoint >= range[0] && codePoint <= range[1]));
|
|
15
|
+
if (entry !== undefined) {
|
|
16
|
+
const label = `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")}`;
|
|
17
|
+
findings.push({
|
|
18
|
+
file,
|
|
19
|
+
fix: entry.replacement === undefined ? undefined : { end: offset + character.length, replacement: entry.replacement, start: offset },
|
|
20
|
+
line,
|
|
21
|
+
message: entry.message ?? `${label} is forbidden.`,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (character === "\n") {
|
|
25
|
+
line += 1;
|
|
26
|
+
}
|
|
27
|
+
offset += character.length;
|
|
28
|
+
}
|
|
29
|
+
return findings;
|
|
30
|
+
}
|
|
4
31
|
function nonAsciiLines(bytes) {
|
|
5
32
|
const lines = new Set();
|
|
6
33
|
let line = 1;
|
|
@@ -14,12 +41,15 @@ function nonAsciiLines(bytes) {
|
|
|
14
41
|
}
|
|
15
42
|
return [...lines];
|
|
16
43
|
}
|
|
17
|
-
export const asciiFindings = Effect.fn("Quality.asciiFindings")(function* ({ files, options, root
|
|
44
|
+
export const asciiFindings = Effect.fn("Quality.asciiFindings")(function* ({ files, options, root }) {
|
|
18
45
|
const fs = yield* FileSystem.FileSystem;
|
|
19
46
|
const patterns = options.files.map(globMatcher);
|
|
20
47
|
const selected = files.filter((file) => patterns.some((matches) => matches(file)));
|
|
21
48
|
const findings = yield* Effect.forEach(selected, (file) => Effect.gen(function* () {
|
|
22
49
|
const bytes = yield* fs.readFile(join(root, file));
|
|
50
|
+
if (options.forbidden !== undefined) {
|
|
51
|
+
return forbiddenLines(new TextDecoder("utf-8", { "ignoreBOM": true }).decode(bytes), options.forbidden, file);
|
|
52
|
+
}
|
|
23
53
|
return nonAsciiLines(bytes).map((line) => ({
|
|
24
54
|
file,
|
|
25
55
|
line,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asciiFindings.js","sourceRoot":"","sources":["../../src/adapters/asciiFindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"asciiFindings.js","sourceRoot":"","sources":["../../src/adapters/asciiFindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAetD,SAAS,cAAc,CAAC,IAAY,EAAE,SAAwC,EAAE,IAAY;IAC3F,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC;YAC3B,SAAS;QACV,CAAC;QACD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAC3B,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,K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
|
@@ -2,6 +2,11 @@ import { Effect } from "effect";
|
|
|
2
2
|
import type { RuleInputs } from "#rule.ts";
|
|
3
3
|
export declare const databaseUrlFindings: (inputs: RuleInputs) => Effect.Effect<{
|
|
4
4
|
count?: number | undefined;
|
|
5
|
+
fix?: {
|
|
6
|
+
readonly end: number;
|
|
7
|
+
readonly replacement: string;
|
|
8
|
+
readonly start: number;
|
|
9
|
+
} | undefined;
|
|
5
10
|
line?: number | undefined;
|
|
6
11
|
message: string;
|
|
7
12
|
subject?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"databaseUrlFindings.d.ts","sourceRoot":"","sources":["../../src/adapters/databaseUrlFindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAM3C,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"databaseUrlFindings.d.ts","sourceRoot":"","sources":["../../src/adapters/databaseUrlFindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAM3C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;uEAU9B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { ResolvedConfig } from "#config/load.ts";
|
|
3
|
+
import { SetupFailure } from "#failure.ts";
|
|
4
|
+
import type { RuleServices } from "#rule.ts";
|
|
5
|
+
export declare const fixAscii: (config: ResolvedConfig) => Effect.Effect<void, SetupFailure, RuleServices>;
|
|
6
|
+
//# sourceMappingURL=fixAscii.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixAscii.d.ts","sourceRoot":"","sources":["../../src/cli/fixAscii.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,QAAQ,6EAoBnB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
|
+
import { scan } from "#engine/session.ts";
|
|
4
|
+
import { SetupFailure } from "#failure.ts";
|
|
5
|
+
import { plural } from "#report/plural.ts";
|
|
6
|
+
export const fixAscii = Effect.fn("Cli.fixAscii")(function* (config) {
|
|
7
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
8
|
+
const rules = config.active.filter((rule) => rule.id === "files/ascii");
|
|
9
|
+
const findings = (yield* scan({ ...config, active: rules })).violations;
|
|
10
|
+
const fixes = findings.flatMap((finding) => (finding.fix === undefined ? [] : [{ file: finding.file, ...finding.fix }]));
|
|
11
|
+
const fs = yield* FileSystem.FileSystem;
|
|
12
|
+
let changed = 0;
|
|
13
|
+
for (const file of new Set(fixes.map((fix) => fix.file))) {
|
|
14
|
+
const fileFixes = fixes.filter((fix) => fix.file === file);
|
|
15
|
+
const bytes = yield* fs.readFile(join(config.root, file)).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
16
|
+
const original = new TextDecoder("utf-8", { "ignoreBOM": true }).decode(bytes);
|
|
17
|
+
const text = fileFixes
|
|
18
|
+
.sort((left, right) => right.start - left.start)
|
|
19
|
+
.reduce((current, fix) => `${current.slice(0, fix.start)}${fix.replacement}${current.slice(fix.end)}`, original);
|
|
20
|
+
if (text !== original) {
|
|
21
|
+
yield* fs.writeFileString(join(config.root, file), text).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
22
|
+
changed += 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
yield* Console.log(`quality: files/ascii rewrote ${plural(changed, "file")}.`);
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=fixAscii.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixAscii.js","sourceRoot":"","sources":["../../src/cli/fixAscii.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAsB;IAClF,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,aAAa,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;IACxE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,E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AC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAClH,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvB,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/I,OAAO,IAAI,CAAC,CAAC;QACd,CAAC;IACF,CAAC;IACD,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;AAChF,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixRule.d.ts","sourceRoot":"","sources":["../../src/cli/fixRule.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,MAAM,EAAoB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"fixRule.d.ts","sourceRoot":"","sources":["../../src/cli/fixRule.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAK3D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,UAAU,CAAC;AAmBzD,eAAO,MAAM,OAAO,yIA4BlB,CAAC"}
|
package/dist/cli/fixRule.js
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
1
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
2
|
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { fixJsxConditionals } from "#adapters/fixJsxConditionals.ts";
|
|
4
|
+
import { fixAscii } from "#cli/fixAscii.ts";
|
|
4
5
|
import { loadConfig } from "#config/load.ts";
|
|
5
6
|
import { scan } from "#engine/session.ts";
|
|
6
7
|
import { GateFailed, SetupFailure } from "#failure.ts";
|
|
7
8
|
import { collectInventory } from "#inventory/collect.ts";
|
|
8
9
|
import { plural } from "#report/plural.ts";
|
|
9
10
|
const GROUPED = "Consecutive assertions stop on the first failure; outcomes constructs rows eagerly, then lazily invokes each readout callback in row order before the grouped assertion. Rewrite these stories by hand to review that change in evaluation and failure order.";
|
|
10
|
-
|
|
11
|
+
const rewriteJsx = Effect.fn("Cli.rewriteJsx")(function* (root, files) {
|
|
11
12
|
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
12
|
-
const config = yield* loadConfig(cwd, configPath);
|
|
13
|
-
for (const rule of rules) {
|
|
14
|
-
if (rule !== "react/jsx-conditionals") {
|
|
15
|
-
return yield* new SetupFailure({
|
|
16
|
-
message: `No safe mechanical fix for ${rule}.${rule === "tests/grouped-outcomes" ? ` ${GROUPED}` : " Repair its findings by hand."}`,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
13
|
const fs = yield* FileSystem.FileSystem;
|
|
21
|
-
const inventory = yield* collectInventory(config.root, config).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
22
14
|
let changed = 0;
|
|
23
|
-
for (const file of
|
|
15
|
+
for (const file of files) {
|
|
24
16
|
const text = fixJsxConditionals(file);
|
|
25
17
|
if (text !== file.text) {
|
|
26
|
-
yield* fs
|
|
27
|
-
.writeFileString(join(config.root, file.path), text)
|
|
28
|
-
.pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
18
|
+
yield* fs.writeFileString(join(root, file.path), text).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
29
19
|
changed += 1;
|
|
30
20
|
}
|
|
31
21
|
}
|
|
32
22
|
yield* Console.log(`quality: react/jsx-conditionals rewrote ${plural(changed, "file")}.`);
|
|
23
|
+
});
|
|
24
|
+
export const fixRule = Effect.fn("Cli.fixRule")(function* (cwd, configPath, rules) {
|
|
25
|
+
const config = yield* loadConfig(cwd, configPath);
|
|
26
|
+
const unsupported = rules.find((rule) => rule !== "react/jsx-conditionals" && rule !== "files/ascii");
|
|
27
|
+
if (unsupported !== undefined) {
|
|
28
|
+
return yield* new SetupFailure({
|
|
29
|
+
message: `No safe mechanical fix for ${unsupported}.${unsupported === "tests/grouped-outcomes" ? ` ${GROUPED}` : " Repair its findings by hand."}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const inventory = yield* collectInventory(config.root, config).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
33
|
+
if (rules.includes("react/jsx-conditionals")) {
|
|
34
|
+
yield* rewriteJsx(config.root, inventory.sources);
|
|
35
|
+
}
|
|
36
|
+
if (rules.includes("files/ascii")) {
|
|
37
|
+
yield* fixAscii(config);
|
|
38
|
+
}
|
|
33
39
|
const remaining = (yield* scan({ ...config, active: config.active.filter((rule) => rules.includes(rule.id)) })).violations;
|
|
34
40
|
for (const finding of remaining) {
|
|
35
41
|
yield* Console.log(`${finding.file}:${finding.line ?? 1} ${finding.rule}: ${finding.message}`);
|
package/dist/cli/fixRule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixRule.js","sourceRoot":"","sources":["../../src/cli/fixRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE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
|
export interface Finding {
|
|
7
7
|
readonly count?: number | undefined;
|
|
8
8
|
readonly file: string;
|
|
9
|
+
readonly fix?: {
|
|
10
|
+
readonly end: number;
|
|
11
|
+
readonly replacement: string;
|
|
12
|
+
readonly start: number;
|
|
13
|
+
} | undefined;
|
|
9
14
|
readonly line?: number | undefined;
|
|
10
15
|
readonly message: string;
|
|
11
16
|
readonly subject?: string | undefined;
|
package/dist/rule.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAA4B,KAAK,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,OAAO,EAAE,CAAC;AAE1C,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC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KAAK,EACrE,UAAU,EAAE,4BAA4B,CAAC,GAAG,EAAE,SAAS,CAAC,GACtD,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC"}
|
package/dist/rule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAwB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAwB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAgFtG,MAAM,UAAU,UAAU,CACzB,UAAsH;IAEtH,MAAM,SAAS,GACd,UAAU,CAAC,OAAO,KAAK,SAAS;QAC/B,CAAC,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC;QAC3F,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAChG,OAAO;QACN,CAAC,iBAAiB,CAAC,EAAE,SAAS;QAC9B,SAAS;QACT,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,IAAI;KAC3C,CAAC;AACH,CAAC"}
|
package/dist/rules/builtIn.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export declare const builtInRules: readonly [import("../rule.ts").Rule<"effect/adapter-imports", undefined, never>, import("../rule.ts").Rule<"effect/boundary", undefined, never>, import("../rule.ts").Rule<"effect/context-capture", undefined, never>, import("../rule.ts").Rule<"effect/failure-honesty", undefined, never>, import("../rule.ts").Rule<"effect/rpc-boundary", undefined, never>, import("../rule.ts").Rule<"effect/service-definition-assembly", undefined, never>, import("../rule.ts").Rule<"effect/service-folders", undefined, never>, import("../rule.ts").Rule<"effect/service-ids", undefined, never>, import("../rule.ts").Rule<"effect/service-model", undefined, never>, import("../rule.ts").Rule<"effect/service-parameters", undefined, never>, import("../rule.ts").Rule<"effect/shared-error-classes", undefined, never>, import("../rule.ts").Rule<"effect/sql-transact", undefined, never>, import("../rule.ts").Rule<"docs/agent-links", undefined, import("effect/FileSystem").FileSystem>, import("../rule.ts").Rule<"docs/repository-paths", undefined, import("effect/FileSystem").FileSystem>, import("../rule.ts").Rule<"files/ascii", {
|
|
2
|
-
readonly files?: readonly string[];
|
|
3
|
-
}, import("effect/FileSystem").FileSystem>, import("../rule.ts").Rule<"manifests/dependency-pins", undefined, never>, import("../rule.ts").Rule<"code/unused", undefined, import("../rule.ts").RuleServices>, import("../rule.ts").Rule<"react/jsx-conditionals", undefined, never>, import("../rule.ts").Rule<"structure/max-lines", {
|
|
1
|
+
export declare const builtInRules: readonly [import("../rule.ts").Rule<"effect/adapter-imports", undefined, never>, import("../rule.ts").Rule<"effect/boundary", undefined, never>, import("../rule.ts").Rule<"effect/context-capture", undefined, never>, import("../rule.ts").Rule<"effect/failure-honesty", undefined, never>, import("../rule.ts").Rule<"effect/rpc-boundary", undefined, never>, import("../rule.ts").Rule<"effect/service-definition-assembly", undefined, never>, import("../rule.ts").Rule<"effect/service-folders", undefined, never>, import("../rule.ts").Rule<"effect/service-ids", undefined, never>, import("../rule.ts").Rule<"effect/service-model", undefined, never>, import("../rule.ts").Rule<"effect/service-parameters", undefined, never>, import("../rule.ts").Rule<"effect/shared-error-classes", undefined, never>, import("../rule.ts").Rule<"effect/sql-transact", undefined, never>, import("../rule.ts").Rule<"docs/agent-links", undefined, import("effect/FileSystem").FileSystem>, import("../rule.ts").Rule<"docs/repository-paths", undefined, import("effect/FileSystem").FileSystem>, import("../rule.ts").Rule<"files/ascii", unknown, import("effect/FileSystem").FileSystem>, import("../rule.ts").Rule<"manifests/dependency-pins", undefined, never>, import("../rule.ts").Rule<"code/unused", undefined, import("../rule.ts").RuleServices>, import("../rule.ts").Rule<"react/jsx-conditionals", undefined, never>, import("../rule.ts").Rule<"structure/max-lines", {
|
|
4
2
|
readonly source?: number;
|
|
5
3
|
readonly test?: number;
|
|
6
4
|
}, never>, import("../rule.ts").Rule<"nesting/max-depth", undefined, never>, import("../rule.ts").Rule<"structure/no-barrel", undefined, never>, import("../rule.ts").Rule<"comments/no-jsdoc", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/rules/builtIn.ts"],"names":[],"mappings":"AAiEA,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/rules/builtIn.ts"],"names":[],"mappings":"AAiEA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8aAiEf,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}, import("effect/FileSystem").FileSystem>;
|
|
1
|
+
import { type FileSystem } from "effect";
|
|
2
|
+
export declare const ascii: import("#rule.ts").Rule<"files/ascii", unknown, FileSystem.FileSystem>;
|
|
4
3
|
//# sourceMappingURL=ascii.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ascii.d.ts","sourceRoot":"","sources":["../../../src/rules/files/ascii.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ascii.d.ts","sourceRoot":"","sources":["../../../src/rules/files/ascii.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,UAAU,EAAU,MAAM,QAAQ,CAAC;AAkBzD,eAAO,MAAM,KAAK,wEAmBhB,CAAC"}
|
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { asciiFindings } from "#adapters/asciiFindings.ts";
|
|
3
3
|
import { defineRule } from "#rule.ts";
|
|
4
|
-
const
|
|
4
|
+
const ForbiddenCharacter = Schema.Struct({
|
|
5
|
+
codePoint: Schema.optional(Schema.Number),
|
|
6
|
+
message: Schema.optional(Schema.String),
|
|
7
|
+
range: Schema.optional(Schema.Tuple([Schema.Number, Schema.Number])),
|
|
8
|
+
replacement: Schema.optional(Schema.String),
|
|
9
|
+
});
|
|
10
|
+
const AsciiOptionsSchema = Schema.Struct({
|
|
5
11
|
files: Schema.Array(Schema.NonEmptyString).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
|
|
12
|
+
forbidden: Schema.optional(Schema.Array(ForbiddenCharacter)),
|
|
6
13
|
});
|
|
7
14
|
export const ascii = defineRule({
|
|
8
15
|
check: asciiFindings,
|
|
9
|
-
description: "Chosen text files contain only ASCII characters. No files are selected by default.",
|
|
16
|
+
description: "Chosen text files contain only ASCII characters or avoid the configured forbidden characters. No files are selected by default.",
|
|
10
17
|
id: "files/ascii",
|
|
11
|
-
options: Schema.toStandardSchemaV1(
|
|
18
|
+
options: Schema.toStandardSchemaV1(AsciiOptionsSchema, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
|
|
19
|
+
validate: ({ options }) => (options.forbidden ?? []).flatMap((entry, index) => {
|
|
20
|
+
const path = `forbidden[${index}]`;
|
|
21
|
+
const hasCodePoint = entry.codePoint !== undefined;
|
|
22
|
+
const hasRange = entry.range !== undefined;
|
|
23
|
+
const points = entry.range ?? (hasCodePoint ? [entry.codePoint, entry.codePoint] : undefined);
|
|
24
|
+
return [
|
|
25
|
+
...(hasCodePoint === hasRange ? [`${path} must name exactly one codePoint or range`] : []),
|
|
26
|
+
...(points !== undefined && (points.some((point) => !Number.isInteger(point) || point < 0 || point > 0x10_ff_ff) || points[0] > points[1])
|
|
27
|
+
? [`${path} must contain valid Unicode code points in ascending order`]
|
|
28
|
+
: []),
|
|
29
|
+
...(entry.message !== undefined && entry.replacement !== undefined ? [`${path} cannot have both message and replacement`] : []),
|
|
30
|
+
];
|
|
31
|
+
}),
|
|
12
32
|
});
|
|
13
33
|
//# sourceMappingURL=ascii.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ascii.js","sourceRoot":"","sources":["../../../src/rules/files/ascii.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ascii.js","sourceRoot":"","sources":["../../../src/rules/files/ascii.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACpE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CAC3C,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAA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AAC,CAAC,CAAC,GAAG,IAAI,4DAA4D,CAAC;gBACvE,CAAC,CAAC,EAAE,CAAC;YACN,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,2CAA2C,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/H,CAAC;IACH,CAAC,CAAC;CACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/quality",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.1",
|
|
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": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@effect/platform-node": "4.1.1",
|
|
69
69
|
"@effect/platform-node-shared": "4.1.1",
|
|
70
70
|
"@effect/vitest": "4.1.1",
|
|
71
|
-
"@shivaedev/test-story": "0.45.
|
|
71
|
+
"@shivaedev/test-story": "0.45.4",
|
|
72
72
|
"@types/node": "24.19.2",
|
|
73
73
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
74
74
|
"effect": "4.1.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@effect/platform-node": "4.1.1",
|
|
79
79
|
"@effect/platform-node-shared": "4.1.1",
|
|
80
|
-
"@shivaedev/test-story": "0.45.
|
|
80
|
+
"@shivaedev/test-story": "0.45.4",
|
|
81
81
|
"effect": "4.1.1",
|
|
82
82
|
"vitest": "5.0.5"
|
|
83
83
|
},
|
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { Effect, FileSystem } from "effect";
|
|
3
3
|
import { globMatcher } from "#imports/globMatcher.ts";
|
|
4
|
-
import type { RuleContext } from "#rule.ts";
|
|
4
|
+
import type { Finding, RuleContext } from "#rule.ts";
|
|
5
|
+
|
|
6
|
+
export interface ForbiddenCharacter {
|
|
7
|
+
readonly codePoint?: number | undefined;
|
|
8
|
+
readonly message?: string | undefined;
|
|
9
|
+
readonly range?: readonly [number, number] | undefined;
|
|
10
|
+
readonly replacement?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AsciiOptions {
|
|
14
|
+
readonly files: readonly string[];
|
|
15
|
+
readonly forbidden?: readonly ForbiddenCharacter[] | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function forbiddenLines(text: string, forbidden: readonly ForbiddenCharacter[], file: string) {
|
|
19
|
+
const findings: Finding[] = [];
|
|
20
|
+
let line = 1;
|
|
21
|
+
let offset = 0;
|
|
22
|
+
for (const character of text) {
|
|
23
|
+
const codePoint = character.codePointAt(0);
|
|
24
|
+
if (codePoint === undefined) {
|
|
25
|
+
offset += character.length;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const entry = forbidden.find(
|
|
29
|
+
({ codePoint: point, range }) => point === codePoint || (range !== undefined && codePoint >= range[0] && codePoint <= range[1]),
|
|
30
|
+
);
|
|
31
|
+
if (entry !== undefined) {
|
|
32
|
+
const label = `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")}`;
|
|
33
|
+
findings.push({
|
|
34
|
+
file,
|
|
35
|
+
fix: entry.replacement === undefined ? undefined : { end: offset + character.length, replacement: entry.replacement, start: offset },
|
|
36
|
+
line,
|
|
37
|
+
message: entry.message ?? `${label} is forbidden.`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (character === "\n") {
|
|
41
|
+
line += 1;
|
|
42
|
+
}
|
|
43
|
+
offset += character.length;
|
|
44
|
+
}
|
|
45
|
+
return findings;
|
|
46
|
+
}
|
|
5
47
|
|
|
6
48
|
function nonAsciiLines(bytes: Uint8Array): readonly number[] {
|
|
7
49
|
const lines = new Set<number>();
|
|
@@ -17,17 +59,16 @@ function nonAsciiLines(bytes: Uint8Array): readonly number[] {
|
|
|
17
59
|
return [...lines];
|
|
18
60
|
}
|
|
19
61
|
|
|
20
|
-
export const asciiFindings = Effect.fn("Quality.asciiFindings")(function* ({
|
|
21
|
-
files,
|
|
22
|
-
options,
|
|
23
|
-
root,
|
|
24
|
-
}: RuleContext<{ readonly files: readonly string[] }>) {
|
|
62
|
+
export const asciiFindings = Effect.fn("Quality.asciiFindings")(function* ({ files, options, root }: RuleContext<AsciiOptions>) {
|
|
25
63
|
const fs = yield* FileSystem.FileSystem;
|
|
26
64
|
const patterns = options.files.map(globMatcher);
|
|
27
65
|
const selected = files.filter((file) => patterns.some((matches) => matches(file)));
|
|
28
66
|
const findings = yield* Effect.forEach(selected, (file) =>
|
|
29
67
|
Effect.gen(function* () {
|
|
30
68
|
const bytes = yield* fs.readFile(join(root, file));
|
|
69
|
+
if (options.forbidden !== undefined) {
|
|
70
|
+
return forbiddenLines(new TextDecoder("utf-8", { "ignoreBOM": true }).decode(bytes), options.forbidden, file);
|
|
71
|
+
}
|
|
31
72
|
return nonAsciiLines(bytes).map((line) => ({
|
|
32
73
|
file,
|
|
33
74
|
line,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
|
+
import type { ResolvedConfig } from "#config/load.ts";
|
|
4
|
+
import { scan } from "#engine/session.ts";
|
|
5
|
+
import { SetupFailure } from "#failure.ts";
|
|
6
|
+
import { plural } from "#report/plural.ts";
|
|
7
|
+
import type { RuleServices } from "#rule.ts";
|
|
8
|
+
|
|
9
|
+
export const fixAscii = Effect.fn("Cli.fixAscii")(function* (config: ResolvedConfig): Effect.fn.Return<void, SetupFailure, RuleServices> {
|
|
10
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
11
|
+
const rules = config.active.filter((rule) => rule.id === "files/ascii");
|
|
12
|
+
const findings = (yield* scan({ ...config, active: rules })).violations;
|
|
13
|
+
const fixes = findings.flatMap((finding) => (finding.fix === undefined ? [] : [{ file: finding.file, ...finding.fix }]));
|
|
14
|
+
const fs = yield* FileSystem.FileSystem;
|
|
15
|
+
let changed = 0;
|
|
16
|
+
for (const file of new Set(fixes.map((fix) => fix.file))) {
|
|
17
|
+
const fileFixes = fixes.filter((fix) => fix.file === file);
|
|
18
|
+
const bytes = yield* fs.readFile(join(config.root, file)).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
19
|
+
const original = new TextDecoder("utf-8", { "ignoreBOM": true }).decode(bytes);
|
|
20
|
+
const text = fileFixes
|
|
21
|
+
.sort((left, right) => right.start - left.start)
|
|
22
|
+
.reduce((current, fix) => `${current.slice(0, fix.start)}${fix.replacement}${current.slice(fix.end)}`, original);
|
|
23
|
+
if (text !== original) {
|
|
24
|
+
yield* fs.writeFileString(join(config.root, file), text).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
25
|
+
changed += 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
yield* Console.log(`quality: files/ascii rewrote ${plural(changed, "file")}.`);
|
|
29
|
+
});
|
package/src/cli/fixRule.ts
CHANGED
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
2
|
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
3
|
import { fixJsxConditionals } from "#adapters/fixJsxConditionals.ts";
|
|
4
|
+
import { fixAscii } from "#cli/fixAscii.ts";
|
|
4
5
|
import { loadConfig } from "#config/load.ts";
|
|
5
6
|
import { scan } from "#engine/session.ts";
|
|
6
7
|
import { GateFailed, SetupFailure } from "#failure.ts";
|
|
7
8
|
import { collectInventory } from "#inventory/collect.ts";
|
|
8
9
|
import { plural } from "#report/plural.ts";
|
|
9
|
-
import type { RuleServices } from "#rule.ts";
|
|
10
|
+
import type { RuleServices, SourceFile } from "#rule.ts";
|
|
10
11
|
|
|
11
12
|
const GROUPED =
|
|
12
13
|
"Consecutive assertions stop on the first failure; outcomes constructs rows eagerly, then lazily invokes each readout callback in row order before the grouped assertion. Rewrite these stories by hand to review that change in evaluation and failure order.";
|
|
13
14
|
|
|
15
|
+
const rewriteJsx = Effect.fn("Cli.rewriteJsx")(function* (root: string, files: readonly SourceFile[]) {
|
|
16
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
17
|
+
const fs = yield* FileSystem.FileSystem;
|
|
18
|
+
let changed = 0;
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const text = fixJsxConditionals(file);
|
|
21
|
+
if (text !== file.text) {
|
|
22
|
+
yield* fs.writeFileString(join(root, file.path), text).pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
23
|
+
changed += 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
yield* Console.log(`quality: react/jsx-conditionals rewrote ${plural(changed, "file")}.`);
|
|
27
|
+
});
|
|
28
|
+
|
|
14
29
|
export const fixRule = Effect.fn("Cli.fixRule")(function* (
|
|
15
30
|
cwd: string,
|
|
16
31
|
configPath: string | undefined,
|
|
17
32
|
rules: readonly string[],
|
|
18
33
|
): Effect.fn.Return<void, SetupFailure | GateFailed, RuleServices> {
|
|
19
|
-
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
20
|
-
|
|
21
34
|
const config = yield* loadConfig(cwd, configPath);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
35
|
+
const unsupported = rules.find((rule) => rule !== "react/jsx-conditionals" && rule !== "files/ascii");
|
|
36
|
+
if (unsupported !== undefined) {
|
|
37
|
+
return yield* new SetupFailure({
|
|
38
|
+
message: `No safe mechanical fix for ${unsupported}.${unsupported === "tests/grouped-outcomes" ? ` ${GROUPED}` : " Repair its findings by hand."}`,
|
|
39
|
+
});
|
|
28
40
|
}
|
|
29
|
-
const fs = yield* FileSystem.FileSystem;
|
|
30
41
|
const inventory = yield* collectInventory(config.root, config).pipe(
|
|
31
42
|
Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })),
|
|
32
43
|
);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.writeFileString(join(config.root, file.path), text)
|
|
39
|
-
.pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: cause.message })));
|
|
40
|
-
changed += 1;
|
|
41
|
-
}
|
|
44
|
+
if (rules.includes("react/jsx-conditionals")) {
|
|
45
|
+
yield* rewriteJsx(config.root, inventory.sources);
|
|
46
|
+
}
|
|
47
|
+
if (rules.includes("files/ascii")) {
|
|
48
|
+
yield* fixAscii(config);
|
|
42
49
|
}
|
|
43
|
-
yield* Console.log(`quality: react/jsx-conditionals rewrote ${plural(changed, "file")}.`);
|
|
44
50
|
const remaining = (yield* scan({ ...config, active: config.active.filter((rule) => rules.includes(rule.id)) })).violations;
|
|
45
51
|
for (const finding of remaining) {
|
|
46
52
|
yield* Console.log(`${finding.file}:${finding.line ?? 1} ${finding.rule}: ${finding.message}`);
|
package/src/rule.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
|
7
7
|
export interface Finding {
|
|
8
8
|
readonly count?: number | undefined;
|
|
9
9
|
readonly file: string;
|
|
10
|
+
readonly fix?: { readonly end: number; readonly replacement: string; readonly start: number } | undefined;
|
|
10
11
|
readonly line?: number | undefined;
|
|
11
12
|
readonly message: string;
|
|
12
13
|
readonly subject?: string | undefined;
|
package/src/rules/files/ascii.ts
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
1
|
+
import { Effect, type FileSystem, Schema } from "effect";
|
|
2
2
|
import { asciiFindings } from "#adapters/asciiFindings.ts";
|
|
3
3
|
import { defineRule } from "#rule.ts";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const ForbiddenCharacter = Schema.Struct({
|
|
6
|
+
codePoint: Schema.optional(Schema.Number),
|
|
7
|
+
message: Schema.optional(Schema.String),
|
|
8
|
+
range: Schema.optional(Schema.Tuple([Schema.Number, Schema.Number])),
|
|
9
|
+
replacement: Schema.optional(Schema.String),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const AsciiOptionsSchema = Schema.Struct({
|
|
6
13
|
files: Schema.Array(Schema.NonEmptyString).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
|
|
14
|
+
forbidden: Schema.optional(Schema.Array(ForbiddenCharacter)),
|
|
7
15
|
});
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
type AsciiOptionsValue = Schema.Schema.Type<typeof AsciiOptionsSchema>;
|
|
18
|
+
|
|
19
|
+
export const ascii = defineRule<"files/ascii", unknown, AsciiOptionsValue, FileSystem.FileSystem>({
|
|
10
20
|
check: asciiFindings,
|
|
11
|
-
description: "Chosen text files contain only ASCII characters. No files are selected by default.",
|
|
21
|
+
description: "Chosen text files contain only ASCII characters or avoid the configured forbidden characters. No files are selected by default.",
|
|
12
22
|
id: "files/ascii",
|
|
13
|
-
options: Schema.toStandardSchemaV1(
|
|
23
|
+
options: Schema.toStandardSchemaV1(AsciiOptionsSchema, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
|
|
24
|
+
validate: ({ options }) =>
|
|
25
|
+
(options.forbidden ?? []).flatMap((entry, index) => {
|
|
26
|
+
const path = `forbidden[${index}]`;
|
|
27
|
+
const hasCodePoint = entry.codePoint !== undefined;
|
|
28
|
+
const hasRange = entry.range !== undefined;
|
|
29
|
+
const points = entry.range ?? (hasCodePoint ? [entry.codePoint, entry.codePoint] : undefined);
|
|
30
|
+
return [
|
|
31
|
+
...(hasCodePoint === hasRange ? [`${path} must name exactly one codePoint or range`] : []),
|
|
32
|
+
...(points !== undefined && (points.some((point) => !Number.isInteger(point) || point < 0 || point > 0x10_ff_ff) || points[0] > points[1])
|
|
33
|
+
? [`${path} must contain valid Unicode code points in ascending order`]
|
|
34
|
+
: []),
|
|
35
|
+
...(entry.message !== undefined && entry.replacement !== undefined ? [`${path} cannot have both message and replacement`] : []),
|
|
36
|
+
];
|
|
37
|
+
}),
|
|
14
38
|
});
|