iamturns / eslint-config-airbnb-typescript

Airbnb's ESLint config with TypeScript support
MIT License
1.05k stars 96 forks source link

Compatibility with new eslint config spec #307

Open jjangga0214 opened 2 years ago

jjangga0214 commented 2 years ago

Eslint announced a new config spec. https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new

스크린샷 2022-09-09 오후 10 07 49

According to eslint's official blog, though backward compatibility was taken care of, not all shareable configs continue to work with the new config system.

Are eslint-config-airbnb-typescript and eslint-config-airbnb-typescript/base compatible with the new config?

Thanks.

samuelneff commented 3 months ago

Two years later and the README doesn't have any references to flat config support.

samuelneff commented 3 months ago

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],
  }
);

From: https://stackoverflow.com/questions/78253188/flat-config-file-with-configs-from-legacy-eslintrc-compat-error

My setup based on this one works. 🙏

Kenneth-Sills commented 2 months ago

I'll make a PR to add this documentation. Thanks for bringing it up, @samuelneff!