@venizia/dev-configs 0.4.6 → 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 -68
- 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 +101 -99
- 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 -69
- 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 +62 -0
- package/dist/cli/codemod/async-style.d.ts.map +1 -0
- package/dist/cli/codemod/async-style.js +248 -0
- package/dist/cli/codemod/async-style.js.map +1 -0
- package/dist/cli/codemod/const-classes.d.ts.map +1 -1
- package/dist/cli/codemod/const-classes.js +2 -1
- package/dist/cli/codemod/const-classes.js.map +1 -1
- package/dist/cli/codemod/drop-redundant-casts.d.ts.map +1 -1
- package/dist/cli/codemod/drop-redundant-casts.js +2 -1
- package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
- package/dist/cli/codemod/files.d.ts +7 -0
- package/dist/cli/codemod/files.d.ts.map +1 -1
- package/dist/cli/codemod/files.js +33 -0
- package/dist/cli/codemod/files.js.map +1 -1
- package/dist/cli/codemod/index.d.ts.map +1 -1
- package/dist/cli/codemod/index.js +12 -3
- 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 -0
- 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 +74 -0
- package/dist/linters/house/await-support.d.ts.map +1 -0
- package/dist/linters/house/await-support.js +238 -0
- package/dist/linters/house/await-support.js.map +1 -0
- package/dist/linters/house/common.d.ts +15 -9
- package/dist/linters/house/common.d.ts.map +1 -1
- package/dist/linters/house/common.js +20 -15
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/configs.d.ts +26 -0
- package/dist/linters/house/configs.d.ts.map +1 -1
- package/dist/linters/house/configs.js +55 -1
- 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.d.ts +17 -0
- package/dist/linters/house/effect-cleanup-consistency.rule.d.ts.map +1 -0
- package/dist/linters/house/effect-cleanup-consistency.rule.js +87 -0
- package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -0
- package/dist/linters/house/hook-support.d.ts +29 -0
- package/dist/linters/house/hook-support.d.ts.map +1 -0
- package/dist/linters/house/hook-support.js +72 -0
- package/dist/linters/house/hook-support.js.map +1 -0
- package/dist/linters/house/index.d.ts +9 -0
- package/dist/linters/house/index.d.ts.map +1 -1
- package/dist/linters/house/index.js +9 -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.d.ts +18 -0
- package/dist/linters/house/no-async-hook-callback.rule.d.ts.map +1 -0
- package/dist/linters/house/no-async-hook-callback.rule.js +50 -0
- package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -0
- 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 +20 -0
- package/dist/linters/house/no-inline-await.rule.d.ts.map +1 -0
- package/dist/linters/house/no-inline-await.rule.js +70 -0
- package/dist/linters/house/no-inline-await.rule.js.map +1 -0
- 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 +15 -0
- package/dist/linters/house/no-return-await.rule.d.ts.map +1 -0
- package/dist/linters/house/no-return-await.rule.js +92 -0
- package/dist/linters/house/no-return-await.rule.js.map +1 -0
- 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 +12 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewriter.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/rewriter.ts"],"names":[],"mappings":";;;AA6CA;;;;;GAKG;AACH,MAAa,kBAAkB;IAC7B,MAAM,CAAC,OAAO,CAAC,IAKd;QACC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QACxD,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAC5C,QAAQ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EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5D,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1F,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC;YACtB,CAAC,CAAC,GAAG,SAAS,IAAI,MAAM,IAAI;YAC5B,CAAC,CAAC,GAAG,SAAS,IAAI,MAAM,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACvD,CAAC;CACF;AApvBD,gDAovBC","sourcesContent":["import type ts from 'typescript';\nimport type { INamespaceMapping } from './mapping';\n\ntype TTypeScript = typeof ts;\n\nexport interface INamespaceFunctionsReport {\n line: number;\n column: number;\n reason: string;\n}\n\nexport interface INamespaceFunctionsResult {\n output: string;\n changed: boolean;\n /** How many calls were rewritten. */\n rewritten: number;\n /** What the codemod found and left for a person, with where. */\n reports: INamespaceFunctionsReport[];\n}\n\ninterface IEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** One way the file reaches an old name: a named import of it, or a namespace import of its module. */\ninterface IBinding {\n mapping: INamespaceMapping;\n declaration: ts.ImportDeclaration;\n module: string;\n /** The local name: of the imported function, or of the namespace. */\n local: string;\n /** The identifier that declares `local`. */\n declarationName: ts.Identifier;\n /** The named import; `undefined` for `import * as name`. */\n specifier?: ts.ImportSpecifier;\n}\n\n/** A matched use of an old name: a call to rewrite, or any other use, which is reported. */\ninterface IUses {\n calls: ts.CallExpression[];\n values: ts.Node[];\n}\n\n/**\n * Rewrites the calls of functions that moved into a class, `oldName(a, b)` to\n * `ClassName.method({ first: a, second: b })`, from a mapping table. Syntactic: it reads one file and\n * needs no type checker, so it only follows names imported from a module the table lists. Every edit\n * is a text edit by position: the argument text, its comments and the untouched code stay as they are.\n */\nexport class NamespaceFunctions {\n static rewrite(opts: {\n typescript: TTypeScript;\n fileName: string;\n source: string;\n mappings: ReadonlyArray<INamespaceMapping>;\n }): INamespaceFunctionsResult {\n const { typescript, fileName, source, mappings } = opts;\n const sourceFile = typescript.createSourceFile(\n fileName,\n source,\n typescript.ScriptTarget.Latest,\n true,\n );\n const reports: INamespaceFunctionsReport[] = [];\n\n const report = (reportOpts: { node: ts.Node; reason: string }) => {\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n reportOpts.node.getStart(sourceFile),\n );\n reports.push({ line: line + 1, column: character + 1, reason: reportOpts.reason });\n };\n\n const lineOf = (node: ts.Node) =>\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;\n\n const byModule = new Map<string, INamespaceMapping[]>();\n for (const mapping of mappings) {\n for (const module of mapping.modules) {\n byModule.set(module, [...(byModule.get(module) ?? []), mapping]);\n }\n }\n\n const bindings = NamespaceFunctions.findBindings({\n typescript,\n sourceFile,\n byModule,\n report,\n });\n if (bindings.length === 0) {\n return { output: source, changed: false, rewritten: 0, reports };\n }\n\n const identifiers = NamespaceFunctions.collectIdentifiers({ typescript, sourceFile });\n const declarationsOf = (name: string) =>\n (identifiers.get(name) ?? []).filter((identifier) =>\n NamespaceFunctions.isDeclarationName({ typescript, identifier }),\n );\n\n const edits: IEdit[] = [];\n const removals = new Set<ts.ImportSpecifier>();\n /** The imports that lose an old name. */\n const trimmed = new Set<ts.ImportDeclaration>();\n const additions = new Map<ts.ImportDeclaration, Set<string>>();\n const newImports = new Map<string, { anchor: ts.ImportDeclaration; names: Set<string> }>();\n /** The class names this run imports, and from which module. */\n const planned = new Map<string, string>();\n let rewritten = 0;\n\n for (const binding of bindings) {\n const { mapping } = binding;\n const uses = NamespaceFunctions.findUses({ typescript, binding, identifiers });\n if (uses.calls.length === 0 && uses.values.length === 0) {\n continue;\n }\n\n const target = NamespaceFunctions.describeTarget({ mapping });\n\n for (const value of uses.values) {\n report({\n node: value,\n reason: `\\`${mapping.oldName}\\` is used as a value (passed, stored, exported or in typeof), so its import stays; change it by hand to ${mapping.className}.${mapping.method}`,\n });\n }\n\n if (uses.calls.length === 0) {\n continue;\n }\n\n const shadow = declarationsOf(binding.local).find(\n (identifier) => identifier !== binding.declarationName,\n );\n if (shadow) {\n report({\n node: shadow,\n reason: `\\`${binding.local}\\` is declared again in this file, so a call cannot be told apart from the import; rewrite the calls of \\`${mapping.oldName}\\` by hand as ${target}`,\n });\n continue;\n }\n\n const classModules = mapping.newModules ?? [binding.module];\n const isNamespaceReach = !binding.specifier && classModules.includes(binding.module);\n let classReference = `${binding.local}.${mapping.className}`;\n let needsImport = false;\n\n if (!isNamespaceReach) {\n const existing = NamespaceFunctions.findClassImport({\n typescript,\n sourceFile,\n className: mapping.className,\n modules: classModules,\n });\n const plannedModule = planned.get(mapping.className);\n const conflict = existing\n ? declarationsOf(existing.text).find((identifier) => identifier !== existing)\n : plannedModule === undefined\n ? declarationsOf(mapping.className)[0]\n : undefined;\n\n if (conflict) {\n report({\n node: uses.calls[0] ?? conflict,\n reason: `the name \\`${conflict.text}\\` is already declared in this file (line ${lineOf(conflict)}), so \\`${mapping.oldName}\\` is left; rewrite its calls by hand as ${target}`,\n });\n continue;\n }\n\n if (!existing && plannedModule !== undefined && !classModules.includes(plannedModule)) {\n report({\n node: uses.calls[0] ?? binding.declaration,\n reason: `\\`${mapping.className}\\` would be imported from both ${plannedModule} and ${classModules[0]}; rewrite the calls of \\`${mapping.oldName}\\` by hand as ${target}`,\n });\n continue;\n }\n\n classReference = existing?.text ?? mapping.className;\n needsImport = !existing && plannedModule === undefined;\n }\n\n let count = 0;\n let left = uses.values.length;\n\n for (const call of uses.calls) {\n const problem = NamespaceFunctions.checkCall({ typescript, call, mapping });\n if (problem) {\n left += 1;\n report({ node: call, reason: `${problem}; rewrite it by hand as ${target}` });\n continue;\n }\n\n edits.push(\n ...NamespaceFunctions.planCall({\n typescript,\n sourceFile,\n call,\n mapping,\n callee: `${classReference}.${mapping.method}`,\n }),\n );\n count += 1;\n }\n\n rewritten += count;\n if (count === 0) {\n continue;\n }\n\n if (needsImport) {\n const sameDeclaration =\n binding.specifier && classModules.includes(binding.module)\n ? binding.declaration\n : undefined;\n const declaration =\n sameDeclaration ??\n NamespaceFunctions.findNamedImport({ typescript, sourceFile, modules: classModules });\n\n if (declaration) {\n additions.set(\n declaration,\n new Set([...(additions.get(declaration) ?? []), mapping.className]),\n );\n planned.set(\n mapping.className,\n sameDeclaration ? binding.module : NamespaceFunctions.moduleOf({ declaration }),\n );\n } else {\n const module = classModules[0] ?? binding.module;\n const entry = newImports.get(module) ?? {\n anchor: binding.declaration,\n names: new Set<string>(),\n };\n entry.names.add(mapping.className);\n newImports.set(module, entry);\n planned.set(mapping.className, module);\n }\n }\n\n if (binding.specifier && left === 0) {\n removals.add(binding.specifier);\n trimmed.add(binding.declaration);\n }\n }\n\n if (rewritten === 0) {\n return { output: source, changed: false, rewritten: 0, reports };\n }\n\n for (const declaration of new Set([...additions.keys(), ...trimmed])) {\n edits.push(\n ...NamespaceFunctions.planImport({\n typescript,\n sourceFile,\n declaration,\n removals,\n additions: [...(additions.get(declaration) ?? [])],\n report,\n }),\n );\n }\n\n for (const [module, { anchor, names }] of newImports) {\n const quote = source.charAt(anchor.moduleSpecifier.getStart(sourceFile));\n edits.push({\n start: anchor.getStart(sourceFile),\n end: anchor.getStart(sourceFile),\n text: `import { ${[...names].join(', ')} } from ${quote}${module}${quote};\\n`,\n });\n }\n\n // At one position a replacement (the longer range) is applied before an insertion, so the\n // inserted key of an outer call lands in front of the rewritten callee of an inner one.\n let output = source;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return { output, changed: output !== source, rewritten, reports };\n }\n\n /** The named and namespace imports of an old name; reports the type-only imports and the re-exports. */\n private static findBindings(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n byModule: Map<string, INamespaceMapping[]>;\n report: (reportOpts: { node: ts.Node; reason: string }) => void;\n }): IBinding[] {\n const { typescript, sourceFile, byModule, report } = opts;\n const bindings: IBinding[] = [];\n\n for (const statement of sourceFile.statements) {\n if (\n typescript.isExportDeclaration(statement) &&\n statement.moduleSpecifier &&\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n statement.exportClause &&\n typescript.isNamedExports(statement.exportClause)\n ) {\n const candidates = byModule.get(statement.moduleSpecifier.text) ?? [];\n for (const element of statement.exportClause.elements) {\n const name = (element.propertyName ?? element.name).text;\n const mapping = candidates.find((candidate) => candidate.oldName === name);\n if (mapping) {\n report({\n node: element,\n reason: `re-exports \\`${name}\\`; re-export ${mapping.className} as well, by hand (the old name goes away in 0.5)`,\n });\n }\n }\n continue;\n }\n\n if (\n !typescript.isImportDeclaration(statement) ||\n !typescript.isStringLiteral(statement.moduleSpecifier) ||\n !statement.importClause\n ) {\n continue;\n }\n\n const module = statement.moduleSpecifier.text;\n const candidates = byModule.get(module);\n const clause = statement.importClause;\n const named = clause.namedBindings;\n if (!candidates || !named) {\n continue;\n }\n\n if (typescript.isNamespaceImport(named)) {\n if (clause.isTypeOnly) {\n continue;\n }\n\n for (const mapping of candidates) {\n bindings.push({\n mapping,\n declaration: statement,\n module,\n local: named.name.text,\n declarationName: named.name,\n });\n }\n continue;\n }\n\n for (const element of named.elements) {\n const imported = (element.propertyName ?? element.name).text;\n const mapping = candidates.find((candidate) => candidate.oldName === imported);\n if (!mapping) {\n continue;\n }\n\n if (clause.isTypeOnly || element.isTypeOnly) {\n report({\n node: element,\n reason: `\\`${imported}\\` is imported as a type only; change it by hand to \\`typeof ${mapping.className}.${mapping.method}\\``,\n });\n continue;\n }\n\n bindings.push({\n mapping,\n declaration: statement,\n module,\n local: element.name.text,\n declarationName: element.name,\n specifier: element,\n });\n }\n }\n\n return bindings;\n }\n\n /** Every identifier of the file by its text; JSDoc is not walked, so a `{@link name}` never counts. */\n private static collectIdentifiers(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n }): Map<string, ts.Identifier[]> {\n const { typescript, sourceFile } = opts;\n const identifiers = new Map<string, ts.Identifier[]>();\n\n const walk = (node: ts.Node): void => {\n if (typescript.isIdentifier(node)) {\n identifiers.set(node.text, [...(identifiers.get(node.text) ?? []), node]);\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(sourceFile);\n return identifiers;\n }\n\n /** The calls of the old name, and every other use of it. */\n private static findUses(opts: {\n typescript: TTypeScript;\n binding: IBinding;\n identifiers: Map<string, ts.Identifier[]>;\n }): IUses {\n const { typescript, binding, identifiers } = opts;\n const uses: IUses = { calls: [], values: [] };\n\n for (const identifier of identifiers.get(binding.local) ?? []) {\n if (\n identifier === binding.declarationName ||\n !NamespaceFunctions.isReference({ typescript, identifier })\n ) {\n continue;\n }\n\n if (!binding.specifier) {\n const parent = identifier.parent;\n const isMember =\n typescript.isPropertyAccessExpression(parent) &&\n parent.expression === identifier &&\n parent.name.text === binding.mapping.oldName;\n\n if (isMember) {\n const call = parent.parent;\n if (typescript.isCallExpression(call) && call.expression === parent) {\n uses.calls.push(call);\n } else {\n uses.values.push(parent);\n }\n continue;\n }\n\n if (\n typescript.isQualifiedName(parent) &&\n parent.left === identifier &&\n parent.right.text === binding.mapping.oldName\n ) {\n uses.values.push(parent);\n }\n continue;\n }\n\n const parent = identifier.parent;\n if (typescript.isCallExpression(parent) && parent.expression === identifier) {\n uses.calls.push(parent);\n continue;\n }\n\n uses.values.push(identifier);\n }\n\n return uses;\n }\n\n /** The identifier names a declaration: a variable, a parameter, a function, a class, an import, a type. */\n private static isDeclarationName(opts: {\n typescript: TTypeScript;\n identifier: ts.Identifier;\n }): boolean {\n const { typescript, identifier } = opts;\n const parent = identifier.parent;\n\n if (\n typescript.isVariableDeclaration(parent) ||\n typescript.isParameter(parent) ||\n typescript.isBindingElement(parent) ||\n typescript.isFunctionDeclaration(parent) ||\n typescript.isFunctionExpression(parent) ||\n typescript.isClassDeclaration(parent) ||\n typescript.isClassExpression(parent) ||\n typescript.isEnumDeclaration(parent) ||\n typescript.isInterfaceDeclaration(parent) ||\n typescript.isTypeAliasDeclaration(parent) ||\n typescript.isModuleDeclaration(parent) ||\n typescript.isImportSpecifier(parent) ||\n typescript.isImportClause(parent) ||\n typescript.isNamespaceImport(parent) ||\n typescript.isImportEqualsDeclaration(parent) ||\n typescript.isTypeParameterDeclaration(parent)\n ) {\n return parent.name === identifier;\n }\n\n return false;\n }\n\n /** The identifier reads a binding: not a property name, a label, a declaration or a lowercase JSX tag. */\n private static isReference(opts: {\n typescript: TTypeScript;\n identifier: ts.Identifier;\n }): boolean {\n const { typescript, identifier } = opts;\n const parent = identifier.parent;\n\n if (NamespaceFunctions.isDeclarationName({ typescript, identifier })) {\n return false;\n }\n\n if (typescript.isPropertyAccessExpression(parent) || typescript.isQualifiedName(parent)) {\n return typescript.isPropertyAccessExpression(parent)\n ? parent.name !== identifier\n : parent.right !== identifier;\n }\n\n if (\n typescript.isPropertyAssignment(parent) ||\n typescript.isPropertyDeclaration(parent) ||\n typescript.isPropertySignature(parent) ||\n typescript.isMethodDeclaration(parent) ||\n typescript.isMethodSignature(parent) ||\n typescript.isGetAccessorDeclaration(parent) ||\n typescript.isSetAccessorDeclaration(parent) ||\n typescript.isEnumMember(parent) ||\n typescript.isJsxAttribute(parent)\n ) {\n return parent.name !== identifier;\n }\n\n if (typescript.isBindingElement(parent)) {\n return parent.propertyName !== identifier;\n }\n\n if (typescript.isExportSpecifier(parent)) {\n return (\n !parent.parent.parent.moduleSpecifier && (parent.propertyName ?? parent.name) === identifier\n );\n }\n\n if (\n typescript.isLabeledStatement(parent) ||\n typescript.isBreakOrContinueStatement(parent) ||\n typescript.isMetaProperty(parent)\n ) {\n return false;\n }\n\n if (\n (typescript.isJsxOpeningElement(parent) ||\n typescript.isJsxSelfClosingElement(parent) ||\n typescript.isJsxClosingElement(parent)) &&\n parent.tagName === identifier\n ) {\n return !/^[a-z]/.test(identifier.text);\n }\n\n return true;\n }\n\n /** Why a call cannot be rewritten, or `undefined` when it can. */\n private static checkCall(opts: {\n typescript: TTypeScript;\n call: ts.CallExpression;\n mapping: INamespaceMapping;\n }): string | undefined {\n const { typescript, call, mapping } = opts;\n const { params, restKey, oldName } = mapping;\n const count = call.arguments.length;\n\n if (mapping.keepsOptions) {\n return undefined;\n }\n\n if (call.arguments.some((argument) => typescript.isSpreadElement(argument))) {\n return `this call of \\`${oldName}\\` has a spread argument`;\n }\n\n const required = params.reduce(\n (last, parameter, index) => (parameter.optional ? last : index + 1),\n 0,\n );\n if (count < required) {\n return `this call of \\`${oldName}\\` passes ${count} argument(s), fewer than the ${required} it needs`;\n }\n\n if (restKey === undefined && count > params.length) {\n return `this call of \\`${oldName}\\` passes ${count} argument(s), more than its ${params.length} parameter(s)`;\n }\n\n return undefined;\n }\n\n /** The edits that turn one call into the class form; the arguments keep their text and comments. */\n private static planCall(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n call: ts.CallExpression;\n mapping: INamespaceMapping;\n callee: string;\n }): IEdit[] {\n const { typescript, sourceFile, call, mapping, callee } = opts;\n const { params, restKey } = mapping;\n const edits: IEdit[] = [\n { start: call.expression.getStart(sourceFile), end: call.expression.end, text: callee },\n ];\n\n if (call.questionDotToken) {\n edits.push({\n start: call.questionDotToken.getStart(sourceFile),\n end: call.questionDotToken.end,\n text: '',\n });\n }\n\n if (mapping.keepsOptions) {\n return edits;\n }\n\n const argumentList = [...call.arguments];\n if (argumentList.length === 0) {\n if (params.length > 0 || restKey !== undefined) {\n const text = restKey === undefined ? '{}' : `{ ${restKey}: [] }`;\n edits.push({ start: call.arguments.pos, end: call.arguments.pos, text });\n }\n return edits;\n }\n\n const insert = (insertOpts: { at: number; text: string }) => {\n if (insertOpts.text !== '') {\n edits.push({ start: insertOpts.at, end: insertOpts.at, text: insertOpts.text });\n }\n };\n\n const positional = argumentList.slice(0, params.length);\n const rest = argumentList.slice(params.length);\n\n positional.forEach((argument, index) => {\n const key = params[index]?.key ?? '';\n const isShorthand = typescript.isIdentifier(argument) && argument.text === key;\n insert({\n at: argument.getStart(sourceFile),\n text: `${index === 0 ? '{ ' : ''}${isShorthand ? '' : `${key}: `}`,\n });\n });\n\n const first = rest[0];\n const last = argumentList[argumentList.length - 1];\n let suffix = ' }';\n\n if (first && restKey !== undefined) {\n insert({\n at: first.getStart(sourceFile),\n text: `${positional.length === 0 ? '{ ' : ''}${restKey}: [`,\n });\n suffix = '] }';\n } else if (restKey !== undefined) {\n suffix = `, ${restKey}: [] }`;\n }\n\n insert({ at: last?.end ?? call.arguments.end, text: suffix });\n return edits;\n }\n\n /** The local name of a value import of the class from one of `modules`. */\n private static findClassImport(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n className: string;\n modules: string[];\n }): ts.Identifier | undefined {\n const { typescript, sourceFile, className, modules } = opts;\n\n for (const statement of sourceFile.statements) {\n const declaration = NamespaceFunctions.asValueImport({ typescript, statement, modules });\n const named = declaration?.importClause?.namedBindings;\n if (!named || !typescript.isNamedImports(named)) {\n continue;\n }\n\n const element = named.elements.find(\n (candidate) =>\n !candidate.isTypeOnly && (candidate.propertyName ?? candidate.name).text === className,\n );\n if (element) {\n return element.name;\n }\n }\n\n return undefined;\n }\n\n /** The first value import with braces from one of `modules`, to add a class to. */\n private static findNamedImport(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n modules: string[];\n }): ts.ImportDeclaration | undefined {\n const { typescript, sourceFile, modules } = opts;\n\n for (const statement of sourceFile.statements) {\n const declaration = NamespaceFunctions.asValueImport({ typescript, statement, modules });\n const named = declaration?.importClause?.namedBindings;\n if (declaration && named && typescript.isNamedImports(named)) {\n return declaration;\n }\n }\n\n return undefined;\n }\n\n /** `statement` as an import that is not `import type`, from one of `modules`. */\n private static asValueImport(opts: {\n typescript: TTypeScript;\n statement: ts.Statement;\n modules: string[];\n }): ts.ImportDeclaration | undefined {\n const { typescript, statement, modules } = opts;\n\n if (\n typescript.isImportDeclaration(statement) &&\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n modules.includes(statement.moduleSpecifier.text) &&\n statement.importClause &&\n !statement.importClause.isTypeOnly\n ) {\n return statement;\n }\n\n return undefined;\n }\n\n private static moduleOf(opts: { declaration: ts.ImportDeclaration }): string {\n const specifier = opts.declaration.moduleSpecifier;\n return 'text' in specifier && typeof specifier.text === 'string' ? specifier.text : '';\n }\n\n /**\n * The edit of one import's braces: the removed old names go, the added classes take the place of\n * the first removed one. Braces that hold a comment are not rewritten: the classes are appended\n * and the old names stay, reported. An import left with nothing is removed.\n */\n private static planImport(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n declaration: ts.ImportDeclaration;\n removals: Set<ts.ImportSpecifier>;\n additions: string[];\n report: (reportOpts: { node: ts.Node; reason: string }) => void;\n }): IEdit[] {\n const { typescript, sourceFile, declaration, removals, additions, report } = opts;\n const clause = declaration.importClause;\n const named = clause?.namedBindings;\n if (!clause || !named || !typescript.isNamedImports(named)) {\n return [];\n }\n\n const source = sourceFile.text;\n const elements = [...named.elements];\n const braces = source.slice(named.getStart(sourceFile), named.end);\n\n if (/\\/\\*|\\/\\//.test(braces)) {\n for (const element of elements.filter((candidate) => removals.has(candidate))) {\n report({\n node: element,\n reason: `the braces of this import hold a comment, so \\`${element.name.text}\\` stays imported; remove it by hand`,\n });\n }\n\n const last = elements[elements.length - 1];\n if (!last || additions.length === 0) {\n return [];\n }\n\n return [{ start: last.end, end: last.end, text: `, ${additions.join(', ')}` }];\n }\n\n const items: string[] = [];\n let isPlaced = false;\n for (const element of elements) {\n if (!removals.has(element)) {\n items.push(element.getText(sourceFile));\n continue;\n }\n\n if (!isPlaced) {\n items.push(...additions);\n isPlaced = true;\n }\n }\n\n if (!isPlaced) {\n items.push(...additions);\n }\n\n if (items.length > 0) {\n const start = named.getStart(sourceFile);\n const lineStart = source.lastIndexOf('\\n', declaration.getStart(sourceFile)) + 1;\n const indent = /^[ \\t]*/.exec(source.slice(lineStart))?.[0] ?? '';\n const text = braces.includes('\\n')\n ? `{\\n${indent} ${items.join(`,\\n${indent} `)},\\n${indent}}`\n : `{ ${items.join(', ')} }`;\n\n return [{ start, end: named.end, text }];\n }\n\n if (clause.name) {\n return [{ start: clause.name.end, end: named.end, text: '' }];\n }\n\n const start = declaration.getStart(sourceFile);\n const newline = /^\\r?\\n/.exec(source.slice(declaration.end))?.[0] ?? '';\n return [{ start, end: declaration.end + newline.length, text: '' }];\n }\n\n /** The call the old one becomes, for a report: `ParseUtility.toFloat({ input, digit })`. */\n private static describeTarget(opts: { mapping: INamespaceMapping }): string {\n const { className, method, params, restKey } = opts.mapping;\n const keys = [...params.map((parameter) => parameter.key), ...(restKey ? [restKey] : [])];\n return keys.length === 0\n ? `${className}.${method}()`\n : `${className}.${method}({ ${keys.join(', ')} })`;\n }\n}\n"]}
|
package/dist/cli/index.js
CHANGED
|
@@ -15,6 +15,8 @@ Commands:
|
|
|
15
15
|
codemod model-settings [paths...] [--write] move @model settings to the grouped shape (dry run unless --write)
|
|
16
16
|
codemod drop-redundant-casts [paths...] remove \`as X\` casts the compiler no longer needs (dry run unless --write)
|
|
17
17
|
codemod const-classes [paths...] turn a string-literal union into a const class (dry run unless --write)
|
|
18
|
+
codemod async-style [paths...] apply the async-style lint fixers and list the rest (dry run unless --write)
|
|
19
|
+
codemod namespace-functions [paths...] move calls of a function that moved into a class to the class form (dry run unless --write)
|
|
18
20
|
|
|
19
21
|
Run \`devz clean --help\` or \`devz codemod --help\` for a command's options.`;
|
|
20
22
|
const main = async (opts) => {
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AACA,mCAAuC;AACvC,mCAAuC;AACvC,uCAA2C;AAC3C,iCAAqC;AAErC,MAAM,KAAK,GAAG
|
|
1
|
+
{"version":3,"file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AAC;AACX,CAAC,CAAC;AAEF,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CACxC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpC,CAAC,KAAc,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC","sourcesContent":["#!/usr/bin/env bun\nimport { CheckCommand } from './check';\nimport { CleanCommand } from './clean';\nimport { CodemodCommand } from './codemod';\nimport { LintCommand } from './lint';\n\nconst USAGE = `Usage: devz <command> [options]\n\nCommands:\n lint [--fix] [files] oxlint, ESLint and the formatter; --fix writes\n check purity --claims <file> [package] [--json] probe every entry claimed browser-pure (needs a build)\n check module-cycles | split-report | catalog shared repository gates; devz check --help lists their options\n clean remove dist, node_modules/.cache and *.tsbuildinfo\n codemod model-settings [paths...] [--write] move @model settings to the grouped shape (dry run unless --write)\n codemod drop-redundant-casts [paths...] remove \\`as X\\` casts the compiler no longer needs (dry run unless --write)\n codemod const-classes [paths...] turn a string-literal union into a const class (dry run unless --write)\n codemod async-style [paths...] apply the async-style lint fixers and list the rest (dry run unless --write)\n codemod namespace-functions [paths...] move calls of a function that moved into a class to the class form (dry run unless --write)\n\nRun \\`devz clean --help\\` or \\`devz codemod --help\\` for a command's options.`;\n\nconst main = async (opts: { argv: string[] }): Promise<number> => {\n const [command, ...args] = opts.argv;\n\n if (command === undefined || command === '--help' || command === '-h') {\n console.log(USAGE);\n return 0;\n }\n\n if (command === 'lint') {\n return LintCommand.run({ root: process.cwd(), args });\n }\n\n if (command === 'check') {\n return CheckCommand.run({ root: process.cwd(), args });\n }\n\n if (command === 'clean') {\n return CleanCommand.run({ root: process.cwd(), args });\n }\n\n if (command === 'codemod') {\n return CodemodCommand.run({ root: process.cwd(), args });\n }\n\n console.error(`devz: unknown command \"${command ?? ''}\"\\n${USAGE}`);\n return 1;\n};\n\nmain({ argv: process.argv.slice(2) }).then(\n (exitCode) => process.exit(exitCode),\n (error: unknown) => {\n console.error(error);\n process.exit(1);\n },\n);\n"]}
|
package/dist/compilers/bun.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare class BunCompiler {
|
|
|
3
3
|
/**
|
|
4
4
|
* `plugins` is a parameter, never resolved here - `dev-configs` sits below every other IGNIS
|
|
5
5
|
* package (see the Makefile chain) and must not import a plugin factory such as
|
|
6
|
-
* `
|
|
6
|
+
* `PlatformaticKafkaPlugins.build()` from `helpers`, which would invert that chain.
|
|
7
7
|
*/
|
|
8
8
|
static compile(opts?: {
|
|
9
9
|
entrypoint?: string;
|
package/dist/compilers/bun.js
CHANGED
|
@@ -9,7 +9,7 @@ class BunCompiler {
|
|
|
9
9
|
/**
|
|
10
10
|
* `plugins` is a parameter, never resolved here - `dev-configs` sits below every other IGNIS
|
|
11
11
|
* package (see the Makefile chain) and must not import a plugin factory such as
|
|
12
|
-
* `
|
|
12
|
+
* `PlatformaticKafkaPlugins.build()` from `helpers`, which would invert that chain.
|
|
13
13
|
*/
|
|
14
14
|
static async compile(opts = {}) {
|
|
15
15
|
const { entrypoint = DEFAULT_ENTRYPOINT, workers = [], outfile = DEFAULT_OUTFILE, target = Bun.env.BUN_TARGET ?? DEFAULT_COMPILE_TARGET, plugins = [], define = {}, check = false, } = opts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.js","sourceRoot":"","sources":["../../src/compilers/bun.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAC7C,MAAM,eAAe,GAAG,YAAY,CAAC;AACrC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAE/C,gHAAgH;AAChH,MAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,OAWI,EAAE;QAEN,MAAM,EACJ,UAAU,GAAG,kBAAkB,EAC/B,OAAO,GAAG,EAAE,EACZ,OAAO,GAAG,eAAe,EACzB,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,IAAI,sBAAsB,EACrD,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,EAAE,EACX,KAAK,GAAG,KAAK,GACd,GAAG,IAAI,CAAC;QAET,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC;YAC5B,WAAW,EAAE,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC;YACrC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE;gBACP,MAAM,EAAE,MAAiC;gBACzC,OAAO;aACR;YACD,MAAM;YACN,OAAO;YACP,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,4FAA4F;YAC5F,8FAA8F;YAC9F,sGAAsG;YACtG,MAAM,IAAI,KAAK,CACb;gBACE,gDAAgD,UAAU,IAAI;gBAC9D,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;aAC5D,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAzDD,kCAyDC","sourcesContent":["const DEFAULT_ENTRYPOINT = './dist/index.js';\nconst DEFAULT_OUTFILE = './dist/bin';\nconst DEFAULT_COMPILE_TARGET = 'bun-linux-x64';\n\n/** Bundles and compiles a single Bun executable: minified, linked sourcemaps, target read from `BUN_TARGET`. */\nexport class BunCompiler {\n /**\n * `plugins` is a parameter, never resolved here - `dev-configs` sits below every other IGNIS\n * package (see the Makefile chain) and must not import a plugin factory such as\n * `
|
|
1
|
+
{"version":3,"file":"bun.js","sourceRoot":"","sources":["../../src/compilers/bun.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAC7C,MAAM,eAAe,GAAG,YAAY,CAAC;AACrC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAE/C,gHAAgH;AAChH,MAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,OAWI,EAAE;QAEN,MAAM,EACJ,UAAU,GAAG,kBAAkB,EAC/B,OAAO,GAAG,EAAE,EACZ,OAAO,GAAG,eAAe,EACzB,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,IAAI,sBAAsB,EACrD,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,EAAE,EACX,KAAK,GAAG,KAAK,GACd,GAAG,IAAI,CAAC;QAET,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC;YAC5B,WAAW,EAAE,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC;YACrC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE;gBACP,MAAM,EAAE,MAAiC;gBACzC,OAAO;aACR;YACD,MAAM;YACN,OAAO;YACP,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,4FAA4F;YAC5F,8FAA8F;YAC9F,sGAAsG;YACtG,MAAM,IAAI,KAAK,CACb;gBACE,gDAAgD,UAAU,IAAI;gBAC9D,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;aAC5D,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAzDD,kCAyDC","sourcesContent":["const DEFAULT_ENTRYPOINT = './dist/index.js';\nconst DEFAULT_OUTFILE = './dist/bin';\nconst DEFAULT_COMPILE_TARGET = 'bun-linux-x64';\n\n/** Bundles and compiles a single Bun executable: minified, linked sourcemaps, target read from `BUN_TARGET`. */\nexport class BunCompiler {\n /**\n * `plugins` is a parameter, never resolved here - `dev-configs` sits below every other IGNIS\n * package (see the Makefile chain) and must not import a plugin factory such as\n * `PlatformaticKafkaPlugins.build()` from `helpers`, which would invert that chain.\n */\n static async compile(\n opts: {\n entrypoint?: string;\n /** Bun Worker files the entrypoint starts (`new Worker('./x.worker.ts')`): compiled into the same binary. */\n workers?: string[];\n outfile?: string;\n target?: string;\n plugins?: Bun.BunPlugin[];\n /** Compile-time constants: each key is replaced by its value, a JSON-encoded expression, wherever the bundle reads it. */\n define?: Record<string, string>;\n /** Type-check the bundle first; a type error stops the compile. */\n check?: boolean;\n } = {},\n ): Promise<void> {\n const {\n entrypoint = DEFAULT_ENTRYPOINT,\n workers = [],\n outfile = DEFAULT_OUTFILE,\n target = Bun.env.BUN_TARGET ?? DEFAULT_COMPILE_TARGET,\n plugins = [],\n define = {},\n check = false,\n } = opts;\n\n const built = await Bun.build({\n entrypoints: [entrypoint, ...workers],\n target: 'bun',\n minify: { whitespace: true, syntax: true },\n sourcemap: 'linked',\n throw: false,\n compile: {\n target: target as Bun.Build.CompileTarget,\n outfile,\n },\n define,\n plugins,\n check,\n });\n\n if (!built.success) {\n // `getError` lives in `inversion`, which depends on `dev-configs` - importing it here would\n // create a circular workspace dependency, so a failed compile throws a plain `Error` instead.\n // eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\n throw new Error(\n [\n `[BunCompiler] compile failed for entrypoint \"${entrypoint}\":`,\n ...built.logs.map((log) => `[${log.level}] ${log.message}`),\n ].join('\\n'),\n );\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Rule, SourceCode } from 'eslint';
|
|
2
|
+
/** The shared parts of the two `await` rules: where a statement can go before another, what may run first, fresh names. */
|
|
3
|
+
export declare class AwaitSupport {
|
|
4
|
+
static parentOf(opts: {
|
|
5
|
+
node: unknown;
|
|
6
|
+
}): unknown;
|
|
7
|
+
/** An ESTree node of the lint run: it has a `type` and a `range`. */
|
|
8
|
+
static isNode(value: unknown): value is Rule.Node;
|
|
9
|
+
static rangeOf(opts: {
|
|
10
|
+
node: unknown;
|
|
11
|
+
}): [number, number] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The statement that can take a `const` in front of it so that `awaitNode` is evaluated first, or `undefined`
|
|
14
|
+
* when hoisting would change what runs: the `await` sits in a branch (`?:`, the right of `&&`, `||`, `??`),
|
|
15
|
+
* in a loop test or update, in an unbraced `if` branch, in an optional chain, or in an arrow expression body.
|
|
16
|
+
*/
|
|
17
|
+
static hoistTarget(opts: {
|
|
18
|
+
awaitNode: unknown;
|
|
19
|
+
}): Rule.Node | undefined;
|
|
20
|
+
static isPure(opts: {
|
|
21
|
+
node: unknown;
|
|
22
|
+
}): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether something that does more than read a value runs, inside `statement`, before `awaitNode` does.
|
|
25
|
+
* Hoisting the `await` in front of the statement would then run it first.
|
|
26
|
+
*/
|
|
27
|
+
static hasEffectBefore(opts: {
|
|
28
|
+
statement: Rule.Node;
|
|
29
|
+
awaitNode: unknown;
|
|
30
|
+
sourceCode: SourceCode;
|
|
31
|
+
}): boolean;
|
|
32
|
+
/** The leading whitespace of the line a node starts on. */
|
|
33
|
+
static indentOf(opts: {
|
|
34
|
+
node: Rule.Node;
|
|
35
|
+
sourceCode: SourceCode;
|
|
36
|
+
}): string;
|
|
37
|
+
/** The nearest function or the program that holds `node`: the scope a new name must be free in. */
|
|
38
|
+
static scopeNodeOf(opts: {
|
|
39
|
+
node: Rule.Node;
|
|
40
|
+
}): Rule.Node;
|
|
41
|
+
/**
|
|
42
|
+
* The outermost function that holds `node` (the program when no function does): the one namespace a hoisted name
|
|
43
|
+
* must be unique in. A name that is free in the nearest function only could still shadow, or be shadowed by, the
|
|
44
|
+
* name another fix hoisted in a function around it or a block inside it.
|
|
45
|
+
*/
|
|
46
|
+
static outermostScopeOf(opts: {
|
|
47
|
+
node: Rule.Node;
|
|
48
|
+
}): Rule.Node;
|
|
49
|
+
/**
|
|
50
|
+
* The names handed out in this lint pass, per outermost scope. They are shared by every rule that hoists a name: the
|
|
51
|
+
* rules run in the same pass over the same text and their fixes are applied together, so two rules that each
|
|
52
|
+
* remembered their own names both handed out `result`. A `SourceCode` lasts for one pass of one file.
|
|
53
|
+
*/
|
|
54
|
+
private static readonly PASS_NAMES;
|
|
55
|
+
/**
|
|
56
|
+
* `base`, or `base2`, `base3`... the first word that does not appear in the outermost function (or program) holding
|
|
57
|
+
* `node` and that no rule has handed out already in this lint pass: no two fixes of one pass declare the same name,
|
|
58
|
+
* and none declares a name that is in scope anywhere around or inside the place it is hoisted to.
|
|
59
|
+
*/
|
|
60
|
+
static freshName(opts: {
|
|
61
|
+
node: Rule.Node;
|
|
62
|
+
base: string;
|
|
63
|
+
sourceCode: SourceCode;
|
|
64
|
+
}): string;
|
|
65
|
+
/**
|
|
66
|
+
* The range to replace with the name that stands for an `await`: the `await` itself, widened over the parentheses
|
|
67
|
+
* around it when they only grouped it (`(await f()).x`, `!(await f())`).
|
|
68
|
+
*/
|
|
69
|
+
static replaceRangeOf(opts: {
|
|
70
|
+
awaitNode: Rule.Node;
|
|
71
|
+
sourceCode: SourceCode;
|
|
72
|
+
}): [number, number];
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=await-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await-support.d.ts","sourceRoot":"","sources":["../../../src/linters/house/await-support.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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IG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAwD;IAE1F;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE,GAAG,MAAM;IAmBzF;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAoBhG"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AwaitSupport = void 0;
|
|
4
|
+
const common_1 = require("./common");
|
|
5
|
+
const STATEMENT_LISTS = new Set(['BlockStatement', 'Program', 'StaticBlock', 'SwitchCase']);
|
|
6
|
+
const FUNCTION_TYPES = new Set([
|
|
7
|
+
'FunctionDeclaration',
|
|
8
|
+
'FunctionExpression',
|
|
9
|
+
'ArrowFunctionExpression',
|
|
10
|
+
]);
|
|
11
|
+
/** The child of a statement that runs exactly once, before anything else of that statement. */
|
|
12
|
+
const HEAD_FIELD = {
|
|
13
|
+
IfStatement: 'test',
|
|
14
|
+
SwitchStatement: 'discriminant',
|
|
15
|
+
ForOfStatement: 'right',
|
|
16
|
+
ForInStatement: 'right',
|
|
17
|
+
ExpressionStatement: 'expression',
|
|
18
|
+
ReturnStatement: 'argument',
|
|
19
|
+
ThrowStatement: 'argument',
|
|
20
|
+
};
|
|
21
|
+
/** Nodes that evaluate to a value without doing anything else, so running them later or earlier changes nothing. */
|
|
22
|
+
const PURE_LEAVES = new Set([
|
|
23
|
+
'Identifier',
|
|
24
|
+
'Literal',
|
|
25
|
+
'ThisExpression',
|
|
26
|
+
'ArrowFunctionExpression',
|
|
27
|
+
'FunctionExpression',
|
|
28
|
+
'PrivateIdentifier',
|
|
29
|
+
]);
|
|
30
|
+
/** Wrappers whose parentheses around an `await` carry no meaning once the `await` is a name. */
|
|
31
|
+
const GROUPING_PARENTS = new Set([
|
|
32
|
+
'MemberExpression',
|
|
33
|
+
'TSAsExpression',
|
|
34
|
+
'TSSatisfiesExpression',
|
|
35
|
+
'TSNonNullExpression',
|
|
36
|
+
'UnaryExpression',
|
|
37
|
+
'BinaryExpression',
|
|
38
|
+
'SpreadElement',
|
|
39
|
+
'ArrayExpression',
|
|
40
|
+
]);
|
|
41
|
+
/** The shared parts of the two `await` rules: where a statement can go before another, what may run first, fresh names. */
|
|
42
|
+
class AwaitSupport {
|
|
43
|
+
static parentOf(opts) {
|
|
44
|
+
return common_1.AstNode.readField({ node: opts.node, key: 'parent' });
|
|
45
|
+
}
|
|
46
|
+
/** An ESTree node of the lint run: it has a `type` and a `range`. */
|
|
47
|
+
static isNode(value) {
|
|
48
|
+
return (common_1.AstNode.getType({ node: value }) !== undefined &&
|
|
49
|
+
AwaitSupport.rangeOf({ node: value }) !== undefined);
|
|
50
|
+
}
|
|
51
|
+
static rangeOf(opts) {
|
|
52
|
+
const range = common_1.AstNode.readField({ node: opts.node, key: 'range' });
|
|
53
|
+
return Array.isArray(range) && typeof range[0] === 'number' && typeof range[1] === 'number'
|
|
54
|
+
? [range[0], range[1]]
|
|
55
|
+
: undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The statement that can take a `const` in front of it so that `awaitNode` is evaluated first, or `undefined`
|
|
59
|
+
* when hoisting would change what runs: the `await` sits in a branch (`?:`, the right of `&&`, `||`, `??`),
|
|
60
|
+
* in a loop test or update, in an unbraced `if` branch, in an optional chain, or in an arrow expression body.
|
|
61
|
+
*/
|
|
62
|
+
static hoistTarget(opts) {
|
|
63
|
+
let child = opts.awaitNode;
|
|
64
|
+
let ancestor = AwaitSupport.parentOf({ node: child });
|
|
65
|
+
while (ancestor) {
|
|
66
|
+
const type = common_1.AstNode.getType({ node: ancestor }) ?? '';
|
|
67
|
+
if (FUNCTION_TYPES.has(type) || type === 'ChainExpression') {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
if (type === 'ConditionalExpression' &&
|
|
71
|
+
common_1.AstNode.readField({ node: ancestor, key: 'test' }) !== child) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
if (type === 'LogicalExpression' &&
|
|
75
|
+
common_1.AstNode.readField({ node: ancestor, key: 'left' }) !== child) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
if (type === 'AssignmentExpression' &&
|
|
79
|
+
['??=', '||=', '&&='].includes(String(common_1.AstNode.readField({ node: ancestor, key: 'operator' }))) &&
|
|
80
|
+
common_1.AstNode.readField({ node: ancestor, key: 'right' }) === child) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
if (type.endsWith('Statement') || type === 'VariableDeclaration') {
|
|
84
|
+
const head = HEAD_FIELD[type];
|
|
85
|
+
const isHead = type === 'VariableDeclaration' ||
|
|
86
|
+
common_1.AstNode.readField({ node: ancestor, key: head }) === child;
|
|
87
|
+
const outer = AwaitSupport.parentOf({ node: ancestor });
|
|
88
|
+
const isListed = STATEMENT_LISTS.has(common_1.AstNode.getType({ node: outer }) ?? '') &&
|
|
89
|
+
(type === 'VariableDeclaration' || head !== undefined);
|
|
90
|
+
return isHead && isListed && AwaitSupport.isNode(ancestor) ? ancestor : undefined;
|
|
91
|
+
}
|
|
92
|
+
child = ancestor;
|
|
93
|
+
ancestor = AwaitSupport.parentOf({ node: child });
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
static isPure(opts) {
|
|
98
|
+
const { node } = opts;
|
|
99
|
+
const type = common_1.AstNode.getType({ node }) ?? '';
|
|
100
|
+
const pure = (child) => AwaitSupport.isPure({ node: child });
|
|
101
|
+
const field = (key) => common_1.AstNode.readField({ node, key });
|
|
102
|
+
const all = (key) => {
|
|
103
|
+
const list = common_1.AstNode.readField({ node, key });
|
|
104
|
+
return Array.isArray(list) && list.every((entry) => entry === null || pure(entry));
|
|
105
|
+
};
|
|
106
|
+
if (PURE_LEAVES.has(type) ||
|
|
107
|
+
(type.startsWith('TS') &&
|
|
108
|
+
!['TSAsExpression', 'TSNonNullExpression', 'TSSatisfiesExpression'].includes(type))) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
const parts = new Map([
|
|
112
|
+
['TemplateLiteral', () => all('expressions')],
|
|
113
|
+
['MemberExpression', () => pure(field('object')) && pure(field('property'))],
|
|
114
|
+
['ArrayExpression', () => all('elements')],
|
|
115
|
+
['ObjectExpression', () => all('properties')],
|
|
116
|
+
['Property', () => pure(field('key')) && pure(field('value'))],
|
|
117
|
+
['SpreadElement', () => pure(field('argument'))],
|
|
118
|
+
['UnaryExpression', () => field('operator') !== 'delete' && pure(field('argument'))],
|
|
119
|
+
['BinaryExpression', () => pure(field('left')) && pure(field('right'))],
|
|
120
|
+
['LogicalExpression', () => pure(field('left')) && pure(field('right'))],
|
|
121
|
+
[
|
|
122
|
+
'ConditionalExpression',
|
|
123
|
+
() => ['test', 'consequent', 'alternate'].every((key) => pure(field(key))),
|
|
124
|
+
],
|
|
125
|
+
['TSAsExpression', () => pure(field('expression'))],
|
|
126
|
+
['TSNonNullExpression', () => pure(field('expression'))],
|
|
127
|
+
['TSSatisfiesExpression', () => pure(field('expression'))],
|
|
128
|
+
]);
|
|
129
|
+
return parts.get(type)?.() ?? false;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Whether something that does more than read a value runs, inside `statement`, before `awaitNode` does.
|
|
133
|
+
* Hoisting the `await` in front of the statement would then run it first.
|
|
134
|
+
*/
|
|
135
|
+
static hasEffectBefore(opts) {
|
|
136
|
+
const target = AwaitSupport.rangeOf({ node: opts.awaitNode });
|
|
137
|
+
if (!target) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
const visit = (node) => {
|
|
141
|
+
const range = AwaitSupport.rangeOf({ node });
|
|
142
|
+
if (!range) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (range[0] <= target[0] && target[1] <= range[1]) {
|
|
146
|
+
const keys = opts.sourceCode.visitorKeys[common_1.AstNode.getType({ node }) ?? ''] ?? [];
|
|
147
|
+
return keys.some((key) => {
|
|
148
|
+
const value = common_1.AstNode.readField({ node, key });
|
|
149
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
150
|
+
return entries.some((entry) => entry && entry !== opts.awaitNode && visit(entry));
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return range[1] <= target[0] && !AwaitSupport.isPure({ node });
|
|
154
|
+
};
|
|
155
|
+
return visit(opts.statement);
|
|
156
|
+
}
|
|
157
|
+
/** The leading whitespace of the line a node starts on. */
|
|
158
|
+
static indentOf(opts) {
|
|
159
|
+
const line = opts.sourceCode.lines[(opts.node.loc?.start.line ?? 1) - 1] ?? '';
|
|
160
|
+
return /^\s*/.exec(line)?.[0] ?? '';
|
|
161
|
+
}
|
|
162
|
+
/** The nearest function or the program that holds `node`: the scope a new name must be free in. */
|
|
163
|
+
static scopeNodeOf(opts) {
|
|
164
|
+
let current = opts.node;
|
|
165
|
+
let parent = AwaitSupport.parentOf({ node: current });
|
|
166
|
+
while (parent && !FUNCTION_TYPES.has(common_1.AstNode.getType({ node: parent }) ?? '')) {
|
|
167
|
+
if (!AwaitSupport.isNode(parent)) {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
current = parent;
|
|
171
|
+
parent = AwaitSupport.parentOf({ node: current });
|
|
172
|
+
}
|
|
173
|
+
return AwaitSupport.isNode(parent) ? parent : current;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The outermost function that holds `node` (the program when no function does): the one namespace a hoisted name
|
|
177
|
+
* must be unique in. A name that is free in the nearest function only could still shadow, or be shadowed by, the
|
|
178
|
+
* name another fix hoisted in a function around it or a block inside it.
|
|
179
|
+
*/
|
|
180
|
+
static outermostScopeOf(opts) {
|
|
181
|
+
let outermost;
|
|
182
|
+
let current = opts.node;
|
|
183
|
+
while (AwaitSupport.isNode(current)) {
|
|
184
|
+
if (FUNCTION_TYPES.has(common_1.AstNode.getType({ node: current }) ?? '')) {
|
|
185
|
+
outermost = current;
|
|
186
|
+
}
|
|
187
|
+
current = AwaitSupport.parentOf({ node: current });
|
|
188
|
+
}
|
|
189
|
+
return outermost ?? AwaitSupport.scopeNodeOf({ node: opts.node });
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The names handed out in this lint pass, per outermost scope. They are shared by every rule that hoists a name: the
|
|
193
|
+
* rules run in the same pass over the same text and their fixes are applied together, so two rules that each
|
|
194
|
+
* remembered their own names both handed out `result`. A `SourceCode` lasts for one pass of one file.
|
|
195
|
+
*/
|
|
196
|
+
static { this.PASS_NAMES = new WeakMap(); }
|
|
197
|
+
/**
|
|
198
|
+
* `base`, or `base2`, `base3`... the first word that does not appear in the outermost function (or program) holding
|
|
199
|
+
* `node` and that no rule has handed out already in this lint pass: no two fixes of one pass declare the same name,
|
|
200
|
+
* and none declares a name that is in scope anywhere around or inside the place it is hoisted to.
|
|
201
|
+
*/
|
|
202
|
+
static freshName(opts) {
|
|
203
|
+
const scope = AwaitSupport.outermostScopeOf({ node: opts.node });
|
|
204
|
+
const text = opts.sourceCode.getText(scope);
|
|
205
|
+
const pass = AwaitSupport.PASS_NAMES.get(opts.sourceCode) ?? new Map();
|
|
206
|
+
const reserved = pass.get(scope) ?? new Set();
|
|
207
|
+
AwaitSupport.PASS_NAMES.set(opts.sourceCode, pass);
|
|
208
|
+
for (let index = 1;; index += 1) {
|
|
209
|
+
const candidate = index === 1 ? opts.base : `${opts.base}${index}`;
|
|
210
|
+
if (!reserved.has(candidate) && !new RegExp(`\\b${candidate}\\b`).test(text)) {
|
|
211
|
+
reserved.add(candidate);
|
|
212
|
+
pass.set(scope, reserved);
|
|
213
|
+
return candidate;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* The range to replace with the name that stands for an `await`: the `await` itself, widened over the parentheses
|
|
219
|
+
* around it when they only grouped it (`(await f()).x`, `!(await f())`).
|
|
220
|
+
*/
|
|
221
|
+
static replaceRangeOf(opts) {
|
|
222
|
+
const { awaitNode, sourceCode } = opts;
|
|
223
|
+
const before = sourceCode.getTokenBefore(awaitNode);
|
|
224
|
+
const after = sourceCode.getTokenAfter(awaitNode);
|
|
225
|
+
const parentType = common_1.AstNode.getType({ node: AwaitSupport.parentOf({ node: awaitNode }) }) ?? '';
|
|
226
|
+
const callee = parentType === 'CallExpression' &&
|
|
227
|
+
common_1.AstNode.readField({ node: AwaitSupport.parentOf({ node: awaitNode }), key: 'callee' }) ===
|
|
228
|
+
awaitNode;
|
|
229
|
+
if (before?.value === '(' &&
|
|
230
|
+
after?.value === ')' &&
|
|
231
|
+
(GROUPING_PARENTS.has(parentType) || callee)) {
|
|
232
|
+
return [before.range[0], after.range[1]];
|
|
233
|
+
}
|
|
234
|
+
return [awaitNode.range?.[0] ?? 0, awaitNode.range?.[1] ?? 0];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.AwaitSupport = AwaitSupport;
|
|
238
|
+
//# sourceMappingURL=await-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await-support.js","sourceRoot":"","sources":["../../../src/linters/house/await-support.ts"],"names":[],"mappings":";;;AACA,qCAAmC;AAEnC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;AAC5F,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,qBAAqB;IACrB,oBAAoB;IACpB,yBAAyB;CAC1B,CAAC,CAAC;AACH,+FAA+F;AAC/F,MAAM,UAAU,GAA2B;IACzC,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AC,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;;AAxPH,oCAyPC","sourcesContent":["import type { Rule, SourceCode } from 'eslint';\nimport { AstNode } from './common';\n\nconst STATEMENT_LISTS = new Set(['BlockStatement', 'Program', 'StaticBlock', 'SwitchCase']);\nconst FUNCTION_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n]);\n/** The child of a statement that runs exactly once, before anything else of that statement. */\nconst HEAD_FIELD: Record<string, string> = {\n IfStatement: 'test',\n SwitchStatement: 'discriminant',\n ForOfStatement: 'right',\n ForInStatement: 'right',\n ExpressionStatement: 'expression',\n ReturnStatement: 'argument',\n ThrowStatement: 'argument',\n};\n/** Nodes that evaluate to a value without doing anything else, so running them later or earlier changes nothing. */\nconst PURE_LEAVES = new Set([\n 'Identifier',\n 'Literal',\n 'ThisExpression',\n 'ArrowFunctionExpression',\n 'FunctionExpression',\n 'PrivateIdentifier',\n]);\n/** Wrappers whose parentheses around an `await` carry no meaning once the `await` is a name. */\nconst GROUPING_PARENTS = new Set([\n 'MemberExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'UnaryExpression',\n 'BinaryExpression',\n 'SpreadElement',\n 'ArrayExpression',\n]);\n\n/** The shared parts of the two `await` rules: where a statement can go before another, what may run first, fresh names. */\nexport class AwaitSupport {\n static parentOf(opts: { node: unknown }): unknown {\n return AstNode.readField({ node: opts.node, key: 'parent' });\n }\n\n /** An ESTree node of the lint run: it has a `type` and a `range`. */\n static isNode(value: unknown): value is Rule.Node {\n return (\n AstNode.getType({ node: value }) !== undefined &&\n AwaitSupport.rangeOf({ node: value }) !== undefined\n );\n }\n\n static rangeOf(opts: { node: unknown }): [number, number] | undefined {\n const range = AstNode.readField({ node: opts.node, key: 'range' });\n return Array.isArray(range) && typeof range[0] === 'number' && typeof range[1] === 'number'\n ? [range[0], range[1]]\n : undefined;\n }\n\n /**\n * The statement that can take a `const` in front of it so that `awaitNode` is evaluated first, or `undefined`\n * when hoisting would change what runs: the `await` sits in a branch (`?:`, the right of `&&`, `||`, `??`),\n * in a loop test or update, in an unbraced `if` branch, in an optional chain, or in an arrow expression body.\n */\n static hoistTarget(opts: { awaitNode: unknown }): Rule.Node | undefined {\n let child: unknown = opts.awaitNode;\n let ancestor = AwaitSupport.parentOf({ node: child });\n\n while (ancestor) {\n const type = AstNode.getType({ node: ancestor }) ?? '';\n\n if (FUNCTION_TYPES.has(type) || type === 'ChainExpression') {\n return undefined;\n }\n if (\n type === 'ConditionalExpression' &&\n AstNode.readField({ node: ancestor, key: 'test' }) !== child\n ) {\n return undefined;\n }\n if (\n type === 'LogicalExpression' &&\n AstNode.readField({ node: ancestor, key: 'left' }) !== child\n ) {\n return undefined;\n }\n if (\n type === 'AssignmentExpression' &&\n ['??=', '||=', '&&='].includes(\n String(AstNode.readField({ node: ancestor, key: 'operator' })),\n ) &&\n AstNode.readField({ node: ancestor, key: 'right' }) === child\n ) {\n return undefined;\n }\n if (type.endsWith('Statement') || type === 'VariableDeclaration') {\n const head = HEAD_FIELD[type];\n const isHead =\n type === 'VariableDeclaration' ||\n AstNode.readField({ node: ancestor, key: head }) === child;\n const outer = AwaitSupport.parentOf({ node: ancestor });\n\n const isListed =\n STATEMENT_LISTS.has(AstNode.getType({ node: outer }) ?? '') &&\n (type === 'VariableDeclaration' || head !== undefined);\n\n return isHead && isListed && AwaitSupport.isNode(ancestor) ? ancestor : undefined;\n }\n\n child = ancestor;\n ancestor = AwaitSupport.parentOf({ node: child });\n }\n\n return undefined;\n }\n\n static isPure(opts: { node: unknown }): boolean {\n const { node } = opts;\n const type = AstNode.getType({ node }) ?? '';\n const pure = (child: unknown) => AwaitSupport.isPure({ node: child });\n const field = (key: string) => AstNode.readField({ node, key });\n const all = (key: string) => {\n const list = AstNode.readField({ node, key });\n return Array.isArray(list) && list.every((entry) => entry === null || pure(entry));\n };\n\n if (\n PURE_LEAVES.has(type) ||\n (type.startsWith('TS') &&\n !['TSAsExpression', 'TSNonNullExpression', 'TSSatisfiesExpression'].includes(type))\n ) {\n return true;\n }\n\n const parts = new Map<string, () => boolean>([\n ['TemplateLiteral', () => all('expressions')],\n ['MemberExpression', () => pure(field('object')) && pure(field('property'))],\n ['ArrayExpression', () => all('elements')],\n ['ObjectExpression', () => all('properties')],\n ['Property', () => pure(field('key')) && pure(field('value'))],\n ['SpreadElement', () => pure(field('argument'))],\n ['UnaryExpression', () => field('operator') !== 'delete' && pure(field('argument'))],\n ['BinaryExpression', () => pure(field('left')) && pure(field('right'))],\n ['LogicalExpression', () => pure(field('left')) && pure(field('right'))],\n [\n 'ConditionalExpression',\n () => ['test', 'consequent', 'alternate'].every((key) => pure(field(key))),\n ],\n ['TSAsExpression', () => pure(field('expression'))],\n ['TSNonNullExpression', () => pure(field('expression'))],\n ['TSSatisfiesExpression', () => pure(field('expression'))],\n ]);\n\n return parts.get(type)?.() ?? false;\n }\n\n /**\n * Whether something that does more than read a value runs, inside `statement`, before `awaitNode` does.\n * Hoisting the `await` in front of the statement would then run it first.\n */\n static hasEffectBefore(opts: {\n statement: Rule.Node;\n awaitNode: unknown;\n sourceCode: SourceCode;\n }): boolean {\n const target = AwaitSupport.rangeOf({ node: opts.awaitNode });\n if (!target) {\n return true;\n }\n\n const visit = (node: unknown): boolean => {\n const range = AwaitSupport.rangeOf({ node });\n if (!range) {\n return false;\n }\n if (range[0] <= target[0] && target[1] <= range[1]) {\n const keys = opts.sourceCode.visitorKeys[AstNode.getType({ node }) ?? ''] ?? [];\n\n return keys.some((key) => {\n const value = AstNode.readField({ node, key });\n const entries = Array.isArray(value) ? value : [value];\n\n return entries.some((entry) => entry && entry !== opts.awaitNode && visit(entry));\n });\n }\n\n return range[1] <= target[0] && !AwaitSupport.isPure({ node });\n };\n\n return visit(opts.statement);\n }\n\n /** The leading whitespace of the line a node starts on. */\n static indentOf(opts: { node: Rule.Node; sourceCode: SourceCode }): string {\n const line = opts.sourceCode.lines[(opts.node.loc?.start.line ?? 1) - 1] ?? '';\n return /^\\s*/.exec(line)?.[0] ?? '';\n }\n\n /** The nearest function or the program that holds `node`: the scope a new name must be free in. */\n static scopeNodeOf(opts: { node: Rule.Node }): Rule.Node {\n let current: Rule.Node = opts.node;\n let parent = AwaitSupport.parentOf({ node: current });\n\n while (parent && !FUNCTION_TYPES.has(AstNode.getType({ node: parent }) ?? '')) {\n if (!AwaitSupport.isNode(parent)) {\n break;\n }\n current = parent;\n parent = AwaitSupport.parentOf({ node: current });\n }\n\n return AwaitSupport.isNode(parent) ? parent : current;\n }\n\n /**\n * The outermost function that holds `node` (the program when no function does): the one namespace a hoisted name\n * must be unique in. A name that is free in the nearest function only could still shadow, or be shadowed by, the\n * name another fix hoisted in a function around it or a block inside it.\n */\n static outermostScopeOf(opts: { node: Rule.Node }): Rule.Node {\n let outermost: Rule.Node | undefined;\n let current: unknown = opts.node;\n\n while (AwaitSupport.isNode(current)) {\n if (FUNCTION_TYPES.has(AstNode.getType({ node: current }) ?? '')) {\n outermost = current;\n }\n current = AwaitSupport.parentOf({ node: current });\n }\n\n return outermost ?? AwaitSupport.scopeNodeOf({ node: opts.node });\n }\n\n /**\n * The names handed out in this lint pass, per outermost scope. They are shared by every rule that hoists a name: the\n * rules run in the same pass over the same text and their fixes are applied together, so two rules that each\n * remembered their own names both handed out `result`. A `SourceCode` lasts for one pass of one file.\n */\n private static readonly PASS_NAMES = new WeakMap<SourceCode, Map<unknown, Set<string>>>();\n\n /**\n * `base`, or `base2`, `base3`... the first word that does not appear in the outermost function (or program) holding\n * `node` and that no rule has handed out already in this lint pass: no two fixes of one pass declare the same name,\n * and none declares a name that is in scope anywhere around or inside the place it is hoisted to.\n */\n static freshName(opts: { node: Rule.Node; base: string; sourceCode: SourceCode }): string {\n const scope = AwaitSupport.outermostScopeOf({ node: opts.node });\n const text = opts.sourceCode.getText(scope);\n const pass = AwaitSupport.PASS_NAMES.get(opts.sourceCode) ?? new Map<unknown, Set<string>>();\n const reserved = pass.get(scope) ?? new Set<string>();\n\n AwaitSupport.PASS_NAMES.set(opts.sourceCode, pass);\n\n for (let index = 1; ; index += 1) {\n const candidate = index === 1 ? opts.base : `${opts.base}${index}`;\n if (!reserved.has(candidate) && !new RegExp(`\\\\b${candidate}\\\\b`).test(text)) {\n reserved.add(candidate);\n pass.set(scope, reserved);\n\n return candidate;\n }\n }\n }\n\n /**\n * The range to replace with the name that stands for an `await`: the `await` itself, widened over the parentheses\n * around it when they only grouped it (`(await f()).x`, `!(await f())`).\n */\n static replaceRangeOf(opts: { awaitNode: Rule.Node; sourceCode: SourceCode }): [number, number] {\n const { awaitNode, sourceCode } = opts;\n const before = sourceCode.getTokenBefore(awaitNode);\n const after = sourceCode.getTokenAfter(awaitNode);\n const parentType = AstNode.getType({ node: AwaitSupport.parentOf({ node: awaitNode }) }) ?? '';\n const callee =\n parentType === 'CallExpression' &&\n AstNode.readField({ node: AwaitSupport.parentOf({ node: awaitNode }), key: 'callee' }) ===\n awaitNode;\n\n if (\n before?.value === '(' &&\n after?.value === ')' &&\n (GROUPING_PARENTS.has(parentType) || callee)\n ) {\n return [before.range[0], after.range[1]];\n }\n\n return [awaitNode.range?.[0] ?? 0, awaitNode.range?.[1] ?? 0];\n }\n}\n"]}
|
|
@@ -7,16 +7,22 @@ export declare class AstNodeTypes {
|
|
|
7
7
|
static readonly ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression";
|
|
8
8
|
static readonly EXPORT_NAMED_DECLARATION = "ExportNamedDeclaration";
|
|
9
9
|
static readonly UNION_TYPE = "TSUnionType";
|
|
10
|
+
static readonly AWAIT_EXPRESSION = "AwaitExpression";
|
|
11
|
+
static readonly RETURN_STATEMENT = "ReturnStatement";
|
|
12
|
+
static readonly CATCH_CLAUSE = "CatchClause";
|
|
10
13
|
}
|
|
11
14
|
/** The ESLint namespace the house rules live under: `venizia/<rule>`. */
|
|
12
15
|
export declare const HOUSE_PLUGIN_NAMESPACE = "venizia";
|
|
13
|
-
/**
|
|
14
|
-
export declare
|
|
15
|
-
node
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
node
|
|
21
|
-
|
|
16
|
+
/** Reads an AST node without trusting its type: TypeScript nodes carry fields estree does not declare. */
|
|
17
|
+
export declare class AstNode {
|
|
18
|
+
/** A field of an AST node. */
|
|
19
|
+
static readField(opts: {
|
|
20
|
+
node: unknown;
|
|
21
|
+
key: string;
|
|
22
|
+
}): unknown;
|
|
23
|
+
/** The node's `type`, or `undefined` for anything that is not an AST node. */
|
|
24
|
+
static getType(opts: {
|
|
25
|
+
node: unknown;
|
|
26
|
+
}): string | undefined;
|
|
27
|
+
}
|
|
22
28
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/linters/house/common.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,qBAAa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,cAAc,mBAAmB;IACjD,MAAM,CAAC,QAAQ,CAAC,eAAe,oBAAoB;IACnD,MAAM,CAAC,QAAQ,CAAC,oBAAoB,yBAAyB;IAC7D,MAAM,CAAC,QAAQ,CAAC,mBAAmB,wBAAwB;IAC3D,MAAM,CAAC,QAAQ,CAAC,yBAAyB,6BAA6B;IACtE,MAAM,CAAC,QAAQ,CAAC,wBAAwB,4BAA4B;IACpE,MAAM,CAAC,QAAQ,CAAC,UAAU,iBAAiB;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/linters/house/common.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,qBAAa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,cAAc,mBAAmB;IACjD,M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