corsa-oxlint 0.47.0 → 0.48.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
@@ -24,7 +24,8 @@ declare namespace ESTree {
24
24
  } ? Kind extends CandidateKind ? Candidate & {
25
25
  readonly type: Kind;
26
26
  } : never : never;
27
- type RemapNodeField<Value> = Value extends ESTree$1.BindingIdentifier ? BindingIdentifier : Value extends OxlintNode ? NodeByType<Extract<Value["type"], string>> : Value extends readonly (infer Item)[] ? readonly RemapNodeField<Item>[] : Value extends (infer Item)[] ? RemapNodeField<Item>[] : Value;
27
+ type RemapTuple<Value extends readonly unknown[]> = Value extends [] ? [] : Value extends [infer Head, ...infer Tail] ? [RemapNodeField<Head>, ...RemapTuple<Tail>] : Value extends readonly [infer Head, ...infer Tail] ? readonly [RemapNodeField<Head>, ...RemapTuple<Tail>] : never;
28
+ type RemapNodeField<Value> = Value extends ESTree$1.BindingIdentifier ? BindingIdentifier : Value extends readonly [unknown, ...unknown[]] ? RemapTuple<Value> : Value extends OxlintNode ? NodeByType<Extract<Value["type"], string>> : Value extends readonly (infer Item)[] ? readonly RemapNodeField<Item>[] : Value extends (infer Item)[] ? RemapNodeField<Item>[] : Value;
28
29
  type RemapNodeShape<Candidate> = Candidate extends object ? { [Key in keyof Candidate]: RemapNodeField<Candidate[Key]> } : Candidate;
29
30
  export type NodeByType<Kind extends string> = Kind extends string ? RemapNodeShape<NarrowNode<OxlintNode, Kind>> : never;
30
31
  export type Node = { [Kind in CorsaAstNodeType]: NodeByType<Kind> }[CorsaAstNodeType] | BindingIdentifier;
@@ -45,7 +45,6 @@ var RuleTester = class {
45
45
  }
