corsa-oxlint 0.40.0 → 0.41.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.
@@ -1,6 +1,6 @@
1
1
  import { Plugin, Rule } from "../plugin.js";
2
2
  declare namespace index_d_exports {
3
- export { corsaOxlintPlugin, corsaOxlintRules, implementedNativeRuleNames, pendingNativeRuleNames };
3
+ export { corsaOxlintPlugin, corsaOxlintRules, corsaOxlintPlugin as default, implementedNativeRuleNames, pendingNativeRuleNames };
4
4
  }
5
5
  /**
6
6
  * Native rule names currently implemented by the Rust-backed Corsa rule bridge.
@@ -94,5 +94,5 @@ declare const corsaOxlintRules: Readonly<{
94
94
  */
95
95
  declare const corsaOxlintPlugin: Plugin;
96
96
  //#endregion
97
- export { corsaOxlintPlugin, corsaOxlintRules, implementedNativeRuleNames, index_d_exports, pendingNativeRuleNames };
97
+ export { corsaOxlintPlugin, corsaOxlintPlugin as default, corsaOxlintRules, implementedNativeRuleNames, index_d_exports, pendingNativeRuleNames };
98
98
  //# sourceMappingURL=index.d.ts.map
@@ -30,6 +30,7 @@ import { useUnknownInCatchCallbackVariableRule } from "./use_unknown_in_catch_ca
30
30
  var rules_exports = /* @__PURE__ */ __exportAll({
31
31
  corsaOxlintPlugin: () => corsaOxlintPlugin,
32
32
  corsaOxlintRules: () => corsaOxlintRules,
33
+ default: () => corsaOxlintPlugin,
33
34
  implementedNativeRuleNames: () => implementedNativeRuleNames,
34
35
  pendingNativeRuleNames: () => pendingNativeRuleNames
35
36
  });
@@ -188,6 +189,6 @@ const corsaOxlintPlugin = definePlugin({
188
189
  rules: corsaOxlintRules
189
190
  });
190
191
  //#endregion
191
- export { corsaOxlintPlugin, corsaOxlintRules, implementedNativeRuleNames, pendingNativeRuleNames, rules_exports };
192
+ export { corsaOxlintPlugin, corsaOxlintPlugin as default, corsaOxlintRules, implementedNativeRuleNames, pendingNativeRuleNames, rules_exports };
192
193
 
