Skip to content

Commit 5997559

Browse files
committed
chore: upgrade eslint to v9
1 parent b350556 commit 5997559

File tree

6 files changed

+383
-358
lines changed

6 files changed

+383
-358
lines changed

.eslintignore

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

.eslintrc.json

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

eslint.config.js

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
import js from '@eslint/js'
2+
import typescript from '@typescript-eslint/eslint-plugin'
3+
import typescriptParser from '@typescript-eslint/parser'
4+
import importPlugin from 'eslint-plugin-import'
5+
import prettier from 'eslint-plugin-prettier'
6+
import react from 'eslint-plugin-react'
7+
import reactHooks from 'eslint-plugin-react-hooks'
8+
import vitest from 'eslint-plugin-vitest'
9+
10+
export default [
11+
js.configs.recommended,
12+
{
13+
files: ['**/*.{js,jsx,ts,tsx}'],
14+
languageOptions: {
15+
parser: typescriptParser,
16+
parserOptions: {
17+
ecmaVersion: 2018,
18+
sourceType: 'module',
19+
ecmaFeatures: {
20+
jsx: true,
21+
},
22+
},
23+
globals: {
24+
// Browser globals
25+
window: 'readonly',
26+
document: 'readonly',
27+
console: 'readonly',
28+
fetch: 'readonly',
29+
URL: 'readonly',
30+
URLSearchParams: 'readonly',
31+
// Node.js globals
32+
process: 'readonly',
33+
Buffer: 'readonly',
34+
__dirname: 'readonly',
35+
__filename: 'readonly',
36+
global: 'readonly',
37+
// ES6 globals
38+
Promise: 'readonly',
39+
Symbol: 'readonly',
40+
Map: 'readonly',
41+
Set: 'readonly',
42+
WeakMap: 'readonly',
43+
WeakSet: 'readonly',
44+
},
45+
},
46+
plugins: {
47+
'@typescript-eslint': typescript,
48+
react,
49+
'react-hooks': reactHooks,
50+
import: importPlugin,
51+
prettier,
52+
vitest,
53+
},
54+
rules: {
55+
// ESLint recommended rules are included via js.configs.recommended
56+
57+
// Custom rules
58+
eqeqeq: 'error',
59+
'no-var': 'error',
60+
'prefer-const': 'error',
61+
curly: ['warn', 'multi-line', 'consistent'],
62+
'no-console': 'off',
63+
64+
// Import rules
65+
'import/no-unresolved': ['error', { commonjs: true, amd: true }],
66+
'import/export': 'error',
67+
'import/no-duplicates': ['error'],
68+
'import/order': [
69+
'error',
70+
{
71+
alphabetize: { order: 'asc', caseInsensitive: true },
72+
groups: [
73+
'builtin',
74+
'external',
75+
'internal',
76+
'parent',
77+
'sibling',
78+
'index',
79+
'object',
80+
],
81+
'newlines-between': 'never',
82+
pathGroups: [
83+
{
84+
pattern: 'react',
85+
group: 'builtin',
86+
position: 'before',
87+
},
88+
],
89+
pathGroupsExcludedImportTypes: ['builtin'],
90+
},
91+
],
92+
93+
// TypeScript rules
94+
'@typescript-eslint/explicit-module-boundary-types': 'off',
95+
'@typescript-eslint/no-unused-vars': [
96+
'warn',
97+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
98+
],
99+
'@typescript-eslint/no-use-before-define': 'off',
100+
'@typescript-eslint/no-empty-function': 'off',
101+
'@typescript-eslint/no-explicit-any': 'off',
102+
'@typescript-eslint/no-redeclare': 'off',
103+
'no-unused-vars': 'off', // Use TypeScript version instead
104+
'no-redeclare': 'off', // Use TypeScript version instead
105+
106+
// React rules
107+
'react/jsx-uses-react': 'off',
108+
'react/react-in-jsx-scope': 'off',
109+
110+
// React hooks rules
111+
'react-hooks/rules-of-hooks': 'error',
112+
'react-hooks/exhaustive-deps': 'warn',
113+
114+
// Vitest rules
115+
'vitest/consistent-test-it': [
116+
'error',
117+
{ fn: 'it', withinDescribe: 'it' },
118+
],
119+
120+
// Sort imports
121+
'sort-imports': [
122+
'error',
123+
{
124+
ignoreDeclarationSort: true,
125+
},
126+
],
127+
},
128+
settings: {
129+
react: {
130+
version: 'detect',
131+
},
132+
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
133+
'import/parsers': {
134+
'@typescript-eslint/parser': ['.js', '.jsx', '.ts', '.tsx'],
135+
},
136+
'import/resolver': {
137+
node: {
138+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
139+
paths: ['src'],
140+
},
141+
alias: {
142+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
143+
map: [['jotai-tanstack-query', './src/index.ts']],
144+
},
145+
},
146+
},
147+
},
148+
{
149+
files: ['src/**/*.{ts,tsx}'],
150+
languageOptions: {
151+
parserOptions: {
152+
project: './tsconfig.json',
153+
},
154+
},
155+
},
156+
{
157+
files: ['tests/**/*.tsx', '__tests__/**/*'],
158+
languageOptions: {
159+
globals: {
160+
describe: 'readonly',
161+
it: 'readonly',
162+
test: 'readonly',
163+
expect: 'readonly',
164+
beforeEach: 'readonly',
165+
afterEach: 'readonly',
166+
beforeAll: 'readonly',
167+
afterAll: 'readonly',
168+
vi: 'readonly',
169+
},
170+
},
171+
},
172+
{
173+
files: ['./*.js'],
174+
rules: {
175+
'@typescript-eslint/no-var-requires': 'off',
176+
},
177+
},
178+
{
179+
files: ['examples/**/*.{ts,tsx}'],
180+
rules: {
181+
'import/no-unresolved': 'off',
182+
},
183+
},
184+
{
185+
ignores: ['dist/**', 'src/vendor/**', 'node_modules/**'],
186+
},
187+
]

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
],
6464
"license": "MIT",
6565
"devDependencies": {
66+
"@eslint/js": "^9.32.0",
6667
"@tanstack/query-core": "^5.83.0",
6768
"@tanstack/react-query": "^5.83.0",
6869
"@testing-library/react": "^14.0.0",
@@ -74,16 +75,16 @@
7475
"@typescript-eslint/parser": "^8.38.0",
7576
"@vitest/ui": "^3.2.4",
7677
"bunchee": "^6.5.4",
77-
"eslint": "^8.48.0",
78-
"eslint-config-prettier": "^9.0.0",
78+
"eslint": "^9.32.0",
79+
"eslint-config-prettier": "^9.1.0",
7980
"eslint-import-resolver-alias": "^1.1.2",
80-
"eslint-plugin-import": "^2.28.1",
81-
"eslint-plugin-prettier": "^5.0.0",
82-
"eslint-plugin-react": "^7.33.2",
83-
"eslint-plugin-react-hooks": "^4.6.0",
81+
"eslint-plugin-import": "^2.31.0",
82+
"eslint-plugin-prettier": "^5.2.1",
83+
"eslint-plugin-react": "^7.37.5",
84+
"eslint-plugin-react-hooks": "^5.1.0",
8485
"eslint-plugin-vitest": "^0.5.4",
85-
"jsdom": "^25.0.1",
8686
"jotai": "^2.4.2",
87+
"jsdom": "^25.0.1",
8788
"npm-run-all": "^4.1.5",
8889
"prettier": "^3.0.3",
8990
"react": "^18.2.0",
@@ -95,8 +96,8 @@
9596
"peerDependencies": {
9697
"@tanstack/query-core": "*",
9798
"@tanstack/react-query": "*",
98-
"react": "^18.0.0 || ^19.0.0",
99-
"jotai": ">=2.0.0"
99+
"jotai": ">=2.0.0",
100+
"react": "^18.0.0 || ^19.0.0"
100101
},
101102
"peerDependenciesMeta": {
102103
"@tanstack/react-query": {

0 commit comments

Comments
 (0)