Skip to content

Commit aa26784

Browse files
authored
Convert from ESLint to oxlint, Prettier to oxfmt (#12930)
1 parent 7c3c6c6 commit aa26784

File tree

441 files changed

+4530
-6708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

441 files changed

+4530
-6708
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,4 @@ dist/**
236236

237237
AGENTS.local.md
238238
.opencode/plans/
239+
.agents/skills

.oxfmtrc.jsonc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"printWidth": 80,
3+
"singleQuote": false,
4+
"semi": true,
5+
"useTabs": true,
6+
"trailingComma": "es5",
7+
"sortImports": {
8+
"groups": ["builtin", "external", "parent", "sibling", "index", "type"],
9+
"newlinesBetween": false,
10+
},
11+
"sortTailwindcss": {},
12+
"sortPackageJson": {},
13+
"overrides": [
14+
{
15+
"files": ["packages/vite-plugin-cloudflare/README.md"],
16+
"options": {
17+
"useTabs": false,
18+
"trailingComma": "all",
19+
},
20+
},
21+
{
22+
"files": [".changeset/*.md"],
23+
"options": {
24+
"proseWrap": "never",
25+
},
26+
},
27+
{
28+
"files": ["packages/local-explorer-ui/**/*.{js,jsx,ts,tsx}"],
29+
"options": {
30+
"sortTailwindcss": {
31+
"stylesheet": "./packages/local-explorer-ui/src/styles/tailwind.css",
32+
"functions": ["cn"],
33+
},
34+
},
35+
},
36+
],
37+
"ignorePatterns": [
38+
"CHANGELOG.md",
39+
// In the C3 templates, in particular framework templates, we want to be able to
40+
// use any format that the framework authors prefer/use in their own templates,
41+
// so let's ignore all the c3 template files, exlcuding the c3.ts ones, and tests
42+
"packages/create-cloudflare/templates*/**/*.*",
43+
"!packages/create-cloudflare/templates*/**/c3.ts",
44+
"!packages/create-cloudflare/templates*/**/test/**/*.ts",
45+
"!packages/create-cloudflare/templates*/**/test/**/*.js",
46+
// Format the hello-world template (negate previous exclusion above) for best practices, since we control these
47+
// but still exclude the worker-configuration.d.ts file, since it's generated
48+
"!packages/create-cloudflare/templates*/hello-world/**/*.*",
49+
"packages/create-cloudflare/templates*/hello-world/**/worker-configuration.d.ts",
50+
51+
"packages/vitest-pool-workers/scripts/rtti/rtti.js",
52+
"packages/vite-plugin-cloudflare/playground/prisma/src/generated",
53+
"dist-functions",
54+
"vscode.d.ts",
55+
"vscode.*.d.ts",
56+
".e2e-logs*",
57+
".github/pull_request_template.md",
58+
"fixtures/interactive-dev-tests/src/startup-error.ts",
59+
"packages/vite-plugin-cloudflare/playground/**/*.d.ts",
60+
"packages/local-explorer-ui/src/routeTree.gen.ts",
61+
"packages/local-explorer-ui/src/api/generated",
62+
],
63+
}