193
194
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../ts/rules/index.ts"],"sourcesContent":["import { definePlugin } from \"../plugin\";\n\nimport { awaitThenableRule } from \"./await_thenable\";\nimport { noArrayDeleteRule } from \"./no_array_delete\";\nimport { noBaseToStringRule } from \"./no_base_to_string\";\nimport { noFloatingPromisesRule } from \"./no_floating_promises\";\nimport { noForInArrayRule } from \"./no_for_in_array\";\nimport { noImpliedEvalRule } from \"./no_implied_eval\";\nimport { noMeaninglessVoidOperatorRule } from \"./no_meaningless_void_operator\";\nimport { noMixedEnumsRule } from \"./no_mixed_enums\";\nimport { noUnsafeAssignmentRule } from \"./no_unsafe_assignment\";\nimport { noUnsafeCallRule } from \"./no_unsafe_call\";\nimport { noUnsafeMemberAccessRule } from \"./no_unsafe_member_access\";\nimport { noUnsafeReturnRule } from \"./no_unsafe_return\";\nimport { noUnsafeTypeAssertionRule } from \"./no_unsafe_type_assertion\";\nimport { noUnsafeUnaryMinusRule } from \"./no_unsafe_unary_minus\";\nimport { onlyThrowErrorRule } from \"./only_throw_error\";\nimport {\n consistentReturnRule,\n consistentTypeExportsRule,\n dotNotationRule,\n noConfusingVoidExpressionRule,\n noDeprecatedRule,\n noDuplicateTypeConstituentsRule,\n noMisusedPromisesRule,\n noMisusedSpreadRule,\n noRedundantTypeConstituentsRule,\n noUnsafeArgumentRule,\n noUnsafeEnumComparisonRule,\n noUnnecessaryBooleanLiteralCompareRule,\n noUnnecessaryConditionRule,\n noUnnecessaryQualifierRule,\n noUnnecessaryTemplateExpressionRule,\n noUnnecessaryTypeArgumentsRule,\n noUnnecessaryTypeAssertionRule,\n noUnnecessaryTypeConversionRule,\n noUnnecessaryTypeParametersRule,\n noUselessDefaultAssignmentRule,\n nonNullableTypeAssertionStyleRule,\n preferNullishCoalescingRule,\n preferOptionalChainRule,\n preferReadonlyParameterTypesRule,\n preferReadonlyRule,\n preferReturnThisTypeRule,\n promiseFunctionAsyncRule,\n relatedGetterSetterPairsRule,\n requireAwaitRule,\n returnAwaitRule,\n strictBooleanExpressionsRule,\n strictVoidReturnRule,\n switchExhaustivenessCheckRule,\n unboundMethodRule,\n} from \"./pending_parity\";\nimport { preferFindRule } from \"./prefer_find\";\nimport { preferIncludesRule } from \"./prefer_includes\";\nimport { preferPromiseRejectErrorsRule } from \"./prefer_promise_reject_errors\";\nimport { preferReduceTypeParameterRule } from \"./prefer_reduce_type_parameter\";\nimport { preferRegexpExecRule } from \"./prefer_regexp_exec\";\nimport { preferStringStartsEndsWithRule } from \"./prefer_string_starts_ends_with\";\nimport { requireArraySortCompareRule } from \"./require_array_sort_compare\";\nimport { restrictPlusOperandsRule } from \"./restrict_plus_operands\";\nimport { restrictTemplateExpressionsRule } from \"./restrict_template_expressions\";\nimport { useUnknownInCatchCallbackVariableRule } from \"./use_unknown_in_catch_callback_variable\";\n\n/**\n * Native rule names currently implemented by the Rust-backed Corsa rule bridge.\n *\n * The list is exported so preset builders, tests, and documentation generators\n * can reason about the exact supported rule surface without instantiating the\n * plugin object.\n */\nexport const implementedNativeRuleNames = [\n \"await-thenable\",\n \"consistent-return\",\n \"consistent-type-exports\",\n \"dot-notation\",\n \"no-array-delete\",\n \"no-base-to-string\",\n \"no-confusing-void-expression\",\n \"no-deprecated\",\n \"no-duplicate-type-constituents\",\n \"no-floating-promises\",\n \"no-for-in-array\",\n \"no-implied-eval\",\n \"no-meaningless-void-operator\",\n \"no-misused-promises\",\n \"no-misused-spread\",\n \"no-mixed-enums\",\n \"no-redundant-type-constituents\",\n \"no-unnecessary-boolean-literal-compare\",\n \"no-unnecessary-condition\",\n \"no-unnecessary-qualifier\",\n \"no-unnecessary-template-expression\",\n \"no-unnecessary-type-arguments\",\n \"no-unnecessary-type-assertion\",\n \"no-unnecessary-type-conversion\",\n \"no-unnecessary-type-parameters\",\n \"no-unsafe-argument\",\n \"no-unsafe-assignment\",\n \"no-unsafe-call\",\n \"no-unsafe-enum-comparison\",\n \"no-unsafe-member-access\",\n \"no-unsafe-return\",\n \"no-unsafe-type-assertion\",\n \"no-unsafe-unary-minus\",\n \"no-useless-default-assignment\",\n \"non-nullable-type-assertion-style\",\n \"only-throw-error\",\n \"prefer-find\",\n \"prefer-includes\",\n \"prefer-nullish-coalescing\",\n \"prefer-optional-chain\",\n \"prefer-promise-reject-errors\",\n \"prefer-readonly\",\n \"prefer-readonly-parameter-types\",\n \"prefer-reduce-type-parameter\",\n \"prefer-regexp-exec\",\n \"prefer-return-this-type\",\n \"prefer-string-starts-ends-with\",\n \"promise-function-async\",\n \"related-getter-setter-pairs\",\n \"require-array-sort-compare\",\n \"require-await\",\n \"restrict-plus-operands\",\n \"restrict-template-expressions\",\n \"return-await\",\n \"strict-boolean-expressions\",\n \"strict-void-return\",\n \"switch-exhaustiveness-check\",\n \"unbound-method\",\n \"use-unknown-in-catch-callback-variable\",\n] as const;\n\n/**\n * Native rule names reserved for future parity work.\n *\n * This is intentionally empty once all registered rule names have a concrete\n * implementation, but keeping the export stable lets callers surface roadmap\n * state without hard-coding package internals.\n */\nexport const pendingNativeRuleNames = [] as const;\n\n/**\n * Oxlint-compatible rule map backed by Corsa type information.\n *\n * Keys are unprefixed rule names. Consumers usually install this through\n * `corsaOxlintPlugin`, while advanced integrations can compose this map into\n * their own plugin object.\n */\nexport const corsaOxlintRules = Object.freeze({\n \"await-thenable\": awaitThenableRule,\n \"consistent-return\": consistentReturnRule,\n \"consistent-type-exports\": consistentTypeExportsRule,\n \"dot-notation\": dotNotationRule,\n \"no-array-delete\": noArrayDeleteRule,\n \"no-base-to-string\": noBaseToStringRule,\n \"no-confusing-void-expression\": noConfusingVoidExpressionRule,\n \"no-deprecated\": noDeprecatedRule,\n \"no-duplicate-type-constituents\": noDuplicateTypeConstituentsRule,\n \"no-floating-promises\": noFloatingPromisesRule,\n \"no-for-in-array\": noForInArrayRule,\n \"no-implied-eval\": noImpliedEvalRule,\n \"no-meaningless-void-operator\": noMeaninglessVoidOperatorRule,\n \"no-misused-promises\": noMisusedPromisesRule,\n \"no-misused-spread\": noMisusedSpreadRule,\n \"no-mixed-enums\": noMixedEnumsRule,\n \"no-redundant-type-constituents\": noRedundantTypeConstituentsRule,\n \"no-unnecessary-boolean-literal-compare\": noUnnecessaryBooleanLiteralCompareRule,\n \"no-unnecessary-condition\": noUnnecessaryConditionRule,\n \"no-unnecessary-qualifier\": noUnnecessaryQualifierRule,\n \"no-unnecessary-template-expression\": noUnnecessaryTemplateExpressionRule,\n \"no-unnecessary-type-arguments\": noUnnecessaryTypeArgumentsRule,\n \"no-unnecessary-type-assertion\": noUnnecessaryTypeAssertionRule,\n \"no-unnecessary-type-conversion\": noUnnecessaryTypeConversionRule,\n \"no-unnecessary-type-parameters\": noUnnecessaryTypeParametersRule,\n \"no-unsafe-argument\": noUnsafeArgumentRule,\n \"no-unsafe-assignment\": noUnsafeAssignmentRule,\n \"no-unsafe-call\": noUnsafeCallRule,\n \"no-unsafe-enum-comparison\": noUnsafeEnumComparisonRule,\n \"no-unsafe-member-access\": noUnsafeMemberAccessRule,\n \"no-unsafe-return\": noUnsafeReturnRule,\n \"no-unsafe-type-assertion\": noUnsafeTypeAssertionRule,\n \"no-unsafe-unary-minus\": noUnsafeUnaryMinusRule,\n \"no-useless-default-assignment\": noUselessDefaultAssignmentRule,\n \"non-nullable-type-assertion-style\": nonNullableTypeAssertionStyleRule,\n \"only-throw-error\": onlyThrowErrorRule,\n \"prefer-find\": preferFindRule,\n \"prefer-includes\": preferIncludesRule,\n \"prefer-nullish-coalescing\": preferNullishCoalescingRule,\n \"prefer-optional-chain\": preferOptionalChainRule,\n \"prefer-promise-reject-errors\": preferPromiseRejectErrorsRule,\n \"prefer-readonly\": preferReadonlyRule,\n \"prefer-readonly-parameter-types\": preferReadonlyParameterTypesRule,\n \"prefer-reduce-type-parameter\": preferReduceTypeParameterRule,\n \"prefer-regexp-exec\": preferRegexpExecRule,\n \"prefer-return-this-type\": preferReturnThisTypeRule,\n \"prefer-string-starts-ends-with\": preferStringStartsEndsWithRule,\n \"promise-function-async\": promiseFunctionAsyncRule,\n \"related-getter-setter-pairs\": relatedGetterSetterPairsRule,\n \"require-array-sort-compare\": requireArraySortCompareRule,\n \"require-await\": requireAwaitRule,\n \"restrict-plus-operands\": restrictPlusOperandsRule,\n \"restrict-template-expressions\": restrictTemplateExpressionsRule,\n \"return-await\": returnAwaitRule,\n \"strict-boolean-expressions\": strictBooleanExpressionsRule,\n \"strict-void-return\": strictVoidReturnRule,\n \"switch-exhaustiveness-check\": switchExhaustivenessCheckRule,\n \"unbound-method\": unboundMethodRule,\n \"use-unknown-in-catch-callback-variable\": useUnknownInCatchCallbackVariableRule,\n});\n\n/**\n * Oxlint plugin object exposing the Corsa-backed native rule set.\n *\n * Register it under the namespace expected by your config, then enable rules\n * such as `typescript/no-floating-promises` or `typescript/restrict-plus-operands`.\n */\nexport const corsaOxlintPlugin = definePlugin({\n meta: { name: \"oxlint-plugin-corsa\" },\n rules: corsaOxlintRules,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,yBAAyB,EAAE;;;;;;;;AASxC,MAAa,mBAAmB,OAAO,OAAO;CAC5C,kBAAkB;CAClB,qBAAqB;CACrB,2BAA2B;CAC3B,gBAAgB;CAChB,mBAAmB;CACnB,qBAAqB;CACrB,gCAAgC;CAChC,iBAAiB;CACjB,kCAAkC;CAClC,wBAAwB;CACxB,mBAAmB;CACnB,mBAAmB;CACnB,gCAAgC;CAChC,uBAAuB;CACvB,qBAAqB;CACrB,kBAAkB;CAClB,kCAAkC;CAClC,0CAA0C;CAC1C,4BAA4B;CAC5B,4BAA4B;CAC5B,sCAAsC;CACtC,iCAAiC;CACjC,iCAAiC;CACjC,kCAAkC;CAClC,kCAAkC;CAClC,sBAAsB;CACtB,wBAAwB;CACxB,kBAAkB;CAClB,6BAA6B;CAC7B,2BAA2B;CAC3B,oBAAoB;CACpB,4BAA4B;CAC5B,yBAAyB;CACzB,iCAAiC;CACjC,qCAAqC;CACrC,oBAAoB;CACpB,eAAe;CACf,mBAAmB;CACnB,6BAA6B;CAC7B,yBAAyB;CACzB,gCAAgC;CAChC,mBAAmB;CACnB,mCAAmC;CACnC,gCAAgC;CAChC,sBAAsB;CACtB,2BAA2B;CAC3B,kCAAkC;CAClC,0BAA0B;CAC1B,+BAA+B;CAC/B,8BAA8B;CAC9B,iBAAiB;CACjB,0BAA0B;CAC1B,iCAAiC;CACjC,gBAAgB;CAChB,8BAA8B;CAC9B,sBAAsB;CACtB,+BAA+B;CAC/B,kBAAkB;CAClB,0CAA0C;CAC3C,CAAC;;;;;;;AAQF,MAAa,oBAAoB,aAAa;CAC5C,MAAM,EAAE,MAAM,uBAAuB;CACrC,OAAO;CACR,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../ts/rules/index.ts"],"sourcesContent":["import { definePlugin } from \"../plugin\";\n\nimport { awaitThenableRule } from \"./await_thenable\";\nimport { noArrayDeleteRule } from \"./no_array_delete\";\nimport { noBaseToStringRule } from \"./no_base_to_string\";\nimport { noFloatingPromisesRule } from \"./no_floating_promises\";\nimport { noForInArrayRule } from \"./no_for_in_array\";\nimport { noImpliedEvalRule } from \"./no_implied_eval\";\nimport { noMeaninglessVoidOperatorRule } from \"./no_meaningless_void_operator\";\nimport { noMixedEnumsRule } from \"./no_mixed_enums\";\nimport { noUnsafeAssignmentRule } from \"./no_unsafe_assignment\";\nimport { noUnsafeCallRule } from \"./no_unsafe_call\";\nimport { noUnsafeMemberAccessRule } from \"./no_unsafe_member_access\";\nimport { noUnsafeReturnRule } from \"./no_unsafe_return\";\nimport { noUnsafeTypeAssertionRule } from \"./no_unsafe_type_assertion\";\nimport { noUnsafeUnaryMinusRule } from \"./no_unsafe_unary_minus\";\nimport { onlyThrowErrorRule } from \"./only_throw_error\";\nimport {\n consistentReturnRule,\n consistentTypeExportsRule,\n dotNotationRule,\n noConfusingVoidExpressionRule,\n noDeprecatedRule,\n noDuplicateTypeConstituentsRule,\n noMisusedPromisesRule,\n noMisusedSpreadRule,\n noRedundantTypeConstituentsRule,\n noUnsafeArgumentRule,\n noUnsafeEnumComparisonRule,\n noUnnecessaryBooleanLiteralCompareRule,\n noUnnecessaryConditionRule,\n noUnnecessaryQualifierRule,\n noUnnecessaryTemplateExpressionRule,\n noUnnecessaryTypeArgumentsRule,\n noUnnecessaryTypeAssertionRule,\n noUnnecessaryTypeConversionRule,\n noUnnecessaryTypeParametersRule,\n noUselessDefaultAssignmentRule,\n nonNullableTypeAssertionStyleRule,\n preferNullishCoalescingRule,\n preferOptionalChainRule,\n preferReadonlyParameterTypesRule,\n preferReadonlyRule,\n preferReturnThisTypeRule,\n promiseFunctionAsyncRule,\n relatedGetterSetterPairsRule,\n requireAwaitRule,\n returnAwaitRule,\n strictBooleanExpressionsRule,\n strictVoidReturnRule,\n switchExhaustivenessCheckRule,\n unboundMethodRule,\n} from \"./pending_parity\";\nimport { preferFindRule } from \"./prefer_find\";\nimport { preferIncludesRule } from \"./prefer_includes\";\nimport { preferPromiseRejectErrorsRule } from \"./prefer_promise_reject_errors\";\nimport { preferReduceTypeParameterRule } from \"./prefer_reduce_type_parameter\";\nimport { preferRegexpExecRule } from \"./prefer_regexp_exec\";\nimport { preferStringStartsEndsWithRule } from \"./prefer_string_starts_ends_with\";\nimport { requireArraySortCompareRule } from \"./require_array_sort_compare\";\nimport { restrictPlusOperandsRule } from \"./restrict_plus_operands\";\nimport { restrictTemplateExpressionsRule } from \"./restrict_template_expressions\";\nimport { useUnknownInCatchCallbackVariableRule } from \"./use_unknown_in_catch_callback_variable\";\n\n/**\n * Native rule names currently implemented by the Rust-backed Corsa rule bridge.\n *\n * The list is exported so preset builders, tests, and documentation generators\n * can reason about the exact supported rule surface without instantiating the\n * plugin object.\n */\nexport const implementedNativeRuleNames = [\n \"await-thenable\",\n \"consistent-return\",\n \"consistent-type-exports\",\n \"dot-notation\",\n \"no-array-delete\",\n \"no-base-to-string\",\n \"no-confusing-void-expression\",\n \"no-deprecated\",\n \"no-duplicate-type-constituents\",\n \"no-floating-promises\",\n \"no-for-in-array\",\n \"no-implied-eval\",\n \"no-meaningless-void-operator\",\n \"no-misused-promises\",\n \"no-misused-spread\",\n \"no-mixed-enums\",\n \"no-redundant-type-constituents\",\n \"no-unnecessary-boolean-literal-compare\",\n \"no-unnecessary-condition\",\n \"no-unnecessary-qualifier\",\n \"no-unnecessary-template-expression\",\n \"no-unnecessary-type-arguments\",\n \"no-unnecessary-type-assertion\",\n \"no-unnecessary-type-conversion\",\n \"no-unnecessary-type-parameters\",\n \"no-unsafe-argument\",\n \"no-unsafe-assignment\",\n \"no-unsafe-call\",\n \"no-unsafe-enum-comparison\",\n \"no-unsafe-member-access\",\n \"no-unsafe-return\",\n \"no-unsafe-type-assertion\",\n \"no-unsafe-unary-minus\",\n \"no-useless-default-assignment\",\n \"non-nullable-type-assertion-style\",\n \"only-throw-error\",\n \"prefer-find\",\n \"prefer-includes\",\n \"prefer-nullish-coalescing\",\n \"prefer-optional-chain\",\n \"prefer-promise-reject-errors\",\n \"prefer-readonly\",\n \"prefer-readonly-parameter-types\",\n \"prefer-reduce-type-parameter\",\n \"prefer-regexp-exec\",\n \"prefer-return-this-type\",\n \"prefer-string-starts-ends-with\",\n \"promise-function-async\",\n \"related-getter-setter-pairs\",\n \"require-array-sort-compare\",\n \"require-await\",\n \"restrict-plus-operands\",\n \"restrict-template-expressions\",\n \"return-await\",\n \"strict-boolean-expressions\",\n \"strict-void-return\",\n \"switch-exhaustiveness-check\",\n \"unbound-method\",\n \"use-unknown-in-catch-callback-variable\",\n] as const;\n\n/**\n * Native rule names reserved for future parity work.\n *\n * This is intentionally empty once all registered rule names have a concrete\n * implementation, but keeping the export stable lets callers surface roadmap\n * state without hard-coding package internals.\n */\nexport const pendingNativeRuleNames = [] as const;\n\n/**\n * Oxlint-compatible rule map backed by Corsa type information.\n *\n * Keys are unprefixed rule names. Consumers usually install this through\n * `corsaOxlintPlugin`, while advanced integrations can compose this map into\n * their own plugin object.\n */\nexport const corsaOxlintRules = Object.freeze({\n \"await-thenable\": awaitThenableRule,\n \"consistent-return\": consistentReturnRule,\n \"consistent-type-exports\": consistentTypeExportsRule,\n \"dot-notation\": dotNotationRule,\n \"no-array-delete\": noArrayDeleteRule,\n \"no-base-to-string\": noBaseToStringRule,\n \"no-confusing-void-expression\": noConfusingVoidExpressionRule,\n \"no-deprecated\": noDeprecatedRule,\n \"no-duplicate-type-constituents\": noDuplicateTypeConstituentsRule,\n \"no-floating-promises\": noFloatingPromisesRule,\n \"no-for-in-array\": noForInArrayRule,\n \"no-implied-eval\": noImpliedEvalRule,\n \"no-meaningless-void-operator\": noMeaninglessVoidOperatorRule,\n \"no-misused-promises\": noMisusedPromisesRule,\n \"no-misused-spread\": noMisusedSpreadRule,\n \"no-mixed-enums\": noMixedEnumsRule,\n \"no-redundant-type-constituents\": noRedundantTypeConstituentsRule,\n \"no-unnecessary-boolean-literal-compare\": noUnnecessaryBooleanLiteralCompareRule,\n \"no-unnecessary-condition\": noUnnecessaryConditionRule,\n \"no-unnecessary-qualifier\": noUnnecessaryQualifierRule,\n \"no-unnecessary-template-expression\": noUnnecessaryTemplateExpressionRule,\n \"no-unnecessary-type-arguments\": noUnnecessaryTypeArgumentsRule,\n \"no-unnecessary-type-assertion\": noUnnecessaryTypeAssertionRule,\n \"no-unnecessary-type-conversion\": noUnnecessaryTypeConversionRule,\n \"no-unnecessary-type-parameters\": noUnnecessaryTypeParametersRule,\n \"no-unsafe-argument\": noUnsafeArgumentRule,\n \"no-unsafe-assignment\": noUnsafeAssignmentRule,\n \"no-unsafe-call\": noUnsafeCallRule,\n \"no-unsafe-enum-comparison\": noUnsafeEnumComparisonRule,\n \"no-unsafe-member-access\": noUnsafeMemberAccessRule,\n \"no-unsafe-return\": noUnsafeReturnRule,\n \"no-unsafe-type-assertion\": noUnsafeTypeAssertionRule,\n \"no-unsafe-unary-minus\": noUnsafeUnaryMinusRule,\n \"no-useless-default-assignment\": noUselessDefaultAssignmentRule,\n \"non-nullable-type-assertion-style\": nonNullableTypeAssertionStyleRule,\n \"only-throw-error\": onlyThrowErrorRule,\n \"prefer-find\": preferFindRule,\n \"prefer-includes\": preferIncludesRule,\n \"prefer-nullish-coalescing\": preferNullishCoalescingRule,\n \"prefer-optional-chain\": preferOptionalChainRule,\n \"prefer-promise-reject-errors\": preferPromiseRejectErrorsRule,\n \"prefer-readonly\": preferReadonlyRule,\n \"prefer-readonly-parameter-types\": preferReadonlyParameterTypesRule,\n \"prefer-reduce-type-parameter\": preferReduceTypeParameterRule,\n \"prefer-regexp-exec\": preferRegexpExecRule,\n \"prefer-return-this-type\": preferReturnThisTypeRule,\n \"prefer-string-starts-ends-with\": preferStringStartsEndsWithRule,\n \"promise-function-async\": promiseFunctionAsyncRule,\n \"related-getter-setter-pairs\": relatedGetterSetterPairsRule,\n \"require-array-sort-compare\": requireArraySortCompareRule,\n \"require-await\": requireAwaitRule,\n \"restrict-plus-operands\": restrictPlusOperandsRule,\n \"restrict-template-expressions\": restrictTemplateExpressionsRule,\n \"return-await\": returnAwaitRule,\n \"strict-boolean-expressions\": strictBooleanExpressionsRule,\n \"strict-void-return\": strictVoidReturnRule,\n \"switch-exhaustiveness-check\": switchExhaustivenessCheckRule,\n \"unbound-method\": unboundMethodRule,\n \"use-unknown-in-catch-callback-variable\": useUnknownInCatchCallbackVariableRule,\n});\n\n/**\n * Oxlint plugin object exposing the Corsa-backed native rule set.\n *\n * Register it under the namespace expected by your config, then enable rules\n * such as `typescript/no-floating-promises` or `typescript/restrict-plus-operands`.\n */\nexport const corsaOxlintPlugin = definePlugin({\n meta: { name: \"oxlint-plugin-corsa\" },\n rules: corsaOxlintRules,\n});\n\nexport default corsaOxlintPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,yBAAyB,EAAE;;;;;;;;AASxC,MAAa,mBAAmB,OAAO,OAAO;CAC5C,kBAAkB;CAClB,qBAAqB;CACrB,2BAA2B;CAC3B,gBAAgB;CAChB,mBAAmB;CACnB,qBAAqB;CACrB,gCAAgC;CAChC,iBAAiB;CACjB,kCAAkC;CAClC,wBAAwB;CACxB,mBAAmB;CACnB,mBAAmB;CACnB,gCAAgC;CAChC,uBAAuB;CACvB,qBAAqB;CACrB,kBAAkB;CAClB,kCAAkC;CAClC,0CAA0C;CAC1C,4BAA4B;CAC5B,4BAA4B;CAC5B,sCAAsC;CACtC,iCAAiC;CACjC,iCAAiC;CACjC,kCAAkC;CAClC,kCAAkC;CAClC,sBAAsB;CACtB,wBAAwB;CACxB,kBAAkB;CAClB,6BAA6B;CAC7B,2BAA2B;CAC3B,oBAAoB;CACpB,4BAA4B;CAC5B,yBAAyB;CACzB,iCAAiC;CACjC,qCAAqC;CACrC,oBAAoB;CACpB,eAAe;CACf,mBAAmB;CACnB,6BAA6B;CAC7B,yBAAyB;CACzB,gCAAgC;CAChC,mBAAmB;CACnB,mCAAmC;CACnC,gCAAgC;CAChC,sBAAsB;CACtB,2BAA2B;CAC3B,kCAAkC;CAClC,0BAA0B;CAC1B,+BAA+B;CAC/B,8BAA8B;CAC9B,iBAAiB;CACjB,0BAA0B;CAC1B,iCAAiC;CACjC,gBAAgB;CAChB,8BAA8B;CAC9B,sBAAsB;CACtB,+BAA+B;CAC/B,kBAAkB;CAClB,0CAA0C;CAC3C,CAAC;;;;;;;AAQF,MAAa,oBAAoB,aAAa;CAC5C,MAAM,EAAE,MAAM,uBAAuB;CACrC,OAAO;CACR,CAAC"}
@@ -2,7 +2,7 @@ import { Plugin, Rule } from "./plugin.js";
2
2
 
