Skip to content

Commit 08a9cdc

Browse files
azuclaude
andauthored
chore: migrate from eslint to oxlint (#1992)
## Summary Migrates the repository's linter from ESLint to oxlint for faster linting. Replaces `eslint.config.js` with `.oxlintrc.json` and updates related scripts and dependencies. ## Changes - Add `.oxlintrc.json` with the project's lint rules - Remove `eslint.config.js` - Update `package.json` scripts and dependencies to use oxlint - Drop the `minimatch` override - Fix lint violations surfaced by oxlint in a few source and test files - Update `pnpm-workspace.yaml` and `pnpm-lock.yaml` ## Breaking Changes None. ## Test Plan - [ ] `pnpm -r run lint` passes - [ ] `pnpm -r run test` passes - [ ] CI is green --------- Co-authored-by: Claude <[email protected]>
1 parent a8d178a commit 08a9cdc

12 files changed

Lines changed: 448 additions & 431 deletions

File tree

.oxlintrc.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": [
4+
"typescript"
5+
],
6+
"categories": {
7+
"correctness": "error"
8+
},
9+
"rules": {
10+
"no-console": "warn",
11+
"no-var": "error",
12+
"prefer-const": "error",
13+
"prefer-rest-params": "error",
14+
"prefer-spread": "error",
15+
"prefer-template": "error",
16+
"no-unused-vars": "off",
17+
"typescript/no-require-imports": "off",
18+
"typescript/no-explicit-any": "error",
19+
"typescript/no-empty-object-type": "error",
20+
"typescript/ban-ts-comment": "error",
21+
"typescript/no-unsafe-function-type": "error",
22+
"typescript/unbound-method": "off",
23+
"typescript/restrict-template-expressions": "off",
24+
"typescript/no-redundant-type-constituents": "off"
25+
},
26+
"overrides": [
27+
{
28+
"files": ["**/*.ts"],
29+
"rules": {
30+
"typescript/no-require-imports": "error"
31+
}
32+
},
33+
{
34+
"files": [
35+
"**/bin/**",
36+
"**/scripts/**",
37+
"examples/**",
38+
"**/debug-*.{js,mjs,ts}",
39+
"**/tools/**",
40+
"**/*.test.ts"
41+
],
42+
"rules": {
43+
"no-console": "off"
44+
}
45+
}
46+
],
47+
"ignorePatterns": [
48+
"**/lib/**",
49+
"**/module/**",
50+
"out/",
51+
"node_modules/**",
52+
"packages/textlint-scripts/examples/",
53+
"test/integration-test/",
54+
"website/",
55+
"dist/**",
56+
"build/**",
57+
"coverage/**",
58+
"*.min.js"
59+
],
60+
"env": {
61+
"browser": true,
62+
"node": true,
63+
"es2022": true,
64+
"mocha": true,
65+
"builtin": true
66+
}
67+
}

eslint.config.js

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