46
46
  run(ruleName, rule, tests) {
47
47
  const workspace = createWorkspace();
48
- writeWorkspaceConfig(workspace);
49
48
  const transformed = {
50
49
  valid: tests.valid.map((test, index) => prepareTestCase(workspace, test, this.#config, "valid", index)),
51
50
  invalid: tests.invalid.map((test, index) => prepareTestCase(workspace, test, this.#config, "invalid", index))
@@ -62,7 +61,7 @@ function prepareTestCase(workspace, test, config, group, index) {
62
61
  const caseWorkspace = resolve(workspace, `${group}-${index}`);
63
62
  const normalized = typeof test === "string" ? { code: test } : test;
64
63
  const filename = resolveCaseFilename(caseWorkspace, normalized.filename, "case.ts");
65
- const projectRoot = isAbsolute(normalized.filename ?? "") ? dirname(filename) : workspace;
64
+ const projectRoot = isAbsolute(normalized.filename ?? "") ? dirname(filename) : caseWorkspace;
66
65
  writeFixture(filename, normalized.code, projectRoot);
67
66
  const testerConfig = config;
68
67
  const baseSettings = testerConfig?.settings?.corsaOxlint;
@@ -113,9 +112,6 @@ function optionalDefaultCorsaExecutable(rootDir) {
113
112
  return;
114
113
  }
115
114
  }
116
- function writeWorkspaceConfig(workspace) {
117
- writeProjectConfig(resolve(workspace, "tsconfig.json"));
118
- }
119
115
  function writeFixture(filename, code, projectRoot) {
120
116
  mkdirSync(dirname(filename), { recursive: true });
121
117
  writeFileSync(filename, code);
@@ -1 +1 @@
1
- {"version":3,"file":"rule_tester.js","names":["OxlintRuleTester","#inner","#config"],"sources":["../ts/rule_tester.ts"],"sourcesContent":["import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\nimport { RuleTester as OxlintRuleTester } from \"oxlint/plugins-dev\";\n\nimport { defaultCorsaExecutable, mergeTypeAwareParserOptions } from \"./context\";\nimport { decorateRule } from \"./plugin\";\nimport type { CorsaOxlintSettings, TypeAwareParserOptions } from \"./types\";\n\ntype TesterConfig = import(\"oxlint/plugins-dev\").RuleTester.Config;\ntype TestCase = import(\"oxlint/plugins-dev\").RuleTester.ValidTestCase &\n Partial<import(\"oxlint/plugins-dev\").RuleTester.InvalidTestCase>;\ntype TestCases = import(\"oxlint/plugins-dev\").RuleTester.TestCases;\nexport type RuleTesterConfig = TesterConfig & {\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n};\ntype TestLifecycleGlobal = typeof globalThis & {\n after?: (callback: () => void) => unknown;\n afterAll?: (callback: () => void) => unknown;\n};\n\nconst cleanupDirs = new Set<string>();\nlet cleanupInstalled = false;\n\nexport class RuleTester {\n /**\n * A thin Oxlint `RuleTester` wrapper that injects\n * `settings.corsaOxlint`\n * settings, temporary fixtures, and a default project service.\n *\n * @example\n * ```ts\n * const tester = new RuleTester();\n * tester.run(\"demo\", rule, {\n * valid: [{ code: \"const answer = 42;\" }],\n * invalid: [],\n * });\n * ```\n */\n static get describe() {\n return OxlintRuleTester.describe;\n }\n\n static set describe(value) {\n OxlintRuleTester.describe = value;\n }\n\n static get it() {\n return OxlintRuleTester.it;\n }\n\n static set it(value) {\n OxlintRuleTester.it = value;\n }\n\n static only(item: string | TestCase): TestCase {\n return OxlintRuleTester.only(item);\n }\n\n readonly #inner: OxlintRuleTester;\n readonly #config?: RuleTesterConfig;\n\n constructor(config?: RuleTesterConfig) {\n this.#config = config;\n this.#inner = new OxlintRuleTester(config);\n }\n\n run(ruleName: string, rule: Record<string, unknown>, tests: TestCases): void {\n const workspace = createWorkspace();\n writeWorkspaceConfig(workspace);\n const transformed = {\n valid: tests.valid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"valid\", index),\n ),\n invalid: tests.invalid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"invalid\", index),\n ),\n };\n this.#inner.run(ruleName, decorateRule(rule as never) as never, transformed as TestCases);\n }\n}\n\nfunction createWorkspace(): string {\n const root = process.env.CORSA_OXLINT_RULE_TESTER_TMPDIR ?? tmpdir();\n const workspace = mkdtempSync(join(root, \"corsa-oxlint-\"));\n registerCleanup(workspace);\n return workspace;\n}\n\nfunction prepareTestCase(\n workspace: string,\n test: string | TestCase,\n config: RuleTesterConfig | undefined,\n group: \"valid\" | \"invalid\",\n index: number,\n): TestCase {\n const caseWorkspace = resolve(workspace, `${group}-${index}`);\n const normalized = typeof test === \"string\" ? ({ code: test } as TestCase) : test;\n const filename = resolveCaseFilename(caseWorkspace, normalized.filename, \"case.ts\");\n const projectRoot = isAbsolute(normalized.filename ?? \"\") ? dirname(filename) : workspace;\n writeFixture(filename, normalized.code, projectRoot);\n const testerConfig = config;\n const baseSettings = testerConfig?.settings?.corsaOxlint;\n const caseSettings = (\n normalized.settings as {\n corsaOxlint?: CorsaOxlintSettings;\n }\n )?.corsaOxlint;\n const parserOptions = mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(baseSettings, baseSettings?.parserOptions),\n mergeTypeAwareParserOptions(caseSettings, caseSettings?.parserOptions),\n ),\n {\n tsconfigRootDir: projectRoot,\n projectService: {\n allowDefaultProject: [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n },\n },\n ),\n mergeTypeAwareParserOptions(\n config?.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n normalized.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n ),\n );\n const parserOptionsWithRuntime = applyRuleTesterRuntimeDefaults(\n parserOptions,\n normalized,\n config,\n );\n return {\n ...normalized,\n filename,\n settings: {\n ...testerConfig?.settings,\n ...normalized.settings,\n corsaOxlint: {\n ...testerConfig?.settings?.corsaOxlint,\n ...(normalized.settings as { corsaOxlint?: CorsaOxlintSettings })?.corsaOxlint,\n parserOptions: parserOptionsWithRuntime,\n },\n } as never,\n languageOptions: {\n ...config?.languageOptions,\n ...normalized.languageOptions,\n parserOptions: {\n ...parserOptionsWithRuntime,\n } as never,\n },\n };\n}\n\nfunction resolveCaseFilename(\n caseWorkspace: string,\n filename: string | undefined,\n fallback: string,\n): string {\n if (!filename) {\n return resolve(caseWorkspace, fallback);\n }\n return isAbsolute(filename) ? filename : resolve(caseWorkspace, filename);\n}\n\nfunction applyRuleTesterRuntimeDefaults(\n parserOptions: TypeAwareParserOptions,\n test: TestCase,\n config: RuleTesterConfig | undefined,\n): TypeAwareParserOptions {\n if (parserOptions.corsa?.executable !== undefined) {\n return parserOptions;\n }\n const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());\n const executable = process.env.CORSA_EXECUTABLE ?? optionalDefaultCorsaExecutable(rootDir);\n if (!executable) {\n return parserOptions;\n }\n return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable,\n },\n });\n}\n\nfunction optionalDefaultCorsaExecutable(rootDir: string): string | undefined {\n try {\n return defaultCorsaExecutable(rootDir);\n } catch {\n return undefined;\n }\n}\n\nfunction writeWorkspaceConfig(workspace: string): void {\n writeProjectConfig(resolve(workspace, \"tsconfig.json\"));\n}\n\nfunction writeFixture(filename: string, code: string, projectRoot: string): void {\n mkdirSync(dirname(filename), { recursive: true });\n writeFileSync(filename, code);\n writeProjectConfig(resolve(projectRoot, \"tsconfig.json\"));\n}\n\nfunction writeProjectConfig(configPath: string): void {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n include: [\"**/*\"],\n },\n null,\n 2,\n ),\n );\n}\n\nfunction registerCleanup(workspace: string): void {\n cleanupDirs.add(workspace);\n const afterAll = lifecycleCleanup();\n if (afterAll) {\n afterAll(() => cleanupWorkspace(workspace));\n }\n if (cleanupInstalled) {\n return;\n }\n cleanupInstalled = true;\n process.once(\"beforeExit\", cleanupAllWorkspaces);\n process.once(\"exit\", cleanupAllWorkspaces);\n}\n\nfunction lifecycleCleanup(): ((callback: () => void) => unknown) | undefined {\n const testGlobal = globalThis as TestLifecycleGlobal;\n return typeof testGlobal.afterAll === \"function\"\n ? testGlobal.afterAll\n : typeof testGlobal.after === \"function\"\n ? testGlobal.after\n : undefined;\n}\n\nfunction cleanupWorkspace(workspace: string): void {\n if (!cleanupDirs.delete(workspace)) {\n return;\n }\n rmSync(workspace, { force: true, recursive: true });\n}\n\nfunction cleanupAllWorkspaces(): void {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ACF;AACF;AAEA,SAAS,qBAAqB,WAAyB;CACrD,mBAAmB,QAAQ,WAAW,eAAe,CAAC;AACxD;AAEA,SAAS,aAAa,UAAkB,MAAc,aAA2B;CAC/E,UAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CAChD,cAAc,UAAU,IAAI;CAC5B,mBAAmB,QAAQ,aAAa,eAAe,CAAC;AAC1D;AAEA,SAAS,mBAAmB,YAA0B;CACpD,UAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAClD,cACE,YACA,KAAK,UACH;EACE,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,QAAQ;EACV;EACA,SAAS,CAAC,MAAM;CAClB,GACA,MACA,CACF,CACF;AACF;AAEA,SAAS,gBAAgB,WAAyB;CAChD,YAAY,IAAI,SAAS;CACzB,MAAM,WAAW,iBAAiB;CAClC,IAAI,UACF,eAAe,iBAAiB,SAAS,CAAC;CAE5C,IAAI,kBACF;CAEF,mBAAmB;CACnB,QAAQ,KAAK,cAAc,oBAAoB;CAC/C,QAAQ,KAAK,QAAQ,oBAAoB;AAC3C;AAEA,SAAS,mBAAoE;CAC3E,MAAM,aAAa;CACnB,OAAO,OAAO,WAAW,aAAa,aAClC,WAAW,WACX,OAAO,WAAW,UAAU,aAC1B,WAAW,QACX,KAAA;AACR;AAEA,SAAS,iBAAiB,WAAyB;CACjD,IAAI,CAAC,YAAY,OAAO,SAAS,GAC/B;CAEF,OAAO,WAAW;EAAE,OAAO;EAAM,WAAW;CAAK,CAAC;AACpD;AAEA,SAAS,uBAA6B;CACpC,KAAK,MAAM,OAAO,aAChB,iBAAiB,GAAG;AAExB"}
1
+ {"version":3,"file":"rule_tester.js","names":["OxlintRuleTester","#inner","#config"],"sources":["../ts/rule_tester.ts"],"sourcesContent":["import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\nimport { RuleTester as OxlintRuleTester } from \"oxlint/plugins-dev\";\n\nimport { defaultCorsaExecutable, mergeTypeAwareParserOptions } from \"./context\";\nimport { decorateRule } from \"./plugin\";\nimport type { CorsaOxlintSettings, TypeAwareParserOptions } from \"./types\";\n\ntype TesterConfig = import(\"oxlint/plugins-dev\").RuleTester.Config;\ntype TestCase = import(\"oxlint/plugins-dev\").RuleTester.ValidTestCase &\n Partial<import(\"oxlint/plugins-dev\").RuleTester.InvalidTestCase>;\ntype TestCases = import(\"oxlint/plugins-dev\").RuleTester.TestCases;\nexport type RuleTesterConfig = TesterConfig & {\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n};\ntype TestLifecycleGlobal = typeof globalThis & {\n after?: (callback: () => void) => unknown;\n afterAll?: (callback: () => void) => unknown;\n};\n\nconst cleanupDirs = new Set<string>();\nlet cleanupInstalled = false;\n\nexport class RuleTester {\n /**\n * A thin Oxlint `RuleTester` wrapper that injects\n * `settings.corsaOxlint`\n * settings, temporary fixtures, and a default project service.\n *\n * @example\n * ```ts\n * const tester = new RuleTester();\n * tester.run(\"demo\", rule, {\n * valid: [{ code: \"const answer = 42;\" }],\n * invalid: [],\n * });\n * ```\n */\n static get describe() {\n return OxlintRuleTester.describe;\n }\n\n static set describe(value) {\n OxlintRuleTester.describe = value;\n }\n\n static get it() {\n return OxlintRuleTester.it;\n }\n\n static set it(value) {\n OxlintRuleTester.it = value;\n }\n\n static only(item: string | TestCase): TestCase {\n return OxlintRuleTester.only(item);\n }\n\n readonly #inner: OxlintRuleTester;\n readonly #config?: RuleTesterConfig;\n\n constructor(config?: RuleTesterConfig) {\n this.#config = config;\n this.#inner = new OxlintRuleTester(config);\n }\n\n run(ruleName: string, rule: Record<string, unknown>, tests: TestCases): void {\n const workspace = createWorkspace();\n const transformed = {\n valid: tests.valid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"valid\", index),\n ),\n invalid: tests.invalid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"invalid\", index),\n ),\n };\n this.#inner.run(ruleName, decorateRule(rule as never) as never, transformed as TestCases);\n }\n}\n\nfunction createWorkspace(): string {\n const root = process.env.CORSA_OXLINT_RULE_TESTER_TMPDIR ?? tmpdir();\n const workspace = mkdtempSync(join(root, \"corsa-oxlint-\"));\n registerCleanup(workspace);\n return workspace;\n}\n\nfunction prepareTestCase(\n workspace: string,\n test: string | TestCase,\n config: RuleTesterConfig | undefined,\n group: \"valid\" | \"invalid\",\n index: number,\n): TestCase {\n const caseWorkspace = resolve(workspace, `${group}-${index}`);\n const normalized = typeof test === \"string\" ? ({ code: test } as TestCase) : test;\n const filename = resolveCaseFilename(caseWorkspace, normalized.filename, \"case.ts\");\n const projectRoot = isAbsolute(normalized.filename ?? \"\") ? dirname(filename) : caseWorkspace;\n writeFixture(filename, normalized.code, projectRoot);\n const testerConfig = config;\n const baseSettings = testerConfig?.settings?.corsaOxlint;\n const caseSettings = (\n normalized.settings as {\n corsaOxlint?: CorsaOxlintSettings;\n }\n )?.corsaOxlint;\n const parserOptions = mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(baseSettings, baseSettings?.parserOptions),\n mergeTypeAwareParserOptions(caseSettings, caseSettings?.parserOptions),\n ),\n {\n tsconfigRootDir: projectRoot,\n projectService: {\n allowDefaultProject: [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n },\n },\n ),\n mergeTypeAwareParserOptions(\n config?.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n normalized.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n ),\n );\n const parserOptionsWithRuntime = applyRuleTesterRuntimeDefaults(\n parserOptions,\n normalized,\n config,\n );\n return {\n ...normalized,\n filename,\n settings: {\n ...testerConfig?.settings,\n ...normalized.settings,\n corsaOxlint: {\n ...testerConfig?.settings?.corsaOxlint,\n ...(normalized.settings as { corsaOxlint?: CorsaOxlintSettings })?.corsaOxlint,\n parserOptions: parserOptionsWithRuntime,\n },\n } as never,\n languageOptions: {\n ...config?.languageOptions,\n ...normalized.languageOptions,\n parserOptions: {\n ...parserOptionsWithRuntime,\n } as never,\n },\n };\n}\n\nfunction resolveCaseFilename(\n caseWorkspace: string,\n filename: string | undefined,\n fallback: string,\n): string {\n if (!filename) {\n return resolve(caseWorkspace, fallback);\n }\n return isAbsolute(filename) ? filename : resolve(caseWorkspace, filename);\n}\n\nfunction applyRuleTesterRuntimeDefaults(\n parserOptions: TypeAwareParserOptions,\n test: TestCase,\n config: RuleTesterConfig | undefined,\n): TypeAwareParserOptions {\n if (parserOptions.corsa?.executable !== undefined) {\n return parserOptions;\n }\n const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());\n const executable = process.env.CORSA_EXECUTABLE ?? optionalDefaultCorsaExecutable(rootDir);\n if (!executable) {\n return parserOptions;\n }\n return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable,\n },\n });\n}\n\nfunction optionalDefaultCorsaExecutable(rootDir: string): string | undefined {\n try {\n return defaultCorsaExecutable(rootDir);\n } catch {\n return undefined;\n }\n}\n\nfunction writeFixture(filename: string, code: string, projectRoot: string): void {\n mkdirSync(dirname(filename), { recursive: true });\n writeFileSync(filename, code);\n writeProjectConfig(resolve(projectRoot, \"tsconfig.json\"));\n}\n\nfunction writeProjectConfig(configPath: string): void {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n include: [\"**/*\"],\n },\n null,\n 2,\n ),\n );\n}\n\nfunction registerCleanup(workspace: string): void {\n cleanupDirs.add(workspace);\n const afterAll = lifecycleCleanup();\n if (afterAll) {\n afterAll(() => cleanupWorkspace(workspace));\n }\n if (cleanupInstalled) {\n return;\n }\n cleanupInstalled = true;\n process.once(\"beforeExit\", cleanupAllWorkspaces);\n process.once(\"exit\", cleanupAllWorkspaces);\n}\n\nfunction lifecycleCleanup(): ((callback: () => void) => unknown) | undefined {\n const testGlobal = globalThis as TestLifecycleGlobal;\n return typeof testGlobal.afterAll === \"function\"\n ? testGlobal.afterAll\n : typeof testGlobal.after === \"function\"\n ? testGlobal.after\n : undefined;\n}\n\nfunction cleanupWorkspace(workspace: string): void {\n if (!cleanupDirs.delete(workspace)) {\n return;\n }\n rmSync(workspace, { force: true, recursive: true });\n}\n\nfunction cleanupAllWorkspaces(): void {\n for (const dir of cleanupDirs) {\n cleanupWorkspace(dir);\n }\n}\n"],"mappings":";;;;;;;AAyBA,MAAM,8BAAc,IAAI,IAAY;AACpC,IAAI,mBAAmB;AAEvB,IAAa,aAAb,MAAwB;;;;;;;;;;;;;;;CAetB,WAAW,WAAW;EACpB,OAAOA,aAAiB;CAC1B;CAEA,WAAW,SAAS,OAAO;EACzB,aAAiB,WAAW;CAC9B;CAEA,WAAW,KAAK;EACd,OAAOA,aAAiB;CAC1B;CAEA,WAAW,GAAG,OAAO;EACnB,aAAiB,KAAK;CACxB;CAEA,OAAO,KAAK,MAAmC;EAC7C,OAAOA,aAAiB,KAAK,IAAI;CACnC;CAEA;CACA;CAEA,YAAY,QAA2B;EACrC,KAAKE,UAAU;EACf,KAAKD,SAAS,IAAID,aAAiB,MAAM;CAC3C;CAEA,IAAI,UAAkB,MAA+B,OAAwB;EAC3E,MAAM,YAAY,gBAAgB;EAClC,MAAM,cAAc;GAClB,OAAO,MAAM,MAAM,KAAK,MAAM,UAC5B,gBAAgB,WAAW,MAAM,KAAKE,SAAS,SAAS,KAAK,CAC/D;GACA,SAAS,MAAM,QAAQ,KAAK,MAAM,UAChC,gBAAgB,WAAW,MAAM,KAAKA,SAAS,WAAW,KAAK,CACjE;EACF;EACA,KAAKD,OAAO,IAAI,UAAU,aAAa,IAAa,GAAY,WAAwB;CAC1F;AACF;AAEA,SAAS,kBAA0B;CAEjC,MAAM,YAAY,YAAY,KADjB,QAAQ,IAAI,mCAAmC,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B,GAAG;AAExB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsa-oxlint",
3
- "version": "0.47.0",
3
+ "version": "0.48.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": {
@@ -101,7 +101,7 @@
101
101
  "./package.json": "./package.json"
102
102
  },
103
103
  "dependencies": {
104
- "@corsa-bind/napi": "0.47.0"
104
+ "@corsa-bind/napi": "0.48.0"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@oxlint/plugins": "1.69.0",