Skip to content

Commit 87ad107

Browse files
committed
feat: upgrade eslint to v9 in created projects
These changes include: - Adding the new required dependencies for eslint v9 (e.g. @eslint/eslintrc, @eslint/js, etc). - Include eslint's compat package to continue using @react-native/eslint-config with the new config format. - Move the inline eslint config (located in package.json) to the new flat file config format, in a separate file.
1 parent 09e8647 commit 87ad107

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

packages/create-react-native-library/templates/common/$package.json

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,22 @@
7777
},
7878
"devDependencies": {
7979
"@commitlint/config-conventional": "^19.6.0",
80+
"@eslint/compat": "^1.2.7",
81+
"@eslint/eslintrc": "^3.3.0",
82+
"@eslint/js": "^9.22.0",
8083
"@evilmartians/lefthook": "^1.5.0",
8184
<% if (example === 'vanilla' && (project.moduleConfig === 'turbo-modules' || project.viewConfig === 'fabric-view')) { -%>
8285
"@react-native-community/cli": "15.0.0-alpha.2",
8386
<% } -%>
84-
"@react-native/eslint-config": "^0.73.1",
87+
"@react-native/eslint-config": "^0.78.0",
8588
"@release-it/conventional-changelog": "^9.0.2",
8689
"@types/jest": "^29.5.5",
8790
"@types/react": "^18.2.44",
8891
"commitlint": "^19.6.1",
8992
"del-cli": "^5.1.0",
90-
"eslint": "^8.51.0",
91-
"eslint-config-prettier": "^9.0.0",
92-
"eslint-plugin-prettier": "^5.0.1",
93+
"eslint": "^9.22.0",
94+
"eslint-config-prettier": "^10.1.1",
95+
"eslint-plugin-prettier": "^5.2.3",
9396
"jest": "^29.7.0",
9497
<% if (project.moduleConfig === 'nitro-modules') { -%>
9598
"nitro-codegen": "^<%- versions.nitroCodegen %>",
@@ -156,30 +159,6 @@
156159
}
157160
}
158161
},
159-
"eslintConfig": {
160-
"root": true,
161-
"extends": [
162-
"@react-native",
163-
"prettier"
164-
],
165-
"rules": {
166-
"react/react-in-jsx-scope": "off",
167-
"prettier/prettier": [
168-
"error",
169-
{
170-
"quoteProps": "consistent",
171-
"singleQuote": true,
172-
"tabWidth": 2,
173-
"trailingComma": "es5",
174-
"useTabs": false
175-
}
176-
]
177-
}
178-
},
179-
"eslintIgnore": [
180-
"node_modules/",
181-
"lib/"
182-
],
183162
"prettier": {
184163
"quoteProps": "consistent",
185164
"singleQuote": true,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { fixupConfigRules } from '@eslint/compat';
2+
import { FlatCompat } from '@eslint/eslintrc';
3+
import js from '@eslint/js';
4+
import prettier from 'eslint-plugin-prettier';
5+
import { defineConfig } from 'eslint/config';
6+
import path from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = path.dirname(__filename);
11+
const compat = new FlatCompat({
12+
baseDirectory: __dirname,
13+
recommendedConfig: js.configs.recommended,
14+
allConfig: js.configs.all,
15+
});
16+
17+
export default defineConfig([
18+
{
19+
extends: fixupConfigRules(compat.extends('@react-native', 'prettier')),
20+
plugins: { prettier },
21+
rules: {
22+
'react/react-in-jsx-scope': 'off',
23+
'prettier/prettier': [
24+
'error',
25+
{
26+
quoteProps: 'consistent',
27+
singleQuote: true,
28+
tabWidth: 2,
29+
trailingComma: 'es5',
30+
useTabs: false,
31+
},
32+
],
33+
},
34+
},
35+
{
36+
ignores: [
37+
'node_modules/',
38+
'lib/'
39+
],
40+
},
41+
]);

0 commit comments

Comments
 (0)