diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index e9c55eec0..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,24 +0,0 @@ -module.exports = { - // parser: '@typescript-eslint/parser', // Specifies the ESLint parser - parserOptions: { - ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features - sourceType: 'module', // Allows for the use of imports - ecmaFeatures: { - jsx: true, // Allows for the parsing of JSX - }, - }, - settings: { - react: { - version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use - }, - }, - extends: [ - 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react - 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. - ], - plugins: ['react', 'react-hooks'], - rules: { - // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs - // e.g. "@typescript-eslint/explicit-function-return-type": "off", - }, -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..b0b00425a --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,39 @@ +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' +import eslintPluginReact from 'eslint-plugin-react' +import eslintPluginReactHooks from 'eslint-plugin-react-hooks' +import globals from 'globals' + +export default [ + { ignores: ['eslint.config.mjs'] }, + { + ...eslintPluginReact.configs.flat.recommended, + ...eslintPluginReact.configs.flat['jsx-runtime'], + files: ['src/**/*.{js,jsx}'], + plugins: { + eslintPluginReact, + 'react-hooks': eslintPluginReactHooks, + }, + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + ecmaVersion: 'latest', + sourceType: 'module', + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + }, + settings: { + react: { + version: 'detect', + }, + }, + rules: { + ...eslintPluginReactHooks.configs.recommended.rules, + }, + }, + eslintPluginPrettierRecommended, +] diff --git a/package.json b/package.json index 62e311371..6dba81284 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "author": "The CoreUI Team (https://github.com/orgs/coreui/people)", "scripts": { "build": "vite build", - "lint": "eslint \"src/**/*.js\"", + "lint": "eslint", "serve": "vite preview", "start": "vite" }, @@ -41,11 +41,12 @@ "devDependencies": { "@vitejs/plugin-react": "^4.3.3", "autoprefixer": "^10.4.20", - "eslint": "^8.57.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.2.1", - "eslint-plugin-react": "^7.37.2", - "eslint-plugin-react-hooks": "^4.6.2", + "eslint": "^9.19.0", + "eslint-config-prettier": "^10.0.1", + "eslint-plugin-prettier": "^5.2.3", + "eslint-plugin-react": "^7.37.4", + "eslint-plugin-react-hooks": "^5.1.0", + "globals": "^15.14.0", "postcss": "^8.4.49", "prettier": "3.3.3", "sass": "^1.81.0",