3
3
  //#region src/bindings/nodejs/corsa_oxlint/ts/stylistic.d.ts
4
4
  declare namespace stylistic_d_exports {
5
- export { CorsaStylisticRuleName, CorsaStylisticRuleOptions, CorsaStylisticSettings, corsaStylisticPlugin, corsaStylisticRules, implementedStylisticRuleNames };
5
+ export { CorsaStylisticRuleName, CorsaStylisticRuleOptions, CorsaStylisticSettings, corsaStylisticPlugin, corsaStylisticRules, corsaStylisticPlugin as default, implementedStylisticRuleNames };
6
6
  }
7
7
  type CorsaStylisticRuleName = "eol-last" | "linebreak-style" | "no-multiple-empty-lines" | "no-tabs" | "no-trailing-spaces" | "quotes" | "unicode-bom" | "arrow-spacing" | "comma-spacing" | "semi-spacing" | "space-in-parens" | "template-curly-spacing" | "rest-spread-spacing" | "no-multi-spaces" | "no-whitespace-before-property" | "dot-location" | "spaced-comment" | "object-curly-spacing" | "array-bracket-spacing" | "computed-property-spacing" | "block-spacing" | "space-before-blocks" | "function-call-spacing" | "space-before-function-paren" | "no-floating-decimal" | "template-tag-spacing" | "yield-star-spacing" | "generator-star-spacing" | "comma-dangle" | "space-infix-ops" | "max-len" | "semi-style" | "comma-style" | "arrow-parens" | "switch-colon-spacing" | "no-extra-semi" | "new-parens" | "space-unary-ops" | "wrap-regex" | "implicit-arrow-linebreak" | "operator-linebreak" | "keyword-spacing";
