corsa-oxlint 0.42.0 → 0.43.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.
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import { oxlintCompat, oxlint_compat_d_exports } from "./oxlint_compat.js";
6
6
  import { ts_utils_d_exports } from "./ts_utils.js";
7
7
  import { utils_d_exports } from "./utils.js";
8
8
  import { getParserServices } from "./parser_services.js";
9
- import { Plugin, Rule, compatPlugin, definePlugin, defineRule } from "./plugin.js";
9
+ import { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleMetaWithMessages, compatPlugin, definePlugin, defineRule } from "./plugin.js";
10
10
  import { ESLintUtils, OxlintUtils, RuleCreator } from "./oxlint_utils.js";
11
11
  import { RuleTester, RuleTesterConfig } from "./rule_tester.js";
12
12
  import { TSESLint } from "./ts_eslint.js";
@@ -206,5 +206,5 @@ declare namespace ESTree {
206
206
  export {};
207
207
  }
208
208
  //#endregion
209
- 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 CorsaStylisticSettings, 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 Plugin, type ProjectServiceOptions, type Rule, RuleCreator, RuleTester, type RuleTesterConfig, SignatureKind, 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, stylistic_d_exports as stylistic };
209
+ 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 CorsaStylisticSettings, 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 Plugin, type ProjectServiceOptions, type Rule, type RuleContext, RuleCreator, type RuleDefinition, type RuleDiagnostic, type RuleMetaWithMessages, RuleTester, type RuleTesterConfig, SignatureKind, 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, stylistic_d_exports as stylistic };
210
210
  //# sourceMappingURL=index.d.ts.map
package/dist/plugin.d.ts CHANGED
@@ -1,10 +1,31 @@
1
- import { Plugin as Plugin$1, Rule as Rule$1 } from "@oxlint/plugins";
1
+ import { ContextWithParserOptions } from "./types.js";
2
+ import { Diagnostic, Plugin as Plugin$1, Rule as Rule$1, RuleMeta, Visitor, VisitorWithHooks } from "@oxlint/plugins";
2
3
 
3
4
  //#region src/bindings/nodejs/corsa_oxlint/ts/plugin.d.ts
4
5
  type Plugin = Omit<Plugin$1, "rules"> & {
5
6
  readonly rules: Record<string, Rule>;
6
7
  } & Record<string, unknown>;
7
8
  type Rule = Rule$1 & Record<string, unknown>;
9
+ type RuleDiagnostic<MessageId extends string = string> = Diagnostic & {
10
+ readonly messageId?: MessageId | null | undefined;
11
+ };
12
+ type RuleContext<MessageId extends string = string, Options extends readonly unknown[] = readonly unknown[]> = Omit<ContextWithParserOptions, "options" | "report"> & {
13
+ readonly options: Readonly<Options>;
14
+ report(this: void, diagnostic: RuleDiagnostic<MessageId>): void;
15
+ };
16
+ type RuleMetaWithMessages<MessageId extends string = string> = RuleMeta & {
17
+ readonly messages?: Record<MessageId, string>;
18
+ };
19
+ type RuleDefinition<MessageId extends string = string, Options extends readonly unknown[] = readonly unknown[]> = Record<string, unknown> & {
20
+ readonly defaultOptions?: Options;
21
+ readonly meta?: RuleMetaWithMessages<MessageId>;
22
+ } & ({
23
+ readonly create: (context: RuleContext<MessageId, Options>) => Visitor;
24
+ readonly createOnce?: never;
25
+ } | {
26
+ readonly create?: (context: RuleContext<MessageId, Options>) => Visitor;
27
+ readonly createOnce: (context: RuleContext<MessageId, Options>) => VisitorWithHooks;
28
+ });
8
29
  declare function definePlugin(plugin: Plugin): Plugin;
9
30
  /**
10
31
  * Defines a single Oxlint rule with type-aware parser services.
@@ -20,9 +41,9 @@ declare function definePlugin(plugin: Plugin): Plugin;
20
41
  * });
21
42
  * ```
22
43
  */
