Skip to content

Commit

Permalink
chore(eslint): migrate eslint configuration .eslintrc.js to eslint.co…
Browse files Browse the repository at this point in the history
…nfig.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.
  • Loading branch information
sukvvon authored Dec 21, 2024
1 parent 5c8d234 commit e1a6a0a
Show file tree
Hide file tree
Showing 7 changed files with 1,205 additions and 615 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

35 changes: 0 additions & 35 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
v20.9.0
36 changes: 36 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import globals from "globals";
import tseslint from "typescript-eslint";
import reactPlugin from "eslint-plugin-react";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

export default tseslint.config(
{
ignores: ["dist"],
},
reactPlugin.configs.flat.recommended,
tseslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.es2021,
},
parser: tseslint.parser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
},
plugins: {
react: reactPlugin,
"@typescript-eslint": tseslint.plugin,
},
rules: {
"react/no-did-update-set-state": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
eslintPluginPrettierRecommended
);
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,22 @@
"@types/jest": "^26.0.15",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"assert": "^2.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^9.0.0",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.2",
"globals": "^15.11.0",
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.4.3",
"prettier": "^3.0.1",
"react": "^18",
"react-dom": "^18",
"rimraf": "^6.0.1",
"ts-jest": "^29.0.5",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"typescript-eslint": "^8.18.0"
},
"peerDependencies": {
"react": ">=16.13.1"
Expand Down
Loading

0 comments on commit e1a6a0a

Please sign in to comment.