8
8
  type CorsaStylisticRuleOptions = readonly unknown[];
@@ -33,5 +33,5 @@ declare const corsaStylisticRules: Readonly<Record<CorsaStylisticRuleName, Retur
33
33
  declare const corsaStylisticPlugin: Plugin;
34
34
  declare function createStylisticRule(ruleName: CorsaStylisticRuleName): Rule;
35
35
  //#endregion
36
- export { CorsaStylisticRuleName, CorsaStylisticRuleOptions, CorsaStylisticSettings, corsaStylisticPlugin, corsaStylisticRules, implementedStylisticRuleNames, stylistic_d_exports };
36
+ export { CorsaStylisticRuleName, CorsaStylisticRuleOptions, CorsaStylisticSettings, corsaStylisticPlugin, corsaStylisticPlugin as default, corsaStylisticRules, implementedStylisticRuleNames, stylistic_d_exports };
37
37
  //# sourceMappingURL=stylistic.d.ts.map
package/dist/stylistic.js CHANGED
@@ -5,6 +5,7 @@ import { nativeStylisticRuleMetas, runNativeStylisticLint } from "@corsa-bind/na
5
5
  var stylistic_exports = /* @__PURE__ */ __exportAll({
6
6
  corsaStylisticPlugin: () => corsaStylisticPlugin,
7
7
  corsaStylisticRules: () => corsaStylisticRules,
8
+ default: () => corsaStylisticPlugin,
8
9
  implementedStylisticRuleNames: () => implementedStylisticRuleNames
9
10
  });
