I’m trying to set up config eslint.
The problem is that ESLint complains about using parserOptions in the configuration, indicating that it is the eslintrc format, not the flat configuration format. I would like the configuration to work without errors and to comply with the new ESLint flat configuration format.
What should I change in the configuration file to make it compatible with the ESLint flat configuration format?
I get the following error:
ConfigError: Config (unnamed): Key "parserOptions": This appears to be in eslintrc format rather than flat config format.
ConfigError: Config (unnamed): Key "parserOptions": This appears to be in eslintrc format rather than flat config format.
at rethrowConfigError (C:\projects\front_3024\node_modules@eslint\config-array\dist\cjs\index.cjs:303:8)
at C:\projects\front_3024\node_modules@eslint\config-array\dist\cjs\index.cjs:1098:5
at Array.reduce (<anonymous>)
at FlatConfigArray.getConfigWithStatus (C:\projects\front_3024\node_modules@eslint\config-array\dist\cjs\index.cjs:1091:43)
at FlatConfigArray.getConfig (C:\projects\front_3024\node_modules@eslint\config-array\dist\cjs\index.cjs:1120:15)
at ESLint.calculateConfigForFile (C:\projects\front_3024\node_modules\eslint\lib\eslint\eslint.js:1187:24)
at async ESLint.isPathIgnored (C:\projects\front_3024\node_modules\eslint\lib\eslint\eslint.js:1209:24)
Process finished with exit code -1
Package.json|deps:
{
"@eslint/js": "^9.8.0",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.8.0",
"typescript": "^5.5.4",
"typescript-eslint": "^7.17.0",
}
eslint.config.mjs:
import globals from "globals";
import pluginJs from "@eslint/js";
import pluginReact from "eslint-plugin-react";
import pluginReactRefresh from "eslint-plugin-react-refresh";
import pluginReactHooks from "eslint-plugin-react-hooks";
import pluginPrettier from "eslint-plugin-prettier";
import tsEslint from "typescript-eslint";
import configPrettier from "eslint-config-prettier";
/**@type {import('eslint').Linter.FlatConfig}*/
export default tsEslint.config(
{
plugins: {
'@typescript-eslint': tsEslint.plugin,
react: pluginReact,
'react-hooks': pluginReactHooks,
'react-refresh': pluginReactRefresh,
prettier: pluginPrettier,
}
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.es2025
},
parserOptions: {
project: ['tsconfig.json']
}
},
parserOptions: {
}
},
pluginJs.configs.recommended,
...tsEslint.configs.recommended,
{
ignores: ['node_modules', 'dist', 'build', 'coverage', 'eslint.config.mjs'],
},
{
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"],
rules: {
...pluginPrettier.configs.recommended.rules,
...configPrettier.rules,
'prefer-const': 'error',
'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }],
'react/self-closing-comp': ['error', { component: true, html: true }],
'max-lines': ['warn', { max: 124 }],
'max-params': ['error', 2],
}
},
);
Daniyar Zhanakhmetov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.