corsa-oxlint 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +9 -9
  2. package/dist/ast_utils.js +1 -1
  3. package/dist/checker.d.ts +4 -4
  4. package/dist/checker.js +41 -32
  5. package/dist/checker.js.map +1 -1
  6. package/dist/compat.d.ts +1 -1
  7. package/dist/compat.js +1 -1
  8. package/dist/context.d.ts +3 -4
  9. package/dist/context.js +13 -18
  10. package/dist/context.js.map +1 -1
  11. package/dist/index.d.ts +15 -2
  12. package/dist/json_schema.js +1 -1
  13. package/dist/node_map.d.ts +6 -6
  14. package/dist/node_map.js +11 -11
  15. package/dist/node_map.js.map +1 -1
  16. package/dist/oxlint_compat.js +1 -1
  17. package/dist/oxlint_utils.d.ts +1 -1
  18. package/dist/oxlint_utils.js +1 -1
  19. package/dist/parser_services.d.ts +1 -1
  20. package/dist/parser_services.js +9 -5
  21. package/dist/parser_services.js.map +1 -1
  22. package/dist/plugin.d.ts +1 -1
  23. package/dist/plugin.js +1 -1
  24. package/dist/registry.d.ts +3 -3
  25. package/dist/registry.js +3 -3
  26. package/dist/registry.js.map +1 -1
  27. package/dist/rule_tester.d.ts +2 -2
  28. package/dist/rule_tester.js +7 -7
  29. package/dist/rule_tester.js.map +1 -1
  30. package/dist/rules/ast.d.ts +1 -1
  31. package/dist/rules/ast.js +1 -1
  32. package/dist/rules/await_thenable.d.ts +1 -1
  33. package/dist/rules/await_thenable.js +1 -1
  34. package/dist/rules/index.d.ts +4 -4
  35. package/dist/rules/index.js +8 -8
  36. package/dist/rules/index.js.map +1 -1
  37. package/dist/rules/native_bridge.d.ts +1 -1
  38. package/dist/rules/native_bridge.js +1 -1
  39. package/dist/rules/native_bridge.js.map +1 -1
  40. package/dist/rules/no_array_delete.d.ts +1 -1
  41. package/dist/rules/no_array_delete.js +1 -1
  42. package/dist/rules/no_base_to_string.d.ts +1 -1
  43. package/dist/rules/no_base_to_string.js +1 -1
  44. package/dist/rules/no_floating_promises.d.ts +1 -1
  45. package/dist/rules/no_floating_promises.js +1 -1
  46. package/dist/rules/no_for_in_array.d.ts +1 -1
  47. package/dist/rules/no_for_in_array.js +1 -1
  48. package/dist/rules/no_implied_eval.d.ts +1 -1
  49. package/dist/rules/no_implied_eval.js +1 -1
  50. package/dist/rules/no_meaningless_void_operator.d.ts +1 -1
  51. package/dist/rules/no_meaningless_void_operator.js +1 -1
  52. package/dist/rules/no_mixed_enums.d.ts +1 -1
  53. package/dist/rules/no_mixed_enums.js +1 -1
  54. package/dist/rules/no_unsafe_assignment.d.ts +1 -1
  55. package/dist/rules/no_unsafe_assignment.js +1 -1
  56. package/dist/rules/no_unsafe_call.d.ts +1 -1
  57. package/dist/rules/no_unsafe_call.js +1 -1
  58. package/dist/rules/no_unsafe_member_access.d.ts +1 -1
  59. package/dist/rules/no_unsafe_member_access.js +1 -1
  60. package/dist/rules/no_unsafe_return.d.ts +1 -1
  61. package/dist/rules/no_unsafe_return.js +1 -1
  62. package/dist/rules/no_unsafe_type_assertion.d.ts +1 -1
  63. package/dist/rules/no_unsafe_type_assertion.js +1 -1
  64. package/dist/rules/no_unsafe_unary_minus.d.ts +1 -1
  65. package/dist/rules/no_unsafe_unary_minus.js +1 -1
  66. package/dist/rules/only_throw_error.d.ts +1 -1
  67. package/dist/rules/only_throw_error.js +1 -1
  68. package/dist/rules/pending_parity.d.ts +1 -1
  69. package/dist/rules/pending_parity.js +1 -1
  70. package/dist/rules/prefer_find.d.ts +1 -1
  71. package/dist/rules/prefer_find.js +1 -1
  72. package/dist/rules/prefer_includes.d.ts +1 -1
  73. package/dist/rules/prefer_includes.js +1 -1
  74. package/dist/rules/prefer_promise_reject_errors.d.ts +1 -1
  75. package/dist/rules/prefer_promise_reject_errors.js +1 -1
  76. package/dist/rules/prefer_reduce_type_parameter.d.ts +1 -1
  77. package/dist/rules/prefer_reduce_type_parameter.js +1 -1
  78. package/dist/rules/prefer_regexp_exec.d.ts +1 -1
  79. package/dist/rules/prefer_regexp_exec.js +1 -1
  80. package/dist/rules/prefer_string_starts_ends_with.d.ts +1 -1
  81. package/dist/rules/prefer_string_starts_ends_with.js +1 -1
  82. package/dist/rules/require_array_sort_compare.d.ts +1 -1
  83. package/dist/rules/require_array_sort_compare.js +1 -1
  84. package/dist/rules/restrict_plus_operands.d.ts +1 -1
  85. package/dist/rules/restrict_plus_operands.js +1 -1
  86. package/dist/rules/restrict_template_expressions.d.ts +1 -1
  87. package/dist/rules/restrict_template_expressions.js +1 -1
  88. package/dist/rules/rule_creator.d.ts +1 -1
  89. package/dist/rules/rule_creator.js +2 -2
  90. package/dist/rules/rule_creator.js.map +1 -1
  91. package/dist/rules/type_utils.d.ts +6 -6
  92. package/dist/rules/type_utils.js +1 -1
  93. package/dist/rules/type_utils.js.map +1 -1
  94. package/dist/rules/use_unknown_in_catch_callback_variable.d.ts +1 -1
  95. package/dist/rules/use_unknown_in_catch_callback_variable.js +1 -1
  96. package/dist/session.d.ts +30 -29
  97. package/dist/session.js +22 -10
  98. package/dist/session.js.map +1 -1
  99. package/dist/ts_eslint.d.ts +1 -1
  100. package/dist/ts_eslint.js +1 -1
  101. package/dist/ts_utils.js +1 -1
  102. package/dist/types.d.ts +53 -63
  103. package/dist/utils.d.ts +1 -1
  104. package/dist/utils.js +1 -1
  105. package/package.json +4 -4
package/README.md CHANGED
@@ -26,7 +26,7 @@ custom rules in plain JS/TS.
26
26
  ## Configuration
27
27
 
28
28
  Oxlint does not expose arbitrary parser options at runtime, so
29
- `corsa oxlint` reads its type-aware settings from `settings.typescriptOxlint`.
29
+ `corsa oxlint` reads its type-aware settings from `settings.corsaOxlint`.
30
30
 
31
31
  ```ts
32
32
  import { OxlintUtils } from "corsa-oxlint";
@@ -76,12 +76,12 @@ export const noStringPlusNumber = createRule({
76
76
  export default [
77
77
  {
78
78
  settings: {
79
- typescriptOxlint: {
79
+ corsaOxlint: {
80
80
  parserOptions: {
81
81
  project: ["./tsconfig.json"],
82
82
  tsconfigRootDir: import.meta.dirname,
83
83
  corsa: {
84
- executable: "./.cache/tsgo",
84
+ executable: "./.cache/corsa",
85
85
  mode: "msgpack",
86
86
  requestTimeoutMs: 30000,
87
87
  },
@@ -99,12 +99,12 @@ Rule parity is tracked against upstream `tsgolint/internal/rules`, but the
99
99
  runtime implementation lives entirely in this package.
100
100
 
101
101
  ```ts
102
- import { typescriptOxlintPlugin } from "corsa-oxlint/rules";
102
+ import { corsaOxlintPlugin } from "corsa-oxlint/rules";
103
103
 