.oxlintrc.jsonc

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "import", "unicorn", "vitest", "react"],
4+
"categories": {
5+
"correctness": "error",
6+
},
7+
"rules": {
8+
"@typescript-eslint/await-thenable": "off",
9+
"@typescript-eslint/no-base-to-string": "off",
10+
"@typescript-eslint/no-duplicate-type-constituents": "off",
11+
"@typescript-eslint/no-for-in-array": "off",
12+
"@typescript-eslint/no-misused-spread": "off",
13+
"@typescript-eslint/no-redundant-type-constituents": "off",
14+
"@typescript-eslint/restrict-template-expressions": "off",
15+
"@typescript-eslint/unbound-method": "off",
16+
"no-meaningless-void-operator": "off",
17+
"require-array-sort-compare": "off",
18+
"unicorn/no-new-array": "off",
19+
"unicorn/no-thenable": "off",
20+
"unicorn/no-useless-fallback-in-spread": "off",
21+
"unicorn/no-useless-spread": "off",
22+
"vitest/hoisted-apis-on-top": "off",
23+
"vitest/warn-todo": "off",
24+
"vitest/no-conditional-tests": "off",
25+
"no-case-declarations": "error",
26+
"no-fallthrough": "error",
27+
"no-prototype-builtins": "error",
28+
"no-array-constructor": "error",
29+
"@typescript-eslint/ban-ts-comment": "error",
30+
"@typescript-eslint/no-unsafe-function-type": "error",
31+
"curly": ["error", "all"],
32+
"prefer-const": "error",
33+
"prefer-rest-params": "error",
34+
"prefer-spread": "error",
35+
"@typescript-eslint/consistent-type-imports": ["error"],
36+
"no-var": "error",
37+
"no-regex-spaces": "error",
38+
"@typescript-eslint/no-empty-object-type": "error",
39+
"@typescript-eslint/no-explicit-any": "error",
40+
"@typescript-eslint/no-namespace": "error",
41+
"@typescript-eslint/no-require-imports": "error",
42+
"no-shadow": ["error", { "allow": ["expect"] }],
43+
"no-unexpected-multiline": "error",
44+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
45+
"unicorn/prefer-node-protocol": "error",
46+
"vitest/no-focused-tests": "error",
47+
"@typescript-eslint/no-non-null-assertion": "error",
48+
"turbo/no-undeclared-env-vars": "error",
49+
"workers-sdk/no-unsafe-command-execution": "error",
50+
"workers-sdk/no-direct-recursive-rm": "error",
51+
52+
"no-unused-vars": [
53+
"error",
54+
{
55+
"argsIgnorePattern": ".*",
56+
"varsIgnorePattern": "^_",
57+
"ignoreRestSiblings": true,
58+
"fix": { "imports": "fix" },
59+
},
60+
],
61+
"no-restricted-imports": [
62+
"error",
63+
{
64+
"paths": [
65+
{
66+
"name": "ci-info",
67+
"importNames": [
68+
"isCI",
69+
"CLOUDFLARE_PAGES",
70+
"CLOUDFLARE_WORKERS",
71+
"isPR",
72+
"name",
73+
],
74+
"message": "Use default import (`import ci from \"ci-info\"`) and access properties via `ci.isCI`, `ci.CLOUDFLARE_PAGES`, etc. Named imports cannot be controlled in test mocks.",
75+
},
76+
{
77+
"name": "vitest",
78+
"importNames": ["expect"],
79+
"message": "Import 'expect' from the test context instead of 'vitest' for concurrency safety. Use: test('name', ({ expect }) => { ... })",
80+
},
81+
],
82+
},
83+
],
84+
},
85+
"ignorePatterns": [
86+
"**/*.js",
87+
"**/*.cjs",
88+
"**/*.mjs",
89+
"fixtures/**",
90+
"packages/create-cloudflare/**/templates/**/*.*",
91+
"!packages/create-cloudflare/**/templates*/**/c3.ts",
92+
// TODO: we really should be linting this folder
93+
"packages/wrangler/templates/**",
94+
// Ignore generated files
95+
"packages/containers-shared/src/client/**",
96+
"packages/local-explorer-ui/src/api/generated/**",
97+
"packages/local-explorer-ui/src/routeTree.gen.ts",
98+
"packages/miniflare/src/runtime/config/workerd.*",
99+
"packages/quick-edit-extension/vscode.d.ts",
100+
"packages/quick-edit-extension/vscode.proposed.*.d.ts",
101+
],
102+
"jsPlugins": [
103+
"eslint-plugin-turbo",
104+
{
105+
"name": "workers-sdk",
106+
"specifier": "./packages/lint-config-shared/oxlint-plugin.mjs",
107+
},
108+
],
109+
"overrides": [
110+
// Published packages which all have their own "logger" class that should be used instead.
111+
{
112+
"files": [
113+
"packages/cli/**",
114+
"packages/create-cloudflare/**",
115+
"packages/miniflare/**",
116+
"packages/wrangler/**",
117+
"packages/workers-utils/**",
118+
],
119+
"rules": {
120+
"no-console": "error",
121+
},
122+
},
123+
// TODO: remove these overrides. This is a legacy of Miniflare's history, not intentional
124+
{
125+
"files": ["packages/miniflare/**"],
126+
"rules": {
127+
"curly": "off",
128+
"@typescript-eslint/no-explicit-any": "off",
129+
"@typescript-eslint/ban-ts-comment": "off",
130+
"@typescript-eslint/consistent-type-imports": "off",
131+
"@typescript-eslint/no-floating-promises": "off",
132+
"no-shadow": "off",
133+
"no-useless-escape": "off",
134+
"no-unsafe-optional-chaining": "off",
135+
"no-control-regex": "off",
136+
"no-case-declarations": "off",
137+
"no-empty-pattern": "off",
138+
"turbo/no-undeclared-env-vars": "off",
139+
},
140+
},
141+
{
142+
"files": ["packages/wrangler/src/**", "packages/workers-utils/src/**"],
143+
"rules": {
144+
"no-restricted-globals": [
145+
"error",
146+
{
147+
"name": "__dirname",
148+
"message": "Use `getBasePath()` instead.",
149+
},
150+
{
151+
"name": "__filename",
152+
"message": "Use `getBasePath()` instead.",
153+
},
154+
{
155+
"name": "fetch",
156+
"message": "Use undici's fetch instead",
157+
},
158+
],
159+
},
160+
},
161+
// Although in _general_ Miniflare shouldn't use console.log(), it's Workers can and should
162+
{
163+
"files": ["packages/miniflare/src/workers/**/*.ts"],
164+
"rules": {
165+
"no-console": "off",
166+
},
167+
},
168+
// Relax some rules for test & script files
169+
{
170+
"files": [
171+
"packages/wrangler/src/__tests__/**",
172+
"packages/wrangler/e2e/**",
173+
"packages/wrangler/scripts/**",
174+
"packages/miniflare/scripts/**",
175+
"packages/cli/src/__tests__/**",
176+
"packages/create-cloudflare/scripts/**",
177+
"packages/create-cloudflare/src/__tests__/**",
178+
"packages/workers-utils/tests/**",
179+
"packages/vite-plugin-cloudflare/e2e/**",
180+
],
181+
"rules": {
182+
"no-console": "off",
183+
"no-restricted-globals": "off",
184+
"workers-sdk/no-unsafe-command-execution": "off",
185+
},
186+
},
187+
// Make sure Wrangler's version checking logic in vite-plugin-cloudflare can run properly
188+
{
189+
"files": ["packages/vite-plugin-cloudflare/**"],
190+
"rules": {
191+
"workers-sdk/no-wrangler-named-imports": "error",
192+
},
193+
},
194+
],
195+
}

.prettierignore

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

.prettierrc

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

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
2+
"recommendations": ["oxc.oxc-vscode"]
33
}

0 commit comments

Comments
 (0)