Skip to content

Commit e1a6a0a

Browse files
authored
chore(eslint): migrate eslint configuration .eslintrc.js to eslint.config.mjs (#205)
This pr converts the existing .eslintrc.js configuration file to the latest eslint format, eslint.config.mjs, and includes necessary updates to related libraries to support this change. a .nvmrc file specifying v20.9.0 has also been added to ensure compatibility with eslint’s minimum version requirements. the update ensures that the original eslint configuration is adapted to the flat config format while maintaining consistent functionality with typescript, react, and prettier plugins and recommended rules. **Why**: the main goal of this change is to adopt eslint’s latest configuration style, making maintenance easier and leveraging the flexibility of the flat config structure. this approach is expected to bring several benefits: * adoption of the latest module standard: the flat config format uses the latest ecmascript module (esm) standard, allowing for more flexible application of javascript features in configuration. * improved maintainability and extensibility: by updating plugins, we are now using versions optimized for flat config. this transition also prepares us to more easily adapt to future eslint version updates. * node version compatibility: a .nvmrc file specifying v20.9.0 has been added to ensure compatibility with [eslint’s minimum version requirements, as the latest eslint requires node.js version 18.18.0, 20.9.0, or 21.1.0 and above](https://eslint.org/docs/latest/use/getting-started#prerequisites). this change helps ensure that all environments using this repository align with the required node version. **How**: * configuration migration: all configurations from .eslintrc.js were transferred to eslint.config.mjs and adapted to the flat config format, ensuring functional parity with the previous setup. * library updates: major eslint-related plugins (typescript, react, prettier) were updated to their latest versions, supporting the new configuration style. * node version specification: a .nvmrc file was added with v20.9.0 to meet eslint’s minimum node version requirements, ensuring compatibility across environments. * environment and global variable consistency: the environment variables and global options (browser, es2021, node) from the previous configuration were applied consistently in the flat config, ensuring that the setup performs identically to the former .eslintrc.js configuration. this transition modularizes the eslint configuration with the latest standards, improving maintainability and allowing for greater flexibility in accommodating future eslint and plugin updates.
1 parent 5c8d234 commit e1a6a0a

File tree

7 files changed

+1205
-615
lines changed

7 files changed

+1205
-615
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

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

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
v20.9.0

eslint.config.mjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import globals from "globals";
2+
import tseslint from "typescript-eslint";
3+
import reactPlugin from "eslint-plugin-react";
4+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
5+
6+
export default tseslint.config(
7+
{
8+
ignores: ["dist"],
9+
},
10+
reactPlugin.configs.flat.recommended,
11+
tseslint.configs.recommended,
12+
{
13+
languageOptions: {
14+
globals: {
15+
...globals.browser,
16+
...globals.es2021,
17+
},
18+
parser: tseslint.parser,
19+
parserOptions: {
20+
ecmaVersion: "latest",
21+
sourceType: "module",
22+
},
23+
},
24+
plugins: {
25+
react: reactPlugin,
26+
"@typescript-eslint": tseslint.plugin,
27+
},
28+
rules: {
29+
"react/no-did-update-set-state": "off",
30+
"react/react-in-jsx-scope": "off",
31+
"react/prop-types": "off",
32+
"@typescript-eslint/no-explicit-any": "off",
33+
},
34+
},
35+
eslintPluginPrettierRecommended
36+
);

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,22 @@
6262
"@types/jest": "^26.0.15",
6363
"@types/react": "^18",
6464
"@types/react-dom": "^18",
65-
"@typescript-eslint/eslint-plugin": "^5.52.0",
6665
"assert": "^2.0.0",
67-
"eslint": "^8.0.1",
68-
"eslint-config-prettier": "^9.0.0",
66+
"eslint": "^9.13.0",
67+
"eslint-config-prettier": "^9.1.0",
6968
"eslint-plugin-import": "^2.25.2",
70-
"eslint-plugin-prettier": "^5.0.0",
71-
"eslint-plugin-react": "^7.33.1",
69+
"eslint-plugin-prettier": "^5.2.1",
70+
"eslint-plugin-react": "^7.37.2",
71+
"globals": "^15.11.0",
7272
"jest": "^29.4.3",
7373
"jest-environment-jsdom": "^29.4.3",
7474
"prettier": "^3.0.1",
7575
"react": "^18",
7676
"react-dom": "^18",
7777
"rimraf": "^6.0.1",
7878
"ts-jest": "^29.0.5",
79-
"typescript": "^5.1.6"
79+
"typescript": "^5.1.6",
80+
"typescript-eslint": "^8.18.0"
8081
},
8182
"peerDependencies": {
8283
"react": ">=16.13.1"

0 commit comments

Comments
 (0)