Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add flat config support #122

Merged
merged 2 commits into from
Aug 26, 2024

Commits on Aug 18, 2024

  1. feat: add flat config support

    This change adds support for ESLint's new Flat config system.  It maintains backwards compatibility with eslintrc style configs as well.
    
    To achieve this, we're now dynamically creating flat configs on a new `flatConfigs` export.  I was a bit on the fence about using this convention, or the other convention that's become prevalent in the community: adding the flat configs directly to the `configs` object, but with a 'flat/' prefix.  I like this better, since it's slightly more ergonomic when using it in practice.  e.g. `...importX.flatConfigs.recommended` vs `...importX.configs['flat/recommended']`, but i'm open to changing that.
    
    Example Usage
    
    ```js
    import importPlugin from 'eslint-plugin-import';
    import js from '@eslint/js';
    import tsParser from '@typescript-eslint/parser';
    
    export default [
      js.configs.recommended,
      importPlugin.flatConfigs.recommended,
      importPlugin.flatConfigs.react,
      importPlugin.flatConfigs.typescript,
      {
        files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
        languageOptions: {
          parser: tsParser,
          ecmaVersion: 'latest',
          sourceType: 'module',
        },
        ignores: ['eslint.config.js'],
        rules: {
          'no-unused-vars': 'off',
          'import/no-dynamic-require': 'warn',
          'import/no-nodejs-modules': 'warn',
        },
      },
    ];
    ```
    
    Closes import-js#29
    michaelfaith committed Aug 18, 2024
    Configuration menu
    Copy the full SHA
    cb36e4b View commit details
    Browse the repository at this point in the history

Commits on Aug 26, 2024

  1. Configuration menu
    Copy the full SHA
    19f0214 View commit details
    Browse the repository at this point in the history