-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "Flat Config" (ESLint 9) #331
Comments
Are there any plans to add support for flat config to this project? |
Some more searching and I stumbled across the compatibility helpers that allow this project to be used with flat config. Example: import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from "eslint-config-prettier";
import { FlatCompat } from "@eslint/eslintrc";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname
});
export default tseslint.config(
eslint.configs.recommended,
...compat.extends("airbnb-base"),
...compat.extends("airbnb-typescript/base"),
...tseslint.configs.recommendedTypeChecked,
eslintConfigPrettier,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['**/*.{js,jsx,cjs,mjs}'],
extends: [tseslint.configs.disableTypeChecked],
}
); My setup based on this one works. 馃檹 |
I'm getting this error with the compat helpers. Oops! Something went wrong! :(
ESLint: 8.57.0
Error: Key "plugins": Cannot redefine plugin "@typescript-eslint". Relevant installs in package.json "@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^8.57.0",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"typescript-eslint": "^7.3.1", eslint.config.mjs import eslint from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import tsEslint from "typescript-eslint";
import { FlatCompat } from "@eslint/eslintrc";
import path from "path";
import { fileURLToPath } from "url";
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const compat = new FlatCompat({
baseDirectory: dirname
});
export default tsEslint.config(
eslint.configs.recommended,
...compat.extends("airbnb-base"),
...compat.extends("airbnb-typescript/base"),
...tsEslint.configs.recommendedTypeChecked,
// This disables the formatting rules in ESLint that Prettier is going to be responsible for handling.
// Make sure it's always the last config, so it gets the chance to override other configs.
eslintConfigPrettier,
{
ignores: ["dist", "distServer", "node_modules", "build"],
},
{
languageOptions: {
parserOptions: {
project : true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ["**/*.{js,jsx,cjs,mjs}"],
...tsEslint.configs.disableTypeChecked
},
); |
Hey, any news here? Like @RashiqAzhan I also can't make it work with |
My working config looks almost exactly like yours; just no Prettier. import { FlatCompat } from "@eslint/eslintrc";
import eslint from '@eslint/js';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import perfectionistConfig from 'eslint-plugin-perfectionist/configs/recommended-natural';
import regexpPlugin from 'eslint-plugin-regexp';
import simpleImportSort from "eslint-plugin-simple-import-sort";
import unicorn from 'eslint-plugin-unicorn';
import tseslint from 'typescript-eslint';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname
});
export default tseslint.config(
eslint.configs.recommended,
...compat.extends("airbnb"),
...compat.extends("airbnb-typescript"),
...tseslint.configs.recommendedTypeChecked,
perfectionistConfig,
regexpPlugin.configs['flat/recommended'],
{
plugins: {
'simple-import-sort': simpleImportSort,
unicorn,
},
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
},
rules: {
}
},
{
ignores: [
'src/client/vite-env.d.ts',
]
}
); "devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.4.0",
"@nabla/vite-plugin-eslint": "^2.0.4",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-plugin-perfectionist": "^2.10.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-unicorn": "^53.0.0",
"typescript": "^5.2.2",
"typescript-eslint": "^7.12.0",
} |
Following @samuelneff solution, I have this error: ESLint: 9.4.0 ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin". It's because with |
@tiavina-mika Look carefully at the instructions on the page you linked to. It's a little confusing. Note for others: This answer and the question it responds to are about This error:
Is because of the first commands: npm un @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm i typescript-eslint The first one uninstalls If you're getting that error, then there is still a reference to it in your In your import tseslint from 'typescript-eslint'; and your |
I' m getting this error using Oops! Something went wrong! :(
ESLint: 9.4.0
ConfigError: Config (unnamed): Key "plugins": Cannot redefine plugin "@typescript-eslint". |
@ento-io sounds like you're defining the plugin within your config and also including the recommended config which itself defines the plugin. Remove your plugin definition. |
馃憢 Coming over from eslint/eslint#18093: ESLint is migrating to a new "flat config" format that will be the default in ESLint v9.
It doesn't look like
eslint-config-airbnb-typescript
has support yet. I'm posting this issue here as a reference & cross-linking it to the table in eslint/eslint#18093. If there's anything technical blocking the extension from supporting flat configs, please let us know - we'd be happy to try to help! 馃挏Additional resources:
The text was updated successfully, but these errors were encountered: