Skip to content

Commit d64f1b1

Browse files
devmgnclaude
andauthored
refactor(oxlint-rules): migrate custom rules to TypeScript with @oxlint/plugins (#2746)
* refactor(oxlint-rules): migrate custom rules to TypeScript with @oxlint/plugins Switches the four custom oxlint rules from `.mjs` with eslint-typed JSDoc to `.ts` with first-party `@oxlint/plugins` types, matching the official oxlint plugin authoring style and removing the eslint type dependency. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop unused eslint dependency and empty gitkeep `eslint` was only referenced by JSDoc type imports in the old `.mjs` custom rules; the TypeScript migration dropped those, so the package is no longer needed at runtime or for type-checking. The `scripts/` directory now contains `postinstall.sh`, so the placeholder file is also removed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * cleanup lockfile --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 358f42b commit d64f1b1

15 files changed

Lines changed: 191 additions & 195 deletions

knip.jsonc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"$schema": "./node_modules/knip/schema-jsonc.json",
3-
"ignore": ["src/**/openapi/**", "src/mocks/**", "tools/**"],
3+
"ignore": ["src/**/openapi/**", "src/mocks/**"],
44
"ignoreBinaries": ["openapiconfig.json", "actionlint", "zizmor"],
55
"ignoreDependencies": ["postcss", "postcss-load-config"],
6+
"ignoreIssues": {
7+
"tools/oxlint-rules/!(index).ts": ["files"],
8+
},
69
"tailwind": {
710
"entry": ["src/lib/styles/globals.css"],
811
},

lefthook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pre-commit:
1313
run: pnpm oxlint --fix {staged_files}
1414
stage_fixed: true
1515
- name: oxfmt
16+
glob: "*"
1617
run: pnpm oxfmt --write {staged_files}
1718
stage_fixed: true
1819
- name: test

oxlint.config.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default defineConfig({
2626
"vitest",
2727
],
2828
jsPlugins: [
29-
"./tools/oxlint-rules/index.mjs",
29+
"./tools/oxlint-rules/index.ts",
3030
"@tanstack/eslint-plugin-query",
3131
{ name: "react-compiler-rules", specifier: "eslint-plugin-react-hooks" },
3232
],
@@ -251,21 +251,6 @@ export default defineConfig({
251251
"typescript/no-unsafe-type-assertion": "off",
252252
},
253253
},
254-
{
255-
// Scripts — plain .mjs files lack TS type info, so no-unsafe-* rules produce false positives
256-
files: ["*.mjs"],
257-
rules: {
258-
"import/no-anonymous-default-export": "off",
259-
"import/no-default-export": "off",
260-
"typescript/no-redundant-type-constituents": "off",
261-
"typescript/no-unsafe-argument": "off",
262-
"typescript/no-unsafe-assignment": "off",
263-
"typescript/no-unsafe-call": "off",
264-
"typescript/no-unsafe-member-access": "off",
265-
"typescript/no-unsafe-return": "off",
266-
"typescript/strict-boolean-expressions": "off",
267-
},
268-
},
269254
{
270255
// Next.js special files + config files → allow default export, relax filename
271256
files: [
@@ -296,5 +281,12 @@ export default defineConfig({
296281
"import/no-default-export": "off",
297282
},
298283
},
284+
{
285+
// Custom oxlint rule plugin entries — default exports are required by the plugin loader
286+
files: ["tools/oxlint-rules/**/*.ts"],
287+
rules: {
288+
"import/no-default-export": "off",
289+
},
290+
},
299291
],
300292
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@babel/core": "7.29.0",
5151
"@faker-js/faker": "10.4.0",
5252
"@next/env": "16.2.4",
53+
"@oxlint/plugins": "1.62.0",
5354
"@rolldown/plugin-babel": "0.2.3",
5455
"@storybook/addon-a11y": "10.3.5",
5556
"@storybook/addon-docs": "10.3.5",
@@ -69,7 +70,6 @@
6970
"@vitest/coverage-v8": "4.1.5",
7071
"axe-core": "4.11.3",
7172
"babel-plugin-react-compiler": "1.0.0",
72-
"eslint": "10.2.1",
7373
"eslint-plugin-react-hooks": "7.1.1",
7474
"eslint-plugin-storybook": "10.3.5",
7575
"happy-dom": "20.9.0",

pnpm-lock.yaml

Lines changed: 54 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/.gitkeep

Whitespace-only changes.

tools/oxlint-rules/index.mjs

Lines changed: 0 additions & 15 deletions
This file was deleted.

tools/oxlint-rules/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { Plugin } from "@oxlint/plugins";
2+
import newlineAfterImport from "./newline-after-import.ts";
3+
import noIndexTsx from "./no-index-tsx.ts";
4+
import noTopLevelArrow from "./no-top-level-arrow.ts";
5+
import sortHookDeps from "./sort-hook-deps.ts";
6+
7+
const plugin: Plugin = {
8+
meta: { name: "custom-rules" },
9+
rules: {
10+
"newline-after-import": newlineAfterImport,
11+
"no-index-tsx": noIndexTsx,
12+
"no-top-level-arrow": noTopLevelArrow,
13+
"sort-hook-deps": sortHookDeps,
14+
},
15+
};
16+
17+
export default plugin;

0 commit comments

Comments
 (0)