104
104
  export default [
105
105
  {
106
106
  plugins: {
107
- typescript: typescriptOxlintPlugin,
107
+ typescript: corsaOxlintPlugin,
108
108
  },
109
109
  rules: {
110
110
  "typescript/no-floating-promises": "error",
@@ -155,13 +155,13 @@ such as `printNode` disabled by default.
155
155
 
156
156
  ```bash
157
157
  vp install
158
- vp run -w build_typescript_oxlint
158
+ vp run -w build_corsa_oxlint
159
159
  vp fmt
160
160
  vp lint
161
161
  vp check
162
- vp test run --config ./vite.config.ts src/bindings/nodejs/typescript_oxlint/ts/**/*.test.ts
163
- vp test bench --config ./vite.config.ts bench/src/typescript_oxlint.bench.ts
164
- vp test bench --config ./vite.config.ts bench/src/typescript_oxlint_rules.bench.ts
162
+ vp test run --config ./vite.config.ts src/bindings/nodejs/corsa_oxlint/ts/**/*.test.ts
163
+ vp test bench --config ./vite.config.ts bench/src/corsa_oxlint.bench.ts
164
+ vp test bench --config ./vite.config.ts bench/src/corsa_oxlint_rules.bench.ts
165
165
  vp run -w bench_tooling_compare
166
166
  ```
167
167
 
package/dist/ast_utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- //#region src/bindings/nodejs/typescript_oxlint/ts/ast_utils.ts
2
+ //#region src/bindings/nodejs/corsa_oxlint/ts/ast_utils.ts
3
3
  var ast_utils_exports = /* @__PURE__ */ __exportAll({
4
4
  ASTUtils: () => ASTUtils,
5
5
  LINEBREAK_MATCHER: () => LINEBREAK_MATCHER,
package/dist/checker.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { ContextWithParserOptions, TsgoProgramShape, TsgoTypeCheckerShape } from "./types.js";
1
+ import { ContextWithParserOptions, CorsaProgramShape, CorsaTypeCheckerShape } from "./types.js";
2
2
  import { createNodeMaps } from "./node_map.js";
3
3
 
4
- //#region src/bindings/nodejs/typescript_oxlint/ts/checker.d.ts
5
- declare function createProgram(context: ContextWithParserOptions): TsgoProgramShape & {
4
+ //#region src/bindings/nodejs/corsa_oxlint/ts/checker.d.ts
5
+ declare function createProgram(context: ContextWithParserOptions): CorsaProgramShape & {
6
6
  readonly nodeMaps: ReturnType<typeof createNodeMaps>;
7
7
  };
8
- declare function createTypeChecker(context: ContextWithParserOptions): TsgoTypeCheckerShape;
8
+ declare function createTypeChecker(context: ContextWithParserOptions): CorsaTypeCheckerShape;
9
9
  //#endregion
10
10
  export { createProgram, createTypeChecker };
11
11
  //# sourceMappingURL=checker.d.ts.map
package/dist/checker.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createNodeMaps, toPosition } from "./node_map.js";
2
2
  import { sessionForContext } from "./registry.js";
3
- //#region src/bindings/nodejs/typescript_oxlint/ts/checker.ts
3
+ //#region src/bindings/nodejs/corsa_oxlint/ts/checker.ts
4
4
  function createProgram(context) {
5
5
  return {
6
6
  nodeMaps: createNodeMaps(context),
@@ -57,7 +57,7 @@ function createTypeChecker(context) {
57
57
  return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);
58
58
  },
59
59
  getTypeOfSymbolAtLocation(symbol, node) {
60
- return this.getTypeAtLocation(node) ?? this.getTypeOfSymbol(symbol);
60
+ return this.getTypeOfSymbol(symbol) ?? this.getDeclaredTypeOfSymbol(symbol) ?? this.getTypeAtLocation(node);
61
61
  },
62
62
  typeToString(type, enclosingDeclaration, flags) {
63
63
  return sessionForContext(context).session.typeToString(type, flags);
@@ -81,7 +81,7 @@ function createTypeChecker(context) {
81
81
  return sessionForContext(context).session.getBaseTypes(type);
82
82
  },
83
83
  getImplementedTypes(node) {
84
- if ("pos" in node) return implementedTypesFromTsgoNode(context, node, this);
84
+ if ("pos" in node) return implementedTypesFromCorsaNode(context, node, this);
85
85
  return implementedClauseNodes(node).map((clause) => {
86
86
  const expression = implementedClauseChildNode(clause, "expression") ?? clause;
87
87
  const symbol = this.getSymbolAtLocation(expression) ?? this.getSymbolAtLocation(clause);
@@ -89,7 +89,12 @@ function createTypeChecker(context) {
89
89
  }).filter((type) => type !== void 0);
90
90
  },
91
91
  getImplementedTypesOfType(type) {
92
- return sessionForContext(context).session.getBaseTypes(type);
92
+ const session = sessionForContext(context).session;
93
+ const symbol = type.symbol ? session.getSymbol(type.symbol) : void 0;
94
+ const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
95
+ const declarationNode = declaration ? session.getNode(declaration) : void 0;
96
+ const sourceText = declarationNode ? sourceTextForPath(context, declarationNode.fileName) : void 0;
97
+ return declarationNode && sourceText ? implementedTypesFromSourceText(declarationNode, sourceText, this) : [];
93
98
  },
94
99
  getTypeArguments(type) {
95
100
  return sessionForContext(context).session.getTypeArguments(type);
@@ -140,9 +145,12 @@ const typeFlags = {
140
145
  intersection: 1 << 28
141
146
  };
142
147
  function sourceTextFor(context, node) {
143
- const normalizedFileName = filenameFor(context, node).toLowerCase();
148
+ return sourceTextForPath(context, filenameFor(context, node));
149
+ }
150
+ function sourceTextForPath(context, fileName) {
151
+ const normalizedFileName = fileName.toLowerCase();
144
152
  const normalizedContextFilename = context.filename.toLowerCase();
145
- return normalizedFileName === normalizedContextFilename || normalizedFileName.endsWith(normalizedContextFilename) || normalizedContextFilename.endsWith(normalizedFileName) ? context.sourceCode.text : void 0;
153
+ return normalizedFileName === normalizedContextFilename || normalizedFileName.endsWith(normalizedContextFilename) || normalizedContextFilename.endsWith(normalizedFileName) ? context.sourceCode.text : sessionForContext(context).session.getSourceTextForPath(fileName);
146
154
  }
147
155
  function typeOfNewExpression(node, checker) {
148
156
  const callee = childNode(node, "callee");
@@ -175,7 +183,7 @@ function implementedClauseChildNode(node, key) {
175
183
  const value = node[key];
176
184
  if (isNode(value)) return value;
177
185
  }
178
- function implementedTypesFromTsgoNode(context, node, checker) {
186
+ function implementedTypesFromCorsaNode(context, node, checker) {
179
187
  const symbol = checker.getSymbolAtLocation(node);
180
188
  if (symbol) {
181
189
  const declaredType = checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol);
@@ -185,34 +193,35 @@ function implementedTypesFromTsgoNode(context, node, checker) {
185
193
  }
186
194
  }
187
195
  const sourceText = sourceTextFor(context, node);
188
- if (sourceText) {
189
- const classText = sourceText.slice(node.pos, node.end);
190
- const bodyOpen = classText.indexOf("{");
191
- const headerText = bodyOpen >= 0 ? classText.slice(0, bodyOpen) : classText;
192
- const implementsIndex = headerText.indexOf("implements");
193
- if (implementsIndex >= 0) {
194
- const clauseText = headerText.slice(implementsIndex + 10);
195
- return splitTopLevelRanges(clauseText, ",").map((range) => {
196
- const raw = clauseText.slice(range.start, range.end);
197
- const leading = raw.search(/\S/);
198
- if (leading < 0) return;
199
- const trailing = raw.match(/\s*$/)?.[0].length ?? 0;
200
- const pos = node.pos + implementsIndex + 10 + range.start + leading;
201
- const end = node.pos + implementsIndex + 10 + range.end - trailing;
202
- const lookupNode = {
203
- fileName: node.fileName,
204
- pos,
205
- end,
206
- range: [pos, end]
207
- };
208
- const symbol = checker.getSymbolAtLocation(lookupNode);
209
- return symbol ? checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol) : checker.getTypeAtLocation(lookupNode);
210
- }).filter((type) => type !== void 0);
211
- }
212
- }
196
+ if (sourceText) return implementedTypesFromSourceText(node, sourceText, checker);
213
197
  const type = checker.getTypeAtLocation(node);
214
198
  return type ? checker.getImplementedTypesOfType(type) : [];
215
199
  }
200
+ function implementedTypesFromSourceText(node, sourceText, checker) {
201
+ if (node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) return [];
202
+ const classText = sourceText.slice(node.pos, node.end);
203
+ const bodyOpen = classText.indexOf("{");
204
+ const headerText = bodyOpen >= 0 ? classText.slice(0, bodyOpen) : classText;
205
+ const implementsIndex = headerText.indexOf("implements");
206
+ if (implementsIndex < 0) return [];
207
+ const clauseText = headerText.slice(implementsIndex + 10);
208
+ return splitTopLevelRanges(clauseText, ",").map((range) => {
209
+ const raw = clauseText.slice(range.start, range.end);
210
+ const leading = raw.search(/\S/);
211
+ if (leading < 0) return;
212
+ const trailing = raw.match(/\s*$/)?.[0].length ?? 0;
213
+ const pos = node.pos + implementsIndex + 10 + range.start + leading;
214
+ const end = node.pos + implementsIndex + 10 + range.end - trailing;
215
+ const lookupNode = {
216
+ fileName: node.fileName,
217
+ pos,
218
+ end,
219
+ range: [pos, end]
220
+ };
221
+ const symbol = checker.getSymbolAtLocation(lookupNode);
222
+ return symbol ? checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol) : checker.getTypeAtLocation(lookupNode);
223
+ }).filter((type) => type !== void 0);
224
+ }
216
225
  function splitTopLevelRanges(text, delimiter) {
217
226
  const ranges = [];
218
227
  const scanner = createScanner();
@@ -1 +1 @@
1
- {"version":3,"file":"checker.js","names":[],"sources":["../ts/checker.ts"],"sourcesContent":["import type { Node } from \"@oxlint/plugins\";\n\nimport { createNodeMaps, toPosition } from \"./node_map\";\nimport { sessionForContext } from \"./registry\";\nimport type {\n ContextWithParserOptions,\n TsgoNode,\n TsgoProgramShape,\n TsgoSignature,\n TsgoSymbol,\n TsgoType,\n TsgoTypeCheckerShape,\n} from \"./types\";\n\nexport function createProgram(\n context: ContextWithParserOptions,\n): TsgoProgramShape & { readonly nodeMaps: ReturnType<typeof createNodeMaps> } {\n const nodeMaps = createNodeMaps(context);\n return {\n nodeMaps,\n getCompilerOptions() {\n return sessionForContext(context).session.getCompilerOptions();\n },\n getCurrentDirectory() {\n return sessionForContext(context).project.rootDir;\n },\n getRootFileNames() {\n return sessionForContext(context).session.getRootFileNames();\n },\n getSourceFile(fileName = context.filename) {\n return { fileName, text: context.sourceCode.text };\n },\n getTypeChecker() {\n return createTypeChecker(context);\n },\n };\n}\n\nexport function createTypeChecker(context: ContextWithParserOptions): TsgoTypeCheckerShape {\n return {\n getTypeAtLocation(node) {\n if ((node as { readonly type?: string }).type === \"NewExpression\") {\n return typeOfNewExpression(node as Node, this);\n }\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getTypeAtPosition(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n );\n },\n getContextualType(node) {\n return this.getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getSymbolAtPosition(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n );\n },\n getSymbol(symbol) {\n return sessionForContext(context).session.getSymbol(symbol);\n },\n getSymbolById(id) {\n return sessionForContext(context).session.getSymbol(id);\n },\n getNode(node) {\n return sessionForContext(context).session.getNode(node);\n },\n getNodeById(id) {\n return sessionForContext(context).session.getNode(id);\n },\n getTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getTypeOfSymbol(symbol);\n },\n getDeclaredTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return this.getTypeAtLocation(node) ?? this.getTypeOfSymbol(symbol);\n },\n typeToString(type, enclosingDeclaration, flags) {\n void enclosingDeclaration;\n return sessionForContext(context).session.typeToString(type, flags);\n },\n getBaseTypeOfLiteralType(type) {\n return sessionForContext(context).session.getBaseTypeOfLiteralType(type);\n },\n getPropertiesOfType(type) {\n return sessionForContext(context).session.getPropertiesOfType(type);\n },\n getSignaturesOfType(type, kind) {\n return sessionForContext(context).session.getSignaturesOfType(type, kind);\n },\n getReturnTypeOfSignature(signature) {\n return sessionForContext(context).session.getReturnTypeOfSignature(signature);\n },\n getTypePredicateOfSignature(signature) {\n return sessionForContext(context).session.getTypePredicateOfSignature(signature);\n },\n getBaseTypes(type) {\n return sessionForContext(context).session.getBaseTypes(type);\n },\n getImplementedTypes(node) {\n if (\"pos\" in node) {\n return implementedTypesFromTsgoNode(context, node, this);\n }\n return implementedClauseNodes(node)\n .map((clause) => {\n const expression = implementedClauseChildNode(clause, \"expression\") ?? clause;\n const symbol = this.getSymbolAtLocation(expression) ?? this.getSymbolAtLocation(clause);\n return symbol\n ? (this.getDeclaredTypeOfSymbol(symbol) ?? this.getTypeOfSymbol(symbol))\n : (this.getTypeAtLocation(expression) ?? this.getTypeAtLocation(clause));\n })\n .filter((type): type is TsgoType => type !== undefined);\n },\n getImplementedTypesOfType(type) {\n return sessionForContext(context).session.getBaseTypes(type);\n },\n getTypeArguments(type) {\n return sessionForContext(context).session.getTypeArguments(type);\n },\n getTypesOfType(type) {\n return sessionForContext(context).session.getTypesOfType(type);\n },\n getTargetOfType(type) {\n return sessionForContext(context).session.getTargetOfType(type);\n },\n getTypeParametersOfType(type) {\n return sessionForContext(context).session.getTypeParametersOfType(type);\n },\n getOuterTypeParametersOfType(type) {\n return sessionForContext(context).session.getOuterTypeParametersOfType(type);\n },\n getLocalTypeParametersOfType(type) {\n return sessionForContext(context).session.getLocalTypeParametersOfType(type);\n },\n getObjectTypeOfType(type) {\n return sessionForContext(context).session.getObjectTypeOfType(type);\n },\n getIndexTypeOfType(type) {\n return sessionForContext(context).session.getIndexTypeOfType(type);\n },\n getCheckTypeOfType(type) {\n return sessionForContext(context).session.getCheckTypeOfType(type);\n },\n getExtendsTypeOfType(type) {\n return sessionForContext(context).session.getExtendsTypeOfType(type);\n },\n getBaseTypeOfType(type) {\n return sessionForContext(context).session.getBaseTypeOfType(type);\n },\n getConstraintOfType(type) {\n return sessionForContext(context).session.getConstraintOfType(type);\n },\n isUnionType(type) {\n return (type.flags & typeFlags.union) !== 0;\n },\n isIntersectionType(type) {\n return (type.flags & typeFlags.intersection) !== 0;\n },\n };\n}\n\nconst typeFlags = {\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nfunction sourceTextFor(\n context: ContextWithParserOptions,\n node: Node | TsgoNode | TsgoType | TsgoSymbol | TsgoSignature,\n): string | undefined {\n const fileName = filenameFor(context, node);\n const normalizedFileName = fileName.toLowerCase();\n const normalizedContextFilename = context.filename.toLowerCase();\n return normalizedFileName === normalizedContextFilename ||\n normalizedFileName.endsWith(normalizedContextFilename) ||\n normalizedContextFilename.endsWith(normalizedFileName)\n ? context.sourceCode.text\n : undefined;\n}\n\nfunction typeOfNewExpression(node: Node, checker: TsgoTypeCheckerShape): TsgoType | undefined {\n const callee = childNode(node, \"callee\");\n if (!callee) {\n return undefined;\n }\n const calleeType = checker.getTypeAtLocation(callee);\n if (!calleeType) {\n return undefined;\n }\n const constructSignature = checker.getSignaturesOfType(calleeType, 1)[0];\n return constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n}\n\nfunction nodeForTypeLookup(node: Node | TsgoNode): Node | TsgoNode {\n if (\"pos\" in node) {\n return node;\n }\n switch ((node as { readonly type?: string }).type) {\n case \"ClassDeclaration\":\n case \"ClassExpression\":\n return childNode(node, \"id\") ?? node;\n case \"TSPropertySignature\":\n return childNode(node, \"key\") ?? node;\n default:\n return node;\n }\n}\n\nfunction childNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedClauseNodes(node: Node | TsgoNode): readonly Node[] {\n if (\"pos\" in node) {\n return [];\n }\n const clauses = (node as unknown as { readonly implements?: unknown }).implements;\n if (!Array.isArray(clauses)) {\n return [];\n }\n return clauses.filter(isNode);\n}\n\nfunction implementedClauseChildNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedTypesFromTsgoNode(\n context: ContextWithParserOptions,\n node: TsgoNode,\n checker: TsgoTypeCheckerShape,\n): readonly TsgoType[] {\n const symbol = checker.getSymbolAtLocation(node);\n if (symbol) {\n const declaredType = checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol);\n if (declaredType) {\n const implemented = checker.getImplementedTypesOfType(declaredType);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n }\n const sourceText = sourceTextFor(context, node);\n if (sourceText) {\n const classText = sourceText.slice(node.pos, node.end);\n const bodyOpen = classText.indexOf(\"{\");\n const headerText = bodyOpen >= 0 ? classText.slice(0, bodyOpen) : classText;\n const implementsIndex = headerText.indexOf(\"implements\");\n if (implementsIndex >= 0) {\n const clauseText = headerText.slice(implementsIndex + \"implements\".length);\n const implemented = splitTopLevelRanges(clauseText, \",\")\n .map((range) => {\n const raw = clauseText.slice(range.start, range.end);\n const leading = raw.search(/\\S/);\n if (leading < 0) {\n return undefined;\n }\n const trailing = raw.match(/\\s*$/)?.[0].length ?? 0;\n const pos = node.pos + implementsIndex + \"implements\".length + range.start + leading;\n const end = node.pos + implementsIndex + \"implements\".length + range.end - trailing;\n const lookupNode: TsgoNode = {\n fileName: node.fileName,\n pos,\n end,\n range: [pos, end] as const,\n };\n const symbol = checker.getSymbolAtLocation(lookupNode);\n return symbol\n ? (checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol))\n : checker.getTypeAtLocation(lookupNode);\n })\n .filter((type): type is TsgoType => type !== undefined);\n return implemented;\n }\n }\n const type = checker.getTypeAtLocation(node);\n return type ? checker.getImplementedTypesOfType(type) : [];\n}\n\nfunction splitTopLevelRanges(\n text: string,\n delimiter: string,\n): readonly { readonly start: number; readonly end: number }[] {\n const ranges: { start: number; end: number }[] = [];\n const scanner = createScanner();\n let start = 0;\n let angleDepth = 0;\n let parenDepth = 0;\n let bracketDepth = 0;\n let braceDepth = 0;\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index];\n if (scanner.inQuote(char)) {\n continue;\n }\n if (char === \"<\") angleDepth += 1;\n else if (char === \">\") angleDepth = Math.max(0, angleDepth - 1);\n else if (char === \"(\") parenDepth += 1;\n else if (char === \")\") parenDepth = Math.max(0, parenDepth - 1);\n else if (char === \"[\") bracketDepth += 1;\n else if (char === \"]\") bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === \"{\") braceDepth += 1;\n else if (char === \"}\") braceDepth = Math.max(0, braceDepth - 1);\n else if (\n char === delimiter &&\n angleDepth === 0 &&\n parenDepth === 0 &&\n bracketDepth === 0 &&\n braceDepth === 0\n ) {\n ranges.push({ start, end: index });\n start = index + 1;\n }\n }\n ranges.push({ start, end: text.length });\n return ranges;\n}\n\nfunction createScanner(): {\n inQuote(char: string): boolean;\n} {\n let quote: string | undefined;\n let escaped = false;\n return {\n inQuote(char) {\n if (quote) {\n if (escaped) {\n escaped = false;\n } else if (char === \"\\\\\") {\n escaped = true;\n } else if (char === quote) {\n quote = undefined;\n }\n return true;\n }\n if (char === '\"' || char === \"'\" || char === \"`\") {\n quote = char;\n return true;\n }\n return false;\n },\n };\n}\n\nfunction isNode(value: unknown): value is Node {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"range\" in value;\n}\n\nfunction filenameFor(\n context: ContextWithParserOptions,\n node: Node | TsgoNode | TsgoType | TsgoSymbol | TsgoSignature,\n): string {\n if (\"fileName\" in node) {\n return node.fileName;\n }\n return context.filename;\n}\n"],"mappings":";;;AAcA,SAAgB,cACd,SAC6E;CAE7E,OAAO;EACL,UAFe,eAAe,QAEtB;EACR,qBAAqB;GACnB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,oBAAoB;;EAEhE,sBAAsB;GACpB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ;;EAE5C,mBAAmB;GACjB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,kBAAkB;;EAE9D,cAAc,WAAW,QAAQ,UAAU;GACzC,OAAO;IAAE;IAAU,MAAM,QAAQ,WAAW;IAAM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AAG,eAAe,EAAE;OAC9D,IAAI,SAAS,KAAK,cAAc;OAChC,IAAI,SAAS,KAAK,aAAa,KAAK,IAAI,GAAG,aAAa,EAAE;OAC1D,IACH,SAAS,aACT,eAAe,KACf,eAAe,KACf,iBAAiB,KACjB,eAAe,GACf;GACA,OAAO,KAAK;IAAE;IAAO,KAAK;IAAO,CAAC;GAClC,QAAQ,QAAQ;;;CAGpB,OAAO,KAAK;EAAE;EAAO,KAAK,KAAK;EAAQ,CAAC;CACxC,OAAO;;AAGT,SAAS,gBAEP;CACA,IAAI;CACJ,IAAI,UAAU;CACd,OAAO,EACL,QAAQ,MAAM;EACZ,IAAI,OAAO;GACT,IAAI,SACF,UAAU;QACL,IAAI,SAAS,MAClB,UAAU;QACL,IAAI,SAAS,OAClB,QAAQ,KAAA;GAEV,OAAO;;EAET,IAAI,SAAS,QAAO,SAAS,OAAO,SAAS,KAAK;GAChD,QAAQ;GACR,OAAO;;EAET,OAAO;IAEV;;AAGH,SAAS,OAAO,OAA+B;CAC7C,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,WAAW;;AAGtF,SAAS,YACP,SACA,MACQ;CACR,IAAI,cAAc,MAChB,OAAO,KAAK;CAEd,OAAO,QAAQ"}
1
+ {"version":3,"file":"checker.js","names":[],"sources":["../ts/checker.ts"],"sourcesContent":["import type { Node } from \"@oxlint/plugins\";\n\nimport { createNodeMaps, toPosition } from \"./node_map\";\nimport { sessionForContext } from \"./registry\";\nimport type {\n ContextWithParserOptions,\n CorsaNode,\n CorsaProgramShape,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypeCheckerShape,\n} from \"./types\";\n\nexport function createProgram(\n context: ContextWithParserOptions,\n): CorsaProgramShape & { readonly nodeMaps: ReturnType<typeof createNodeMaps> } {\n const nodeMaps = createNodeMaps(context);\n return {\n nodeMaps,\n getCompilerOptions() {\n return sessionForContext(context).session.getCompilerOptions();\n },\n getCurrentDirectory() {\n return sessionForContext(context).project.rootDir;\n },\n getRootFileNames() {\n return sessionForContext(context).session.getRootFileNames();\n },\n getSourceFile(fileName = context.filename) {\n return { fileName, text: context.sourceCode.text };\n },\n getTypeChecker() {\n return createTypeChecker(context);\n },\n };\n}\n\nexport function createTypeChecker(context: ContextWithParserOptions): CorsaTypeCheckerShape {\n return {\n getTypeAtLocation(node) {\n if ((node as { readonly type?: string }).type === \"NewExpression\") {\n return typeOfNewExpression(node as Node, this);\n }\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getTypeAtPosition(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n );\n },\n getContextualType(node) {\n return this.getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getSymbolAtPosition(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n );\n },\n getSymbol(symbol) {\n return sessionForContext(context).session.getSymbol(symbol);\n },\n getSymbolById(id) {\n return sessionForContext(context).session.getSymbol(id);\n },\n getNode(node) {\n return sessionForContext(context).session.getNode(node);\n },\n getNodeById(id) {\n return sessionForContext(context).session.getNode(id);\n },\n getTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getTypeOfSymbol(symbol);\n },\n getDeclaredTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return (\n this.getTypeOfSymbol(symbol) ??\n this.getDeclaredTypeOfSymbol(symbol) ??\n this.getTypeAtLocation(node)\n );\n },\n typeToString(type, enclosingDeclaration, flags) {\n void enclosingDeclaration;\n return sessionForContext(context).session.typeToString(type, flags);\n },\n getBaseTypeOfLiteralType(type) {\n return sessionForContext(context).session.getBaseTypeOfLiteralType(type);\n },\n getPropertiesOfType(type) {\n return sessionForContext(context).session.getPropertiesOfType(type);\n },\n getSignaturesOfType(type, kind) {\n return sessionForContext(context).session.getSignaturesOfType(type, kind);\n },\n getReturnTypeOfSignature(signature) {\n return sessionForContext(context).session.getReturnTypeOfSignature(signature);\n },\n getTypePredicateOfSignature(signature) {\n return sessionForContext(context).session.getTypePredicateOfSignature(signature);\n },\n getBaseTypes(type) {\n return sessionForContext(context).session.getBaseTypes(type);\n },\n getImplementedTypes(node) {\n if (\"pos\" in node) {\n return implementedTypesFromCorsaNode(context, node, this);\n }\n return implementedClauseNodes(node)\n .map((clause) => {\n const expression = implementedClauseChildNode(clause, \"expression\") ?? clause;\n const symbol = this.getSymbolAtLocation(expression) ?? this.getSymbolAtLocation(clause);\n return symbol\n ? (this.getDeclaredTypeOfSymbol(symbol) ?? this.getTypeOfSymbol(symbol))\n : (this.getTypeAtLocation(expression) ?? this.getTypeAtLocation(clause));\n })\n .filter((type): type is CorsaType => type !== undefined);\n },\n getImplementedTypesOfType(type) {\n const session = sessionForContext(context).session;\n const symbol = type.symbol ? session.getSymbol(type.symbol) : undefined;\n const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];\n const declarationNode = declaration ? session.getNode(declaration) : undefined;\n const sourceText = declarationNode\n ? sourceTextForPath(context, declarationNode.fileName)\n : undefined;\n return declarationNode && sourceText\n ? implementedTypesFromSourceText(declarationNode, sourceText, this)\n : [];\n },\n getTypeArguments(type) {\n return sessionForContext(context).session.getTypeArguments(type);\n },\n getTypesOfType(type) {\n return sessionForContext(context).session.getTypesOfType(type);\n },\n getTargetOfType(type) {\n return sessionForContext(context).session.getTargetOfType(type);\n },\n getTypeParametersOfType(type) {\n return sessionForContext(context).session.getTypeParametersOfType(type);\n },\n getOuterTypeParametersOfType(type) {\n return sessionForContext(context).session.getOuterTypeParametersOfType(type);\n },\n getLocalTypeParametersOfType(type) {\n return sessionForContext(context).session.getLocalTypeParametersOfType(type);\n },\n getObjectTypeOfType(type) {\n return sessionForContext(context).session.getObjectTypeOfType(type);\n },\n getIndexTypeOfType(type) {\n return sessionForContext(context).session.getIndexTypeOfType(type);\n },\n getCheckTypeOfType(type) {\n return sessionForContext(context).session.getCheckTypeOfType(type);\n },\n getExtendsTypeOfType(type) {\n return sessionForContext(context).session.getExtendsTypeOfType(type);\n },\n getBaseTypeOfType(type) {\n return sessionForContext(context).session.getBaseTypeOfType(type);\n },\n getConstraintOfType(type) {\n return sessionForContext(context).session.getConstraintOfType(type);\n },\n isUnionType(type) {\n return (type.flags & typeFlags.union) !== 0;\n },\n isIntersectionType(type) {\n return (type.flags & typeFlags.intersection) !== 0;\n },\n };\n}\n\nconst typeFlags = {\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nfunction sourceTextFor(\n context: ContextWithParserOptions,\n node: Node | CorsaNode | CorsaType | CorsaSymbol | CorsaSignature,\n): string | undefined {\n return sourceTextForPath(context, filenameFor(context, node));\n}\n\nfunction sourceTextForPath(\n context: ContextWithParserOptions,\n fileName: string,\n): string | undefined {\n const normalizedFileName = fileName.toLowerCase();\n const normalizedContextFilename = context.filename.toLowerCase();\n return normalizedFileName === normalizedContextFilename ||\n normalizedFileName.endsWith(normalizedContextFilename) ||\n normalizedContextFilename.endsWith(normalizedFileName)\n ? context.sourceCode.text\n : sessionForContext(context).session.getSourceTextForPath(fileName);\n}\n\nfunction typeOfNewExpression(node: Node, checker: CorsaTypeCheckerShape): CorsaType | undefined {\n const callee = childNode(node, \"callee\");\n if (!callee) {\n return undefined;\n }\n const calleeType = checker.getTypeAtLocation(callee);\n if (!calleeType) {\n return undefined;\n }\n const constructSignature = checker.getSignaturesOfType(calleeType, 1)[0];\n return constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n}\n\nfunction nodeForTypeLookup(node: Node | CorsaNode): Node | CorsaNode {\n if (\"pos\" in node) {\n return node;\n }\n switch ((node as { readonly type?: string }).type) {\n case \"ClassDeclaration\":\n case \"ClassExpression\":\n return childNode(node, \"id\") ?? node;\n case \"TSPropertySignature\":\n return childNode(node, \"key\") ?? node;\n default:\n return node;\n }\n}\n\nfunction childNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedClauseNodes(node: Node | CorsaNode): readonly Node[] {\n if (\"pos\" in node) {\n return [];\n }\n const clauses = (node as unknown as { readonly implements?: unknown }).implements;\n if (!Array.isArray(clauses)) {\n return [];\n }\n return clauses.filter(isNode);\n}\n\nfunction implementedClauseChildNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedTypesFromCorsaNode(\n context: ContextWithParserOptions,\n node: CorsaNode,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const symbol = checker.getSymbolAtLocation(node);\n if (symbol) {\n const declaredType = checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol);\n if (declaredType) {\n const implemented = checker.getImplementedTypesOfType(declaredType);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n }\n const sourceText = sourceTextFor(context, node);\n if (sourceText) {\n return implementedTypesFromSourceText(node, sourceText, checker);\n }\n const type = checker.getTypeAtLocation(node);\n return type ? checker.getImplementedTypesOfType(type) : [];\n}\n\nfunction implementedTypesFromSourceText(\n node: CorsaNode,\n sourceText: string,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n if (node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return [];\n }\n const classText = sourceText.slice(node.pos, node.end);\n const bodyOpen = classText.indexOf(\"{\");\n const headerText = bodyOpen >= 0 ? classText.slice(0, bodyOpen) : classText;\n const implementsIndex = headerText.indexOf(\"implements\");\n if (implementsIndex < 0) {\n return [];\n }\n const clauseText = headerText.slice(implementsIndex + \"implements\".length);\n return splitTopLevelRanges(clauseText, \",\")\n .map((range) => {\n const raw = clauseText.slice(range.start, range.end);\n const leading = raw.search(/\\S/);\n if (leading < 0) {\n return undefined;\n }\n const trailing = raw.match(/\\s*$/)?.[0].length ?? 0;\n const pos = node.pos + implementsIndex + \"implements\".length + range.start + leading;\n const end = node.pos + implementsIndex + \"implements\".length + range.end - trailing;\n const lookupNode: CorsaNode = {\n fileName: node.fileName,\n pos,\n end,\n range: [pos, end] as const,\n };\n const symbol = checker.getSymbolAtLocation(lookupNode);\n return symbol\n ? (checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol))\n : checker.getTypeAtLocation(lookupNode);\n })\n .filter((type): type is CorsaType => type !== undefined);\n}\n\nfunction splitTopLevelRanges(\n text: string,\n delimiter: string,\n): readonly { readonly start: number; readonly end: number }[] {\n const ranges: { start: number; end: number }[] = [];\n const scanner = createScanner();\n let start = 0;\n let angleDepth = 0;\n let parenDepth = 0;\n let bracketDepth = 0;\n let braceDepth = 0;\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index];\n if (scanner.inQuote(char)) {\n continue;\n }\n if (char === \"<\") angleDepth += 1;\n else if (char === \">\") angleDepth = Math.max(0, angleDepth - 1);\n else if (char === \"(\") parenDepth += 1;\n else if (char === \")\") parenDepth = Math.max(0, parenDepth - 1);\n else if (char === \"[\") bracketDepth += 1;\n else if (char === \"]\") bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === \"{\") braceDepth += 1;\n else if (char === \"}\") braceDepth = Math.max(0, braceDepth - 1);\n else if (\n char === delimiter &&\n angleDepth === 0 &&\n parenDepth === 0 &&\n bracketDepth === 0 &&\n braceDepth === 0\n ) {\n ranges.push({ start, end: index });\n start = index + 1;\n }\n }\n ranges.push({ start, end: text.length });\n return ranges;\n}\n\nfunction createScanner(): {\n inQuote(char: string): boolean;\n} {\n let quote: string | undefined;\n let escaped = false;\n return {\n inQuote(char) {\n if (quote) {\n if (escaped) {\n escaped = false;\n } else if (char === \"\\\\\") {\n escaped = true;\n } else if (char === quote) {\n quote = undefined;\n }\n return true;\n }\n if (char === '\"' || char === \"'\" || char === \"`\") {\n quote = char;\n return true;\n }\n return false;\n },\n };\n}\n\nfunction isNode(value: unknown): value is Node {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"range\" in value;\n}\n\nfunction filenameFor(\n context: ContextWithParserOptions,\n node: Node | CorsaNode | CorsaType | CorsaSymbol | CorsaSignature,\n): string {\n if (\"fileName\" in node) {\n return node.fileName;\n }\n return context.filename;\n}\n"],"mappings":";;;AAcA,SAAgB,cACd,SAC8E;CAE9E,OAAO;EACL,UAFe,eAAe,QAEtB;EACR,qBAAqB;GACnB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,oBAAoB;;EAEhE,sBAAsB;GACpB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ;;EAE5C,mBAAmB;GACjB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,kBAAkB;;EAE9D,cAAc,WAAW,QAAQ,UAAU;GACzC,OAAO;IAAE;IAAU,MAAM,QAAQ,WAAW;IAAM;;EAEpD,iBAAiB;GACf,OAAO,kBAAkB,QAAQ;;EAEpC;;AAGH,SAAgB,kBAAkB,SAA0D;CAC1F,OAAO;EACL,kBAAkB,MAAM;GACtB,IAAK,KAAoC,SAAS,iBAChD,OAAO,oBAAoB,MAAc,KAAK;GAEhD,MAAM,aAAa,kBAAkB,KAAK;GAC1C,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,kBACxC,YAAY,SAAS,WAAW,EAChC,WAAW,WAAW,EACtB,cAAc,SAAS,WAAW,CACnC;;EAEH,kBAAkB,MAAM;GACtB,OAAO,KAAK,kBAAkB,KAAK;;EAErC,oBAAoB,MAAM;GACxB,MAAM,aAAa,kBAAkB,KAAK;GAC1C,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,oBACxC,YAAY,SAAS,WAAW,EAChC,WAAW,WAAW,EACtB,cAAc,SAAS,WAAW,CACnC;;EAEH,UAAU,QAAQ;GAChB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,UAAU,OAAO;;EAE7D,cAAc,IAAI;GAChB,OAAO,kBAAkB,QAAQ,CAAC,QAAQ,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AG,aAAa,EAAE;OAC1D,IACH,SAAS,aACT,eAAe,KACf,eAAe,KACf,iBAAiB,KACjB,eAAe,GACf;GACA,OAAO,KAAK;IAAE;IAAO,KAAK;IAAO,CAAC;GAClC,QAAQ,QAAQ;;;CAGpB,OAAO,KAAK;EAAE;EAAO,KAAK,KAAK;EAAQ,CAAC;CACxC,OAAO;;AAGT,SAAS,gBAEP;CACA,IAAI;CACJ,IAAI,UAAU;CACd,OAAO,EACL,QAAQ,MAAM;EACZ,IAAI,OAAO;GACT,IAAI,SACF,UAAU;QACL,IAAI,SAAS,MAClB,UAAU;QACL,IAAI,SAAS,OAClB,QAAQ,KAAA;GAEV,OAAO;;EAET,IAAI,SAAS,QAAO,SAAS,OAAO,SAAS,KAAK;GAChD,QAAQ;GACR,OAAO;;EAET,OAAO;IAEV;;AAGH,SAAS,OAAO,OAA+B;CAC7C,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,WAAW;;AAGtF,SAAS,YACP,SACA,MACQ;CACR,IAAI,cAAc,MAChB,OAAO,KAAK;CAEd,OAAO,QAAQ"}
package/dist/compat.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/bindings/nodejs/typescript_oxlint/ts/compat.d.ts
1
+ //#region src/bindings/nodejs/corsa_oxlint/ts/compat.d.ts
2
2
  declare const AST_NODE_TYPES: Readonly<{
3
3
  readonly AccessorProperty: "AccessorProperty";
4
4
  readonly ArrayExpression: "ArrayExpression";
package/dist/compat.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/bindings/nodejs/typescript_oxlint/ts/compat.ts
1
+ //#region src/bindings/nodejs/corsa_oxlint/ts/compat.ts
2
2
  const AST_NODE_TYPES = Object.freeze({
3
3
  AccessorProperty: "AccessorProperty",
4
4
  ArrayExpression: "ArrayExpression",
package/dist/context.d.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  import { ContextWithParserOptions, ResolvedProjectConfig, TypeAwareParserOptions } from "./types.js";
2
2
 
3
- //#region src/bindings/nodejs/typescript_oxlint/ts/context.d.ts
3
+ //#region src/bindings/nodejs/corsa_oxlint/ts/context.d.ts
4
4
  declare function defaultCorsaExecutable(rootDir: string, platform?: NodeJS.Platform): string;
5
- declare const defaultTsgoExecutable: typeof defaultCorsaExecutable;
6
5
  declare function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig;
7
6
  /**
8
7
  * Resolves the type-aware parser options visible to a rule.
9
8
  *
10
9
  * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at
11
10
  * runtime, so `corsa oxlint` stores its richer configuration under
12
- * `settings.typescriptOxlint` and rehydrates the rule-facing parser options
11
+ * `settings.corsaOxlint` and rehydrates the rule-facing parser options
13
12
  * shape from there.
14
13
  *
15
14
  * @example
@@ -21,5 +20,5 @@ declare function resolveProjectConfig(context: ContextWithParserOptions): Resolv
21
20
  declare function resolveTypeAwareParserOptions(context: ContextWithParserOptions): TypeAwareParserOptions;
22
21
  declare function mergeTypeAwareParserOptions(base: TypeAwareParserOptions | undefined, override: TypeAwareParserOptions | undefined): TypeAwareParserOptions;
23
22
  //#endregion
24
- export { defaultCorsaExecutable, defaultTsgoExecutable, mergeTypeAwareParserOptions, resolveProjectConfig, resolveTypeAwareParserOptions };
23
+ export { defaultCorsaExecutable, mergeTypeAwareParserOptions, resolveProjectConfig, resolveTypeAwareParserOptions };
25
24
  //# sourceMappingURL=context.d.ts.map
package/dist/context.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
- //#region src/bindings/nodejs/typescript_oxlint/ts/context.ts
3
+ //#region src/bindings/nodejs/corsa_oxlint/ts/context.ts
4
4
  const DEFAULT_CACHE_LIFETIME_MS = 250;
5
5
  const DEFAULT_PROJECT_PATTERNS = [
6
6
  "*.ts",
@@ -14,9 +14,8 @@ const DEFAULT_TS_CONFIG = { compilerOptions: {
14
14
  strict: true
15
15
  } };
16
16
  function defaultCorsaExecutable(rootDir, platform = process.platform) {
17
- return resolve(rootDir, platform === "win32" ? ".cache/tsgo.exe" : ".cache/tsgo");
17
+ return resolve(rootDir, platform === "win32" ? ".cache/corsa.exe" : ".cache/corsa");
18
18
  }
19
- const defaultTsgoExecutable = defaultCorsaExecutable;
20
19
  function resolveProjectConfig(context) {
21
20
  const filename = resolve(context.filename);
22
21
  const parserOptions = resolveTypeAwareParserOptions(context);
@@ -36,7 +35,7 @@ function resolveProjectConfig(context) {
36
35
  *
37
36
  * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at
38
37
  * runtime, so `corsa oxlint` stores its richer configuration under
39
- * `settings.typescriptOxlint` and rehydrates the rule-facing parser options
38
+ * `settings.corsaOxlint` and rehydrates the rule-facing parser options
40
39
  * shape from there.
41
40
  *
42
41
  * @example
@@ -46,12 +45,12 @@ function resolveProjectConfig(context) {
46
45
  * ```
47
46
  */
48
47
  function resolveTypeAwareParserOptions(context) {
49
- return mergeTypeAwareParserOptions(resolveSettingsParserOptions(context.settings?.typescriptOxlint), mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions));
48
+ return mergeTypeAwareParserOptions(resolveSettingsParserOptions(context.settings?.corsaOxlint), mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions));
50
49
  }
51
50
  function resolveRuntimeOptions(rootDir, parserOptions) {
52
- const runtime = parserOptions.corsa ?? parserOptions.tsgo;
51
+ const runtime = parserOptions.corsa;
53
52
  return {
54
- executable: resolve(runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? process.env.TSGO_EXECUTABLE ?? defaultCorsaExecutable(rootDir)),
53
+ executable: resolve(runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir)),
55
54
  cwd: resolve(runtime?.cwd ?? rootDir),
56
55
  mode: runtime?.mode ?? "msgpack",
57
56
  cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS
@@ -78,7 +77,7 @@ function resolveDefaultProject(rootDir, filename, projectService) {
78
77
  if (projectService !== true && projectService.defaultProject) return resolve(rootDir, projectService.defaultProject);
79
78
  if (!matchesDefaultProject(filename, projectService)) return;
80
79
  const id = Buffer.from(filename).toString("hex").slice(0, 24);
81
- const cacheDir = resolve(rootDir, ".cache/typescript_oxlint/default");
80
+ const cacheDir = resolve(rootDir, ".cache/corsa_oxlint/default");
82
81
  const configPath = resolve(cacheDir, `${id}.tsconfig.json`);
83
82
  if (!existsSync(configPath)) {
84
83
  mkdirSync(cacheDir, { recursive: true });
@@ -108,8 +107,8 @@ function mergeTypeAwareParserOptions(base, override) {
108
107
  if (!base) return normalizeTypeAwareParserOptions(override ?? {});
109
108
  if (!override) return normalizeTypeAwareParserOptions(base);
110
109
  const runtime = {
111
- ...base.corsa ?? base.tsgo,
112
- ...override.corsa ?? override.tsgo
110
+ ...base.corsa,
111
+ ...override.corsa
113
112
  };
114
113
  return {
115
114
  ...base,
@@ -117,19 +116,15 @@ function mergeTypeAwareParserOptions(base, override) {
117
116
  project: override.project ?? base.project,
118
117
  projectService: mergeProjectService(base.projectService, override.projectService),
119
118
  tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,
120
- ...Object.keys(runtime).length > 0 ? {
121
- corsa: runtime,
122
- tsgo: runtime
123
- } : {}
119
+ ...Object.keys(runtime).length > 0 ? { corsa: runtime } : {}
124
120
  };
125
121
  }
126
122
  function normalizeTypeAwareParserOptions(options) {
127
- const runtime = options.corsa ?? options.tsgo;
123
+ const runtime = options.corsa;
128
124
  if (!runtime) return options;
129
125
  return {
130
126
  ...options,
131
- corsa: runtime,
132
- tsgo: runtime
127
+ corsa: runtime
133
128
  };
134
129
  }
135
130
  function mergeProjectService(base, override) {
@@ -144,6 +139,6 @@ function mergeProjectService(base, override) {
144
139
  };
145
140
  }
146
141
  //#endregion
147
- export { defaultCorsaExecutable, defaultTsgoExecutable, mergeTypeAwareParserOptions, resolveProjectConfig, resolveTypeAwareParserOptions };
142
+ export { defaultCorsaExecutable, mergeTypeAwareParserOptions, resolveProjectConfig, resolveTypeAwareParserOptions };
148
143
 
149
144
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n TypescriptOxlintSettings,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\nexport function defaultCorsaExecutable(rootDir: string, platform = process.platform): string {\n return resolve(rootDir, platform === \"win32\" ? \".cache/tsgo.exe\" : \".cache/tsgo\");\n}\n\nexport const defaultTsgoExecutable = defaultCorsaExecutable;\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.typescriptOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n): TypeAwareParserOptions {\n return mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.typescriptOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n}\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa ?? parserOptions.tsgo;\n return {\n executable: resolve(\n runtime?.executable ??\n process.env.CORSA_EXECUTABLE ??\n process.env.TSGO_EXECUTABLE ??\n defaultCorsaExecutable(rootDir),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/typescript_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveSettingsParserOptions(\n settings: TypescriptOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...(base.corsa ?? base.tsgo),\n ...(override.corsa ?? override.tsgo),\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime, tsgo: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa ?? options.tsgo;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n tsgo: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;AAYA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;CAAQ;AACnE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;CACT,EACF;AAED,SAAgB,uBAAuB,SAAiB,WAAW,QAAQ,UAAkB;CAC3F,OAAO,QAAQ,SAAS,aAAa,UAAU,oBAAoB,cAAc;;AAGnF,MAAa,wBAAwB;AAErC,SAAgB,qBAAqB,SAA0D;CAC7F,MAAM,WAAW,QAAQ,QAAQ,SAAS;CAC1C,MAAM,gBAAgB,8BAA8B,QAAQ;CAC5D,MAAM,UAAU,QAAQ,cAAc,mBAAmB,QAAQ,IAAI;CACrE,MAAM,UAAU,sBAAsB,SAAS,cAAc;CAC7D,MAAM,aACJ,uBAAuB,SAAS,cAAc,IAC9C,iBAAiB,UAAU,QAAQ,IACnC,sBAAsB,SAAS,UAAU,cAAc,eAAe;CACxE,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,iDAAiD,WAAW;CAE9E,OAAO;EAAE;EAAU;EAAS;EAAY;EAAS;;;;;;;;;;;;;;;;AAiBnD,SAAgB,8BACd,SACwB;CACxB,OAAO,4BACL,6BAA6B,QAAQ,UAAU,iBAAiB,EAChE,4BAA4B,QAAQ,eAAe,QAAQ,iBAAiB,cAAc,CAC3F;;AAGH,SAAS,sBACP,SACA,eACwB;CACxB,MAAM,UAAU,cAAc,SAAS,cAAc;CACrD,OAAO;EACL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BAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;EACjD"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n CorsaOxlintSettings,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\nexport function defaultCorsaExecutable(rootDir: string, platform = process.platform): string {\n return resolve(rootDir, platform === \"win32\" ? \".cache/corsa.exe\" : \".cache/corsa\");\n}\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.corsaOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n): TypeAwareParserOptions {\n return mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.corsaOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n}\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa;\n return {\n executable: resolve(\n runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/corsa_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveSettingsParserOptions(\n settings: CorsaOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...base.corsa,\n ...override.corsa,\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;AAYA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;CAAQ;AACnE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;CACT,EACF;AAED,SAAgB,uBAAuB,SAAiB,WAAW,QAAQ,UAAkB;CAC3F,OAAO,QAAQ,SAAS,aAAa,UAAU,qBAAqB,eAAe;;AAGrF,SAAgB,qBAAqB,SAA0D;CAC7F,MAAM,WAAW,QAAQ,QAAQ,SAAS;CAC1C,MAAM,gBAAgB,8BAA8B,QAAQ;CAC5D,MAAM,UAAU,QAAQ,cAAc,mBAAmB,QAAQ,IAAI;CACrE,MAAM,UAAU,sBAAsB,SAAS,cAAc;CAC7D,MAAM,aACJ,uBAAuB,SAAS,cAAc,IAC9C,iBAAiB,UAAU,QAAQ,IACnC,sBAAsB,SAAS,UAAU,cAAc,eAAe;CACxE,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,iDAAiD,WAAW;CAE9E,OAAO;EAAE;EAAU;EAAS;EAAY;EAAS;;;;;;;;;;;;;;;;AAiBnD,SAAgB,8BACd,SACwB;CACxB,OAAO,4BACL,6BAA6B,QAAQ,UAAU,YAAY,EAC3D,4BAA4B,QAAQ,eAAe,QAAQ,iBAAiB,cAAc,CAC3F;;AAGH,SAAS,sBACP,SACA,eACwB;CACxB,MAAM,UAAU,cAAc;CAC9B,OAAO;EACL,YAAY,QACV,SAAS,cAAc,QAAQ,IAAI,oBAAoB,uBAAuB,QAAQ,CACvF;EACD,KAAK,QAAQ,SAAS,OAAO,QAAQ;EACrC,MAAM,SAAS,QAAQ;EACvB,iBAAiB,SAAS,mBAAmB;EAC9C;;AAGH,SAAS,uBACP,SACA,eACoB;CAIpB,OAHiB,QAAQ,cAAc,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AAS,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM,GAAI,EAAE;;AAG9D,SAAS,6BACP,UACwB;CACxB,IAAI,CAAC,UACH,OAAO,EAAE;CAEX,MAAM,EAAE,eAAe,GAAG,WAAW;CACrC,OAAO,4BAA4B,QAAQ,cAAc;;AAG3D,SAAgB,4BACd,MACA,UACwB;CACxB,IAAI,CAAC,MACH,OAAO,gCAAgC,YAAY,EAAE,CAAC;CAExD,IAAI,CAAC,UACH,OAAO,gCAAgC,KAAK;CAE9C,MAAM,UAAU;EACd,GAAG,KAAK;EACR,GAAG,SAAS;EACb;CACD,OAAO;EACL,GAAG;EACH,GAAG;EACH,SAAS,SAAS,WAAW,KAAK;EAClC,gBAAgB,oBAAoB,KAAK,gBAAgB,SAAS,eAAe;EACjF,iBAAiB,SAAS,mBAAmB,KAAK;EAClD,GAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,IAAI,EAAE,OAAO,SAAS,GAAG,EAAE;EAC9D;;AAGH,SAAS,gCAAgC,SAAyD;CAChG,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,OAAO;EACR;;AAGH,SAAS,oBACP,MACA,UAC6C;CAC7C,IAAI,aAAa,KAAA,GACf,OAAO;CAET,IAAI,OAAO,aAAa,WACtB,OAAO;CAET,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,WACxC,OAAO;CAET,OAAO;EACL,GAAG;EACH,GAAG;EACH,qBAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;EACjD"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ast_utils_d_exports } from "./ast_utils.js";
2
- import { ContextWithParserOptions, CorsaNode, CorsaProgramShape, CorsaRuntimeOptions, CorsaSignature, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, ParserServices, ParserServicesWithTypeInformation, ProjectServiceOptions, TsgoNode, TsgoProgramShape, TsgoSignature, TsgoSymbol, TsgoType, TsgoTypeCheckerShape, TypeAwareParserOptions } from "./types.js";
2
+ import { ContextWithParserOptions, CorsaNode, CorsaOxlintSettings, CorsaProgramShape, CorsaRuntimeOptions, CorsaSignature, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, ParserServices, ParserServicesWithTypeInformation, ProjectServiceOptions, TypeAwareParserOptions } from "./types.js";
3
3
  import { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree } from "./compat.js";
4
4
  import { json_schema_d_exports } from "./json_schema.js";
5
5
  import { oxlintCompat, oxlint_compat_d_exports } from "./oxlint_compat.js";
@@ -11,4 +11,17 @@ import { compatPlugin, definePlugin, defineRule } from "./plugin.js";
11
11
  import { RuleTester } from "./rule_tester.js";
12
12
  import { TSESLint } from "./ts_eslint.js";
13
13
  import { index_d_exports } from "./rules/index.js";
14
- export { ast_utils_d_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, type ContextWithParserOptions, type CorsaNode, type CorsaProgramShape, type CorsaRuntimeOptions, type CorsaSignature, type CorsaSymbol, type CorsaType, type CorsaTypeCheckerShape, ESLintUtils, json_schema_d_exports as JSONSchema, oxlint_compat_d_exports as OxlintCompat, OxlintUtils, type ParserServices, type ParserServicesWithTypeInformation, type ProjectServiceOptions, RuleCreator, RuleTester, TSESLint, TSESTree, ts_utils_d_exports as TSUtils, type TsgoNode, type TsgoProgramShape, type TsgoSignature, type TsgoSymbol, type TsgoType, type TsgoTypeCheckerShape, type TypeAwareParserOptions, utils_d_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, index_d_exports as rules };
14
+ import { ESTree as ESTree$1 } from "@oxlint/plugins";
15
+
16
+ //#region src/bindings/nodejs/corsa_oxlint/ts/index.d.ts
17
+ type ESTree = {
18
+ NewExpression: ESTree$1.NewExpression;
19
+ BindingIdentifier: Omit<ESTree$1.BindingIdentifier, "typeAnnotation"> & {
20
+ typeAnnotation?: ESTree$1.TSTypeAnnotation | null;
21
+ };
22
+ TSTypeAnnotation: ESTree$1.TSTypeAnnotation;
23
+ [key: string]: unknown;
24
+ };
25
+ //#endregion
26
+ export { ast_utils_d_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, type ContextWithParserOptions, type CorsaNode, type CorsaOxlintSettings, type CorsaProgramShape, type CorsaRuntimeOptions, type CorsaSignature, type CorsaSymbol, type CorsaType, type CorsaTypeCheckerShape, ESLintUtils, ESTree, json_schema_d_exports as JSONSchema, oxlint_compat_d_exports as OxlintCompat, OxlintUtils, type ParserServices, type ParserServicesWithTypeInformation, type ProjectServiceOptions, RuleCreator, RuleTester, TSESLint, TSESTree, ts_utils_d_exports as TSUtils, type TypeAwareParserOptions, utils_d_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, index_d_exports as rules };
27
+ //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- //#region src/bindings/nodejs/typescript_oxlint/ts/json_schema.ts
2
+ //#region src/bindings/nodejs/corsa_oxlint/ts/json_schema.ts
3
3
  var json_schema_exports = /* @__PURE__ */ __exportAll({
4
4
  JSONSchema: () => JSONSchema,
5
5
  tupleSchema: () => tupleSchema
@@ -1,18 +1,18 @@
1
- import { ContextWithParserOptions, TsgoNode } from "./types.js";
1
+ import { ContextWithParserOptions, CorsaNode } from "./types.js";
2
2
  import { Node } from "@oxlint/plugins";
3
3
 
4
- //#region src/bindings/nodejs/typescript_oxlint/ts/node_map.d.ts
4
+ //#region src/bindings/nodejs/corsa_oxlint/ts/node_map.d.ts
5
5
  declare function createNodeMaps(context: ContextWithParserOptions): {
6
6
  esTreeNodeToTSNodeMap: {
7
- get(node: Node): TsgoNode;
7
+ get(node: Node): CorsaNode;
8
8
  has(node: Node): boolean;
9
9
  };
10
10
  tsNodeToESTreeNodeMap: {
11
- get(node: TsgoNode): Node;
12
- has(node: TsgoNode): boolean;
11
+ get(node: CorsaNode): Node;
12
+ has(node: CorsaNode): boolean;
13
13
  };
14
14
  };
15
- declare function toPosition(node: Node | TsgoNode): number;
15
+ declare function toPosition(node: Node | CorsaNode): number;
16
16
  //#endregion
17
17
  export { createNodeMaps, toPosition };
18
18
  //# sourceMappingURL=node_map.d.ts.map
package/dist/node_map.js CHANGED
@@ -1,30 +1,30 @@
1
- //#region src/bindings/nodejs/typescript_oxlint/ts/node_map.ts
2
- const estreeToTsgo = /* @__PURE__ */ new WeakMap();
3
- const tsgoToEstree = /* @__PURE__ */ new WeakMap();
1
+ //#region src/bindings/nodejs/corsa_oxlint/ts/node_map.ts
2
+ const estreeToCorsa = /* @__PURE__ */ new WeakMap();
3
+ const corsaToEstree = /* @__PURE__ */ new WeakMap();
4
4
  function createNodeMaps(context) {
5
5
  return {
6
6
  esTreeNodeToTSNodeMap: {
7
7
  get(node) {
8
- let current = estreeToTsgo.get(node);
8
+ let current = estreeToCorsa.get(node);
9
9
  if (!current) {
10
- current = createTsgoNode(context.filename, node);
11
- estreeToTsgo.set(node, current);
12
- tsgoToEstree.set(current, node);
10
+ current = createCorsaNode(context.filename, node);
11
+ estreeToCorsa.set(node, current);
12
+ corsaToEstree.set(current, node);
13
13
  }
14
14
  return current;
15
15
  },
16
16
  has(node) {
17
- return estreeToTsgo.has(node);
17
+ return estreeToCorsa.has(node);
18
18
  }
19
19
  },
20
20
  tsNodeToESTreeNodeMap: {
21
21
  get(node) {
22
- const value = tsgoToEstree.get(node);
22
+ const value = corsaToEstree.get(node);
23
23
  if (!value) throw new Error("corsa oxlint could not map Corsa node back to ESTree");
24
24
  return value;
25
25
  },
26
26
  has(node) {
27
- return tsgoToEstree.has(node);
27
+ return corsaToEstree.has(node);
28
28
  }
29
29
  }
30
30
  };
@@ -32,7 +32,7 @@ function createNodeMaps(context) {
32
32
  function toPosition(node) {
33
33
  return "pos" in node ? node.pos : assertRange(node)[0];
34
34
  }
35
- function createTsgoNode(fileName, node) {
35
+ function createCorsaNode(fileName, node) {
36
36
  const [pos, end] = assertRange(node);
37
37
  return {
38
38
  fileName,
@@ -1 +1 @@
1
- {"version":3,"file":"node_map.js","names":[],"sources":["../ts/node_map.ts"],"sourcesContent":["import type { Node } from \"@oxlint/plugins\";\n\nimport type { ContextWithParserOptions, TsgoNode } from \"./types\";\n\nconst estreeToTsgo = new WeakMap<object, TsgoNode>();\nconst tsgoToEstree = new WeakMap<object, Node>();\n\nexport function createNodeMaps(context: ContextWithParserOptions): {\n esTreeNodeToTSNodeMap: {\n get(node: Node): TsgoNode;\n has(node: Node): boolean;\n };\n tsNodeToESTreeNodeMap: {\n get(node: TsgoNode): Node;\n has(node: TsgoNode): boolean;\n };\n} {\n return {\n esTreeNodeToTSNodeMap: {\n get(node) {\n let current = estreeToTsgo.get(node);\n if (!current) {\n current = createTsgoNode(context.filename, node);\n estreeToTsgo.set(node, current);\n tsgoToEstree.set(current, node);\n }\n return current;\n },\n has(node) {\n return estreeToTsgo.has(node);\n },\n },\n tsNodeToESTreeNodeMap: {\n get(node) {\n const value = tsgoToEstree.get(node);\n if (!value) {\n throw new Error(\"corsa oxlint could not map Corsa node back to ESTree\");\n }\n return value;\n },\n has(node) {\n return tsgoToEstree.has(node);\n },\n },\n };\n}\n\nexport function toPosition(node: Node | TsgoNode): number {\n return \"pos\" in node ? node.pos : assertRange(node)[0];\n}\n\nfunction createTsgoNode(fileName: string, node: Node): TsgoNode {\n const [pos, end] = assertRange(node);\n return {\n fileName,\n pos,\n end,\n range: [pos, end],\n };\n}\n\nfunction assertRange(node: Node): readonly [number, number] {\n const range = (node as Node & { range?: readonly [number, number] }).range;\n if (!range) {\n throw new Error(\"corsa oxlint requires ESTree nodes with range data\");\n }\n return range;\n}\n"],"mappings":";AAIA,MAAM,+BAAe,IAAI,SAA2B;AACpD,MAAM,+BAAe,IAAI,SAAuB;AAEhD,SAAgB,eAAe,SAS7B;CACA,OAAO;EACL,uBAAuB;GACrB,IAAI,MAAM;IACR,IAAI,UAAU,aAAa,IAAI,KAAK;IACpC,IAAI,CAAC,SAAS;KACZ,UAAU,eAAe,QAAQ,UAAU,KAAK;KAChD,aAAa,IAAI,MAAM,QAAQ;KAC/B,aAAa,IAAI,SAAS,KAAK;;IAEjC,OAAO;;GAET,IAAI,MAAM;IACR,OAAO,aAAa,IAAI,KAAK;;GAEhC;EACD,uBAAuB;GACrB,IAAI,MAAM;IACR,MAAM,QAAQ,aAAa,IAAI,KAAK;IACpC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,uDAAuD;IAEzE,OAAO;;GAET,IAAI,MAAM;IACR,OAAO,aAAa,IAAI,KAAK;;GAEhC;EACF;;AAGH,SAAgB,WAAW,MAA+B;CACxD,OAAO,SAAS,OAAO,KAAK,MAAM,YAAY,KAAK,CAAC;;AAGtD,SAAS,eAAe,UAAkB,MAAsB;CAC9D,MAAM,CAAC,KAAK,OAAO,YAAY,KAAK;CACpC,OAAO;EACL;EACA;EACA;EACA,OAAO,CAAC,KAAK,IAAI;EAClB;;AAGH,SAAS,YAAY,MAAuC;CAC1D,MAAM,QAAS,KAAsD;CACrE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,qDAAqD;CAEvE,OAAO"}
1
+ {"version":3,"file":"node_map.js","names":[],"sources":["../ts/node_map.ts"],"sourcesContent":["import type { Node } from \"@oxlint/plugins\";\n\nimport type { ContextWithParserOptions, CorsaNode } from \"./types\";\n\nconst estreeToCorsa = new WeakMap<object, CorsaNode>();\nconst corsaToEstree = new WeakMap<object, Node>();\n\nexport function createNodeMaps(context: ContextWithParserOptions): {\n esTreeNodeToTSNodeMap: {\n get(node: Node): CorsaNode;\n has(node: Node): boolean;\n };\n tsNodeToESTreeNodeMap: {\n get(node: CorsaNode): Node;\n has(node: CorsaNode): boolean;\n };\n} {\n return {\n esTreeNodeToTSNodeMap: {\n get(node) {\n let current = estreeToCorsa.get(node);\n if (!current) {\n current = createCorsaNode(context.filename, node);\n estreeToCorsa.set(node, current);\n corsaToEstree.set(current, node);\n }\n return current;\n },\n has(node) {\n return estreeToCorsa.has(node);\n },\n },\n tsNodeToESTreeNodeMap: {\n get(node) {\n const value = corsaToEstree.get(node);\n if (!value) {\n throw new Error(\"corsa oxlint could not map Corsa node back to ESTree\");\n }\n return value;\n },\n has(node) {\n return corsaToEstree.has(node);\n },\n },\n };\n}\n\nexport function toPosition(node: Node | CorsaNode): number {\n return \"pos\" in node ? node.pos : assertRange(node)[0];\n}\n\nfunction createCorsaNode(fileName: string, node: Node): CorsaNode {\n const [pos, end] = assertRange(node);\n return {\n fileName,\n pos,\n end,\n range: [pos, end],\n };\n}\n\nfunction assertRange(node: Node): readonly [number, number] {\n const range = (node as Node & { range?: readonly [number, number] }).range;\n if (!range) {\n throw new Error(\"corsa oxlint requires ESTree nodes with range data\");\n }\n return range;\n}\n"],"mappings":";AAIA,MAAM,gCAAgB,IAAI,SAA4B;AACtD,MAAM,gCAAgB,IAAI,SAAuB;AAEjD,SAAgB,eAAe,SAS7B;CACA,OAAO;EACL,uBAAuB;GACrB,IAAI,MAAM;IACR,IAAI,UAAU,cAAc,IAAI,KAAK;IACrC,IAAI,CAAC,SAAS;KACZ,UAAU,gBAAgB,QAAQ,UAAU,KAAK;KACjD,cAAc,IAAI,MAAM,QAAQ;KAChC,cAAc,IAAI,SAAS,KAAK;;IAElC,OAAO;;GAET,IAAI,MAAM;IACR,OAAO,cAAc,IAAI,KAAK;;GAEjC;EACD,uBAAuB;GACrB,IAAI,MAAM;IACR,MAAM,QAAQ,cAAc,IAAI,KAAK;IACrC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,uDAAuD;IAEzE,OAAO;;GAET,IAAI,MAAM;IACR,OAAO,cAAc,IAAI,KAAK;;GAEjC;EACF;;AAGH,SAAgB,WAAW,MAAgC;CACzD,OAAO,SAAS,OAAO,KAAK,MAAM,YAAY,KAAK,CAAC;;AAGtD,SAAS,gBAAgB,UAAkB,MAAuB;CAChE,MAAM,CAAC,KAAK,OAAO,YAAY,KAAK;CACpC,OAAO;EACL;EACA;EACA;EACA,OAAO,CAAC,KAAK,IAAI;EAClB;;AAGH,SAAS,YAAY,MAAuC;CAC1D,MAAM,QAAS,KAAsD;CACrE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,qDAAqD;CAEvE,OAAO"}
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- //#region src/bindings/nodejs/typescript_oxlint/ts/oxlint_compat.ts
2
+ //#region src/bindings/nodejs/corsa_oxlint/ts/oxlint_compat.ts
3
3
  var oxlint_compat_exports = /* @__PURE__ */ __exportAll({ oxlintCompat: () => oxlintCompat });
4
4
  const oxlintCompat = Object.freeze({
5
5
  config(...configs) {