1

I'm trying to run ESLint through the ng lint CLI command, but it fails, returning the following error:

Error when running ESLint: All files matching the following patterns are ignored:
- '/src/\*\*/\*.ts'
- '/src/\*\*/\*.html'

Please check your '.eslintignore' file.

I do not have a .eslintignore file. I tried creating one, but it didn't change the outcome.

I tried adding --no-ignore (as per Google AI suggestion) but it is not accepted.

angular.json config related to linting

...
        "lint": {
          "builder": "@angular-eslint/builder:lint",
          "options": {
            "lintFilePatterns": [
              "/src/**/*.ts",
              "/src/**/*.html"
            ]
          }
        }
...

I tried not giving lintFilePatterns, but then I get following error:

Error: Schema validation failed with the following errors:
  Data path "" must have required property 'lintFilePatterns'.

eslint.config.mjs:

import typescriptEslint from 'typescript-eslint';

export default typescriptEslint.config(
  { ignores: [ '.angular/**', 'dist/**', 'node_modules/**' ] },
  {
    name: 'Basic JS/TS PIT ESLint config',
    files: [ '**/*.js', '**/*.cjs', '**/*.mjs', '**/*.ts' ],
    rules: {
      'arrow-body-style': [ 'warn', 'as-needed' ],
      'capitalized-comments': [
        'warn',
        'always',
        { line: { ignoreConsecutiveComments: true } },
      ],
      'constructor-super': 'error',
      curly: 'error',
      complexity: 'off',
      eqeqeq: [ 'error', 'always' ],
      'guard-for-in': 'error',
      'max-classes-per-file': 'off',
      'no-bitwise': 'error',
      'no-caller': 'error',
      'no-cond-assign': [ 'error', 'always' ],
      'no-console': [ 'error', { allow: [ 'error', 'info', 'warn' ] } ],
      'no-debugger': 'error',
      'no-empty': 'error',
      'no-eval': 'error',
      'no-fallthrough': 'error',
      'no-new-wrappers': 'error',
      'no-shadow': 'off',
      'no-undef-init': 'warn',
      'no-unsafe-finally': 'error',
      'no-unused-expressions': 'error',
      'no-unused-labels': 'error',
      'no-use-before-define': 'off',
      'no-var': 'error',
      'object-shorthand': 'warn',
      'prefer-template': 'warn',
      radix: 'error',
      'use-isnan': 'error',
      'valid-typeof': 'off',
    },
  }
);

1 Answer 1

0

Finally found what is wrong:

 ...
        "lint": {
          "builder": "@angular-eslint/builder:lint",
          "options": {
            "lintFilePatterns": [
              "src/**/*.ts",
              "src/**/*.html"
            ]
          }
        }
...

Notice the absence of forward slashes before the 2 paths in the "lintFilePatterns" section.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.