package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
"ci:versionup:patch": "lerna version patch --no-push --no-git-tag-version --yes && pnpm run commit-version",
1010
"clean": "pnpm -r run clean",
1111
"commit-version": "git add . && git commit -m \"chore(release): v`node -p 'require(\"./lerna.json\").version'`\"",
12-
"eslint": "eslint --cache \"packages/**/{src,test}/**/*.{js,ts}\"",
13-
"eslint:fix": "eslint --fix --cache \"packages/**/{src,test}/**/*.{js,ts}\"",
1412
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
15-
"lint": "npm-run-all eslint",
16-
"lint:fix": "npm-run-all eslint:fix",
13+
"lint": "oxlint --type-aware",
14+
"lint:fix": "oxlint --type-aware --fix",
1715
"perf": "cd ./examples/perf && pnpm run test:ci",
1816
"prepare": "git config --local core.hooksPath .githooks",
1917
"release": "lerna publish from-package",
@@ -42,19 +40,15 @@
4240
"trailingComma": "none"
4341
},
4442
"devDependencies": {
45-
"@eslint/js": "catalog:",
4643
"@lerna-lite/cli": "catalog:",
4744
"@lerna-lite/publish": "catalog:",
4845
"@lerna-lite/version": "catalog:",
4946
"@monorepo-utils/workspaces-to-typescript-project-references": "catalog:",
50-
"@typescript-eslint/eslint-plugin": "catalog:",
51-
"@typescript-eslint/parser": "catalog:",
5247
"ajv": "catalog:",
53-
"eslint": "catalog:",
54-
"eslint-config-prettier": "catalog:",
55-
"globals": "catalog:",
5648
"lint-staged": "catalog:",
5749
"npm-run-all2": "catalog:",
50+
"oxlint": "catalog:",
51+
"oxlint-tsgolint": "catalog:",
5852
"prettier": "catalog:",
5953
"typescript": "catalog:",
6054
"vitest": "catalog:"

packages/@textlint/fixer-formatter/test/formatters/compats.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import remainingFixture from "../fixtures/remaining.js";
1313
// Helper function to normalize paths to just filenames for cross-platform compatibility
1414
const normalizePaths = (output: string) => {
1515
// Replace any path ending with a filename and replace with just the filename
16-
return output.replace(/[^\s]*[\/\\]([^\/\\]+\.md)/g, "$1");
16+
return output.replace(/[^\s]*[/\\]([^/\\]+\.md)/g, "$1");
1717
};
1818

1919
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/@textlint/fixer-formatter/test/formatters/diff.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import remainingFixture from "../fixtures/remaining.js";
1414
// Helper function to normalize paths to just filenames for cross-platform compatibility
1515
const normalizePaths = (output: string) => {
1616
// Replace any path ending with a filename and replace with just the filename
17-
return output.replace(/[^\s]*[\/\\]([^\/\\]+\.md)/g, "$1");
17+
return output.replace(/[^\s]*[/\\]([^/\\]+\.md)/g, "$1");
1818
};
1919

2020
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/@textlint/kernel/src/core/source-location.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type SourceLocationPaddingIR =
3030

3131
const assertReportArgs = (reportArgs: Pick<TextlintRuleContextReportFunctionArgs, "node" | "ruleError" | "ruleId">) => {
3232
const { ruleError, ruleId } = reportArgs;
33-
const errorPrefix = `[${ruleId}]` || "";
33+
const errorPrefix = `[${ruleId}]`;
3434
const padding = ruleError;
3535

3636
/*

packages/@textlint/kernel/src/descriptor/TextlintPluginDescriptor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const getAvailableExtensions = (pluginProcessor: TextlintPluginProcessor): strin
2222
if (typeof PluginProcessorConstructor.availableExtensions === "function") {
2323
return PluginProcessorConstructor.availableExtensions();
2424
}
25-
throw new Error(`Plugin(${pluginProcessor}) should implement availableExtensions() method`);
25+
throw new Error(`Plugin(${pluginProcessor.constructor.name}) should implement availableExtensions() method`);
2626
};
2727

2828
/**
@@ -32,7 +32,6 @@ export class TextlintPluginDescriptor implements Descriptor<TextlintKernelPlugin
3232
public processor: TextlintPluginProcessor;
3333

3434
constructor(private plugin: TextlintKernelPlugin) {
35-
this.plugin = plugin;
3635
if (!this.plugin.plugin.Processor) {
3736
throw new Error(`Plugin should have Processor property.
3837
module.exports = {

packages/@textlint/kernel/src/task/promise-event-emitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ export class PromiseEventEmitter {
6666
}
6767

6868
emit(event: string, ...args: unknown[]): Promise<void[]> {
69-
const promises: (Promise<void> | void)[] = [];
69+
const promises: Promise<void>[] = [];
7070

7171
this.events.listeners(event).forEach((listener) => {
72-
promises.push(listener(...args));
72+
promises.push(Promise.resolve(listener(...args)));
7373
});
7474

7575
return Promise.all(promises);

packages/textlint/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const cli = {
9090

9191
const mcpServer = await connectStdioMcpServer(mcpOptions);
9292
process.on("SIGINT", () => {
93-
mcpServer.close();
93+
void mcpServer.close();
9494
process.exitCode = 0;
9595
});
9696
return 0;

packages/textlint/test/mcp-snapshot-test/snapshot-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function normalizeStructuredPaths(obj: unknown, snapshotDir: string, testCaseNam
141141
}
142142
} else if (normalizedPath.includes("snapshots")) {
143143
// Fallback: extract from path structure
144-
const parts = normalizedPath.split(/[\/\\]/);
144+
const parts = normalizedPath.split(/[/\\]/);
145145
const snapshotIndex = parts.findIndex((part) => part === "snapshots");
146146
if (snapshotIndex >= 0 && snapshotIndex < parts.length - 2) {
147147
const caseName = parts[snapshotIndex + 1];

0 commit comments

Comments
 (0)