eslint: .eslintignore being ignored and files being ignored

188 Views Asked by At

I have the following eslint.config.js file:

'use strict';

const customEslintRulesPlugin = require("./custom-lint-rules/eslint-custom-rules-plugin"); const typeScriptEsLintPlugin = require('@typescript-eslint/eslint-plugin'); const { FlatCompat } = require('@eslint/eslintrc');

// Translate ESLintRC-style configs into flat configs. // @typescript-eslint doesn't support flat config type so need to include @eslint/eslintrc see https://github.com/typescript-eslint/typescript-eslint/issues/7694 const compat = new FlatCompat({   baseDirectory: __dirname,   recommendedConfig: typeScriptEsLintPlugin.configs['recommended'], });

module.exports = [   'eslint:recommended',

  // Our custom rules defined in /custom-lint-rules   {
    files: ["**/*.ts"],
    languageOptions: {
      sourceType: "module",
      ecmaVersion: "latest",
    },
    plugins: { "customRule": customEslintRulesPlugin },
    rules: {
      "customRule/do-not-use-should": "error",
      "customRule/async-describe": "error",
    },   },

  // Flat config for parsing TypeScript files. Includes rules for TypeScript & Playwright which don't yet work with this style of config.   ...compat.config({
    overrides: [
      {
        files: ["**/*.ts"],
        env: { node: true },
        extends: ['plugin:@typescript-eslint/recommended', "plugin:playwright/recommended"],
        parser: '@typescript-eslint/parser',
        parserOptions: {
          ecmaVersion: 'latest',
          sourceType: 'module',
        },
        plugins: ['@typescript-eslint'],
        rules: {
          '@typescript-eslint/no-unused-vars': 'off',
          '@typescript-eslint/no-empty-interface': 'error',
          "playwright/max-nested-describe": ["error", { "max": 1 }],
          "playwright/prefer-lowercase-title": ["error", { "ignoreTopLevelDescribe": true }],
          "playwright/require-top-level-describe": ["error", { "maxTopLevelDescribes": 1 }],
          "playwright/expect-expect": ["off", { "additionalAssertFunctionNames": ["assertCustomCondition"] }],
          "playwright/no-conditional-in-test": "off",
        },
      },
    ],   }), ];

I've set files to only be .ts files and I've even set .eslintignore to ignore all .js files but when I run my lint job it still flags up a couple of js files and fails them for typescript errors.

My custom rules section is working fine, that only checks .ts files.

Can anybody see what I've done wrong? It's driving me crazy!

my .eslintignore file is in the root, same as the config:

**/*.js

1

There are 1 best solutions below

0
On

eslintignore not supported

Looks like .eslintignore is no longer supported.

https://github.com/antfu/eslint-config

Try add { ignores: [**/*.js] } in your eslint.config.js