How can ESLint be configured using the new "flat config" system (specifically with the eslint.config.js file) to work seamlessly with both @typescript-eslint/eslint-plugin and /parser?
I have been struggling to make ESLint's new configuration system play well with plugins, and conversely, I am unable to get plugins to function smoothly with flat config.
When it comes to linting TypeScript code with ESLint, incorporating the two essential plugins listed below is crucial. These plugins define rules that enable ESLint to effectively lint TypeScript code bases:
My current configuration file resembles the example provided below. However, please note that this is just my latest attempt as I have experimented with various approaches:
import eslintPlugin from '@typescript-eslint/eslint-plugin'
export default [
{
files: ["src/**/*.ts", "src/main.cts", "src/main.mts"],
ignores: ["**/*.d.*", "**/*.map.*", "**/*.js", "**/*.mjs", "**/*.cjs"],
plugins: { eslintPlugin },
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: "eslintPlugin/parser",
},
rules: {
semi: "error",
quotes: ["error", "single"],
indent: [
"error",
2,
{
SwitchCase: 1,
VariableDeclarator: "first",
ImportDeclaration: "first",
ArrayExpression: "first",
ObjectExpression: "first",
CallExpression: { arguments: "first" },
FunctionDeclaration: { body: 1, parameters: 4 },
FunctionExpression: { body: 1, parameters: 4 },
},
],
},
},
];
In addition, I utilize the TypeScript ESLint Language Service plugin. I prefer not to have any overlap in error reporting between TypeScript and ESLint; therefore, I do not use any ESLint extension. Instead, I have integrated a build system that conducts linting on my project as I work, and any errors identified by ESLint are presented through the TSC compiler.
However, the issue persists – I am still encountering difficulties getting the language service plugin to cooperate with flat config.