Skip to content

Commit 5049074

Browse files
authored
Chore/migrate eslint flat config (#56)
1 parent 91cdbc2 commit 5049074

22 files changed

Lines changed: 3288 additions & 1704 deletions

.changeset/rare-radios-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"y-durableobjects": patch
3+
---
4+
5+
migrate eslint config to flatconfig

.eslintignore

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

.eslintrc.cjs

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

.github/workflows/check.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ concurrency:
77
group: ${{ github.workflow }}-${{ github.ref }}
88
cancel-in-progress: true
99

10+
env:
11+
NODE_VERSION: "22.14.0"
12+
PNPM_VERSION: "10.7.1"
13+
1014
jobs:
1115
type-check:
1216
runs-on: ubuntu-latest
@@ -15,12 +19,12 @@ jobs:
1519

1620
- uses: pnpm/action-setup@v3
1721
with:
18-
version: 8
22+
version: ${{ env.PNPM_VERSION }}
1923

2024
- name: Setup Node.js
2125
uses: actions/setup-node@v4
2226
with:
23-
node-version: "20.x"
27+
node-version: ${{ env.NODE_VERSION }}
2428
cache: "pnpm"
2529

2630
- name: Install dependencies
@@ -36,12 +40,12 @@ jobs:
3640

3741
- uses: pnpm/action-setup@v3
3842
with:
39-
version: 8
43+
version: ${{ env.PNPM_VERSION }}
4044

4145
- name: Setup Node.js
4246
uses: actions/setup-node@v4
4347
with:
44-
node-version: "20.x"
48+
node-version: ${{ env.NODE_VERSION }}
4549
cache: "pnpm"
4650

4751
- name: Install dependencies
@@ -57,12 +61,12 @@ jobs:
5761

5862
- uses: pnpm/action-setup@v3
5963
with:
60-
version: 8
64+
version: ${{ env.PNPM_VERSION }}
6165

6266
- name: Setup Node.js
6367
uses: actions/setup-node@v4
6468
with:
65-
node-version: "20.x"
69+
node-version: ${{ env.NODE_VERSION }}
6670
cache: "pnpm"
6771

6872
- name: Install dependencies
@@ -81,12 +85,12 @@ jobs:
8185

8286
- uses: pnpm/action-setup@v3
8387
with:
84-
version: 8
88+
version: ${{ env.PNPM_VERSION }}
8589

8690
- name: Setup Node.js
8791
uses: actions/setup-node@v4
8892
with:
89-
node-version: "20.x"
93+
node-version: ${{ env.NODE_VERSION }}
9094
cache: "pnpm"
9195

9296
- name: Install dependencies

.github/workflows/package-size.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ concurrency:
77
group: ${{ github.workflow }}-${{ github.ref }}
88
cancel-in-progress: true
99

10+
env:
11+
NODE_VERSION: "22.14.0"
12+
1013
jobs:
1114
pkg-size-report:
1215
name: Package Size Report
@@ -19,7 +22,7 @@ jobs:
1922
- name: Setup Node.js
2023
uses: actions/setup-node@v4
2124
with:
22-
node-version: "20.x"
25+
node-version: ${{ env.NODE_VERSION }}
2326

2427
- name: Package size report
2528
uses: pkg-size/action@v1

.github/workflows/pre-release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ concurrency:
66
group: ${{ github.workflow }}-${{ github.ref }}
77
cancel-in-progress: true
88

9+
env:
10+
NODE_VERSION: "22.14.0"
11+
912
jobs:
1013
pre-release:
1114
runs-on: ubuntu-latest
@@ -17,7 +20,7 @@ jobs:
1720
- run: corepack enable
1821
- uses: actions/setup-node@v4
1922
with:
20-
node-version: "20.x"
23+
node-version: ${{ env.NODE_VERSION }}
2124
cache: "pnpm"
2225

2326
- name: Install dependencies

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111

12+
env:
13+
NODE_VERSION: "22.14.0"
14+
PNPM_VERSION: "10.7.1"
15+
1216
jobs:
1317
release:
1418
name: Release
@@ -19,12 +23,12 @@ jobs:
1923

2024
- uses: pnpm/action-setup@v3
2125
with:
22-
version: 8
26+
version: ${{ env.PNPM_VERSION }}
2327

2428
- name: Setup Node.js
2529
uses: actions/setup-node@v4
2630
with:
27-
node-version: "20.x"
31+
node-version: ${{ env.NODE_VERSION }}
2832
cache: "pnpm"
2933

3034
- name: Install Dependencies

.mise.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[tools]
22
"npm:pnpm" = "9.4.0"
3-
node = "20.13.1"
3+
node = "22.14.0"
4+
pnpm = "10.7.1"

.npmrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dedupe-peer-dependents=true
2+
strict-peer-dependencies=false
3+
auto-install-peers=true
4+
resolve-peers-from-workspace-root=true
5+
shamefully-hoist=true

eslint.config.js

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
import { fixupConfigRules } from "@eslint/compat";
2+
import { FlatCompat } from "@eslint/eslintrc";
3+
import eslint from "@eslint/js";
4+
import vitestPlugin from "@vitest/eslint-plugin";
5+
import prettierConfig from "eslint-config-prettier";
6+
import importPlugin from "eslint-plugin-import-x";
7+
import unicornPlugin from "eslint-plugin-unicorn";
8+
import unusedImportsPlugin from "eslint-plugin-unused-imports";
9+
import globals from "globals";
10+
import tseslint from "typescript-eslint";
11+
12+
const compat = new FlatCompat();
13+
const standard = fixupConfigRules(compat.config({ extends: ["standard"] }));
14+
15+
/** @type {import("eslint").Linter.Config[]} */
16+
const config = [
17+
eslint.configs.recommended,
18+
...standard,
19+
{
20+
ignores: [
21+
"**/fixtures/**",
22+
"**/dist/**",
23+
"**/build/**",
24+
"**/node_modules/**",
25+
"worker-configuration.d.ts",
26+
".wrangler",
27+
"example/**",
28+
"*.config.js",
29+
],
30+
},
31+
{
32+
files: ["**/*.{js,ts,tsx}"],
33+
languageOptions: {
34+
ecmaVersion: 2024,
35+
sourceType: "module",
36+
parser: tseslint.parser,
37+
parserOptions: {
38+
project: true,
39+
},
40+
},
41+
rules: {
42+
"no-void": "off",
43+
"no-unreachable": "error",
44+
"no-restricted-imports": "off",
45+
"lines-between-class-members": "off",
46+
"no-array-constructor": "off",
47+
"no-console": "error",
48+
"newline-before-return": "error",
49+
"no-unused-vars": "off",
50+
camelcase: [
51+
"error",
52+
{
53+
ignoreImports: true,
54+
properties: "never",
55+
allow: [],
56+
},
57+
],
58+
},
59+
},
60+
{
61+
files: ["**/*.{js,ts,tsx}"],
62+
languageOptions: {
63+
ecmaVersion: 2024,
64+
sourceType: "module",
65+
parser: tseslint.parser,
66+
parserOptions: {
67+
project: true,
68+
},
69+
globals: {
70+
...globals.es2024,
71+
CloudflareEnv: "readonly",
72+
Queue: "readonly",
73+
ExecutionContext: "readonly",
74+
ExportedHandler: "readonly",
75+
DurableObjectNamespace: "readonly",
76+
WebSocket: "readonly",
77+
DurableObjectStub: "readonly",
78+
DurableObjectTransaction: "readonly",
79+
DurableObjectState: "readonly",
80+
WebSocketPair: "readonly",
81+
RequestInfo: "readonly",
82+
},
83+
},
84+
plugins: {
85+
"@typescript-eslint": tseslint.plugin,
86+
"import-x": importPlugin,
87+
"unused-imports": unusedImportsPlugin,
88+
unicorn: unicornPlugin,
89+
},
90+
rules: {
91+
...importPlugin.configs.recommended.rules,
92+
"@typescript-eslint/no-unused-vars": [
93+
"error",
94+
{
95+
argsIgnorePattern: "^_",
96+
varsIgnorePattern: "^_",
97+
caughtErrorsIgnorePattern: "^_",
98+
destructuredArrayIgnorePattern: "^_",
99+
},
100+
],
101+
"@typescript-eslint/no-use-before-define": "off",
102+
"@typescript-eslint/interface-name-prefix": "off",
103+
"@typescript-eslint/explicit-module-boundary-types": "off",
104+
"@typescript-eslint/no-explicit-any": "error",
105+
"@typescript-eslint/no-var-requires": "error",
106+
"@typescript-eslint/no-floating-promises": "error",
107+
"@typescript-eslint/no-array-constructor": "error",
108+
"@typescript-eslint/no-unnecessary-condition": "error",
109+
"@typescript-eslint/strict-boolean-expressions": "error",
110+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
111+
"@typescript-eslint/consistent-generic-constructors": [
112+
"error",
113+
"constructor",
114+
],
115+
"@typescript-eslint/array-type": ["error", { default: "array" }],
116+
"@typescript-eslint/consistent-type-exports": [
117+
"error",
118+
{
119+
fixMixedExportsWithInlineTypeSpecifier: false,
120+
},
121+
],
122+
"@typescript-eslint/consistent-type-imports": [
123+
"error",
124+
{
125+
prefer: "type-imports",
126+
},
127+
],
128+
"import-x/default": "off",
129+
"import-x/no-named-as-default-member": "off",
130+
"import-x/order": [
131+
"error",
132+
{
133+
groups: [
134+
"builtin",
135+
"external",
136+
"internal",
137+
"parent",
138+
"sibling",
139+
"index",
140+
"object",
141+
"type",
142+
],
143+
"newlines-between": "always",
144+
pathGroupsExcludedImportTypes: ["builtin"],
145+
alphabetize: { order: "asc", caseInsensitive: true },
146+
pathGroups: [
147+
{ pattern: "./types/**", group: "internal", position: "before" },
148+
],
149+
},
150+
],
151+
"import-x/no-unresolved": [
152+
"error",
153+
{
154+
ignore: ["^cloudflare:"],
155+
},
156+
],
157+
"unused-imports/no-unused-imports": "warn",
158+
"unicorn/prefer-node-protocol": "error",
159+
"unicorn/filename-case": ["error", { case: "kebabCase" }],
160+
"unicorn/better-regex": "error",
161+
},
162+
settings: {
163+
"import-x/resolver": {
164+
typescript: true,
165+
node: true,
166+
},
167+
"import-x/parsers": {
168+
"@typescript-eslint/parser": [".js", ".jsx", ".ts", ".tsx"],
169+
},
170+
},
171+
},
172+
{
173+
files: ["**/*.test.{ts,tsx}"],
174+
plugins: {
175+
vitest: vitestPlugin,
176+
},
177+
languageOptions: {
178+
globals: {
179+
...globals.vitest,
180+
},
181+
},
182+
rules: {
183+
...vitestPlugin.configs.recommended.rules,
184+
"@typescript-eslint/no-unused-vars": "off",
185+
"no-console": "off",
186+
"vitest/max-nested-describe": ["error", { max: 3 }],
187+
},
188+
},
189+
prettierConfig,
190+
];
191+
192+
export default config;

0 commit comments

Comments
 (0)