@venizia/dev-configs 0.4.7 → 0.4.8-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.
Files changed (199) hide show
  1. package/README.md +3 -3
  2. package/dist/checks/catalog.d.ts +15 -2
  3. package/dist/checks/catalog.js +1 -0
  4. package/dist/checks/catalog.js.map +1 -1
  5. package/dist/checks/module-cycles.d.ts +2 -0
  6. package/dist/checks/module-cycles.js +2 -0
  7. package/dist/checks/module-cycles.js.map +1 -1
  8. package/dist/checks/purity/manifest.d.ts +6 -1
  9. package/dist/checks/purity/manifest.js.map +1 -1
  10. package/dist/checks/purity/probe.d.ts +4 -1
  11. package/dist/checks/purity/probe.js +1 -0
  12. package/dist/checks/purity/probe.js.map +1 -1
  13. package/dist/checks/purity/run.d.ts +3 -0
  14. package/dist/checks/purity/run.js +1 -0
  15. package/dist/checks/purity/run.js.map +1 -1
  16. package/dist/checks/split-report.d.ts +1 -0
  17. package/dist/checks/split-report.js +1 -0
  18. package/dist/checks/split-report.js.map +1 -1
  19. package/dist/checks/test-controls.d.ts +11 -2
  20. package/dist/checks/test-controls.js +1 -0
  21. package/dist/checks/test-controls.js.map +1 -1
  22. package/dist/checks/test-dead-code.d.ts +1 -0
  23. package/dist/checks/test-dead-code.js +1 -0
  24. package/dist/checks/test-dead-code.js.map +1 -1
  25. package/dist/checks/test-mutate.d.ts +14 -2
  26. package/dist/checks/test-mutate.js +1 -0
  27. package/dist/checks/test-mutate.js.map +1 -1
  28. package/dist/checks/test-weight.d.ts +3 -0
  29. package/dist/checks/test-weight.js +1 -0
  30. package/dist/checks/test-weight.js.map +1 -1
  31. package/dist/cli/check.js.map +1 -1
  32. package/dist/cli/clean.js.map +1 -1
  33. package/dist/cli/codemod/async-style.d.ts +1 -1
  34. package/dist/cli/codemod/async-style.js +3 -3
  35. package/dist/cli/codemod/async-style.js.map +1 -1
  36. package/dist/cli/codemod/connector-imports.js.map +1 -1
  37. package/dist/cli/codemod/const-classes.js.map +1 -1
  38. package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
  39. package/dist/cli/codemod/files.js.map +1 -1
  40. package/dist/cli/codemod/index.js.map +1 -1
  41. package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
  42. package/dist/cli/codemod/namespace-functions/logger-scope.js.map +1 -1
  43. package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -1
  44. package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
  45. package/dist/cli/index.js.map +1 -1
  46. package/dist/cli/lint.js.map +1 -1
  47. package/dist/linters/eslint.js +7 -5
  48. package/dist/linters/eslint.js.map +1 -1
  49. package/dist/linters/house/async-rules.d.ts +10 -0
  50. package/dist/linters/house/async-rules.js +29 -0
  51. package/dist/linters/house/async-rules.js.map +1 -0
  52. package/dist/linters/house/await-support.d.ts +2 -0
  53. package/dist/linters/house/await-support.js +15 -10
  54. package/dist/linters/house/await-support.js.map +1 -1
  55. package/dist/linters/house/common.d.ts +2 -0
  56. package/dist/linters/house/common.js +2 -0
  57. package/dist/linters/house/common.js.map +1 -1
  58. package/dist/linters/house/configs.d.ts +3 -29
  59. package/dist/linters/house/configs.js +24 -51
  60. package/dist/linters/house/configs.js.map +1 -1
  61. package/dist/linters/house/const-class-values.rule.js.map +1 -1
  62. package/dist/linters/house/effect-cleanup-consistency.rule.js +2 -1
  63. package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
  64. package/dist/linters/house/hook-support.js.map +1 -1
  65. package/dist/linters/house/index.d.ts +2 -1
  66. package/dist/linters/house/index.js +4 -1
  67. package/dist/linters/house/index.js.map +1 -1
  68. package/dist/linters/house/max-params-own.rule.d.ts +3 -1
  69. package/dist/linters/house/max-params-own.rule.js +1 -1
  70. package/dist/linters/house/max-params-own.rule.js.map +1 -1
  71. package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
  72. package/dist/linters/house/no-await-promise-chain.rule.js +2 -3
  73. package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
  74. package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
  75. package/dist/linters/house/no-return-await.rule.js +2 -8
  76. package/dist/linters/house/no-return-await.rule.js.map +1 -1
  77. package/dist/linters/house/no-silent-catch.rule.js +1 -1
  78. package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
  79. package/dist/linters/house/no-unbraced-case.rule.d.ts +15 -0
  80. package/dist/linters/house/no-unbraced-case.rule.js +45 -0
  81. package/dist/linters/house/no-unbraced-case.rule.js.map +1 -0
  82. package/dist/linters/house/plugin.js +2 -0
  83. package/dist/linters/house/plugin.js.map +1 -1
  84. package/dist/linters/house/promise-chain-support.js.map +1 -1
  85. package/dist/linters/ignore.js.map +1 -1
  86. package/dist/linters/index.d.ts +1 -0
  87. package/dist/linters/index.js +1 -0
  88. package/dist/linters/index.js.map +1 -1
  89. package/dist/linters/oxlint.d.ts +6 -1
  90. package/dist/linters/oxlint.js.map +1 -1
  91. package/dist/linters/padding.d.ts +8 -0
  92. package/dist/linters/padding.js +25 -0
  93. package/dist/linters/padding.js.map +1 -0
  94. package/dist/linters/rules/eqeqeq.rule.js.map +1 -1
  95. package/dist/linters/rules/index.d.ts +2 -0
  96. package/dist/linters/rules/index.js +2 -0
  97. package/dist/linters/rules/index.js.map +1 -1
  98. package/dist/linters/rules/lines-between-class-members.rule.d.ts +14 -0
  99. package/dist/linters/rules/lines-between-class-members.rule.js +17 -0
  100. package/dist/linters/rules/lines-between-class-members.rule.js.map +1 -0
  101. package/dist/linters/rules/naming-convention.rule.js.map +1 -1
  102. package/dist/linters/rules/no-restricted-imports.rule.js.map +1 -1
  103. package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
  104. package/dist/linters/rules/no-unused-vars.rule.d.ts +6 -1
  105. package/dist/linters/rules/no-unused-vars.rule.js +1 -1
  106. package/dist/linters/rules/no-unused-vars.rule.js.map +1 -1
  107. package/dist/linters/rules/padding-line-between-statements.rule.d.ts +16 -0
  108. package/dist/linters/rules/padding-line-between-statements.rule.js +25 -0
  109. package/dist/linters/rules/padding-line-between-statements.rule.js.map +1 -0
  110. package/dist/linters/rules/prefer-nullish-coalescing.rule.js.map +1 -1
  111. package/dist/linters/rules/switch-case-braces.rule.js.map +1 -1
  112. package/dist/testing/rejection.helper.d.ts +1 -0
  113. package/dist/testing/rejection.helper.js +1 -0
  114. package/dist/testing/rejection.helper.js.map +1 -1
  115. package/dist/testing/repo-tmp.d.ts +1 -0
  116. package/dist/testing/repo-tmp.js +1 -0
  117. package/dist/testing/repo-tmp.js.map +1 -1
  118. package/dist/testing/spawn.helper.d.ts +1 -0
  119. package/dist/testing/spawn.helper.js +1 -0
  120. package/dist/testing/spawn.helper.js.map +1 -1
  121. package/package.json +3 -5
  122. package/dist/checks/catalog.d.ts.map +0 -1
  123. package/dist/checks/index.d.ts.map +0 -1
  124. package/dist/checks/module-cycles.d.ts.map +0 -1
  125. package/dist/checks/purity/manifest.d.ts.map +0 -1
  126. package/dist/checks/purity/probe.d.ts.map +0 -1
  127. package/dist/checks/purity/run.d.ts.map +0 -1
  128. package/dist/checks/split-report.d.ts.map +0 -1
  129. package/dist/checks/test-controls.d.ts.map +0 -1
  130. package/dist/checks/test-dead-code.d.ts.map +0 -1
  131. package/dist/checks/test-mutate.d.ts.map +0 -1
  132. package/dist/checks/test-weight.d.ts.map +0 -1
  133. package/dist/cli/check.d.ts.map +0 -1
  134. package/dist/cli/clean.d.ts.map +0 -1
  135. package/dist/cli/codemod/async-style.d.ts.map +0 -1
  136. package/dist/cli/codemod/connector-imports.d.ts.map +0 -1
  137. package/dist/cli/codemod/const-classes.d.ts.map +0 -1
  138. package/dist/cli/codemod/drop-redundant-casts.d.ts.map +0 -1
  139. package/dist/cli/codemod/files.d.ts.map +0 -1
  140. package/dist/cli/codemod/index.d.ts.map +0 -1
  141. package/dist/cli/codemod/namespace-functions/index.d.ts.map +0 -1
  142. package/dist/cli/codemod/namespace-functions/logger-scope.d.ts.map +0 -1
  143. package/dist/cli/codemod/namespace-functions/mapping.d.ts.map +0 -1
  144. package/dist/cli/codemod/namespace-functions/mappings/boot.d.ts.map +0 -1
  145. package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts.map +0 -1
  146. package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts.map +0 -1
  147. package/dist/cli/codemod/namespace-functions/mappings/core-worker.d.ts.map +0 -1
  148. package/dist/cli/codemod/namespace-functions/mappings/dev-configs.d.ts.map +0 -1
  149. package/dist/cli/codemod/namespace-functions/mappings/filter.d.ts.map +0 -1
  150. package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts.map +0 -1
  151. package/dist/cli/codemod/namespace-functions/mappings/index.d.ts.map +0 -1
  152. package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts.map +0 -1
  153. package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts.map +0 -1
  154. package/dist/cli/codemod/namespace-functions/rewriter.d.ts.map +0 -1
  155. package/dist/cli/index.d.ts.map +0 -1
  156. package/dist/cli/lint.d.ts.map +0 -1
  157. package/dist/compilers/bun.d.ts.map +0 -1
  158. package/dist/compilers/index.d.ts.map +0 -1
  159. package/dist/index.d.ts.map +0 -1
  160. package/dist/linters/browser.d.ts.map +0 -1
  161. package/dist/linters/eslint.d.ts.map +0 -1
  162. package/dist/linters/house/await-support.d.ts.map +0 -1
  163. package/dist/linters/house/common.d.ts.map +0 -1
  164. package/dist/linters/house/configs.d.ts.map +0 -1
  165. package/dist/linters/house/const-class-values.rule.d.ts.map +0 -1
  166. package/dist/linters/house/effect-cleanup-consistency.rule.d.ts.map +0 -1
  167. package/dist/linters/house/hook-support.d.ts.map +0 -1
  168. package/dist/linters/house/index.d.ts.map +0 -1
  169. package/dist/linters/house/max-params-own.rule.d.ts.map +0 -1
  170. package/dist/linters/house/no-async-hook-callback.rule.d.ts.map +0 -1
  171. package/dist/linters/house/no-await-promise-chain.rule.d.ts.map +0 -1
  172. package/dist/linters/house/no-inline-await.rule.d.ts.map +0 -1
  173. package/dist/linters/house/no-leaked-render.rule.d.ts.map +0 -1
  174. package/dist/linters/house/no-new-error.rule.d.ts.map +0 -1
  175. package/dist/linters/house/no-return-await.rule.d.ts.map +0 -1
  176. package/dist/linters/house/no-silent-catch.rule.d.ts.map +0 -1
  177. package/dist/linters/house/plugin.d.ts.map +0 -1
  178. package/dist/linters/house/promise-chain-support.d.ts.map +0 -1
  179. package/dist/linters/ignore.d.ts.map +0 -1
  180. package/dist/linters/index.d.ts.map +0 -1
  181. package/dist/linters/jsx-files.d.ts.map +0 -1
  182. package/dist/linters/oxlint-presets.d.ts.map +0 -1
  183. package/dist/linters/oxlint.d.ts.map +0 -1
  184. package/dist/linters/react-eslint.d.ts.map +0 -1
  185. package/dist/linters/react-oxlint.d.ts.map +0 -1
  186. package/dist/linters/rules/common.d.ts.map +0 -1
  187. package/dist/linters/rules/eqeqeq.rule.d.ts.map +0 -1
  188. package/dist/linters/rules/index.d.ts.map +0 -1
  189. package/dist/linters/rules/naming-convention.rule.d.ts.map +0 -1
  190. package/dist/linters/rules/no-restricted-imports.rule.d.ts.map +0 -1
  191. package/dist/linters/rules/no-restricted-properties.rule.d.ts.map +0 -1
  192. package/dist/linters/rules/no-unused-vars.rule.d.ts.map +0 -1
  193. package/dist/linters/rules/prefer-nullish-coalescing.rule.d.ts.map +0 -1
  194. package/dist/linters/rules/switch-case-braces.rule.d.ts.map +0 -1
  195. package/dist/testing/index.d.ts.map +0 -1
  196. package/dist/testing/rejection.helper.d.ts.map +0 -1
  197. package/dist/testing/repo-tmp.d.ts.map +0 -1
  198. package/dist/testing/spawn.helper.d.ts.map +0 -1
  199. package/dist/testing/tmpdir-preload.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"logger-scope.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/logger-scope.ts"],"names":[],"mappings":";;;AAqBA;;;;;;;;;;;GAWG;AACH,MAAa,mBAAmB;aACd,eAAU,GAAG,mBAAmB,CAAC;aACjC,gBAAW,GAA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AAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACxD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAErC,IAAI,IAAI,EAAE,CAAC;YACT,KAAK,CAAC,IAAI,CAAC;gBACT,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;gBACrC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAC9B,IAAI,EAAE,EAAE;aACT,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,QAAQ,EAAE,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;;AAzgBH,kDA0gBC","sourcesContent":["import type ts from 'typescript';\nimport type { INamespaceFunctionsReport, INamespaceFunctionsResult } from './rewriter';\n\ntype TTypeScript = typeof ts;\n\ninterface IEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** How a file reaches `ApplicationLogger`: by a named import (aliased too), or through a namespace import. */\ninterface ILocals {\n /** Local name -> the import specifier that declares it. */\n named: Map<string, ts.ImportSpecifier>;\n /** Local name of `import * as name`. */\n namespaces: Set<string>;\n /** The import declarations of the listed modules, in order. */\n declarations: ts.ImportDeclaration[];\n}\n\n/**\n * The call-shape rule that goes with the table. `ApplicationLogger` is removed: every form of it becomes\n * `LoggerFactory.getLogger([scope])`, so `ApplicationLogger.get('scope')`, `ApplicationLogger.get(NAME)` and\n * `ApplicationLogger.get({ scope: NAME })` all become `LoggerFactory.getLogger(['scope'])`, `...([NAME])`. The call is on a\n * class, not a function in a table, so the table cannot carry it.\n *\n * It follows `ApplicationLogger` imported by name (aliased too) or reached through a namespace import from\n * `@venizia/ignis-helpers` or `@venizia/ignis`, adds `LoggerFactory` to that import and drops `ApplicationLogger` once\n * nothing else uses it. The argument may be a string literal, a template, an identifier, a property access, or an\n * object literal that holds only `scope`. It never touches `Logger.get` or `HfLogger.get`, and it lists a call it cannot\n * decide with file and line.\n */\nexport class LoggerScopeRewriter {\n static readonly CLASS_NAME = 'ApplicationLogger';\n static readonly TARGET_NAME = 'LoggerFactory';\n static readonly MODULES: ReadonlyArray<string> = ['@venizia/ignis-helpers', '@venizia/ignis'];\n\n /** Whether the file can hold such a call, so a file without it is not parsed. */\n static mentions(opts: { source: string }): boolean {\n return opts.source.includes(LoggerScopeRewriter.CLASS_NAME);\n }\n\n static rewrite(opts: {\n typescript: TTypeScript;\n fileName: string;\n source: string;\n }): INamespaceFunctionsResult {\n const { typescript, fileName, source } = opts;\n const reports: INamespaceFunctionsReport[] = [];\n const unchanged = { output: source, changed: false, rewritten: 0, reports };\n\n if (!LoggerScopeRewriter.mentions({ source })) {\n return unchanged;\n }\n\n const sourceFile = typescript.createSourceFile(\n fileName,\n source,\n typescript.ScriptTarget.Latest,\n true,\n );\n\n const report = (node: ts.Node, reason: string) => {\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(sourceFile),\n );\n reports.push({ line: line + 1, column: character + 1, reason });\n };\n\n // A re-export or a type-only import of the removed class is not a call: it is listed, never silently kept.\n LoggerScopeRewriter.reportDeclarations({ typescript, sourceFile, report });\n\n const locals = LoggerScopeRewriter.findLocals({ typescript, sourceFile });\n if (locals.named.size === 0 && locals.namespaces.size === 0) {\n return unchanged;\n }\n\n const factory = LoggerScopeRewriter.findFactory({ typescript, sourceFile });\n if (factory.collision) {\n report(\n factory.collision,\n '`LoggerFactory` is already declared in this file (or imported from another module): rewrite `ApplicationLogger` by hand as `LoggerFactory.getLogger([scope])`',\n );\n return unchanged;\n }\n\n const factoryName = factory.local ?? LoggerScopeRewriter.TARGET_NAME;\n const edits: IEdit[] = [];\n /** Identifiers of the old class that a rewritten call replaced: what is left after them keeps the import. */\n const rewrittenOwners = new Set<ts.Node>();\n\n const visit = (node: ts.Node): void => {\n if (typescript.isCallExpression(node)) {\n const owner = LoggerScopeRewriter.loggerOwnerOf({ typescript, call: node, locals });\n\n if (owner) {\n LoggerScopeRewriter.plan({\n typescript,\n sourceFile,\n call: node,\n owner,\n factoryName,\n edits,\n rewrittenOwners,\n report,\n });\n }\n }\n\n typescript.forEachChild(node, visit);\n };\n visit(sourceFile);\n\n if (edits.length === 0) {\n return unchanged;\n }\n\n LoggerScopeRewriter.planImports({\n typescript,\n sourceFile,\n locals,\n rewrittenOwners,\n hasFactory: factory.local !== undefined,\n edits,\n });\n LoggerScopeRewriter.reportLeftovers({\n typescript,\n sourceFile,\n locals,\n rewrittenOwners,\n report,\n });\n\n let output = source;\n for (const edit of [...edits].sort((first, second) => second.start - first.start)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return { output, changed: true, rewritten: rewrittenOwners.size, reports };\n }\n\n private static findLocals(opts: { typescript: TTypeScript; sourceFile: ts.SourceFile }): ILocals {\n const { typescript, sourceFile } = opts;\n const locals: ILocals = { named: new Map(), namespaces: new Set(), declarations: [] };\n\n for (const statement of sourceFile.statements) {\n if (\n !typescript.isImportDeclaration(statement) ||\n !typescript.isStringLiteral(statement.moduleSpecifier) ||\n !LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text)\n ) {\n continue;\n }\n\n const bindings = statement.importClause?.namedBindings;\n if (!bindings || statement.importClause?.isTypeOnly) {\n continue;\n }\n\n locals.declarations.push(statement);\n\n if (typescript.isNamespaceImport(bindings)) {\n locals.namespaces.add(bindings.name.text);\n continue;\n }\n\n for (const specifier of bindings.elements) {\n if (specifier.isTypeOnly) {\n continue;\n }\n\n if ((specifier.propertyName ?? specifier.name).text === LoggerScopeRewriter.CLASS_NAME) {\n locals.named.set(specifier.name.text, specifier);\n }\n }\n }\n\n return locals;\n }\n\n /** The node that names the class in `<ApplicationLogger>.get(...)` or `<namespace>.ApplicationLogger.get(...)`, else undefined. */\n private static loggerOwnerOf(opts: {\n typescript: TTypeScript;\n call: ts.CallExpression;\n locals: ILocals;\n }): ts.Identifier | ts.PropertyAccessExpression | undefined {\n const { typescript, call, locals } = opts;\n const callee = call.expression;\n\n if (!typescript.isPropertyAccessExpression(callee) || callee.name.text !== 'get') {\n return undefined;\n }\n\n const owner = callee.expression;\n if (typescript.isIdentifier(owner) && locals.named.has(owner.text)) {\n return owner;\n }\n\n if (\n typescript.isPropertyAccessExpression(owner) &&\n owner.name.text === LoggerScopeRewriter.CLASS_NAME &&\n typescript.isIdentifier(owner.expression) &&\n locals.namespaces.has(owner.expression.text)\n ) {\n return owner;\n }\n\n return undefined;\n }\n\n /** The scope expression of the call, as text, or a reason it cannot be decided. */\n private static scopeOf(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n call: ts.CallExpression;\n }): { text: string } | { reason: string } {\n const { typescript, sourceFile, call } = opts;\n const [argument] = call.arguments;\n\n if (call.arguments.length !== 1 || !argument) {\n return {\n reason:\n '`ApplicationLogger.get` is called with no argument or more than one: rewrite it by hand as `LoggerFactory.getLogger([scope])`',\n };\n }\n\n if (typescript.isObjectLiteralExpression(argument)) {\n const [property, ...rest] = argument.properties;\n const isOnlyScope =\n rest.length === 0 &&\n property !== undefined &&\n (typescript.isShorthandPropertyAssignment(property) ||\n typescript.isPropertyAssignment(property)) &&\n typescript.isIdentifier(property.name) &&\n property.name.text === 'scope';\n\n if (!isOnlyScope) {\n return {\n reason:\n '`ApplicationLogger.get` gets an object that is not `{ scope: <expression> }`: rewrite it by hand as `LoggerFactory.getLogger([scope])`',\n };\n }\n\n return {\n text: typescript.isShorthandPropertyAssignment(property)\n ? property.name.text\n : property.initializer.getText(sourceFile),\n };\n }\n\n const isDecidable =\n typescript.isStringLiteral(argument) ||\n typescript.isNoSubstitutionTemplateLiteral(argument) ||\n typescript.isTemplateExpression(argument) ||\n typescript.isIdentifier(argument) ||\n typescript.isPropertyAccessExpression(argument);\n\n if (!isDecidable) {\n return {\n reason:\n '`ApplicationLogger.get` gets an argument whose type the codemod cannot tell (a call, a spread or another expression): rewrite it by hand as `LoggerFactory.getLogger([<argument>])`',\n };\n }\n\n return { text: argument.getText(sourceFile) };\n }\n\n /** One edit for a call whose scope is decided: the whole call text becomes `<owner replaced>.getLogger([scope])`. */\n private static plan(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n call: ts.CallExpression;\n owner: ts.Identifier | ts.PropertyAccessExpression;\n factoryName: string;\n edits: IEdit[];\n rewrittenOwners: Set<ts.Node>;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, sourceFile, call, owner, factoryName, edits, rewrittenOwners, report } =\n opts;\n const scope = LoggerScopeRewriter.scopeOf({ typescript, sourceFile, call });\n\n if ('reason' in scope) {\n report(call, scope.reason);\n return;\n }\n\n // `<namespace>.ApplicationLogger` keeps its namespace: `helpers.LoggerFactory.getLogger([...])`.\n const ownerText = typescript.isIdentifier(owner)\n ? factoryName\n : `${owner.expression.getText(sourceFile)}.${LoggerScopeRewriter.TARGET_NAME}`;\n\n edits.push({\n start: call.getStart(sourceFile),\n end: call.getEnd(),\n text: `${ownerText}.getLogger([${scope.text}])`,\n });\n rewrittenOwners.add(owner);\n }\n\n /**\n * `LoggerFactory` is added to the import that carried `ApplicationLogger`, and `ApplicationLogger` leaves it when no\n * other use of it remains.\n */\n private static planImports(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n locals: ILocals;\n rewrittenOwners: Set<ts.Node>;\n /** `LoggerFactory` is already imported from a listed module (maybe under another name). */\n hasFactory: boolean;\n edits: IEdit[];\n }): void {\n const { typescript, sourceFile, locals, rewrittenOwners, hasFactory, edits } = opts;\n\n for (const [local, specifier] of locals.named) {\n const used = LoggerScopeRewriter.countReferences({ typescript, sourceFile, name: local });\n const replaced = [...rewrittenOwners].filter(\n (owner) => typescript.isIdentifier(owner) && owner.text === local,\n ).length;\n const declaration = specifier.parent.parent.parent;\n const imported = declaration.importClause?.namedBindings;\n\n if (!imported || !typescript.isNamedImports(imported)) {\n continue;\n }\n\n const hasTarget = hasFactory;\n const isLeft = used - replaced > 1; // the import specifier itself is one reference\n\n if (isLeft) {\n if (!hasTarget) {\n edits.push({\n start: specifier.getEnd(),\n end: specifier.getEnd(),\n text: `, ${LoggerScopeRewriter.TARGET_NAME}`,\n });\n }\n continue;\n }\n\n if (hasTarget) {\n LoggerScopeRewriter.dropSpecifier({\n sourceFile,\n specifier,\n elements: imported.elements,\n edits,\n });\n } else {\n edits.push({\n start: specifier.getStart(sourceFile),\n end: specifier.getEnd(),\n text: LoggerScopeRewriter.TARGET_NAME,\n });\n }\n }\n }\n\n /** A re-export of the removed class from a listed module, or a type-only import of it, is listed. */\n private static reportDeclarations(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, sourceFile, report } = opts;\n const named = (element: { propertyName?: ts.ModuleExportName; name: ts.ModuleExportName }) =>\n (element.propertyName ?? element.name).text === LoggerScopeRewriter.CLASS_NAME;\n\n for (const statement of sourceFile.statements) {\n if (\n typescript.isExportDeclaration(statement) &&\n statement.moduleSpecifier &&\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text) &&\n statement.exportClause &&\n typescript.isNamedExports(statement.exportClause) &&\n statement.exportClause.elements.some(named)\n ) {\n report(\n statement,\n '`ApplicationLogger` no longer exists: this re-export has no replacement, remove it (`LoggerFactory` is the class)',\n );\n }\n\n if (\n typescript.isImportDeclaration(statement) &&\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text)\n ) {\n const bindings = statement.importClause?.namedBindings;\n const isNamed = bindings && typescript.isNamedImports(bindings);\n const isTypeImport = statement.importClause?.isTypeOnly === true;\n const typed =\n isNamed &&\n bindings.elements.some(\n (element) => named(element) && (isTypeImport || element.isTypeOnly),\n );\n\n if (typed) {\n report(\n statement,\n '`ApplicationLogger` no longer exists: this type-only import has no replacement, use the type of what `LoggerFactory.getLogger` returns (`ILogger`)',\n );\n }\n }\n }\n }\n\n /** Where `LoggerFactory` stands in the file: imported from a listed module (under which local name), or a name clash. */\n private static findFactory(opts: { typescript: TTypeScript; sourceFile: ts.SourceFile }): {\n local?: string;\n collision?: ts.Node;\n } {\n const { typescript, sourceFile } = opts;\n const found: { local?: string; collision?: ts.Node } = {};\n\n for (const statement of sourceFile.statements) {\n if (typescript.isImportDeclaration(statement)) {\n const bindings = statement.importClause?.namedBindings;\n if (!bindings || !typescript.isNamedImports(bindings)) {\n continue;\n }\n\n for (const element of bindings.elements) {\n if ((element.propertyName ?? element.name).text !== LoggerScopeRewriter.TARGET_NAME) {\n continue;\n }\n\n const isListed =\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text);\n if (isListed) {\n found.local = element.name.text;\n } else {\n found.collision = element;\n }\n }\n continue;\n }\n\n const isNamedDeclaration =\n (typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement)) &&\n statement.name?.text === LoggerScopeRewriter.TARGET_NAME;\n const isNamedVariable =\n typescript.isVariableStatement(statement) &&\n statement.declarationList.declarations.some(\n (declaration) =>\n typescript.isIdentifier(declaration.name) &&\n declaration.name.text === LoggerScopeRewriter.TARGET_NAME,\n );\n\n if (isNamedDeclaration || isNamedVariable) {\n found.collision = statement;\n }\n }\n\n return found;\n }\n\n /** Every use of the removed class that is not a call this run rewrote (a type, a value, an export) is listed. */\n private static reportLeftovers(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n locals: ILocals;\n rewrittenOwners: Set<ts.Node>;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, sourceFile, locals, rewrittenOwners, report } = opts;\n\n const visit = (node: ts.Node): void => {\n if (typescript.isIdentifier(node) && !rewrittenOwners.has(node)) {\n const parent = node.parent;\n const isImportName = typescript.isImportSpecifier(parent);\n const isProperty = typescript.isPropertyAccessExpression(parent) && parent.name === node;\n const isLocal = locals.named.has(node.text);\n\n if (isLocal && !isImportName && !isProperty) {\n report(\n node,\n '`ApplicationLogger` no longer exists and this use is not a call the codemod rewrites: change it by hand (`LoggerFactory` is the class, `ILogger` the type of a logger)',\n );\n }\n }\n\n if (\n typescript.isPropertyAccessExpression(node) &&\n node.name.text === LoggerScopeRewriter.CLASS_NAME &&\n typescript.isIdentifier(node.expression) &&\n locals.namespaces.has(node.expression.text) &&\n !rewrittenOwners.has(node)\n ) {\n report(\n node,\n '`ApplicationLogger` no longer exists and this use is not a call the codemod rewrites: change it by hand',\n );\n }\n\n typescript.forEachChild(node, visit);\n };\n visit(sourceFile);\n }\n\n /** How many identifiers named `name` the file holds, the import specifier included. */\n private static countReferences(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n name: string;\n }): number {\n const { typescript, sourceFile, name } = opts;\n let count = 0;\n\n const visit = (node: ts.Node): void => {\n if (typescript.isIdentifier(node) && node.text === name) {\n // A property name (`x.name`) is not a reference to the import.\n const parent = node.parent;\n const isProperty = typescript.isPropertyAccessExpression(parent) && parent.name === node;\n if (!isProperty) {\n count += 1;\n }\n }\n typescript.forEachChild(node, visit);\n };\n visit(sourceFile);\n\n return count;\n }\n\n /** Removes one specifier from a named import together with its comma. */\n private static dropSpecifier(opts: {\n sourceFile: ts.SourceFile;\n specifier: ts.ImportSpecifier;\n elements: ts.NodeArray<ts.ImportSpecifier>;\n edits: IEdit[];\n }): void {\n const { sourceFile, specifier, elements, edits } = opts;\n const index = elements.indexOf(specifier);\n const next = elements[index + 1];\n const previous = elements[index - 1];\n\n if (next) {\n edits.push({\n start: specifier.getStart(sourceFile),\n end: next.getStart(sourceFile),\n text: '',\n });\n } else if (previous) {\n edits.push({ start: previous.getEnd(), end: specifier.getEnd(), text: '' });\n } else {\n edits.push({ start: specifier.getStart(sourceFile), end: specifier.getEnd(), text: '' });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"logger-scope.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/logger-scope.ts"],"names":[],"mappings":";;;AAqBA;;;;;;;;;;;GAWG;AACH,MAAa,mBAAmB;aACd,eAAU,GAAG,mBAAmB,CAAC;aACjC,gBAAW,GAAG,eAAe,CAAC;aAC9B,YAAO,GAA0B,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;IAE9F,iFAAiF;IACjF,MAAM,CAAC,QAAQ,CAAC,IAAwB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,IAId;QACC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAC9C,MAAM,OAAO,GAAgC,EAAE,CAAC;QAChD,MAAM,SAAS,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;QAE5E,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YAC9C,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,UAAU,GAAG,UAAU,CAAC,gBA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EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;;AAzhBH,kDA0hBC","sourcesContent":["import type ts from 'typescript';\nimport type { INamespaceFunctionsReport, INamespaceFunctionsResult } from './rewriter';\n\ntype TTypeScript = typeof ts;\n\ninterface IEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** How a file reaches `ApplicationLogger`: by a named import (aliased too), or through a namespace import. */\ninterface ILocals {\n /** Local name -> the import specifier that declares it. */\n named: Map<string, ts.ImportSpecifier>;\n /** Local name of `import * as name`. */\n namespaces: Set<string>;\n /** The import declarations of the listed modules, in order. */\n declarations: ts.ImportDeclaration[];\n}\n\n/**\n * The call-shape rule that goes with the table. `ApplicationLogger` is removed: every form of it becomes\n * `LoggerFactory.getLogger([scope])`, so `ApplicationLogger.get('scope')`, `ApplicationLogger.get(NAME)` and\n * `ApplicationLogger.get({ scope: NAME })` all become `LoggerFactory.getLogger(['scope'])`, `...([NAME])`. The call is on a\n * class, not a function in a table, so the table cannot carry it.\n *\n * It follows `ApplicationLogger` imported by name (aliased too) or reached through a namespace import from\n * `@venizia/ignis-helpers` or `@venizia/ignis`, adds `LoggerFactory` to that import and drops `ApplicationLogger` once\n * nothing else uses it. The argument may be a string literal, a template, an identifier, a property access, or an\n * object literal that holds only `scope`. It never touches `Logger.get` or `HfLogger.get`, and it lists a call it cannot\n * decide with file and line.\n */\nexport class LoggerScopeRewriter {\n static readonly CLASS_NAME = 'ApplicationLogger';\n static readonly TARGET_NAME = 'LoggerFactory';\n static readonly MODULES: ReadonlyArray<string> = ['@venizia/ignis-helpers', '@venizia/ignis'];\n\n /** Whether the file can hold such a call, so a file without it is not parsed. */\n static mentions(opts: { source: string }): boolean {\n return opts.source.includes(LoggerScopeRewriter.CLASS_NAME);\n }\n\n static rewrite(opts: {\n typescript: TTypeScript;\n fileName: string;\n source: string;\n }): INamespaceFunctionsResult {\n const { typescript, fileName, source } = opts;\n const reports: INamespaceFunctionsReport[] = [];\n const unchanged = { output: source, changed: false, rewritten: 0, reports };\n\n if (!LoggerScopeRewriter.mentions({ source })) {\n return unchanged;\n }\n\n const sourceFile = typescript.createSourceFile(\n fileName,\n source,\n typescript.ScriptTarget.Latest,\n true,\n );\n\n const report = (node: ts.Node, reason: string) => {\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(sourceFile),\n );\n reports.push({ line: line + 1, column: character + 1, reason });\n };\n\n // A re-export or a type-only import of the removed class is not a call: it is listed, never silently kept.\n LoggerScopeRewriter.reportDeclarations({ typescript, sourceFile, report });\n\n const locals = LoggerScopeRewriter.findLocals({ typescript, sourceFile });\n\n if (locals.named.size === 0 && locals.namespaces.size === 0) {\n return unchanged;\n }\n\n const factory = LoggerScopeRewriter.findFactory({ typescript, sourceFile });\n\n if (factory.collision) {\n report(\n factory.collision,\n '`LoggerFactory` is already declared in this file (or imported from another module): rewrite `ApplicationLogger` by hand as `LoggerFactory.getLogger([scope])`',\n );\n\n return unchanged;\n }\n\n const factoryName = factory.local ?? LoggerScopeRewriter.TARGET_NAME;\n const edits: IEdit[] = [];\n /** Identifiers of the old class that a rewritten call replaced: what is left after them keeps the import. */\n const rewrittenOwners = new Set<ts.Node>();\n\n const visit = (node: ts.Node): void => {\n if (typescript.isCallExpression(node)) {\n const owner = LoggerScopeRewriter.loggerOwnerOf({ typescript, call: node, locals });\n\n if (owner) {\n LoggerScopeRewriter.plan({\n typescript,\n sourceFile,\n call: node,\n owner,\n factoryName,\n edits,\n rewrittenOwners,\n report,\n });\n }\n }\n\n typescript.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\n if (edits.length === 0) {\n return unchanged;\n }\n\n LoggerScopeRewriter.planImports({\n typescript,\n sourceFile,\n locals,\n rewrittenOwners,\n hasFactory: factory.local !== undefined,\n edits,\n });\n LoggerScopeRewriter.reportLeftovers({\n typescript,\n sourceFile,\n locals,\n rewrittenOwners,\n report,\n });\n\n let output = source;\n\n for (const edit of [...edits].sort((first, second) => second.start - first.start)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return { output, changed: true, rewritten: rewrittenOwners.size, reports };\n }\n\n private static findLocals(opts: { typescript: TTypeScript; sourceFile: ts.SourceFile }): ILocals {\n const { typescript, sourceFile } = opts;\n const locals: ILocals = { named: new Map(), namespaces: new Set(), declarations: [] };\n\n for (const statement of sourceFile.statements) {\n if (\n !typescript.isImportDeclaration(statement) ||\n !typescript.isStringLiteral(statement.moduleSpecifier) ||\n !LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text)\n ) {\n continue;\n }\n\n const bindings = statement.importClause?.namedBindings;\n\n if (!bindings || statement.importClause?.isTypeOnly) {\n continue;\n }\n\n locals.declarations.push(statement);\n\n if (typescript.isNamespaceImport(bindings)) {\n locals.namespaces.add(bindings.name.text);\n continue;\n }\n\n for (const specifier of bindings.elements) {\n if (specifier.isTypeOnly) {\n continue;\n }\n\n if ((specifier.propertyName ?? specifier.name).text === LoggerScopeRewriter.CLASS_NAME) {\n locals.named.set(specifier.name.text, specifier);\n }\n }\n }\n\n return locals;\n }\n\n /** The node that names the class in `<ApplicationLogger>.get(...)` or `<namespace>.ApplicationLogger.get(...)`, else undefined. */\n private static loggerOwnerOf(opts: {\n typescript: TTypeScript;\n call: ts.CallExpression;\n locals: ILocals;\n }): ts.Identifier | ts.PropertyAccessExpression | undefined {\n const { typescript, call, locals } = opts;\n const callee = call.expression;\n\n if (!typescript.isPropertyAccessExpression(callee) || callee.name.text !== 'get') {\n return undefined;\n }\n\n const owner = callee.expression;\n\n if (typescript.isIdentifier(owner) && locals.named.has(owner.text)) {\n return owner;\n }\n\n if (\n typescript.isPropertyAccessExpression(owner) &&\n owner.name.text === LoggerScopeRewriter.CLASS_NAME &&\n typescript.isIdentifier(owner.expression) &&\n locals.namespaces.has(owner.expression.text)\n ) {\n return owner;\n }\n\n return undefined;\n }\n\n /** The scope expression of the call, as text, or a reason it cannot be decided. */\n private static scopeOf(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n call: ts.CallExpression;\n }): { text: string } | { reason: string } {\n const { typescript, sourceFile, call } = opts;\n const [argument] = call.arguments;\n\n if (call.arguments.length !== 1 || !argument) {\n return {\n reason:\n '`ApplicationLogger.get` is called with no argument or more than one: rewrite it by hand as `LoggerFactory.getLogger([scope])`',\n };\n }\n\n if (typescript.isObjectLiteralExpression(argument)) {\n const [property, ...rest] = argument.properties;\n const isOnlyScope =\n rest.length === 0 &&\n property !== undefined &&\n (typescript.isShorthandPropertyAssignment(property) ||\n typescript.isPropertyAssignment(property)) &&\n typescript.isIdentifier(property.name) &&\n property.name.text === 'scope';\n\n if (!isOnlyScope) {\n return {\n reason:\n '`ApplicationLogger.get` gets an object that is not `{ scope: <expression> }`: rewrite it by hand as `LoggerFactory.getLogger([scope])`',\n };\n }\n\n return {\n text: typescript.isShorthandPropertyAssignment(property)\n ? property.name.text\n : property.initializer.getText(sourceFile),\n };\n }\n\n const isDecidable =\n typescript.isStringLiteral(argument) ||\n typescript.isNoSubstitutionTemplateLiteral(argument) ||\n typescript.isTemplateExpression(argument) ||\n typescript.isIdentifier(argument) ||\n typescript.isPropertyAccessExpression(argument);\n\n if (!isDecidable) {\n return {\n reason:\n '`ApplicationLogger.get` gets an argument whose type the codemod cannot tell (a call, a spread or another expression): rewrite it by hand as `LoggerFactory.getLogger([<argument>])`',\n };\n }\n\n return { text: argument.getText(sourceFile) };\n }\n\n /** One edit for a call whose scope is decided: the whole call text becomes `<owner replaced>.getLogger([scope])`. */\n private static plan(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n call: ts.CallExpression;\n owner: ts.Identifier | ts.PropertyAccessExpression;\n factoryName: string;\n edits: IEdit[];\n rewrittenOwners: Set<ts.Node>;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, sourceFile, call, owner, factoryName, edits, rewrittenOwners, report } =\n opts;\n const scope = LoggerScopeRewriter.scopeOf({ typescript, sourceFile, call });\n\n if ('reason' in scope) {\n report(call, scope.reason);\n\n return;\n }\n\n // `<namespace>.ApplicationLogger` keeps its namespace: `helpers.LoggerFactory.getLogger([...])`.\n const ownerText = typescript.isIdentifier(owner)\n ? factoryName\n : `${owner.expression.getText(sourceFile)}.${LoggerScopeRewriter.TARGET_NAME}`;\n\n edits.push({\n start: call.getStart(sourceFile),\n end: call.getEnd(),\n text: `${ownerText}.getLogger([${scope.text}])`,\n });\n rewrittenOwners.add(owner);\n }\n\n /**\n * `LoggerFactory` is added to the import that carried `ApplicationLogger`, and `ApplicationLogger` leaves it when no\n * other use of it remains.\n */\n private static planImports(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n locals: ILocals;\n rewrittenOwners: Set<ts.Node>;\n /** `LoggerFactory` is already imported from a listed module (maybe under another name). */\n hasFactory: boolean;\n edits: IEdit[];\n }): void {\n const { typescript, sourceFile, locals, rewrittenOwners, hasFactory, edits } = opts;\n\n for (const [local, specifier] of locals.named) {\n const used = LoggerScopeRewriter.countReferences({ typescript, sourceFile, name: local });\n const replaced = [...rewrittenOwners].filter(\n (owner) => typescript.isIdentifier(owner) && owner.text === local,\n ).length;\n const declaration = specifier.parent.parent.parent;\n const imported = declaration.importClause?.namedBindings;\n\n if (!imported || !typescript.isNamedImports(imported)) {\n continue;\n }\n\n const hasTarget = hasFactory;\n const isLeft = used - replaced > 1; // the import specifier itself is one reference\n\n if (isLeft) {\n if (!hasTarget) {\n edits.push({\n start: specifier.getEnd(),\n end: specifier.getEnd(),\n text: `, ${LoggerScopeRewriter.TARGET_NAME}`,\n });\n }\n\n continue;\n }\n\n if (hasTarget) {\n LoggerScopeRewriter.dropSpecifier({\n sourceFile,\n specifier,\n elements: imported.elements,\n edits,\n });\n } else {\n edits.push({\n start: specifier.getStart(sourceFile),\n end: specifier.getEnd(),\n text: LoggerScopeRewriter.TARGET_NAME,\n });\n }\n }\n }\n\n /** A re-export of the removed class from a listed module, or a type-only import of it, is listed. */\n private static reportDeclarations(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, sourceFile, report } = opts;\n const named = (element: { propertyName?: ts.ModuleExportName; name: ts.ModuleExportName }) =>\n (element.propertyName ?? element.name).text === LoggerScopeRewriter.CLASS_NAME;\n\n for (const statement of sourceFile.statements) {\n if (\n typescript.isExportDeclaration(statement) &&\n statement.moduleSpecifier &&\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text) &&\n statement.exportClause &&\n typescript.isNamedExports(statement.exportClause) &&\n statement.exportClause.elements.some(named)\n ) {\n report(\n statement,\n '`ApplicationLogger` no longer exists: this re-export has no replacement, remove it (`LoggerFactory` is the class)',\n );\n }\n\n if (\n typescript.isImportDeclaration(statement) &&\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text)\n ) {\n const bindings = statement.importClause?.namedBindings;\n const isNamed = bindings && typescript.isNamedImports(bindings);\n const isTypeImport = statement.importClause?.isTypeOnly === true;\n const typed =\n isNamed &&\n bindings.elements.some(\n (element) => named(element) && (isTypeImport || element.isTypeOnly),\n );\n\n if (typed) {\n report(\n statement,\n '`ApplicationLogger` no longer exists: this type-only import has no replacement, use the type of what `LoggerFactory.getLogger` returns (`ILogger`)',\n );\n }\n }\n }\n }\n\n /** Where `LoggerFactory` stands in the file: imported from a listed module (under which local name), or a name clash. */\n private static findFactory(opts: { typescript: TTypeScript; sourceFile: ts.SourceFile }): {\n local?: string;\n collision?: ts.Node;\n } {\n const { typescript, sourceFile } = opts;\n const found: { local?: string; collision?: ts.Node } = {};\n\n for (const statement of sourceFile.statements) {\n if (typescript.isImportDeclaration(statement)) {\n const bindings = statement.importClause?.namedBindings;\n\n if (!bindings || !typescript.isNamedImports(bindings)) {\n continue;\n }\n\n for (const element of bindings.elements) {\n if ((element.propertyName ?? element.name).text !== LoggerScopeRewriter.TARGET_NAME) {\n continue;\n }\n\n const isListed =\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n LoggerScopeRewriter.MODULES.includes(statement.moduleSpecifier.text);\n\n if (isListed) {\n found.local = element.name.text;\n } else {\n found.collision = element;\n }\n }\n\n continue;\n }\n\n const isNamedDeclaration =\n (typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement)) &&\n statement.name?.text === LoggerScopeRewriter.TARGET_NAME;\n const isNamedVariable =\n typescript.isVariableStatement(statement) &&\n statement.declarationList.declarations.some(\n (declaration) =>\n typescript.isIdentifier(declaration.name) &&\n declaration.name.text === LoggerScopeRewriter.TARGET_NAME,\n );\n\n if (isNamedDeclaration || isNamedVariable) {\n found.collision = statement;\n }\n }\n\n return found;\n }\n\n /** Every use of the removed class that is not a call this run rewrote (a type, a value, an export) is listed. */\n private static reportLeftovers(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n locals: ILocals;\n rewrittenOwners: Set<ts.Node>;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, sourceFile, locals, rewrittenOwners, report } = opts;\n\n const visit = (node: ts.Node): void => {\n if (typescript.isIdentifier(node) && !rewrittenOwners.has(node)) {\n const parent = node.parent;\n const isImportName = typescript.isImportSpecifier(parent);\n const isProperty = typescript.isPropertyAccessExpression(parent) && parent.name === node;\n const isLocal = locals.named.has(node.text);\n\n if (isLocal && !isImportName && !isProperty) {\n report(\n node,\n '`ApplicationLogger` no longer exists and this use is not a call the codemod rewrites: change it by hand (`LoggerFactory` is the class, `ILogger` the type of a logger)',\n );\n }\n }\n\n if (\n typescript.isPropertyAccessExpression(node) &&\n node.name.text === LoggerScopeRewriter.CLASS_NAME &&\n typescript.isIdentifier(node.expression) &&\n locals.namespaces.has(node.expression.text) &&\n !rewrittenOwners.has(node)\n ) {\n report(\n node,\n '`ApplicationLogger` no longer exists and this use is not a call the codemod rewrites: change it by hand',\n );\n }\n\n typescript.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n }\n\n /** How many identifiers named `name` the file holds, the import specifier included. */\n private static countReferences(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n name: string;\n }): number {\n const { typescript, sourceFile, name } = opts;\n let count = 0;\n\n const visit = (node: ts.Node): void => {\n if (typescript.isIdentifier(node) && node.text === name) {\n // A property name (`x.name`) is not a reference to the import.\n const parent = node.parent;\n const isProperty = typescript.isPropertyAccessExpression(parent) && parent.name === node;\n\n if (!isProperty) {\n count += 1;\n }\n }\n\n typescript.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\n return count;\n }\n\n /** Removes one specifier from a named import together with its comma. */\n private static dropSpecifier(opts: {\n sourceFile: ts.SourceFile;\n specifier: ts.ImportSpecifier;\n elements: ts.NodeArray<ts.ImportSpecifier>;\n edits: IEdit[];\n }): void {\n const { sourceFile, specifier, elements, edits } = opts;\n const index = elements.indexOf(specifier);\n const next = elements[index + 1];\n const previous = elements[index - 1];\n\n if (next) {\n edits.push({\n start: specifier.getStart(sourceFile),\n end: next.getStart(sourceFile),\n text: '',\n });\n } else if (previous) {\n edits.push({ start: previous.getEnd(), end: specifier.getEnd(), text: '' });\n } else {\n edits.push({ start: specifier.getStart(sourceFile), end: specifier.getEnd(), text: '' });\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/mapping.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AA8BH,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAExC,8BA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AAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,EAAE,CAAC;gBACzF,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,sDAAsD,CAAC,CAAC;YAChF,CAAC;YAED,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBAC1C,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;oBACjB,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,SAAS,MAAM,kBAAkB,CAAC,CAAC;gBAC/E,CAAC;gBACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAzED,8CAyEC","sourcesContent":["/**\n * The table behind `devz codemod namespace-functions`. One entry per public function that moved into\n * a class: the old name is no longer exported, and the codemod moves callers to the class form, so an\n * entry is the only upgrade path for that name.\n *\n * How an entry is written, in the file of the package that exports the old name\n * (`mappings/<package-dir>.ts`):\n *\n * ```ts\n * {\n * // Every module specifier the old name can be imported from: the root, a subpath, a re-export.\n * modules: ['@venizia/ignis-helpers', '@venizia/ignis-helpers/core'],\n * oldName: 'float',\n * className: 'ParseUtility',\n * method: 'toFloat',\n * // Where the class is imported from, when that is not where the old name came from. Optional.\n * newModules: ['@venizia/ignis-helpers'],\n * // The old positional parameters in order; each becomes a key of the options object. A parameter\n * // that has a default value in the old function is `optional`, and an optional one is never\n * // followed by a required one.\n * params: [{ key: 'input' }, { key: 'digit', optional: true }],\n * // The old rest parameter, if any (`float` has none): its arguments go under this key as one\n * // array, `[]` when the call passes none. Optional.\n * // restKey: 'values',\n * }\n * ```\n *\n * So `float(value, 3)` becomes `ParseUtility.toFloat({ input: value, digit: 3 })`, and `float(input)`\n * becomes `ParseUtility.toFloat({ input })`. Add the entry in the pull request that adds the class\n * and removes the old export, never before: the codemod would rewrite callers to a method that does not\n * exist yet. `NamespaceMappings.validate` checks every entry in the test suite.\n */\n\n/** One old positional parameter, and the key it becomes in the options object. */\nexport interface INamespaceMappingParameter {\n key: string;\n /** The old parameter has a default value: a call may leave it out, and then the key is left out. */\n optional?: boolean;\n}\n\n/** One function that moved into a class. */\nexport interface INamespaceMapping {\n /** Every module specifier the old name can be imported from. */\n modules: string[];\n oldName: string;\n className: string;\n method: string;\n /** Where the class is imported from; without it, from the module the old name was imported from. */\n newModules?: string[];\n /** The old positional parameters, in order. */\n params: INamespaceMappingParameter[];\n /** The old rest parameter: its arguments are passed as one array under this key. */\n restKey?: string;\n /**\n * The old function already takes ONE options object and the method takes the same one, so a call\n * keeps its arguments and only the callee changes: `isEmpty({ value })` becomes\n * `ObjectUtility.isEmpty({ value })`. `params` is empty and `restKey` unset for such an entry.\n */\n keepsOptions?: boolean;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\n/** Checks a mapping table. */\nexport class NamespaceMappings {\n /** What is wrong with the table, one line per problem; empty when every entry is usable. */\n static validate(opts: { mappings: ReadonlyArray<INamespaceMapping> }): string[] {\n const { mappings } = opts;\n const problems: string[] = [];\n const seen = new Set<string>();\n\n for (const mapping of mappings) {\n const label = `${mapping.oldName} -> ${mapping.className}.${mapping.method}`;\n\n for (const [field, value] of [\n ['oldName', mapping.oldName],\n ['className', mapping.className],\n ['method', mapping.method],\n ] as const) {\n if (!IDENTIFIER.test(value)) {\n problems.push(`${label}: ${field} \"${value}\" is not an identifier`);\n }\n }\n\n if (mapping.modules.length === 0 || mapping.modules.some((module) => module.trim() === '')) {\n problems.push(`${label}: modules must list at least one module specifier, none empty`);\n }\n\n if (mapping.newModules?.length === 0) {\n problems.push(`${label}: newModules, when given, lists at least one module specifier`);\n }\n\n const keys = new Set<string>();\n let isOptionalSeen = false;\n for (const parameter of mapping.params) {\n if (!IDENTIFIER.test(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is not an identifier`);\n }\n\n if (keys.has(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is listed twice`);\n }\n keys.add(parameter.key);\n\n if (isOptionalSeen && !parameter.optional) {\n problems.push(\n `${label}: the required parameter \"${parameter.key}\" follows an optional one`,\n );\n }\n isOptionalSeen = isOptionalSeen || parameter.optional === true;\n }\n\n if (mapping.restKey !== undefined) {\n if (!IDENTIFIER.test(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is not an identifier`);\n }\n\n if (keys.has(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is also a parameter key`);\n }\n }\n\n if (mapping.keepsOptions && (mapping.params.length > 0 || mapping.restKey !== undefined)) {\n problems.push(`${label}: keepsOptions leaves params empty and restKey unset`);\n }\n\n for (const module of mapping.modules) {\n const id = `${module}#${mapping.oldName}`;\n if (seen.has(id)) {\n problems.push(`${label}: ${mapping.oldName} from ${module} has two entries`);\n }\n seen.add(id);\n }\n }\n\n return problems;\n }\n}\n"]}
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/mapping.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AA8BH,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAExC,8BAA8B;AAC9B,MAAa,iBAAiB;IAC5B,4FAA4F;IAC5F,MAAM,CAAC,QAAQ,CAAC,IAAoD;QAClE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAE/B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,KAAK,GAAG,GAAG,OAAO,CAAC,OAAO,OAAO,OAAO,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GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;oBACjB,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,SAAS,MAAM,kBAAkB,CAAC,CAAC;gBAC/E,CAAC;gBAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA9ED,8CA8EC","sourcesContent":["/**\n * The table behind `devz codemod namespace-functions`. One entry per public function that moved into\n * a class: the old name is no longer exported, and the codemod moves callers to the class form, so an\n * entry is the only upgrade path for that name.\n *\n * How an entry is written, in the file of the package that exports the old name\n * (`mappings/<package-dir>.ts`):\n *\n * ```ts\n * {\n * // Every module specifier the old name can be imported from: the root, a subpath, a re-export.\n * modules: ['@venizia/ignis-helpers', '@venizia/ignis-helpers/core'],\n * oldName: 'float',\n * className: 'ParseUtility',\n * method: 'toFloat',\n * // Where the class is imported from, when that is not where the old name came from. Optional.\n * newModules: ['@venizia/ignis-helpers'],\n * // The old positional parameters in order; each becomes a key of the options object. A parameter\n * // that has a default value in the old function is `optional`, and an optional one is never\n * // followed by a required one.\n * params: [{ key: 'input' }, { key: 'digit', optional: true }],\n * // The old rest parameter, if any (`float` has none): its arguments go under this key as one\n * // array, `[]` when the call passes none. Optional.\n * // restKey: 'values',\n * }\n * ```\n *\n * So `float(value, 3)` becomes `ParseUtility.toFloat({ input: value, digit: 3 })`, and `float(input)`\n * becomes `ParseUtility.toFloat({ input })`. Add the entry in the pull request that adds the class\n * and removes the old export, never before: the codemod would rewrite callers to a method that does not\n * exist yet. `NamespaceMappings.validate` checks every entry in the test suite.\n */\n\n/** One old positional parameter, and the key it becomes in the options object. */\nexport interface INamespaceMappingParameter {\n key: string;\n /** The old parameter has a default value: a call may leave it out, and then the key is left out. */\n optional?: boolean;\n}\n\n/** One function that moved into a class. */\nexport interface INamespaceMapping {\n /** Every module specifier the old name can be imported from. */\n modules: string[];\n oldName: string;\n className: string;\n method: string;\n /** Where the class is imported from; without it, from the module the old name was imported from. */\n newModules?: string[];\n /** The old positional parameters, in order. */\n params: INamespaceMappingParameter[];\n /** The old rest parameter: its arguments are passed as one array under this key. */\n restKey?: string;\n /**\n * The old function already takes ONE options object and the method takes the same one, so a call\n * keeps its arguments and only the callee changes: `isEmpty({ value })` becomes\n * `ObjectUtility.isEmpty({ value })`. `params` is empty and `restKey` unset for such an entry.\n */\n keepsOptions?: boolean;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\n/** Checks a mapping table. */\nexport class NamespaceMappings {\n /** What is wrong with the table, one line per problem; empty when every entry is usable. */\n static validate(opts: { mappings: ReadonlyArray<INamespaceMapping> }): string[] {\n const { mappings } = opts;\n const problems: string[] = [];\n const seen = new Set<string>();\n\n for (const mapping of mappings) {\n const label = `${mapping.oldName} -> ${mapping.className}.${mapping.method}`;\n\n for (const [field, value] of [\n ['oldName', mapping.oldName],\n ['className', mapping.className],\n ['method', mapping.method],\n ] as const) {\n if (!IDENTIFIER.test(value)) {\n problems.push(`${label}: ${field} \"${value}\" is not an identifier`);\n }\n }\n\n if (mapping.modules.length === 0 || mapping.modules.some((module) => module.trim() === '')) {\n problems.push(`${label}: modules must list at least one module specifier, none empty`);\n }\n\n if (mapping.newModules?.length === 0) {\n problems.push(`${label}: newModules, when given, lists at least one module specifier`);\n }\n\n const keys = new Set<string>();\n let isOptionalSeen = false;\n\n for (const parameter of mapping.params) {\n if (!IDENTIFIER.test(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is not an identifier`);\n }\n\n if (keys.has(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is listed twice`);\n }\n\n keys.add(parameter.key);\n\n if (isOptionalSeen && !parameter.optional) {\n problems.push(\n `${label}: the required parameter \"${parameter.key}\" follows an optional one`,\n );\n }\n\n isOptionalSeen = isOptionalSeen || parameter.optional === true;\n }\n\n if (mapping.restKey !== undefined) {\n if (!IDENTIFIER.test(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is not an identifier`);\n }\n\n if (keys.has(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is also a parameter key`);\n }\n }\n\n if (mapping.keepsOptions && (mapping.params.length > 0 || mapping.restKey !== undefined)) {\n problems.push(`${label}: keepsOptions leaves params empty and restKey unset`);\n }\n\n for (const module of mapping.modules) {\n const id = `${module}#${mapping.oldName}`;\n\n if (seen.has(id)) {\n problems.push(`${label}: ${mapping.oldName} from ${module} has two entries`);\n }\n\n seen.add(id);\n }\n }\n\n return problems;\n }\n}\n"]}
@@ -1 +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,EACR,MAAM,EACN,UAAU,CAAC,YAAY,CAAC,MAAM,EAC9B,IAAI,CACL,CAAC;QACF,MAAM,OAAO,GAAgC,EAAE,CAAC;QAEhD,MAAM,MAAM,GAAG,CAAC,UAA6C,EAAE,EAAE;YAC/D,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,6BAA6B,CAClE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CACrC,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACrF,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,CAAC,IAAa,EAAE,EAA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cesContent":["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"]}
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,EACR,MAAM,EACN,UAAU,CAAC,YAAY,CAAC,MAAM,EAC9B,IAAI,CACL,CAAC;QACF,MAAM,OAAO,GAAgC,EAAE,CAAC;QAEhD,MAAM,MAAM,GAAG,CAAC,UAA6C,EAAE,EAAE;YAC/D,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,6BAA6B,CAClE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CACrC,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QACrF,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,CAAC,IAAa,EAAE,EAAE,CAC/B,UAAU,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAE/E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;QAExD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,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AAU,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAExE,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,4FAA4F;IACpF,MAAM,CAAC,cAAc,CAAC,IAAoC;QAChE,MAAM,EAAE,SAAS,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;QAE1F,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;AAnxBD,gDAmxBC","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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\n if (typescript.isCallExpression(call) && call.expression === parent) {\n uses.calls.push(call);\n } else {\n uses.values.push(parent);\n }\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\n continue;\n }\n\n const parent = identifier.parent;\n\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\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\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\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\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\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\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\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\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\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\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\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\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\n return keys.length === 0\n ? `${className}.${method}()`\n : `${className}.${method}({ ${keys.join(', ')} })`;\n }\n}\n"]}
@@ -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;;;;;;;;;;;;;8EAagE,CAAC;AAE/E,MAAM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AC,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 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 codemod connector-imports [paths...] move @venizia/ignis/<connector sub-path> imports to @venizia/ignis-connectors (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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AAK,EAAE,CAAC,CAAC;IAEpE,OAAO,CAAC,CAAC;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 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 codemod connector-imports [paths...] move @venizia/ignis/<connector sub-path> imports to @venizia/ignis-connectors (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\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\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAmD;AAEnD,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,MAAM,aAAa,GAAG,kCAAkC,CAAC;AACzD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACzD,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;AACpF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1E,qHAAqH;AACrH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,GAAG,iBAAiB;IACpB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,2DAA2D,CAAC;AAChF,MAAM,QAAQ,GAAG,OAAO,CAAC;AAQzB;;;;;GAKG;AACH,MAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,IAAoC;QACpD,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO,E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AE,IAAI,CAAC,IAAI;gBACd,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;aACzC,CAAC,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC;YAEpC,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;gBACnB,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAtHD,kCAsHC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\n\nconst LINT_CONFIG = '.configs/lints/oxlint.config.mts';\nconst ESLINT_CONFIG = '.configs/lints/eslint.config.mjs';\nconst LINT_IGNORE_FILE = '.configs/lints/.ignore';\nconst FORMAT_IGNORE_FILE = '.configs/formatters/.ignore';\nconst ESLINT_CACHE = ['--cache', '--cache-location', 'node_modules/.cache/eslint/'];\nconst LINTED_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.js', '.mjs']);\n/** What `bun fmt` formats: the code, JSON (package.json keys are sorted), YAML, CSS, HTML and Vue - not Markdown. */\nconst FORMATTED_EXTENSIONS = new Set([\n ...LINTED_EXTENSIONS,\n '.json',\n '.jsonc',\n '.yml',\n '.yaml',\n '.css',\n '.html',\n '.vue',\n]);\nconst FORMAT_GLOB = '**/*.{ts,mts,tsx,js,mjs,json,jsonc,yml,yaml,css,html,vue}';\nconst FIX_FLAG = '--fix';\n\n/** One tool call: the tool name and its arguments, run from the project root. */\nexport interface ILintStep {\n tool: string;\n args: string[];\n}\n\n/**\n * `devz lint [--fix] [files]`: oxlint, then ESLint, then `bun fmt`, from the project's\n * `.configs/lints/` and `.configs/formatters/.ignore`. `bun fmt` takes its options from the `[fmt]` table\n * of the nearest `bunfig.toml`. With no file it checks the whole project; with files it handles only\n * those, as a pre-commit hook passes them.\n */\nexport class LintCommand {\n /**\n * The patterns of an ignore file, one per line, `#` comments and blank lines skipped. An ignore\n * file resolves its patterns from its own folder, so they go on the command line instead, which\n * resolves from the project root.\n */\n static readIgnore(opts: { root: string; file: string }): string[] {\n const path = join(opts.root, opts.file);\n if (!existsSync(path)) {\n return [];\n }\n\n return readFileSync(path, 'utf8')\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line !== '' && !line.startsWith('#'));\n }\n\n /**\n * The tool calls for these arguments, in order; empty when a file list holds nothing to lint or\n * format. oxlint and ESLint take the code files; `bun fmt` takes those and the other formatted types.\n */\n static plan(opts: { root: string; args: string[] }): ILintStep[] {\n const fix = opts.args[0] === FIX_FLAG;\n const paths = fix ? opts.args.slice(1) : opts.args;\n const whole = paths.length === 0;\n const files = paths.filter((path) => LINTED_EXTENSIONS.has(extname(path)));\n const formatted = paths.filter((path) => FORMATTED_EXTENSIONS.has(extname(path)));\n\n if (!whole && formatted.length === 0) {\n return [];\n }\n\n const targets = whole ? ['.'] : files;\n const lintIgnore = LintCommand.readIgnore({ root: opts.root, file: LINT_IGNORE_FILE }).flatMap(\n (pattern) => ['--ignore-pattern', pattern],\n );\n const formatIgnore = LintCommand.readIgnore({\n root: opts.root,\n file: FORMAT_IGNORE_FILE,\n }).flatMap((pattern) => ['--ignore-pattern', pattern]);\n const unmatched = whole ? [] : ['--no-error-on-unmatched-pattern'];\n const eslintQuiet = whole ? [] : ['--no-warn-ignored'];\n\n const linters: ILintStep[] = [\n {\n tool: 'oxlint',\n args: [\n '-c',\n LINT_CONFIG,\n ...lintIgnore,\n ...unmatched,\n fix ? FIX_FLAG : '--deny-warnings',\n ...targets,\n ],\n },\n {\n tool: 'eslint',\n args: [\n '-c',\n ESLINT_CONFIG,\n ...ESLINT_CACHE,\n ...eslintQuiet,\n ...lintIgnore,\n ...(fix ? [FIX_FLAG] : []),\n ...targets,\n ],\n },\n ];\n const formatter: ILintStep = {\n tool: 'bun',\n args: [\n 'fmt',\n '--no-script',\n ...unmatched,\n ...formatIgnore,\n ...(fix ? [] : ['--check']),\n ...(whole ? [FORMAT_GLOB] : formatted),\n ],\n };\n\n return whole || files.length > 0 ? [...linters, formatter] : [formatter];\n }\n\n /** The tool's binary in the nearest `node_modules/.bin`, else its bare name for PATH to find. */\n static resolveTool(opts: { root: string; tool: string }): string {\n let dir = opts.root;\n while (true) {\n const candidate = join(dir, 'node_modules', '.bin', opts.tool);\n if (existsSync(candidate)) {\n return candidate;\n }\n\n const parent = dirname(dir);\n if (parent === dir) {\n return opts.tool;\n }\n dir = parent;\n }\n }\n\n /** Runs the plan in order and stops at the first tool that fails; returns the exit code. */\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n for (const step of LintCommand.plan(opts)) {\n const child = Bun.spawn({\n cmd: [LintCommand.resolveTool({ root: opts.root, tool: step.tool }), ...step.args],\n cwd: opts.root,\n stdio: ['inherit', 'inherit', 'inherit'],\n });\n const exitCode = await child.exited;\n\n if (exitCode !== 0) {\n return exitCode;\n }\n }\n\n return 0;\n }\n}\n"]}
1
+ {"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAmD;AAEnD,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,MAAM,aAAa,GAAG,kCAAkC,CAAC;AACzD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACzD,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;AACpF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1E,qHAAqH;AACrH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,GAAG,iBAAiB;IACpB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,2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rD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;gBACtB,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;gBAClF,GAAG,EAAE,IAAI,CAAC,IAAI;gBACd,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;aACzC,CAAC,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC;YAEpC,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;gBACnB,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA3HD,kCA2HC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\n\nconst LINT_CONFIG = '.configs/lints/oxlint.config.mts';\nconst ESLINT_CONFIG = '.configs/lints/eslint.config.mjs';\nconst LINT_IGNORE_FILE = '.configs/lints/.ignore';\nconst FORMAT_IGNORE_FILE = '.configs/formatters/.ignore';\nconst ESLINT_CACHE = ['--cache', '--cache-location', 'node_modules/.cache/eslint/'];\nconst LINTED_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.js', '.mjs']);\n/** What `bun fmt` formats: the code, JSON (package.json keys are sorted), YAML, CSS, HTML and Vue - not Markdown. */\nconst FORMATTED_EXTENSIONS = new Set([\n ...LINTED_EXTENSIONS,\n '.json',\n '.jsonc',\n '.yml',\n '.yaml',\n '.css',\n '.html',\n '.vue',\n]);\nconst FORMAT_GLOB = '**/*.{ts,mts,tsx,js,mjs,json,jsonc,yml,yaml,css,html,vue}';\nconst FIX_FLAG = '--fix';\n\n/** One tool call: the tool name and its arguments, run from the project root. */\nexport interface ILintStep {\n tool: string;\n args: string[];\n}\n\n/**\n * `devz lint [--fix] [files]`: oxlint, then ESLint, then `bun fmt`, from the project's\n * `.configs/lints/` and `.configs/formatters/.ignore`. `bun fmt` takes its options from the `[fmt]` table\n * of the nearest `bunfig.toml`. With no file it checks the whole project; with files it handles only\n * those, as a pre-commit hook passes them.\n */\nexport class LintCommand {\n /**\n * The patterns of an ignore file, one per line, `#` comments and blank lines skipped. An ignore\n * file resolves its patterns from its own folder, so they go on the command line instead, which\n * resolves from the project root.\n */\n static readIgnore(opts: { root: string; file: string }): string[] {\n const path = join(opts.root, opts.file);\n\n if (!existsSync(path)) {\n return [];\n }\n\n return readFileSync(path, 'utf8')\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line !== '' && !line.startsWith('#'));\n }\n\n /**\n * The tool calls for these arguments, in order; empty when a file list holds nothing to lint or\n * format. oxlint and ESLint take the code files; `bun fmt` takes those and the other formatted types.\n */\n static plan(opts: { root: string; args: string[] }): ILintStep[] {\n const fix = opts.args[0] === FIX_FLAG;\n const paths = fix ? opts.args.slice(1) : opts.args;\n const whole = paths.length === 0;\n const files = paths.filter((path) => LINTED_EXTENSIONS.has(extname(path)));\n const formatted = paths.filter((path) => FORMATTED_EXTENSIONS.has(extname(path)));\n\n if (!whole && formatted.length === 0) {\n return [];\n }\n\n const targets = whole ? ['.'] : files;\n const lintIgnore = LintCommand.readIgnore({ root: opts.root, file: LINT_IGNORE_FILE }).flatMap(\n (pattern) => ['--ignore-pattern', pattern],\n );\n const formatIgnore = LintCommand.readIgnore({\n root: opts.root,\n file: FORMAT_IGNORE_FILE,\n }).flatMap((pattern) => ['--ignore-pattern', pattern]);\n const unmatched = whole ? [] : ['--no-error-on-unmatched-pattern'];\n const eslintQuiet = whole ? [] : ['--no-warn-ignored'];\n\n const linters: ILintStep[] = [\n {\n tool: 'oxlint',\n args: [\n '-c',\n LINT_CONFIG,\n ...lintIgnore,\n ...unmatched,\n fix ? FIX_FLAG : '--deny-warnings',\n ...targets,\n ],\n },\n {\n tool: 'eslint',\n args: [\n '-c',\n ESLINT_CONFIG,\n ...ESLINT_CACHE,\n ...eslintQuiet,\n ...lintIgnore,\n ...(fix ? [FIX_FLAG] : []),\n ...targets,\n ],\n },\n ];\n const formatter: ILintStep = {\n tool: 'bun',\n args: [\n 'fmt',\n '--no-script',\n ...unmatched,\n ...formatIgnore,\n ...(fix ? [] : ['--check']),\n ...(whole ? [FORMAT_GLOB] : formatted),\n ],\n };\n\n return whole || files.length > 0 ? [...linters, formatter] : [formatter];\n }\n\n /** The tool's binary in the nearest `node_modules/.bin`, else its bare name for PATH to find. */\n static resolveTool(opts: { root: string; tool: string }): string {\n let dir = opts.root;\n\n while (true) {\n const candidate = join(dir, 'node_modules', '.bin', opts.tool);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n\n const parent = dirname(dir);\n\n if (parent === dir) {\n return opts.tool;\n }\n\n dir = parent;\n }\n }\n\n /** Runs the plan in order and stops at the first tool that fails; returns the exit code. */\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n for (const step of LintCommand.plan(opts)) {\n const child = Bun.spawn({\n cmd: [LintCommand.resolveTool({ root: opts.root, tool: step.tool }), ...step.args],\n cwd: opts.root,\n stdio: ['inherit', 'inherit', 'inherit'],\n });\n const exitCode = await child.exited;\n\n if (exitCode !== 0) {\n return exitCode;\n }\n }\n\n return 0;\n }\n}\n"]}
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.namingConventionConfigs = exports.eslintConfigs = void 0;
7
7
  const js_1 = __importDefault(require("@eslint/js"));