23
- declare function defineRule(rule: Rule): Rule;
44
+ declare function defineRule<MessageId extends string = string, const Options extends readonly unknown[] = readonly unknown[]>(rule: RuleDefinition<MessageId, Options>): Rule;
24
45
  declare function compatPlugin(plugin: Plugin): Plugin;
25
46
  declare function decorateRule(rule: Rule): Rule;
26
47
  //#endregion
27
- export { Plugin, Rule, compatPlugin, decorateRule, definePlugin, defineRule };
48
+ export { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleMetaWithMessages, compatPlugin, decorateRule, definePlugin, defineRule };
28
49
  //# sourceMappingURL=plugin.d.ts.map
package/dist/plugin.js CHANGED
@@ -11,20 +11,6 @@ function definePlugin(plugin) {
11
11
  rules: wrapRules(plugin.rules ?? {})
12
12
  });
13
13
  }
14
- /**
15
- * Defines a single Oxlint rule with type-aware parser services.
16
- *
17
- * @example
18
- * ```ts
19
- * export default defineRule({
20
- * meta: { schema: [], messages: { demo: "demo" } },
21
- * create(context) {
22
- * const services = context.parserServices;
23
- * return {};
24
- * },
25
- * });
26
- * ```
27
- */
28
14
  function defineRule(rule) {
29
15
  return defineOxlintRule(decorateRule(rule));
30
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","names":[],"sources":["../ts/plugin.ts"],"sourcesContent":["import * as oxlintPluginApi from \"@oxlint/plugins\";\nimport type {\n Context as OxlintContext,\n Plugin as OxlintPlugin,\n Rule as OxlintRule,\n} from \"@oxlint/plugins\";\n\nimport { resolveTypeAwareParserOptions } from \"./context\";\nimport { getParserServices } from \"./parser_services\";\nimport type { ContextWithParserOptions, ParserServices } from \"./types\";\n\nexport type Plugin = Omit<OxlintPlugin, \"rules\"> & {\n readonly rules: Record<string, Rule>;\n} & Record<string, unknown>;\nexport type Rule = OxlintRule & Record<string, unknown>;\n\nconst defineOxlintPlugin = oxlintPluginApi.definePlugin;\nconst defineOxlintRule = oxlintPluginApi.defineRule;\nconst baseCompatPlugin = Reflect.get(\n oxlintPluginApi as object,\n [\"es\", \"lintCompatPlugin\"].join(\"\"),\n) as typeof oxlintPluginApi.definePlugin;\n\nexport function definePlugin(plugin: Plugin): Plugin {\n return defineOxlintPlugin({\n ...plugin,\n rules: wrapRules(plugin.rules ?? {}),\n } as OxlintPlugin) as Plugin;\n}\n\n/**\n * Defines a single Oxlint rule with type-aware parser services.\n *\n * @example\n * ```ts\n * export default defineRule({\n * meta: { schema: [], messages: { demo: \"demo\" } },\n * create(context) {\n * const services = context.parserServices;\n * return {};\n * },\n * });\n * ```\n */\nexport function defineRule(rule: Rule): Rule {\n return defineOxlintRule(decorateRule(rule) as OxlintRule) as Rule;\n}\n\nexport function compatPlugin(plugin: Plugin): Plugin {\n return baseCompatPlugin(definePlugin(plugin)) as Plugin;\n}\n\nexport function decorateRule(rule: Rule): Rule {\n if (rule.create) {\n return {\n ...rule,\n create(context) {\n return rule.create!(decorateContext(context, rule));\n },\n } as Rule;\n }\n if (\"createOnce\" in rule && typeof (rule as any).createOnce === \"function\") {\n return {\n ...rule,\n createOnce(context) {\n return (rule as any).createOnce(decorateContext(context, rule));\n },\n } as Rule;\n }\n return rule;\n}\n\nfunction wrapRules(rules: Record<string, Rule>): Record<string, Rule> {\n return Object.fromEntries(\n Object.entries(rules).map(([name, rule]) => [name, decorateRule(rule)]),\n );\n}\n\nfunction decorateContext(context: ContextWithParserOptions, rule: Rule): ContextWithParserOptions {\n const typeAware = requiresTypeChecking(rule);\n const parserOptions = Object.freeze(\n resolveTypeAwareParserOptions(context, {\n corsa: typeAware,\n projectService: typeAware,\n }),\n );\n const baseLanguageOptions = context.languageOptions;\n const languageOptions = Object.freeze({\n ...baseLanguageOptions,\n parserOptions,\n });\n return Object.create(context as OxlintContext, {\n languageOptions: {\n configurable: true,\n enumerable: true,\n get() {\n return languageOptions;\n },\n },\n parserOptions: {\n configurable: true,\n enumerable: false,\n get() {\n return parserOptions;\n },\n },\n parserServices: {\n configurable: true,\n enumerable: false,\n get(): ParserServices {\n return getParserServices(context);\n },\n },\n }) as ContextWithParserOptions;\n}\n\nfunction requiresTypeChecking(rule: Rule): boolean {\n return (\n (rule.meta as { readonly docs?: { readonly requiresTypeChecking?: unknown } } | undefined)?.docs\n ?.requiresTypeChecking === true\n );\n}\n"],"mappings":";;;;AAgBA,MAAM,qBAAqB,gBAAgB;AAC3C,MAAM,mBAAmB,gBAAgB;AACzC,MAAM,mBAAmB,QAAQ,IAC/B,iBACA,CAAC,MAAM,mBAAmB,CAAC,KAAK,GAAG,CACpC;AAED,SAAgB,aAAa,QAAwB;CACnD,OAAO,mBAAmB;EACxB,GAAG;EACH,OAAO,UAAU,OAAO,SAAS,EAAE,CAAC;EACrC,CAAiB;;;;;;;;;;;;;;;;AAiBpB,SAAgB,WAAW,MAAkB;CAC3C,OAAO,iBAAiB,aAAa,KAAK,CAAe;;AAG3D,SAAgB,aAAa,QAAwB;CACnD,OAAO,iBAAiB,aAAa,OAAO,CAAC;;AAG/C,SAAgB,aAAa,MAAkB;CAC7C,IAAI,KAAK,QACP,OAAO;EACL,GAAG;EACH,OAAO,SAAS;GACd,OAAO,KAAK,OAAQ,gBAAgB,SAAS,KAAK,CAAC;;EAEtD;CAEH,IAAI,gBAAgB,QAAQ,OAAQ,KAAa,eAAe,YAC9D,OAAO;EACL,GAAG;EACH,WAAW,SAAS;GAClB,OAAQ,KAAa,WAAW,gBAAgB,SAAS,KAAK,CAAC;;EAElE;CAEH,OAAO;;AAGT,SAAS,UAAU,OAAmD;CACpE,OAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,aAAa,KAAK,CAAC,CAAC,CACxE;;AAGH,SAAS,gBAAgB,SAAmC,MAAsC;CAChG,MAAM,YAAY,qBAAqB,KAAK;CAC5C,MAAM,gBAAgB,OAAO,OAC3B,8BAA8B,SAAS;EACrC,OAAO;EACP,gBAAgB;EACjB,CAAC,CACH;CACD,MAAM,sBAAsB,QAAQ;CACpC,MAAM,kBAAkB,OAAO,OAAO;EACpC,GAAG;EACH;EACD,CAAC;CACF,OAAO,OAAO,OAAO,SAA0B;EAC7C,iBAAiB;GACf,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,OAAO;;GAEV;EACD,eAAe;GACb,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,OAAO;;GAEV;EACD,gBAAgB;GACd,cAAc;GACd,YAAY;GACZ,MAAsB;IACpB,OAAO,kBAAkB,QAAQ;;GAEpC;EACF,CAAC;;AAGJ,SAAS,qBAAqB,MAAqB;CACjD,OACG,KAAK,MAAsF,MACxF,yBAAyB"}
1
+ {"version":3,"file":"plugin.js","names":[],"sources":["../ts/plugin.ts"],"sourcesContent":["import * as oxlintPluginApi from \"@oxlint/plugins\";\nimport type {\n Context as OxlintContext,\n Diagnostic,\n Plugin as OxlintPlugin,\n Rule as OxlintRule,\n RuleMeta,\n Visitor,\n VisitorWithHooks,\n} from \"@oxlint/plugins\";\n\nimport { resolveTypeAwareParserOptions } from \"./context\";\nimport { getParserServices } from \"./parser_services\";\nimport type { ContextWithParserOptions, ParserServices } from \"./types\";\n\nexport type Plugin = Omit<OxlintPlugin, \"rules\"> & {\n readonly rules: Record<string, Rule>;\n} & Record<string, unknown>;\nexport type Rule = OxlintRule & Record<string, unknown>;\nexport type RuleDiagnostic<MessageId extends string = string> = Diagnostic & {\n readonly messageId?: MessageId | null | undefined;\n};\nexport type RuleContext<\n MessageId extends string = string,\n Options extends readonly unknown[] = readonly unknown[],\n> = Omit<ContextWithParserOptions, \"options\" | \"report\"> & {\n readonly options: Readonly<Options>;\n report(this: void, diagnostic: RuleDiagnostic<MessageId>): void;\n};\nexport type RuleMetaWithMessages<MessageId extends string = string> = RuleMeta & {\n readonly messages?: Record<MessageId, string>;\n};\nexport type RuleDefinition<\n MessageId extends string = string,\n Options extends readonly unknown[] = readonly unknown[],\n> = Record<string, unknown> & {\n readonly defaultOptions?: Options;\n readonly meta?: RuleMetaWithMessages<MessageId>;\n} & (\n | {\n readonly create: (context: RuleContext<MessageId, Options>) => Visitor;\n readonly createOnce?: never;\n }\n | {\n readonly create?: (context: RuleContext<MessageId, Options>) => Visitor;\n readonly createOnce: (context: RuleContext<MessageId, Options>) => VisitorWithHooks;\n }\n );\n\nconst defineOxlintPlugin = oxlintPluginApi.definePlugin;\nconst defineOxlintRule = oxlintPluginApi.defineRule;\nconst baseCompatPlugin = Reflect.get(\n oxlintPluginApi as object,\n [\"es\", \"lintCompatPlugin\"].join(\"\"),\n) as typeof oxlintPluginApi.definePlugin;\n\nexport function definePlugin(plugin: Plugin): Plugin {\n return defineOxlintPlugin({\n ...plugin,\n rules: wrapRules(plugin.rules ?? {}),\n } as OxlintPlugin) as Plugin;\n}\n\n/**\n * Defines a single Oxlint rule with type-aware parser services.\n *\n * @example\n * ```ts\n * export default defineRule({\n * meta: { schema: [], messages: { demo: \"demo\" } },\n * create(context) {\n * const services = context.parserServices;\n * return {};\n * },\n * });\n * ```\n */\nexport function defineRule<\n MessageId extends string = string,\n const Options extends readonly unknown[] = readonly unknown[],\n>(rule: RuleDefinition<MessageId, Options>): Rule;\nexport function defineRule(rule: Rule): Rule {\n return defineOxlintRule(decorateRule(rule) as OxlintRule) as Rule;\n}\n\nexport function compatPlugin(plugin: Plugin): Plugin {\n return baseCompatPlugin(definePlugin(plugin)) as Plugin;\n}\n\nexport function decorateRule(rule: Rule): Rule {\n if (rule.create) {\n return {\n ...rule,\n create(context) {\n return rule.create!(decorateContext(context, rule));\n },\n } as Rule;\n }\n if (\"createOnce\" in rule && typeof (rule as any).createOnce === \"function\") {\n return {\n ...rule,\n createOnce(context) {\n return (rule as any).createOnce(decorateContext(context, rule));\n },\n } as Rule;\n }\n return rule;\n}\n\nfunction wrapRules(rules: Record<string, Rule>): Record<string, Rule> {\n return Object.fromEntries(\n Object.entries(rules).map(([name, rule]) => [name, decorateRule(rule)]),\n );\n}\n\nfunction decorateContext(context: ContextWithParserOptions, rule: Rule): ContextWithParserOptions {\n const typeAware = requiresTypeChecking(rule);\n const parserOptions = Object.freeze(\n resolveTypeAwareParserOptions(context, {\n corsa: typeAware,\n projectService: typeAware,\n }),\n );\n const baseLanguageOptions = context.languageOptions;\n const languageOptions = Object.freeze({\n ...baseLanguageOptions,\n parserOptions,\n });\n return Object.create(context as OxlintContext, {\n languageOptions: {\n configurable: true,\n enumerable: true,\n get() {\n return languageOptions;\n },\n },\n parserOptions: {\n configurable: true,\n enumerable: false,\n get() {\n return parserOptions;\n },\n },\n parserServices: {\n configurable: true,\n enumerable: false,\n get(): ParserServices {\n return getParserServices(context);\n },\n },\n }) as ContextWithParserOptions;\n}\n\nfunction requiresTypeChecking(rule: Rule): boolean {\n return (\n (rule.meta as { readonly docs?: { readonly requiresTypeChecking?: unknown } } | undefined)?.docs\n ?.requiresTypeChecking === true\n );\n}\n"],"mappings":";;;;AAiDA,MAAM,qBAAqB,gBAAgB;AAC3C,MAAM,mBAAmB,gBAAgB;AACzC,MAAM,mBAAmB,QAAQ,IAC/B,iBACA,CAAC,MAAM,mBAAmB,CAAC,KAAK,GAAG,CACpC;AAED,SAAgB,aAAa,QAAwB;CACnD,OAAO,mBAAmB;EACxB,GAAG;EACH,OAAO,UAAU,OAAO,SAAS,EAAE,CAAC;EACrC,CAAiB;;AAqBpB,SAAgB,WAAW,MAAkB;CAC3C,OAAO,iBAAiB,aAAa,KAAK,CAAe;;AAG3D,SAAgB,aAAa,QAAwB;CACnD,OAAO,iBAAiB,aAAa,OAAO,CAAC;;AAG/C,SAAgB,aAAa,MAAkB;CAC7C,IAAI,KAAK,QACP,OAAO;EACL,GAAG;EACH,OAAO,SAAS;GACd,OAAO,KAAK,OAAQ,gBAAgB,SAAS,KAAK,CAAC;;EAEtD;CAEH,IAAI,gBAAgB,QAAQ,OAAQ,KAAa,eAAe,YAC9D,OAAO;EACL,GAAG;EACH,WAAW,SAAS;GAClB,OAAQ,KAAa,WAAW,gBAAgB,SAAS,KAAK,CAAC;;EAElE;CAEH,OAAO;;AAGT,SAAS,UAAU,OAAmD;CACpE,OAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,aAAa,KAAK,CAAC,CAAC,CACxE;;AAGH,SAAS,gBAAgB,SAAmC,MAAsC;CAChG,MAAM,YAAY,qBAAqB,KAAK;CAC5C,MAAM,gBAAgB,OAAO,OAC3B,8BAA8B,SAAS;EACrC,OAAO;EACP,gBAAgB;EACjB,CAAC,CACH;CACD,MAAM,sBAAsB,QAAQ;CACpC,MAAM,kBAAkB,OAAO,OAAO;EACpC,GAAG;EACH;EACD,CAAC;CACF,OAAO,OAAO,OAAO,SAA0B;EAC7C,iBAAiB;GACf,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,OAAO;;GAEV;EACD,eAAe;GACb,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,OAAO;;GAEV;EACD,gBAAgB;GACd,cAAc;GACd,YAAY;GACZ,MAAsB;IACpB,OAAO,kBAAkB,QAAQ;;GAEpC;EACF,CAAC;;AAGJ,SAAS,qBAAqB,MAAqB;CACjD,OACG,KAAK,MAAsF,MACxF,yBAAyB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsa-oxlint",
3
- "version": "0.42.0",
3
+ "version": "0.43.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.42.0"
106
+ "@corsa-bind/napi": "0.43.0"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@typescript-eslint/utils": "8.59.3"