eslinteslint-flat-config

Directories in ESLint 'ignores' should be ignored, but are still being linted


I've set up ESLint using FlatCompat and added directories (including contents) that should be ignored. It seems that the linter is still doing it's job of linting the files in the ignored directory. I want the directories and contents to be ignored so that I'm not getting unwanted errors.

The lint config (eslint.config.js):

import eslint from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint';

/** @type { import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile } */
export default [
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  ...tseslint.configs.stylistic,

  stylistic.configs.customize({
    'indent': 2,
    'brace-style': '1tbs',
    'semi': true,
    'arrow-parens': false,
  }),
  {
    plugins: {
      '@typescript-eslint': tseslint.plugin,
      '@stylistic': stylistic,
    },
    files: [
      '**/*.ts',
    ],
    ignores: [
      '**/tests-examples/**',
      '**/pw-report/**',
    ],
    rules: {
      ...
    },
  },
];

The ignores section is set up just like I've seen in the documentation.


Solution

  • I found the answer here: https://stackoverflow.com/a/78887005/5338948

    The problem was that the ESLint docs don't specifically state that the ignores should be it's own object. I changed my eslint as below and it worked

    import eslint from '@eslint/js';
    import stylistic from '@stylistic/eslint-plugin';
    import tseslint from 'typescript-eslint';
    
    /** @type { import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile } */
    export default [
      eslint.configs.recommended,
      ...tseslint.configs.recommendedTypeChecked,
      ...tseslint.configs.stylisticTypeChecked,
    
      stylistic.configs.customize({
        'indent': 2,
        'brace-style': '1tbs',
        'semi': true,
        'arrow-parens': true,
      }),
      {
        ignores: [
          '**/*.js',
          '**/tests-examples/**',
          '**/pw-report/**',
          'assets',
        ]
      },
      {
        plugins: {
          '@typescript-eslint': tseslint.plugin,
          '@stylistic': stylistic,
        },
    ...