8
8
  const config_1 = require("eslint/config");
9
- const eslint_plugin_n_1 = __importDefault(require("eslint-plugin-n"));
10
- const eslint_plugin_unicorn_1 = __importDefault(require("eslint-plugin-unicorn"));
11
9
  const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
10
+ const common_1 = require("./house/common");
11
+ const no_unbraced_case_rule_1 = require("./house/no-unbraced-case.rule");
12
+ const plugin_1 = require("./house/plugin");
13
+ const padding_1 = require("./padding");
12
14
  const rules_1 = require("./rules");
13
15
  /** Every file the preset lints. */
14
16
  const SOURCE_FILES = [
@@ -64,7 +66,6 @@ const STRICT_RULES = {
64
66
  'no-void': 'error',
65
67
  'no-useless-escape': 'warn',
66
68
  'no-caller': 'error',
67
- 'n/prefer-node-protocol': ['error'],
68
69
  '@typescript-eslint/adjacent-overload-signatures': 'error',
69
70
  '@typescript-eslint/prefer-for-of': 'error',
70
71
  '@typescript-eslint/unified-signatures': 'error',
@@ -98,16 +99,17 @@ exports.eslintConfigs = (0, config_1.defineConfig)([
98
99
  projectService: { allowDefaultProject: ['*.js', '*.cjs', '*.mjs', '.*.js'] },
99
100
  },
100
101
  },
101
- plugins: { n: eslint_plugin_n_1.default, unicorn: eslint_plugin_unicorn_1.default },
102
+ plugins: { [common_1.HOUSE_PLUGIN_NAMESPACE]: plugin_1.houseEslintPlugin },
102
103
  rules: {
103
104
  ...OFF_RULES,
104
105
  ...STRICT_RULES,
106
+ [no_unbraced_case_rule_1.NoUnbracedCaseRule.NAME]: no_unbraced_case_rule_1.NoUnbracedCaseRule.build(),
105
107
  '@typescript-eslint/no-unused-vars': rules_1.NoUnusedVarsRule.build(),
106
108
  [rules_1.NoRestrictedImportsRule.NAME]: rules_1.NoRestrictedImportsRule.build(),
107
- [rules_1.SwitchCaseBracesRule.NAME]: rules_1.SwitchCaseBracesRule.build(),
108
109
  [rules_1.NamingConventionRule.NAME]: rules_1.NamingConventionRule.build(),
109
110
  },
110
111
  },
112
+ ...padding_1.paddingConfigs,
111
113
  {
112
114
  ignores: [
113
115
  '**/node_modules/',