10
11
  const stylisticMetas = nativeStylisticRuleMetas();
@@ -105,9 +106,12 @@ function diagnosticsForRule(context, ruleName) {
105
106
  diagnosticsCache.set(sourceCode, sourceCache);
106
107
  }
107
108
  const cached = sourceCache.get(key);
108
- if (cached) return cached;
109
+ if (cached?.sourceText === sourceText) return cached.diagnostics;
109
110
  const diagnostics = runNativeStylisticLint(sourceText, { rules: config });
110
- sourceCache.set(key, diagnostics);
111
+ sourceCache.set(key, {
112
+ sourceText,
113
+ diagnostics
114
+ });
111
115
  return diagnostics;
112
116
  }
113
117
  function stylisticRunConfig(context, currentRuleName) {
@@ -165,6 +169,6 @@ function stylisticRuleMeta(ruleName) {
165
169
  return meta;
166
170
  }
167
171
  //#endregion
168
- export { corsaStylisticPlugin, corsaStylisticRules, implementedStylisticRuleNames, stylistic_exports };
172
+ export { corsaStylisticPlugin, corsaStylisticPlugin as default, corsaStylisticRules, implementedStylisticRuleNames, stylistic_exports };
169
173
 
170
174
  //# sourceMappingURL=stylistic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stylistic.js","names":[],"sources":["../ts/stylistic.ts"],"sourcesContent":["import {\n nativeStylisticRuleMetas,\n runNativeStylisticLint,\n type NativeLintDiagnostic,\n type NativeLintRange,\n type NativeLintRuleMeta,\n type NativeStylisticRuleConfig,\n} from \"@corsa-bind/napi\";\n\nimport { definePlugin, defineRule } from \"./plugin\";\nimport type { ContextWithParserOptions } from \"./types\";\n\ntype ProgramNode = {\n readonly type: string;\n readonly range?: readonly [number, number];\n};\n\nexport type CorsaStylisticRuleName =\n | \"eol-last\"\n | \"linebreak-style\"\n | \"no-multiple-empty-lines\"\n | \"no-tabs\"\n | \"no-trailing-spaces\"\n | \"quotes\"\n | \"unicode-bom\"\n | \"arrow-spacing\"\n | \"comma-spacing\"\n | \"semi-spacing\"\n | \"space-in-parens\"\n | \"template-curly-spacing\"\n | \"rest-spread-spacing\"\n | \"no-multi-spaces\"\n | \"no-whitespace-before-property\"\n | \"dot-location\"\n | \"spaced-comment\"\n | \"object-curly-spacing\"\n | \"array-bracket-spacing\"\n | \"computed-property-spacing\"\n | \"block-spacing\"\n | \"space-before-blocks\"\n | \"function-call-spacing\"\n | \"space-before-function-paren\"\n | \"no-floating-decimal\"\n | \"template-tag-spacing\"\n | \"yield-star-spacing\"\n | \"generator-star-spacing\"\n | \"comma-dangle\"\n | \"space-infix-ops\"\n | \"max-len\"\n | \"semi-style\"\n | \"comma-style\"\n | \"arrow-parens\"\n | \"switch-colon-spacing\"\n | \"no-extra-semi\"\n | \"new-parens\"\n | \"space-unary-ops\"\n | \"wrap-regex\"\n | \"implicit-arrow-linebreak\"\n | \"operator-linebreak\"\n | \"keyword-spacing\";\n\nexport type CorsaStylisticRuleOptions = readonly unknown[];\n\nexport interface CorsaStylisticSettings {\n /**\n * Rule options used by the native batch runner.\n *\n * Keep this in sync with enabled Oxlint rules when several stylistic rules\n * are active; the JS bridge can then perform one native scan and share the\n * diagnostics across individual rule reports.\n */\n readonly rules?: Partial<Record<CorsaStylisticRuleName, CorsaStylisticRuleOptions>>;\n}\n\nconst stylisticMetas = nativeStylisticRuleMetas();\nconst stylisticMetasByName = new Map(stylisticMetas.map((meta) => [meta.name, meta]));\nconst diagnosticsCache = new WeakMap<object, Map<string, readonly NativeLintDiagnostic[]>>();\n\n/**\n * Native stylistic rule names exported by `corsa-oxlint/stylistic`.\n */\nexport const implementedStylisticRuleNames = [\n \"eol-last\",\n \"linebreak-style\",\n \"no-multiple-empty-lines\",\n \"no-tabs\",\n \"no-trailing-spaces\",\n \"quotes\",\n \"unicode-bom\",\n \"arrow-spacing\",\n \"comma-spacing\",\n \"semi-spacing\",\n \"space-in-parens\",\n \"template-curly-spacing\",\n \"rest-spread-spacing\",\n \"no-multi-spaces\",\n \"no-whitespace-before-property\",\n \"dot-location\",\n \"spaced-comment\",\n \"object-curly-spacing\",\n \"array-bracket-spacing\",\n \"computed-property-spacing\",\n \"block-spacing\",\n \"space-before-blocks\",\n \"function-call-spacing\",\n \"space-before-function-paren\",\n \"no-floating-decimal\",\n \"template-tag-spacing\",\n \"yield-star-spacing\",\n \"generator-star-spacing\",\n \"comma-dangle\",\n \"space-infix-ops\",\n \"max-len\",\n \"semi-style\",\n \"comma-style\",\n \"arrow-parens\",\n \"switch-colon-spacing\",\n \"no-extra-semi\",\n \"new-parens\",\n \"space-unary-ops\",\n \"wrap-regex\",\n \"implicit-arrow-linebreak\",\n \"operator-linebreak\",\n \"keyword-spacing\",\n] as const satisfies readonly CorsaStylisticRuleName[];\n\n/**\n * Oxlint-compatible stylistic rules backed by the Rust source scanner.\n */\nexport const corsaStylisticRules = Object.freeze(\n Object.fromEntries(\n implementedStylisticRuleNames.map((ruleName) => [ruleName, createStylisticRule(ruleName)]),\n ),\n) as Readonly<Record<CorsaStylisticRuleName, ReturnType<typeof createStylisticRule>>>;\n\n/**\n * Oxlint plugin exposing Corsa's Rust-backed stylistic rules.\n *\n * Register it under any namespace, then enable rules such as\n * `stylistic/quotes` or `stylistic/no-trailing-spaces`.\n */\nexport const corsaStylisticPlugin = definePlugin({\n meta: { name: \"oxlint-plugin-corsa-stylistic\" },\n rules: corsaStylisticRules,\n});\n\nfunction createStylisticRule(ruleName: CorsaStylisticRuleName) {\n const meta = stylisticRuleMeta(ruleName);\n return defineRule({\n defaultOptions: [],\n meta: {\n type: \"layout\",\n docs: {\n description: meta.docsDescription,\n requiresTypeChecking: false,\n url: `https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint/ts/stylistic.ts`,\n },\n fixable: \"whitespace\",\n hasSuggestions: meta.hasSuggestions,\n messages: meta.messages,\n schema: { type: \"array\" },\n },\n create(context: ContextWithParserOptions) {\n return {\n Program(node: ProgramNode) {\n reportStylisticDiagnostics(\n context,\n node,\n diagnosticsForRule(context, ruleName).filter(\n (diagnostic) => diagnostic.ruleName === ruleName,\n ),\n );\n },\n };\n },\n });\n}\n\nfunction diagnosticsForRule(\n context: ContextWithParserOptions,\n ruleName: CorsaStylisticRuleName,\n): readonly NativeLintDiagnostic[] {\n const sourceCode = context.sourceCode as unknown as object;\n const sourceText = sourceTextForContext(context);\n const config = stylisticRunConfig(context, ruleName);\n const key = JSON.stringify(config);\n let sourceCache = diagnosticsCache.get(sourceCode);\n if (!sourceCache) {\n sourceCache = new Map();\n diagnosticsCache.set(sourceCode, sourceCache);\n }\n\n const cached = sourceCache.get(key);\n if (cached) {\n return cached;\n }\n\n const diagnostics = runNativeStylisticLint(sourceText, { rules: config });\n sourceCache.set(key, diagnostics);\n return diagnostics;\n}\n\nfunction stylisticRunConfig(\n context: ContextWithParserOptions,\n currentRuleName: CorsaStylisticRuleName,\n): readonly NativeStylisticRuleConfig[] {\n const settingsRules = context.settings?.corsaStylistic?.rules;\n const rules = new Map<CorsaStylisticRuleName, CorsaStylisticRuleOptions>();\n\n if (settingsRules) {\n for (const [name, options] of Object.entries(settingsRules)) {\n assertKnownStylisticRuleName(name);\n rules.set(name, normalizeOptions(options));\n }\n }\n\n const currentOptions = currentRuleOptions(context);\n if (!rules.has(currentRuleName) || currentOptions.length > 0) {\n rules.set(currentRuleName, currentOptions);\n }\n\n return implementedStylisticRuleNames\n .filter((ruleName) => rules.has(ruleName))\n .map((ruleName) => ({\n name: ruleName,\n options: rules.get(ruleName) ?? [],\n }));\n}\n\nfunction reportStylisticDiagnostics(\n context: ContextWithParserOptions,\n program: ProgramNode,\n diagnostics: readonly NativeLintDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n context.report({\n node: rangeNode(program, diagnostic.range),\n messageId: diagnostic.messageId,\n ...(diagnostic.suggestions?.length\n ? {\n suggest: diagnostic.suggestions.map((suggestion) => ({\n messageId: suggestion.messageId,\n fix: (fixer: any) =>\n suggestion.fixes.map((fix) =>\n fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText),\n ),\n })),\n }\n : {}),\n } as never);\n }\n}\n\nfunction rangeNode(program: ProgramNode, range: NativeLintRange): ProgramNode {\n return {\n ...program,\n range: oxlintRange(range),\n };\n}\n\nfunction oxlintRange(range: NativeLintRange): [number, number] {\n return [range.start, range.end];\n}\n\nfunction sourceTextForContext(context: ContextWithParserOptions): string {\n const text = (context.sourceCode as { text?: unknown }).text;\n if (typeof text === \"string\") {\n return text;\n }\n return context.sourceCode.getText({ type: \"Program\" } as never);\n}\n\nfunction currentRuleOptions(context: ContextWithParserOptions): CorsaStylisticRuleOptions {\n return normalizeOptions((context as { options?: unknown }).options);\n}\n\nfunction normalizeOptions(options: unknown): CorsaStylisticRuleOptions {\n if (Array.isArray(options)) {\n return options;\n }\n if (options == null) {\n return [];\n }\n return [options];\n}\n\nfunction assertKnownStylisticRuleName(name: string): asserts name is CorsaStylisticRuleName {\n if (!(implementedStylisticRuleNames as readonly string[]).includes(name)) {\n throw new Error(`unknown corsa stylistic rule: ${name}`);\n }\n}\n\nfunction stylisticRuleMeta(ruleName: CorsaStylisticRuleName): NativeLintRuleMeta {\n const meta = stylisticMetasByName.get(ruleName);\n if (!meta) {\n throw new Error(`corsa stylistic native Rust rule is not registered: ${ruleName}`);\n }\n return meta;\n}\n"],"mappings":";;;;;;;;;AA0EA,MAAM,iBAAiB,0BAA0B;AACjD,MAAM,uBAAuB,IAAI,IAAI,eAAe,KAAK,SAAS,CAAC,KAAK,MAAM,KAAK,CAAC,CAAC;AACrF,MAAM,mCAAmB,IAAI,SAA+D;;;;AAK5F,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,sBAAsB,OAAO,OACxC,OAAO,YACL,8BAA8B,KAAK,aAAa,CAAC,UAAU,oBAAoB,SAAS,CAAC,CAAC,CAC3F,CACF;;;;;;;AAQD,MAAa,uBAAuB,aAAa;CAC/C,MAAM,EAAE,MAAM,iCAAiC;CAC/C,OAAO;CACR,CAAC;AAEF,SAAS,oBAAoB,UAAkC;CAC7D,MAAM,OAAO,kBAAkB,SAAS;CACxC,OAAO,WAAW;EAChB,gBAAgB,EAAE;EAClB,MAAM;GACJ,MAAM;GACN,MAAM;IACJ,aAAa,KAAK;IAClB,sBAAsB;IACtB,KAAK;IACN;GACD,SAAS;GACT,gBAAgB,KAAK;GACrB,UAAU,KAAK;GACf,QAAQ,EAAE,MAAM,SAAS;GAC1B;EACD,OAAO,SAAmC;GACxC,OAAO,EACL,QAAQ,MAAmB;IACzB,2BACE,SACA,MACA,mBAAmB,SAAS,SAAS,CAAC,QACnC,eAAe,WAAW,aAAa,SACzC,CACF;MAEJ;;EAEJ,CAAC;;AAGJ,SAAS,mBACP,SACA,UACiC;CACjC,MAAM,aAAa,QAAQ;C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E,EACJ,GACD,EAAE;EACP,CAAU;;AAIf,SAAS,UAAU,SAAsB,OAAqC;CAC5E,OAAO;EACL,GAAG;EACH,OAAO,YAAY,MAAM;EAC1B;;AAGH,SAAS,YAAY,OAA0C;CAC7D,OAAO,CAAC,MAAM,OAAO,MAAM,IAAI;;AAGjC,SAAS,qBAAqB,SAA2C;CACvE,MAAM,OAAQ,QAAQ,WAAkC;CACxD,IAAI,OAAO,SAAS,UAClB,OAAO;CAET,OAAO,QAAQ,WAAW,QAAQ,EAAE,MAAM,WAAW,CAAU;;AAGjE,SAAS,mBAAmB,SAA8D;CACxF,OAAO,iBAAkB,QAAkC,QAAQ;;AAGrE,SAAS,iBAAiB,SAA6C;CACrE,IAAI,MAAM,QAAQ,QAAQ,EACxB,OAAO;CAET,IAAI,WAAW,MACb,OAAO,EAAE;CAEX,OAAO,CAAC,QAAQ;;AAGlB,SAAS,6BAA6B,MAAsD;CAC1F,IAAI,CAAE,8BAAoD,SAAS,KAAK,EACtE,MAAM,IAAI,MAAM,iCAAiC,OAAO;;AAI5D,SAAS,kBAAkB,UAAsD;CAC/E,MAAM,OAAO,qBAAqB,IAAI,SAAS;CAC/C,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,uDAAuD,WAAW;CAEpF,OAAO"}
1
+ {"version":3,"file":"stylistic.js","names":[],"sources":["../ts/stylistic.ts"],"sourcesContent":["import {\n nativeStylisticRuleMetas,\n runNativeStylisticLint,\n type NativeLintDiagnostic,\n type NativeLintRange,\n type NativeLintRuleMeta,\n type NativeStylisticRuleConfig,\n} from \"@corsa-bind/napi\";\n\nimport { definePlugin, defineRule } from \"./plugin\";\nimport type { ContextWithParserOptions } from \"./types\";\n\ntype ProgramNode = {\n readonly type: string;\n readonly range?: readonly [number, number];\n};\n\nexport type CorsaStylisticRuleName =\n | \"eol-last\"\n | \"linebreak-style\"\n | \"no-multiple-empty-lines\"\n | \"no-tabs\"\n | \"no-trailing-spaces\"\n | \"quotes\"\n | \"unicode-bom\"\n | \"arrow-spacing\"\n | \"comma-spacing\"\n | \"semi-spacing\"\n | \"space-in-parens\"\n | \"template-curly-spacing\"\n | \"rest-spread-spacing\"\n | \"no-multi-spaces\"\n | \"no-whitespace-before-property\"\n | \"dot-location\"\n | \"spaced-comment\"\n | \"object-curly-spacing\"\n | \"array-bracket-spacing\"\n | \"computed-property-spacing\"\n | \"block-spacing\"\n | \"space-before-blocks\"\n | \"function-call-spacing\"\n | \"space-before-function-paren\"\n | \"no-floating-decimal\"\n | \"template-tag-spacing\"\n | \"yield-star-spacing\"\n | \"generator-star-spacing\"\n | \"comma-dangle\"\n | \"space-infix-ops\"\n | \"max-len\"\n | \"semi-style\"\n | \"comma-style\"\n | \"arrow-parens\"\n | \"switch-colon-spacing\"\n | \"no-extra-semi\"\n | \"new-parens\"\n | \"space-unary-ops\"\n | \"wrap-regex\"\n | \"implicit-arrow-linebreak\"\n | \"operator-linebreak\"\n | \"keyword-spacing\";\n\nexport type CorsaStylisticRuleOptions = readonly unknown[];\n\nexport interface CorsaStylisticSettings {\n /**\n * Rule options used by the native batch runner.\n *\n * Keep this in sync with enabled Oxlint rules when several stylistic rules\n * are active; the JS bridge can then perform one native scan and share the\n * diagnostics across individual rule reports.\n */\n readonly rules?: Partial<Record<CorsaStylisticRuleName, CorsaStylisticRuleOptions>>;\n}\n\nconst stylisticMetas = nativeStylisticRuleMetas();\nconst stylisticMetasByName = new Map(stylisticMetas.map((meta) => [meta.name, meta]));\ntype CachedStylisticDiagnostics = {\n readonly sourceText: string;\n readonly diagnostics: readonly NativeLintDiagnostic[];\n};\n\nconst diagnosticsCache = new WeakMap<object, Map<string, CachedStylisticDiagnostics>>();\n\n/**\n * Native stylistic rule names exported by `corsa-oxlint/stylistic`.\n */\nexport const implementedStylisticRuleNames = [\n \"eol-last\",\n \"linebreak-style\",\n \"no-multiple-empty-lines\",\n \"no-tabs\",\n \"no-trailing-spaces\",\n \"quotes\",\n \"unicode-bom\",\n \"arrow-spacing\",\n \"comma-spacing\",\n \"semi-spacing\",\n \"space-in-parens\",\n \"template-curly-spacing\",\n \"rest-spread-spacing\",\n \"no-multi-spaces\",\n \"no-whitespace-before-property\",\n \"dot-location\",\n \"spaced-comment\",\n \"object-curly-spacing\",\n \"array-bracket-spacing\",\n \"computed-property-spacing\",\n \"block-spacing\",\n \"space-before-blocks\",\n \"function-call-spacing\",\n \"space-before-function-paren\",\n \"no-floating-decimal\",\n \"template-tag-spacing\",\n \"yield-star-spacing\",\n \"generator-star-spacing\",\n \"comma-dangle\",\n \"space-infix-ops\",\n \"max-len\",\n \"semi-style\",\n \"comma-style\",\n \"arrow-parens\",\n \"switch-colon-spacing\",\n \"no-extra-semi\",\n \"new-parens\",\n \"space-unary-ops\",\n \"wrap-regex\",\n \"implicit-arrow-linebreak\",\n \"operator-linebreak\",\n \"keyword-spacing\",\n] as const satisfies readonly CorsaStylisticRuleName[];\n\n/**\n * Oxlint-compatible stylistic rules backed by the Rust source scanner.\n */\nexport const corsaStylisticRules = Object.freeze(\n Object.fromEntries(\n implementedStylisticRuleNames.map((ruleName) => [ruleName, createStylisticRule(ruleName)]),\n ),\n) as Readonly<Record<CorsaStylisticRuleName, ReturnType<typeof createStylisticRule>>>;\n\n/**\n * Oxlint plugin exposing Corsa's Rust-backed stylistic rules.\n *\n * Register it under any namespace, then enable rules such as\n * `stylistic/quotes` or `stylistic/no-trailing-spaces`.\n */\nexport const corsaStylisticPlugin = definePlugin({\n meta: { name: \"oxlint-plugin-corsa-stylistic\" },\n rules: corsaStylisticRules,\n});\n\nexport default corsaStylisticPlugin;\n\nfunction createStylisticRule(ruleName: CorsaStylisticRuleName) {\n const meta = stylisticRuleMeta(ruleName);\n return defineRule({\n defaultOptions: [],\n meta: {\n type: \"layout\",\n docs: {\n description: meta.docsDescription,\n requiresTypeChecking: false,\n url: `https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint/ts/stylistic.ts`,\n },\n fixable: \"whitespace\",\n hasSuggestions: meta.hasSuggestions,\n messages: meta.messages,\n schema: { type: \"array\" },\n },\n create(context: ContextWithParserOptions) {\n return {\n Program(node: ProgramNode) {\n reportStylisticDiagnostics(\n context,\n node,\n diagnosticsForRule(context, ruleName).filter(\n (diagnostic) => diagnostic.ruleName === ruleName,\n ),\n );\n },\n };\n },\n });\n}\n\nfunction diagnosticsForRule(\n context: ContextWithParserOptions,\n ruleName: CorsaStylisticRuleName,\n): readonly NativeLintDiagnostic[] {\n const sourceCode = context.sourceCode as unknown as object;\n const sourceText = sourceTextForContext(context);\n const config = stylisticRunConfig(context, ruleName);\n const key = JSON.stringify(config);\n let sourceCache = diagnosticsCache.get(sourceCode);\n if (!sourceCache) {\n sourceCache = new Map();\n diagnosticsCache.set(sourceCode, sourceCache);\n }\n\n const cached = sourceCache.get(key);\n if (cached?.sourceText === sourceText) {\n return cached.diagnostics;\n }\n\n const diagnostics = runNativeStylisticLint(sourceText, { rules: config });\n sourceCache.set(key, { sourceText, diagnostics });\n return diagnostics;\n}\n\nfunction stylisticRunConfig(\n context: ContextWithParserOptions,\n currentRuleName: CorsaStylisticRuleName,\n): readonly NativeStylisticRuleConfig[] {\n const settingsRules = context.settings?.corsaStylistic?.rules;\n const rules = new Map<CorsaStylisticRuleName, CorsaStylisticRuleOptions>();\n\n if (settingsRules) {\n for (const [name, options] of Object.entries(settingsRules)) {\n assertKnownStylisticRuleName(name);\n rules.set(name, normalizeOptions(options));\n }\n }\n\n const currentOptions = currentRuleOptions(context);\n if (!rules.has(currentRuleName) || currentOptions.length > 0) {\n rules.set(currentRuleName, currentOptions);\n }\n\n return implementedStylisticRuleNames\n .filter((ruleName) => rules.has(ruleName))\n .map((ruleName) => ({\n name: ruleName,\n options: rules.get(ruleName) ?? [],\n }));\n}\n\nfunction reportStylisticDiagnostics(\n context: ContextWithParserOptions,\n program: ProgramNode,\n diagnostics: readonly NativeLintDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n context.report({\n node: rangeNode(program, diagnostic.range),\n messageId: diagnostic.messageId,\n ...(diagnostic.suggestions?.length\n ? {\n suggest: diagnostic.suggestions.map((suggestion) => ({\n messageId: suggestion.messageId,\n fix: (fixer: any) =>\n suggestion.fixes.map((fix) =>\n fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText),\n ),\n })),\n }\n : {}),\n } as never);\n }\n}\n\nfunction rangeNode(program: ProgramNode, range: NativeLintRange): ProgramNode {\n return {\n ...program,\n range: oxlintRange(range),\n };\n}\n\nfunction oxlintRange(range: NativeLintRange): [number, number] {\n return [range.start, range.end];\n}\n\nfunction sourceTextForContext(context: ContextWithParserOptions): string {\n const text = (context.sourceCode as { text?: unknown }).text;\n if (typeof text === \"string\") {\n return text;\n }\n return context.sourceCode.getText({ type: \"Program\" } as never);\n}\n\nfunction currentRuleOptions(context: ContextWithParserOptions): CorsaStylisticRuleOptions {\n return normalizeOptions((context as { options?: unknown }).options);\n}\n\nfunction normalizeOptions(options: unknown): CorsaStylisticRuleOptions {\n if (Array.isArray(options)) {\n return options;\n }\n if (options == null) {\n return [];\n }\n return [options];\n}\n\nfunction assertKnownStylisticRuleName(name: string): asserts name is CorsaStylisticRuleName {\n if (!(implementedStylisticRuleNames as readonly string[]).includes(name)) {\n throw new Error(`unknown corsa stylistic rule: ${name}`);\n }\n}\n\nfunction stylisticRuleMeta(ruleName: CorsaStylisticRuleName): NativeLintRuleMeta {\n const meta = stylisticMetasByName.get(ruleName);\n if (!meta) {\n throw new Error(`corsa stylistic native Rust rule is not registered: ${ruleName}`);\n }\n return meta;\n}\n"],"mappings":";;;;;;;;;;AA0EA,MAAM,iBAAiB,0BAA0B;AACjD,MAAM,uBAAuB,IAAI,IAAI,eAAe,KAAK,SAAS,CAAC,KAAK,MAAM,KAAK,CAAC,CAAC;AAMrF,MAAM,mCAAmB,IAAI,SAA0D;;;;AAKvF,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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F,OAAO,iBAAkB,QAAkC,QAAQ;;AAGrE,SAAS,iBAAiB,SAA6C;CACrE,IAAI,MAAM,QAAQ,QAAQ,EACxB,OAAO;CAET,IAAI,WAAW,MACb,OAAO,EAAE;CAEX,OAAO,CAAC,QAAQ;;AAGlB,SAAS,6BAA6B,MAAsD;CAC1F,IAAI,CAAE,8BAAoD,SAAS,KAAK,EACtE,MAAM,IAAI,MAAM,iCAAiC,OAAO;;AAI5D,SAAS,kBAAkB,UAAsD;CAC/E,MAAM,OAAO,qBAAqB,IAAI,SAAS;CAC/C,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,uDAAuD,WAAW;CAEpF,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsa-oxlint",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Type-aware Oxlint helpers powered by Corsa",
5
5
  "homepage": "https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint",
6
6
  "bugs": {
@@ -103,7 +103,7 @@
103
103
  "dependencies": {
104
104
  "@oxlint/plugins": "1.66.0",
105
105
  "oxlint": "1.66.0",
106
- "@corsa-bind/napi": "0.40.0"
106
+ "@corsa-bind/napi": "0.41.0"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@typescript-eslint/utils": "8.59.3"