@venizia/dev-configs 0.4.7-0 → 0.4.7-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/LICENSE.md +1 -3
- package/README.md +1 -1
- package/dist/checks/catalog.d.ts +4 -2
- package/dist/checks/catalog.d.ts.map +1 -1
- package/dist/checks/catalog.js +72 -70
- package/dist/checks/catalog.js.map +1 -1
- package/dist/checks/module-cycles.d.ts +11 -9
- package/dist/checks/module-cycles.d.ts.map +1 -1
- package/dist/checks/module-cycles.js +32 -30
- package/dist/checks/module-cycles.js.map +1 -1
- package/dist/checks/purity/manifest.d.ts +44 -38
- package/dist/checks/purity/manifest.d.ts.map +1 -1
- package/dist/checks/purity/manifest.js +121 -115
- package/dist/checks/purity/manifest.js.map +1 -1
- package/dist/checks/purity/probe.d.ts +22 -18
- package/dist/checks/purity/probe.d.ts.map +1 -1
- package/dist/checks/purity/probe.js +99 -98
- package/dist/checks/purity/probe.js.map +1 -1
- package/dist/checks/purity/run.d.ts +18 -16
- package/dist/checks/purity/run.d.ts.map +1 -1
- package/dist/checks/purity/run.js +90 -86
- package/dist/checks/purity/run.js.map +1 -1
- package/dist/checks/test-controls.d.ts +17 -15
- package/dist/checks/test-controls.d.ts.map +1 -1
- package/dist/checks/test-controls.js +71 -70
- package/dist/checks/test-controls.js.map +1 -1
- package/dist/checks/test-dead-code.d.ts +5 -3
- package/dist/checks/test-dead-code.d.ts.map +1 -1
- package/dist/checks/test-dead-code.js +23 -21
- package/dist/checks/test-dead-code.js.map +1 -1
- package/dist/checks/test-mutate.d.ts +12 -7
- package/dist/checks/test-mutate.d.ts.map +1 -1
- package/dist/checks/test-mutate.js +59 -56
- package/dist/checks/test-mutate.js.map +1 -1
- package/dist/checks/test-weight.d.ts +11 -8
- package/dist/checks/test-weight.d.ts.map +1 -1
- package/dist/checks/test-weight.js +98 -94
- package/dist/checks/test-weight.js.map +1 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +11 -8
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/codemod/async-style.d.ts +29 -8
- package/dist/cli/codemod/async-style.d.ts.map +1 -1
- package/dist/cli/codemod/async-style.js +102 -20
- package/dist/cli/codemod/async-style.js.map +1 -1
- package/dist/cli/codemod/index.d.ts.map +1 -1
- package/dist/cli/codemod/index.js +6 -2
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/model-settings.d.ts +7 -5
- package/dist/cli/codemod/model-settings.d.ts.map +1 -1
- package/dist/cli/codemod/model-settings.js +293 -291
- package/dist/cli/codemod/model-settings.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/index.d.ts +20 -0
- package/dist/cli/codemod/namespace-functions/index.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/index.js +182 -0
- package/dist/cli/codemod/namespace-functions/index.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.d.ts +32 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.js +128 -0
- package/dist/cli/codemod/namespace-functions/logger-scope.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mapping.d.ts +66 -0
- package/dist/cli/codemod/namespace-functions/mapping.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mapping.js +99 -0
- package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.js +28 -0
- package/dist/cli/codemod/namespace-functions/mappings/boot.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts +4 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js +218 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.js +162 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-server.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.js +18 -0
- package/dist/cli/codemod/namespace-functions/mappings/core-worker.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js +192 -0
- package/dist/cli/codemod/namespace-functions/mappings/dev-configs.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.js +30 -0
- package/dist/cli/codemod/namespace-functions/mappings/filter.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +16 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js +535 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.d.ts +4 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.js +25 -0
- package/dist/cli/codemod/namespace-functions/mappings/index.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts +10 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js +81 -0
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts +17 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js +229 -0
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts +61 -0
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts.map +1 -0
- package/dist/cli/codemod/namespace-functions/rewriter.js +564 -0
- package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -0
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/compilers/bun.d.ts +1 -1
- package/dist/compilers/bun.js +1 -1
- package/dist/compilers/bun.js.map +1 -1
- package/dist/linters/house/await-support.d.ts +17 -3
- package/dist/linters/house/await-support.d.ts.map +1 -1
- package/dist/linters/house/await-support.js +52 -23
- package/dist/linters/house/await-support.js.map +1 -1
- package/dist/linters/house/common.d.ts +13 -9
- package/dist/linters/house/common.d.ts.map +1 -1
- package/dist/linters/house/common.js +18 -15
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/configs.d.ts +5 -2
- package/dist/linters/house/configs.d.ts.map +1 -1
- package/dist/linters/house/configs.js +11 -2
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.d.ts.map +1 -1
- package/dist/linters/house/const-class-values.rule.js +27 -19
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.js +3 -3
- package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
- package/dist/linters/house/hook-support.d.ts.map +1 -1
- package/dist/linters/house/hook-support.js +17 -14
- package/dist/linters/house/hook-support.js.map +1 -1
- package/dist/linters/house/index.d.ts +3 -0
- package/dist/linters/house/index.d.ts.map +1 -1
- package/dist/linters/house/index.js +3 -0
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/max-params-own.rule.d.ts.map +1 -1
- package/dist/linters/house/max-params-own.rule.js +33 -24
- package/dist/linters/house/max-params-own.rule.js.map +1 -1
- package/dist/linters/house/no-async-hook-callback.rule.js +1 -1
- package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
- package/dist/linters/house/no-await-promise-chain.rule.d.ts +24 -0
- package/dist/linters/house/no-await-promise-chain.rule.d.ts.map +1 -0
- package/dist/linters/house/no-await-promise-chain.rule.js +298 -0
- package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -0
- package/dist/linters/house/no-inline-await.rule.d.ts.map +1 -1
- package/dist/linters/house/no-inline-await.rule.js +6 -12
- package/dist/linters/house/no-inline-await.rule.js.map +1 -1
- package/dist/linters/house/no-new-error.rule.js +4 -4
- package/dist/linters/house/no-new-error.rule.js.map +1 -1
- package/dist/linters/house/no-return-await.rule.d.ts.map +1 -1
- package/dist/linters/house/no-return-await.rule.js +11 -11
- package/dist/linters/house/no-return-await.rule.js.map +1 -1
- package/dist/linters/house/no-silent-catch.rule.d.ts +22 -0
- package/dist/linters/house/no-silent-catch.rule.d.ts.map +1 -0
- package/dist/linters/house/no-silent-catch.rule.js +88 -0
- package/dist/linters/house/no-silent-catch.rule.js.map +1 -0
- package/dist/linters/house/plugin.d.ts.map +1 -1
- package/dist/linters/house/plugin.js +4 -0
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/promise-chain-support.d.ts +49 -0
- package/dist/linters/house/promise-chain-support.d.ts.map +1 -0
- package/dist/linters/house/promise-chain-support.js +188 -0
- package/dist/linters/house/promise-chain-support.js.map +1 -0
- package/dist/linters/rules/no-restricted-properties.rule.js +1 -1
- package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
- package/dist/testing/rejection.helper.d.ts +25 -20
- package/dist/testing/rejection.helper.d.ts.map +1 -1
- package/dist/testing/rejection.helper.js +33 -31
- package/dist/testing/rejection.helper.js.map +1 -1
- package/dist/testing/repo-tmp.d.ts +19 -9
- package/dist/testing/repo-tmp.d.ts.map +1 -1
- package/dist/testing/repo-tmp.js +50 -48
- package/dist/testing/repo-tmp.js.map +1 -1
- package/dist/testing/spawn.helper.d.ts +12 -10
- package/dist/testing/spawn.helper.d.ts.map +1 -1
- package/dist/testing/spawn.helper.js +22 -16
- package/dist/testing/spawn.helper.js.map +1 -1
- package/dist/testing/tmpdir-preload.js +1 -1
- package/dist/testing/tmpdir-preload.js.map +1 -1
- package/package.json +2 -3
|
@@ -9,30 +9,51 @@ export interface IAsyncStyleReport {
|
|
|
9
9
|
export interface IAsyncStyleResult {
|
|
10
10
|
output: string;
|
|
11
11
|
changed: boolean;
|
|
12
|
-
/** How many findings the fixers
|
|
12
|
+
/** How many findings of the original source carried a fix, once the fixers changed it. */
|
|
13
13
|
fixes: number;
|
|
14
14
|
/** What is still reported after every pass. */
|
|
15
15
|
reports: IAsyncStyleReport[];
|
|
16
16
|
}
|
|
17
|
-
/** Runs the
|
|
17
|
+
/** Runs the async-style rules, and only those, over source text with ESLint's own fixer loop. */
|
|
18
18
|
export declare class AsyncStyle {
|
|
19
|
-
/** The `Linter` config: the TypeScript parser and the
|
|
19
|
+
/** The `Linter` config: the TypeScript parser and the rules of `asyncStyleConfigs`, at error. */
|
|
20
20
|
static createConfig(): Promise<Linter.Config[]>;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* The self-check's config: four scope rules, run on the text before and after the fixers. A hoisted name must be
|
|
23
|
+
* declared once, shadow nothing, be used after it is declared and be used at all; when the fixers break one of these
|
|
24
|
+
* the count of that rule goes up, and the file is left as it was.
|
|
25
|
+
*/
|
|
26
|
+
static createChecks(): Promise<Linter.Config[]>;
|
|
27
|
+
/** What got worse between `source` and `output` by the self-check's rules: empty when nothing did. */
|
|
28
|
+
static selfCheck(opts: {
|
|
29
|
+
linter: Linter;
|
|
30
|
+
checks: Linter.Config[];
|
|
31
|
+
source: string;
|
|
32
|
+
output: string;
|
|
33
|
+
filename: string;
|
|
34
|
+
}): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Fixes `source` (ESLint applies up to ten passes) and returns the text and what is left. `filename` is relative to
|
|
37
|
+
* the linter's `cwd`. The fixed text is checked against the original (`checks`): if it has more redeclarations,
|
|
38
|
+
* shadowed names, uses before declaration or unused variables than the original, no fix is returned and the file is
|
|
39
|
+
* reported as `self-check`, so a hoisted name that does not match the expression it replaced never reaches a file.
|
|
40
|
+
*/
|
|
22
41
|
static fix(opts: {
|
|
23
42
|
linter: Linter;
|
|
24
43
|
config: Linter.Config[];
|
|
44
|
+
checks: Linter.Config[];
|
|
25
45
|
source: string;
|
|
26
46
|
filename: string;
|
|
27
47
|
}): IAsyncStyleResult;
|
|
28
48
|
}
|
|
29
49
|
/**
|
|
30
|
-
* `devz codemod async-style [paths...] [--write | --check]`: applies the fixers of `no-inline-await
|
|
31
|
-
*
|
|
32
|
-
*
|
|
50
|
+
* `devz codemod async-style [paths...] [--write | --check]`: applies the fixers of `no-inline-await`,
|
|
51
|
+
* `no-return-await` and `no-await-promise-chain`, and lists what is left of those and of `no-silent-catch`.
|
|
52
|
+
* It is a dry run unless `--write` is given. `--check` is the same dry run, and exits 1 when anything would
|
|
53
|
+
* change or is left unfixed.
|
|
33
54
|
*/
|
|
34
55
|
export declare class AsyncStyleCommand {
|
|
35
|
-
static readonly USAGE = "Usage: devz codemod async-style [paths...] [--write | --check]\n\nApplies the fixers of
|
|
56
|
+
static readonly USAGE = "Usage: devz codemod async-style [paths...] [--write | --check]\n\nApplies the fixers of three house lint rules, so a repository can sweep them without a lint pass:\n\n venizia/no-inline-await `expect(await f())` becomes `const result = await f(); expect(result)`\n venizia/no-return-await `return await f()` becomes `return f()` (`const result = await f(); return result;` in a try)\n venizia/no-await-promise-chain `const x = await f().catch(() => null)` becomes\n `let x; try { x = await f(); } catch (error) { x = null; }`\n\nIt changes only what the fixers can change safely, and lists the rest with its file, line and rule:\nan `await` inside a ternary or logical operand, a loop test, an unbraced `if` branch, or after a call\nthat may have effects; an awaited `.then` or `.finally`, a `.catch` whose handler has a block body or\ncalls something, and an awaited chain that is not the whole initializer of a `const` or `let`; and\nevery venizia/no-silent-catch finding (a handler or catch block that swallows the error), which it never\nfixes: what to log is your decision.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 when anything would change or is left unfixed (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.";
|
|
36
57
|
static run(opts: {
|
|
37
58
|
root: string;
|
|
38
59
|
args: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-style.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/async-style.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"async-style.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/async-style.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAmDrC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAED,iGAAiG;AACjG,qBAAa,UAAU;IACrB,iGAAiG;WACpF,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAgBrD;;;;OAIG;WACU,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAsBrD,sGAAsG;IACtG,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,MAAM,EAAE;IAmBZ;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,iBAAiB;CA+CtB;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,KAAK,+lDAAS;WAEjB,GAAG,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CA8G1E"}
|
|
@@ -6,14 +6,19 @@ const node_path_1 = require("node:path");
|
|
|
6
6
|
const files_1 = require("./files");
|
|
7
7
|
const USAGE = `Usage: devz codemod async-style [paths...] [--write | --check]
|
|
8
8
|
|
|
9
|
-
Applies the fixers of
|
|
9
|
+
Applies the fixers of three house lint rules, so a repository can sweep them without a lint pass:
|
|
10
10
|
|
|
11
|
-
venizia/no-inline-await
|
|
12
|
-
venizia/no-return-await
|
|
11
|
+
venizia/no-inline-await \`expect(await f())\` becomes \`const result = await f(); expect(result)\`
|
|
12
|
+
venizia/no-return-await \`return await f()\` becomes \`return f()\` (\`const result = await f(); return result;\` in a try)
|
|
13
|
+
venizia/no-await-promise-chain \`const x = await f().catch(() => null)\` becomes
|
|
14
|
+
\`let x; try { x = await f(); } catch (error) { x = null; }\`
|
|
13
15
|
|
|
14
|
-
It changes only what the fixers can change safely
|
|
15
|
-
test, an unbraced \`if\` branch, or after a call
|
|
16
|
-
|
|
16
|
+
It changes only what the fixers can change safely, and lists the rest with its file, line and rule:
|
|
17
|
+
an \`await\` inside a ternary or logical operand, a loop test, an unbraced \`if\` branch, or after a call
|
|
18
|
+
that may have effects; an awaited \`.then\` or \`.finally\`, a \`.catch\` whose handler has a block body or
|
|
19
|
+
calls something, and an awaited chain that is not the whole initializer of a \`const\` or \`let\`; and
|
|
20
|
+
every venizia/no-silent-catch finding (a handler or catch block that swallows the error), which it never
|
|
21
|
+
fixes: what to log is your decision.
|
|
17
22
|
|
|
18
23
|
--write write the changed files (without it, nothing is written)
|
|
19
24
|
--check dry run that exits 1 when anything would change or is left unfixed (for CI)
|
|
@@ -24,8 +29,8 @@ files git knows (tracked, or untracked and not ignored), and --write refuses a f
|
|
|
24
29
|
(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;
|
|
25
30
|
/** A usage error: nothing was read or written. */
|
|
26
31
|
const USAGE_ERROR_CODE = 2;
|
|
27
|
-
/** A file that can hold an `await`. */
|
|
28
|
-
const
|
|
32
|
+
/** A file that can hold an `await` or a `catch`. */
|
|
33
|
+
const ASYNC_TEXT = /\b(await|catch)\b/;
|
|
29
34
|
class AsyncStyleFlags {
|
|
30
35
|
static { this.WRITE = '--write'; }
|
|
31
36
|
static { this.CHECK = '--check'; }
|
|
@@ -41,9 +46,9 @@ class AsyncStyleFlags {
|
|
|
41
46
|
return this.SCHEME_SET.has(value);
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
|
-
/** Runs the
|
|
49
|
+
/** Runs the async-style rules, and only those, over source text with ESLint's own fixer loop. */
|
|
45
50
|
class AsyncStyle {
|
|
46
|
-
/** The `Linter` config: the TypeScript parser and the
|
|
51
|
+
/** The `Linter` config: the TypeScript parser and the rules of `asyncStyleConfigs`, at error. */
|
|
47
52
|
static async createConfig() {
|
|
48
53
|
const { default: tseslint } = await import('typescript-eslint');
|
|
49
54
|
const { asyncStyleConfigs } = await import('../../linters/house/index.js');
|
|
@@ -51,22 +56,97 @@ class AsyncStyle {
|
|
|
51
56
|
{
|
|
52
57
|
files: ['**/*.{ts,tsx,mts,cts}'],
|
|
53
58
|
languageOptions: { parser: tseslint.parser },
|
|
54
|
-
// Only
|
|
59
|
+
// Only the async-style rules run here, so a `// eslint-disable-next-line` for any other rule looks unused and
|
|
55
60
|
// ESLint's fixer would delete it. A codemod never touches a directive.
|
|
56
61
|
linterOptions: { reportUnusedDisableDirectives: 'off' },
|
|
57
62
|
},
|
|
58
63
|
...asyncStyleConfigs,
|
|
59
64
|
];
|
|
60
65
|
}
|
|
61
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* The self-check's config: four scope rules, run on the text before and after the fixers. A hoisted name must be
|
|
68
|
+
* declared once, shadow nothing, be used after it is declared and be used at all; when the fixers break one of these
|
|
69
|
+
* the count of that rule goes up, and the file is left as it was.
|
|
70
|
+
*/
|
|
71
|
+
static async createChecks() {
|
|
72
|
+
const { default: tseslint } = await import('typescript-eslint');
|
|
73
|
+
return [
|
|
74
|
+
{
|
|
75
|
+
files: ['**/*.{ts,tsx,mts,cts}'],
|
|
76
|
+
languageOptions: { parser: tseslint.parser },
|
|
77
|
+
linterOptions: { reportUnusedDisableDirectives: 'off' },
|
|
78
|
+
plugins: { '@typescript-eslint': tseslint.plugin },
|
|
79
|
+
rules: {
|
|
80
|
+
'@typescript-eslint/no-redeclare': 'error',
|
|
81
|
+
'@typescript-eslint/no-shadow': 'error',
|
|
82
|
+
'@typescript-eslint/no-use-before-define': [
|
|
83
|
+
'error',
|
|
84
|
+
{ functions: false, classes: false },
|
|
85
|
+
],
|
|
86
|
+
'@typescript-eslint/no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
/** What got worse between `source` and `output` by the self-check's rules: empty when nothing did. */
|
|
92
|
+
static selfCheck(opts) {
|
|
93
|
+
const { linter, checks, source, output, filename } = opts;
|
|
94
|
+
const count = (text) => {
|
|
95
|
+
const found = new Map();
|
|
96
|
+
for (const message of linter.verify(text, checks, { filename })) {
|
|
97
|
+
const key = message.ruleId ?? 'parse error';
|
|
98
|
+
found.set(key, (found.get(key) ?? 0) + 1);
|
|
99
|
+
}
|
|
100
|
+
return found;
|
|
101
|
+
};
|
|
102
|
+
const was = count(source);
|
|
103
|
+
const now = count(output);
|
|
104
|
+
return [...now]
|
|
105
|
+
.filter(([rule, total]) => total > (was.get(rule) ?? 0))
|
|
106
|
+
.map(([rule, total]) => `${rule}: ${was.get(rule) ?? 0} before, ${total} after`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Fixes `source` (ESLint applies up to ten passes) and returns the text and what is left. `filename` is relative to
|
|
110
|
+
* the linter's `cwd`. The fixed text is checked against the original (`checks`): if it has more redeclarations,
|
|
111
|
+
* shadowed names, uses before declaration or unused variables than the original, no fix is returned and the file is
|
|
112
|
+
* reported as `self-check`, so a hoisted name that does not match the expression it replaced never reaches a file.
|
|
113
|
+
*/
|
|
62
114
|
static fix(opts) {
|
|
63
|
-
const { linter, config, source, filename } = opts;
|
|
64
|
-
|
|
115
|
+
const { linter, config, checks, source, filename } = opts;
|
|
116
|
+
// A fix can leave a new finding behind (the try/catch of no-await-promise-chain is a silent catch when the
|
|
117
|
+
// fallback is a constant), so the count is of the fixable findings, not of the findings that went away.
|
|
118
|
+
const fixable = linter
|
|
119
|
+
.verify(source, config, { filename })
|
|
120
|
+
.filter((message) => message.fix !== undefined).length;
|
|
65
121
|
const result = linter.verifyAndFix(source, config, { filename });
|
|
122
|
+
if (result.output !== source) {
|
|
123
|
+
const broken = AsyncStyle.selfCheck({
|
|
124
|
+
linter,
|
|
125
|
+
checks,
|
|
126
|
+
source,
|
|
127
|
+
output: result.output,
|
|
128
|
+
filename,
|
|
129
|
+
});
|
|
130
|
+
if (broken.length > 0) {
|
|
131
|
+
return {
|
|
132
|
+
output: source,
|
|
133
|
+
changed: false,
|
|
134
|
+
fixes: 0,
|
|
135
|
+
reports: [
|
|
136
|
+
{
|
|
137
|
+
line: 1,
|
|
138
|
+
column: 1,
|
|
139
|
+
ruleId: 'self-check',
|
|
140
|
+
message: `the fixers would have made this file worse (${broken.join('; ')}); it is left as it was - fix it by hand`,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
66
146
|
return {
|
|
67
147
|
output: result.output,
|
|
68
148
|
changed: result.output !== source,
|
|
69
|
-
fixes: result.fixed ?
|
|
149
|
+
fixes: result.fixed ? fixable : 0,
|
|
70
150
|
reports: result.messages.map((message) => ({
|
|
71
151
|
line: message.line,
|
|
72
152
|
column: message.column,
|
|
@@ -78,9 +158,10 @@ class AsyncStyle {
|
|
|
78
158
|
}
|
|
79
159
|
exports.AsyncStyle = AsyncStyle;
|
|
80
160
|
/**
|
|
81
|
-
* `devz codemod async-style [paths...] [--write | --check]`: applies the fixers of `no-inline-await
|
|
82
|
-
*
|
|
83
|
-
*
|
|
161
|
+
* `devz codemod async-style [paths...] [--write | --check]`: applies the fixers of `no-inline-await`,
|
|
162
|
+
* `no-return-await` and `no-await-promise-chain`, and lists what is left of those and of `no-silent-catch`.
|
|
163
|
+
* It is a dry run unless `--write` is given. `--check` is the same dry run, and exits 1 when anything would
|
|
164
|
+
* change or is left unfixed.
|
|
84
165
|
*/
|
|
85
166
|
class AsyncStyleCommand {
|
|
86
167
|
static { this.USAGE = USAGE; }
|
|
@@ -113,6 +194,7 @@ class AsyncStyleCommand {
|
|
|
113
194
|
return 1;
|
|
114
195
|
}
|
|
115
196
|
const config = await AsyncStyle.createConfig();
|
|
197
|
+
const checks = await AsyncStyle.createChecks();
|
|
116
198
|
const targets = (paths.length > 0 ? paths : ['.']).map((path) => (0, node_path_1.resolve)(root, path));
|
|
117
199
|
let changedCount = 0;
|
|
118
200
|
let fixCount = 0;
|
|
@@ -126,11 +208,11 @@ class AsyncStyleCommand {
|
|
|
126
208
|
}
|
|
127
209
|
for (const file of files) {
|
|
128
210
|
const source = (0, node_fs_1.readFileSync)(file, 'utf8');
|
|
129
|
-
if (!
|
|
211
|
+
if (!ASYNC_TEXT.test(source)) {
|
|
130
212
|
continue;
|
|
131
213
|
}
|
|
132
214
|
const shown = (0, node_path_1.relative)(root, file).split('\\').join('/');
|
|
133
|
-
const result = AsyncStyle.fix({ linter, config, source, filename: shown });
|
|
215
|
+
const result = AsyncStyle.fix({ linter, config, checks, source, filename: shown });
|
|
134
216
|
for (const report of result.reports) {
|
|
135
217
|
reportCount += 1;
|
|
136
218
|
console.warn(`${shown}:${report.line}:${report.column} ${report.ruleId ?? 'parse error'} ${report.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-style.js","sourceRoot":"","sources":["../../../src/cli/codemod/async-style.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAE9C,mCAAuC;AAEvC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;uFAiByE,CAAC;AAExF,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,uCAAuC;AACvC,MAAM,UAAU,GAAG,WAAW,CAAC;AAE/B,MAAM,eAAe;aACH,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,SAAI,GAAG,QAAQ,CAAC;aAChB,eAAU,GAAG,IAAI,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,UAAU;KAChB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;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import { relative, resolve } from 'node:path';\nimport type { Linter } from 'eslint';\nimport { CodemodFiles } from './files';\n\nconst USAGE = `Usage: devz codemod async-style [paths...] [--write | --check]\n\nApplies the fixers of two house lint rules, so a repository can sweep them without a lint pass:\n\n venizia/no-inline-await \\`expect(await f())\\` becomes \\`const result = await f(); expect(result)\\`\n venizia/no-return-await \\`return await f()\\` becomes \\`return f()\\` (\\`const result = await f(); return result;\\` in a try)\n\nIt changes only what the fixers can change safely. An \\`await\\` inside a ternary or logical operand, a loop\ntest, an unbraced \\`if\\` branch, or after a call that may have effects is listed with its file, line and\nrule, and left for you.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 when anything would change or is left unfixed (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\n/** A file that can hold an `await`. */\nconst AWAIT_TEXT = /\\bawait\\b/;\n\nclass AsyncStyleFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport interface IAsyncStyleReport {\n line: number;\n column: number;\n /** The rule id, or `undefined` for a file ESLint could not parse. */\n ruleId: string | null;\n message: string;\n}\n\nexport interface IAsyncStyleResult {\n output: string;\n changed: boolean;\n /** How many findings the fixers removed. */\n fixes: number;\n /** What is still reported after every pass. */\n reports: IAsyncStyleReport[];\n}\n\n/** Runs the two async-style rules, and only those, over source text with ESLint's own fixer loop. */\nexport class AsyncStyle {\n /** The `Linter` config: the TypeScript parser and the two rules at error, from `asyncStyleConfigs`. */\n static async createConfig(): Promise<Linter.Config[]> {\n const { default: tseslint } = await import('typescript-eslint');\n const { asyncStyleConfigs } = await import('../../linters/house/index.js');\n\n return [\n {\n files: ['**/*.{ts,tsx,mts,cts}'],\n languageOptions: { parser: tseslint.parser },\n // Only two rules run here, so a `// eslint-disable-next-line` for any other rule looks unused and\n // ESLint's fixer would delete it. A codemod never touches a directive.\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n },\n ...asyncStyleConfigs,\n ];\n }\n\n /** Fixes `source` (ESLint applies up to ten passes) and returns the text and what is left. `filename` is relative to the linter's `cwd`. */\n static fix(opts: {\n linter: Linter;\n config: Linter.Config[];\n source: string;\n filename: string;\n }): IAsyncStyleResult {\n const { linter, config, source, filename } = opts;\n const before = linter.verify(source, config, { filename }).length;\n const result = linter.verifyAndFix(source, config, { filename });\n\n return {\n output: result.output,\n changed: result.output !== source,\n fixes: result.fixed ? Math.max(0, before - result.messages.length) : 0,\n reports: result.messages.map((message) => ({\n line: message.line,\n column: message.column,\n ruleId: message.ruleId,\n message: message.message,\n })),\n };\n }\n}\n\n/**\n * `devz codemod async-style [paths...] [--write | --check]`: applies the fixers of `no-inline-await`\n * and `no-return-await`. It is a dry run unless `--write` is given. `--check` is the same dry run, and\n * exits 1 when anything would change or is left unfixed.\n */\nexport class AsyncStyleCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { root, args } = opts;\n\n if (args.includes(AsyncStyleFlags.HELP) || args.includes(AsyncStyleFlags.HELP_SHORT)) {\n console.log(USAGE);\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !AsyncStyleFlags.isValid(flag));\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(AsyncStyleFlags.WRITE);\n const isCheck = flags.includes(AsyncStyleFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${AsyncStyleFlags.WRITE} and ${AsyncStyleFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n let linter: Linter;\n try {\n const { Linter: EslintLinter } = await import('eslint');\n linter = new EslintLinter({ cwd: root });\n } catch {\n console.error('devz codemod: the \"eslint\" package is required to run the lint fixers');\n return 1;\n }\n\n const config = await AsyncStyle.createConfig();\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let fixCount = 0;\n let reportCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!AWAIT_TEXT.test(source)) {\n continue;\n }\n\n const shown = relative(root, file).split('\\\\').join('/');\n const result = AsyncStyle.fix({ linter, config, source, filename: shown });\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(\n `${shown}:${report.line}:${report.column} ${report.ruleId ?? 'parse error'} ${report.message}`,\n );\n }\n\n if (!result.changed) {\n continue;\n }\n\n if (dirty?.has(file)) {\n refusedCount += 1;\n console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n fixCount += result.fixes;\n console.log(`${isWrite ? 'changed' : 'would change'} ${shown} (${result.fixes} fix(es))`);\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod async-style: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${fixCount} fix(es) ${isWrite ? 'applied' : 'would be applied'}, ${reportCount} left unfixed` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(`Nothing was written. Run again with ${AsyncStyleFlags.WRITE} to apply.`);\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"async-style.js","sourceRoot":"","sources":["../../../src/cli/codemod/async-style.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAE9C,mCAAuC;AAEvC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;uFAsByE,CAAC;AAExF,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,oDAAoD;AACpD,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAEvC,MAAM,eAAe;aACH,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,SAAI,GAAG,QAAQ,CAAC;aAChB,eAAU,GAAG,IAAI,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,UAAU;KAChB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAoBH,iGAAiG;AACjG,MAAa,UAAU;IACrB,iGAAiG;IACjG,MAAM,CAAC,KAAK,CAAC,YAAY;QACvB,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAChE,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;QAE3E,OAAO;YACL;gBACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;gBAChC,eAAe,EAAE,EAAE,MA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,CAAC,CAAC;gBAE5F,IAAI,OAAO,EAAE,CAAC;oBACZ,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CACT,6BAA6B,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,QAAQ,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,KAAK,WAAW,eAAe;YACvL,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD,CAAC;QAEF,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,uCAAuC,eAAe,CAAC,KAAK,YAAY,CAAC,CAAC;QACxF,CAAC;QAED,IAAI,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AAhHH,8CAiHC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type { Linter } from 'eslint';\nimport { CodemodFiles } from './files';\n\nconst USAGE = `Usage: devz codemod async-style [paths...] [--write | --check]\n\nApplies the fixers of three house lint rules, so a repository can sweep them without a lint pass:\n\n venizia/no-inline-await \\`expect(await f())\\` becomes \\`const result = await f(); expect(result)\\`\n venizia/no-return-await \\`return await f()\\` becomes \\`return f()\\` (\\`const result = await f(); return result;\\` in a try)\n venizia/no-await-promise-chain \\`const x = await f().catch(() => null)\\` becomes\n \\`let x; try { x = await f(); } catch (error) { x = null; }\\`\n\nIt changes only what the fixers can change safely, and lists the rest with its file, line and rule:\nan \\`await\\` inside a ternary or logical operand, a loop test, an unbraced \\`if\\` branch, or after a call\nthat may have effects; an awaited \\`.then\\` or \\`.finally\\`, a \\`.catch\\` whose handler has a block body or\ncalls something, and an awaited chain that is not the whole initializer of a \\`const\\` or \\`let\\`; and\nevery venizia/no-silent-catch finding (a handler or catch block that swallows the error), which it never\nfixes: what to log is your decision.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 when anything would change or is left unfixed (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\n/** A file that can hold an `await` or a `catch`. */\nconst ASYNC_TEXT = /\\b(await|catch)\\b/;\n\nclass AsyncStyleFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport interface IAsyncStyleReport {\n line: number;\n column: number;\n /** The rule id, or `undefined` for a file ESLint could not parse. */\n ruleId: string | null;\n message: string;\n}\n\nexport interface IAsyncStyleResult {\n output: string;\n changed: boolean;\n /** How many findings of the original source carried a fix, once the fixers changed it. */\n fixes: number;\n /** What is still reported after every pass. */\n reports: IAsyncStyleReport[];\n}\n\n/** Runs the async-style rules, and only those, over source text with ESLint's own fixer loop. */\nexport class AsyncStyle {\n /** The `Linter` config: the TypeScript parser and the rules of `asyncStyleConfigs`, at error. */\n static async createConfig(): Promise<Linter.Config[]> {\n const { default: tseslint } = await import('typescript-eslint');\n const { asyncStyleConfigs } = await import('../../linters/house/index.js');\n\n return [\n {\n files: ['**/*.{ts,tsx,mts,cts}'],\n languageOptions: { parser: tseslint.parser },\n // Only the async-style rules run here, so a `// eslint-disable-next-line` for any other rule looks unused and\n // ESLint's fixer would delete it. A codemod never touches a directive.\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n },\n ...asyncStyleConfigs,\n ];\n }\n\n /**\n * The self-check's config: four scope rules, run on the text before and after the fixers. A hoisted name must be\n * declared once, shadow nothing, be used after it is declared and be used at all; when the fixers break one of these\n * the count of that rule goes up, and the file is left as it was.\n */\n static async createChecks(): Promise<Linter.Config[]> {\n const { default: tseslint } = await import('typescript-eslint');\n\n return [\n {\n files: ['**/*.{ts,tsx,mts,cts}'],\n languageOptions: { parser: tseslint.parser },\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n plugins: { '@typescript-eslint': tseslint.plugin as never },\n rules: {\n '@typescript-eslint/no-redeclare': 'error',\n '@typescript-eslint/no-shadow': 'error',\n '@typescript-eslint/no-use-before-define': [\n 'error',\n { functions: false, classes: false },\n ],\n '@typescript-eslint/no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }],\n },\n },\n ];\n }\n\n /** What got worse between `source` and `output` by the self-check's rules: empty when nothing did. */\n static selfCheck(opts: {\n linter: Linter;\n checks: Linter.Config[];\n source: string;\n output: string;\n filename: string;\n }): string[] {\n const { linter, checks, source, output, filename } = opts;\n const count = (text: string): Map<string, number> => {\n const found = new Map<string, number>();\n for (const message of linter.verify(text, checks, { filename })) {\n const key = message.ruleId ?? 'parse error';\n found.set(key, (found.get(key) ?? 0) + 1);\n }\n\n return found;\n };\n const was = count(source);\n const now = count(output);\n\n return [...now]\n .filter(([rule, total]) => total > (was.get(rule) ?? 0))\n .map(([rule, total]) => `${rule}: ${was.get(rule) ?? 0} before, ${total} after`);\n }\n\n /**\n * Fixes `source` (ESLint applies up to ten passes) and returns the text and what is left. `filename` is relative to\n * the linter's `cwd`. The fixed text is checked against the original (`checks`): if it has more redeclarations,\n * shadowed names, uses before declaration or unused variables than the original, no fix is returned and the file is\n * reported as `self-check`, so a hoisted name that does not match the expression it replaced never reaches a file.\n */\n static fix(opts: {\n linter: Linter;\n config: Linter.Config[];\n checks: Linter.Config[];\n source: string;\n filename: string;\n }): IAsyncStyleResult {\n const { linter, config, checks, source, filename } = opts;\n // A fix can leave a new finding behind (the try/catch of no-await-promise-chain is a silent catch when the\n // fallback is a constant), so the count is of the fixable findings, not of the findings that went away.\n const fixable = linter\n .verify(source, config, { filename })\n .filter((message) => message.fix !== undefined).length;\n const result = linter.verifyAndFix(source, config, { filename });\n\n if (result.output !== source) {\n const broken = AsyncStyle.selfCheck({\n linter,\n checks,\n source,\n output: result.output,\n filename,\n });\n\n if (broken.length > 0) {\n return {\n output: source,\n changed: false,\n fixes: 0,\n reports: [\n {\n line: 1,\n column: 1,\n ruleId: 'self-check',\n message: `the fixers would have made this file worse (${broken.join('; ')}); it is left as it was - fix it by hand`,\n },\n ],\n };\n }\n }\n\n return {\n output: result.output,\n changed: result.output !== source,\n fixes: result.fixed ? fixable : 0,\n reports: result.messages.map((message) => ({\n line: message.line,\n column: message.column,\n ruleId: message.ruleId,\n message: message.message,\n })),\n };\n }\n}\n\n/**\n * `devz codemod async-style [paths...] [--write | --check]`: applies the fixers of `no-inline-await`,\n * `no-return-await` and `no-await-promise-chain`, and lists what is left of those and of `no-silent-catch`.\n * It is a dry run unless `--write` is given. `--check` is the same dry run, and exits 1 when anything would\n * change or is left unfixed.\n */\nexport class AsyncStyleCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { root, args } = opts;\n\n if (args.includes(AsyncStyleFlags.HELP) || args.includes(AsyncStyleFlags.HELP_SHORT)) {\n console.log(USAGE);\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !AsyncStyleFlags.isValid(flag));\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(AsyncStyleFlags.WRITE);\n const isCheck = flags.includes(AsyncStyleFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${AsyncStyleFlags.WRITE} and ${AsyncStyleFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n let linter: Linter;\n try {\n const { Linter: EslintLinter } = await import('eslint');\n linter = new EslintLinter({ cwd: root });\n } catch {\n console.error('devz codemod: the \"eslint\" package is required to run the lint fixers');\n return 1;\n }\n\n const config = await AsyncStyle.createConfig();\n const checks = await AsyncStyle.createChecks();\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let fixCount = 0;\n let reportCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!ASYNC_TEXT.test(source)) {\n continue;\n }\n\n const shown = relative(root, file).split('\\\\').join('/');\n const result = AsyncStyle.fix({ linter, config, checks, source, filename: shown });\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(\n `${shown}:${report.line}:${report.column} ${report.ruleId ?? 'parse error'} ${report.message}`,\n );\n }\n\n if (!result.changed) {\n continue;\n }\n\n if (dirty?.has(file)) {\n refusedCount += 1;\n console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n fixCount += result.fixes;\n console.log(`${isWrite ? 'changed' : 'would change'} ${shown} (${result.fixes} fix(es))`);\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod async-style: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${fixCount} fix(es) ${isWrite ? 'applied' : 'would be applied'}, ${reportCount} left unfixed` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(`Nothing was written. Run again with ${AsyncStyleFlags.WRITE} to apply.`);\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":"AA4CA;;;;;;GAMG;AACH,qBAAa,cAAc;WACZ,GAAG,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CA2H1E"}
|
|
@@ -8,6 +8,7 @@ const const_classes_1 = require("./const-classes");
|
|
|
8
8
|
const drop_redundant_casts_1 = require("./drop-redundant-casts");
|
|
9
9
|
const files_1 = require("./files");
|
|
10
10
|
const model_settings_1 = require("./model-settings");
|
|
11
|
+
const namespace_functions_1 = require("./namespace-functions");
|
|
11
12
|
const USAGE = `Usage: devz codemod model-settings [paths...] [--write | --check]
|
|
12
13
|
|
|
13
14
|
Moves @model settings to the grouped shape and skipMigrate to migration.use.
|
|
@@ -57,8 +58,11 @@ class CodemodCommand {
|
|
|
57
58
|
if (name === 'async-style') {
|
|
58
59
|
return async_style_1.AsyncStyleCommand.run({ root: opts.root, args: rest });
|
|
59
60
|
}
|
|
61
|
+
if (name === 'namespace-functions') {
|
|
62
|
+
return namespace_functions_1.NamespaceFunctionsCommand.run({ root: opts.root, args: rest });
|
|
63
|
+
}
|
|
60
64
|
if (args.includes(CodemodFlags.HELP) || args.includes(CodemodFlags.HELP_SHORT)) {
|
|
61
|
-
console.log(`${USAGE}\n\n${drop_redundant_casts_1.DropRedundantCastsCommand.USAGE}\n\n${const_classes_1.ConstClassesCommand.USAGE}\n\n${async_style_1.AsyncStyleCommand.USAGE}`);
|
|
65
|
+
console.log(`${USAGE}\n\n${drop_redundant_casts_1.DropRedundantCastsCommand.USAGE}\n\n${const_classes_1.ConstClassesCommand.USAGE}\n\n${async_style_1.AsyncStyleCommand.USAGE}\n\n${namespace_functions_1.NamespaceFunctionsCommand.USAGE}`);
|
|
62
66
|
return 0;
|
|
63
67
|
}
|
|
64
68
|
if (name !== 'model-settings') {
|
|
@@ -99,7 +103,7 @@ class CodemodCommand {
|
|
|
99
103
|
if (!MODEL_TEXT.test(source)) {
|
|
100
104
|
continue;
|
|
101
105
|
}
|
|
102
|
-
const result =
|
|
106
|
+
const result = model_settings_1.ModelSettingsCodemod.migrate({ typescript, fileName: file, source });
|
|
103
107
|
const shown = (0, node_path_1.relative)(opts.root, file) || file;
|
|
104
108
|
for (const report of result.reports) {
|
|
105
109
|
reportCount += 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,+CAAkD;AAClD,mDAAsD;AACtD,iEAAmE;AACnE,mCAAuC;AACvC,qDAAwD;AAExD,MAAM,KAAK,GAAG;;;;;;;;;+FASiF,CAAC;AAEhG,oGAAoG;AACpG,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAE3D,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,YAAY;aACA,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,SAAI,GAAG,QAAQ,CAAC;aAChB,eAAU,GAAG,IAAI,CAAC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AAC;IAClE,CAAC;CACF;AAxHD,wCAwHC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { AsyncStyleCommand } from './async-style';\nimport { ConstClassesCommand } from './const-classes';\nimport { DropRedundantCastsCommand } from './drop-redundant-casts';\nimport { CodemodFiles } from './files';\nimport { migrateModelSettings } from './model-settings';\n\nconst USAGE = `Usage: devz codemod model-settings [paths...] [--write | --check]\n\nMoves @model settings to the grouped shape and skipMigrate to migration.use.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 when anything would change or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), so ignored folders are never touched.`;\n\n/** A file that can hold a `@model` call: the decorator, an aliased import of it, or `ns.model(`. */\nconst MODEL_TEXT = /@model\\b|\\bmodel\\s+as\\s+\\w+|\\.model\\(/;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass CodemodFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/**\n * `devz codemod model-settings [paths...] [--write | --check]`: moves `@model` settings from the\n * flat keys (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access`,\n * and `skipMigrate` to `migration.use`. It is a dry run unless `--write` is given: it lists what\n * would change. `--check` is the same dry run, and exits 1 when anything would change or is\n * left untouched (an untouched model still throws when its decorator runs).\n */\nexport class CodemodCommand {\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { args } = opts;\n\n const [name, ...rest] = args;\n\n if (name === 'drop-redundant-casts') {\n return DropRedundantCastsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'const-classes') {\n return ConstClassesCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'async-style') {\n return AsyncStyleCommand.run({ root: opts.root, args: rest });\n }\n\n if (args.includes(CodemodFlags.HELP) || args.includes(CodemodFlags.HELP_SHORT)) {\n console.log(\n `${USAGE}\\n\\n${DropRedundantCastsCommand.USAGE}\\n\\n${ConstClassesCommand.USAGE}\\n\\n${AsyncStyleCommand.USAGE}`,\n );\n return 0;\n }\n\n if (name !== 'model-settings') {\n console.error(`devz codemod: unknown codemod \"${name ?? ''}\"\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n\n const unknown = rest.filter(\n (argument) => argument.startsWith('-') && !CodemodFlags.isValid(argument),\n );\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = rest.includes(CodemodFlags.WRITE);\n const isCheck = rest.includes(CodemodFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${CodemodFlags.WRITE} and ${CodemodFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const paths = rest.filter((argument) => !argument.startsWith('-'));\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(opts.root, path));\n\n let typescript: typeof import('typescript');\n try {\n const result2 = await import('typescript');\n typescript = result2.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n return 1;\n }\n\n let changedCount = 0;\n let reportCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(opts.root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!MODEL_TEXT.test(source)) {\n continue;\n }\n\n const result = migrateModelSettings({ typescript, fileName: file, source });\n const shown = relative(opts.root, file) || file;\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(`${shown}:${report.line}:${report.column} ${report.reason}`);\n }\n\n if (!result.changed) {\n continue;\n }\n\n changedCount += 1;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} model(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod model-settings: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${reportCount} left untouched`,\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(`Nothing was written. Run again with ${CodemodFlags.WRITE} to apply.`);\n }\n\n if (isCheck && changedCount === 0 && reportCount > 0) {\n console.log(\n 'Nothing to rewrite, but the models above throw when the decorator runs: fix them by hand.',\n );\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,+CAAkD;AAClD,mDAAsD;AACtD,iEAAmE;AACnE,mCAAuC;AACvC,qDAAwD;AACxD,+DAAkE;AAElE,MAAM,KAAK,GAAG;;;;;;;;;+FASiF,CAAC;AAEhG,oGAAoG;AACpG,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAE3D,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,YAAY;aACA,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,SAAI,GAAG,QAAQ,CAAC;aAChB,eAAU,GAAG,IAAI,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,UAAU;KAChB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,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AC,CAAC,CAAC;IAClE,CAAC;CACF;AA5HD,wCA4HC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { AsyncStyleCommand } from './async-style';\nimport { ConstClassesCommand } from './const-classes';\nimport { DropRedundantCastsCommand } from './drop-redundant-casts';\nimport { CodemodFiles } from './files';\nimport { ModelSettingsCodemod } from './model-settings';\nimport { NamespaceFunctionsCommand } from './namespace-functions';\n\nconst USAGE = `Usage: devz codemod model-settings [paths...] [--write | --check]\n\nMoves @model settings to the grouped shape and skipMigrate to migration.use.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 when anything would change or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), so ignored folders are never touched.`;\n\n/** A file that can hold a `@model` call: the decorator, an aliased import of it, or `ns.model(`. */\nconst MODEL_TEXT = /@model\\b|\\bmodel\\s+as\\s+\\w+|\\.model\\(/;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass CodemodFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/**\n * `devz codemod model-settings [paths...] [--write | --check]`: moves `@model` settings from the\n * flat keys (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access`,\n * and `skipMigrate` to `migration.use`. It is a dry run unless `--write` is given: it lists what\n * would change. `--check` is the same dry run, and exits 1 when anything would change or is\n * left untouched (an untouched model still throws when its decorator runs).\n */\nexport class CodemodCommand {\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { args } = opts;\n\n const [name, ...rest] = args;\n\n if (name === 'drop-redundant-casts') {\n return DropRedundantCastsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'const-classes') {\n return ConstClassesCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'async-style') {\n return AsyncStyleCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'namespace-functions') {\n return NamespaceFunctionsCommand.run({ root: opts.root, args: rest });\n }\n\n if (args.includes(CodemodFlags.HELP) || args.includes(CodemodFlags.HELP_SHORT)) {\n console.log(\n `${USAGE}\\n\\n${DropRedundantCastsCommand.USAGE}\\n\\n${ConstClassesCommand.USAGE}\\n\\n${AsyncStyleCommand.USAGE}\\n\\n${NamespaceFunctionsCommand.USAGE}`,\n );\n return 0;\n }\n\n if (name !== 'model-settings') {\n console.error(`devz codemod: unknown codemod \"${name ?? ''}\"\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n\n const unknown = rest.filter(\n (argument) => argument.startsWith('-') && !CodemodFlags.isValid(argument),\n );\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = rest.includes(CodemodFlags.WRITE);\n const isCheck = rest.includes(CodemodFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${CodemodFlags.WRITE} and ${CodemodFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const paths = rest.filter((argument) => !argument.startsWith('-'));\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(opts.root, path));\n\n let typescript: typeof import('typescript');\n try {\n const result2 = await import('typescript');\n typescript = result2.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n return 1;\n }\n\n let changedCount = 0;\n let reportCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(opts.root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!MODEL_TEXT.test(source)) {\n continue;\n }\n\n const result = ModelSettingsCodemod.migrate({ typescript, fileName: file, source });\n const shown = relative(opts.root, file) || file;\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(`${shown}:${report.line}:${report.column} ${report.reason}`);\n }\n\n if (!result.changed) {\n continue;\n }\n\n changedCount += 1;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} model(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod model-settings: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${reportCount} left untouched`,\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(`Nothing was written. Run again with ${CodemodFlags.WRITE} to apply.`);\n }\n\n if (isCheck && changedCount === 0 && reportCount > 0) {\n console.log(\n 'Nothing to rewrite, but the models above throw when the decorator runs: fix them by hand.',\n );\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
@@ -25,10 +25,12 @@ export interface IModelSettingsResult {
|
|
|
25
25
|
* never guesses: a `settings` value that is not an object literal, a spread, a computed key, or a
|
|
26
26
|
* `scopeFilter` that is not an object literal is reported and the model is left untouched.
|
|
27
27
|
*/
|
|
28
|
-
export declare
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
export declare class ModelSettingsCodemod {
|
|
29
|
+
static migrate(opts: {
|
|
30
|
+
typescript: TTypeScript;
|
|
31
|
+
fileName: string;
|
|
32
|
+
source: string;
|
|
33
|
+
}): IModelSettingsResult;
|
|
34
|
+
}
|
|
33
35
|
export {};
|
|
34
36
|
//# sourceMappingURL=model-settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-settings.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/model-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,KAAK,WAAW,GAAG,OAAO,EAAE,CAAC;AAK7B,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC;AAWD;;;;;;;;;;GAUG;AACH,
|
|
1
|
+
{"version":3,"file":"model-settings.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/model-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,KAAK,WAAW,GAAG,OAAO,EAAE,CAAC;AAK7B,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC;AAWD;;;;;;;;;;GAUG;AACH,qBAAa,oBAAoB;IAC/B,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QACnB,UAAU,EAAE,WAAW,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,oBAAoB;CA+azB"}
|