question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: excludedFiles in overrides do not apply some regexp pattern

See original GitHub issue

Environment

Node version: 14.17.6 npm version: 6.14.15 Local ESLint version: 8.10.0 Global ESLint version: none Operating System: Darwin

What parser are you using?

@typescript-eslint/parser

What did you do?

Configuration
const commentsRules = require('../rules/comments');
const importRules = require('../rules/import');
const jestRules = require('../rules/jest');
const jsxA11yRules = require('../rules/jsx-a11y');
const reactRules = require('../rules/react');
const typescriptRules = require('../rules/typescript');

module.exports = {
  root: true,
  env: {
    node: true,
    browser: true,
    es2020: true,
  },
  plugins: ['import', 'unused-imports', 'jest', 'jest-formatting', 'testing-library'],
  extends: [
    'eslint:recommended',
    'airbnb',
    'airbnb/hooks',
    'airbnb-typescript',
    'plugin:json/recommended-with-comments',
    'plugin:eslint-comments/recommended',
    'plugin:promise/recommended',
    'plugin:no-unsanitized/DOM',
    'plugin:@typescript-eslint/recommended',
    'prettier',
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    sourceType: 'module',
    extraFileExtensions: ['.json'],
    projectFolderIgnoreList: [
      '**/node_modules/**',
      './.github',
      './.husky',
      './.circleci',
      './stats',
      './docs',
      './documentations',
      './reports',
      './coverage',
      './build',
      './dist',
      './lib',
    ],
    ecmaFeatures: {
      jsx: true,
    },
  },
  rules: {
    ...commentsRules,
    ...importRules,
    ...jsxA11yRules,
    ...reactRules,
    ...typescriptRules,
  },
  overrides: [
    {
      files: ['./public/locales/**/*.json'],
      extends: ['plugin:i18n-json/recommended'],
      rules: {
        'i18n-json/valid-message-syntax': [
          'error',
          {
            syntax: require.resolve('../parser/i18n/message-parser.js'),
          },
        ],
        'i18n-json/sorted-keys': [
          'error',
          {
            order: 'asc',
            indentSpaces: 2,
          },
        ],
        'i18n-json/valid-json': 'error',
      },
    },
    {
      files: ['./**/__tests__/**/*.[jt]s?(x)', './**/?(*.)+(spec|test).[jt]s?(x)'],
      excludedFiles: ['./**/Storyshots.(spec|test).[jt]s?(x)'],
      extends: ['plugin:jest/all', 'plugin:jest-formatting/strict', 'plugin:testing-library/react'],
      env: {
        'jest/globals': true,
      },
      rules: {
        ...jestRules,
        // too hard to do in the codebase actually
        'jest/prefer-expect-assertions': 'off',
      },
    },
  ],
};

// ./src/Storyshots.test.ts

import initStoryshots from '@storybook/addon-storyshots';

initStoryshots({});

What did you expect to happen?

Eslint should not check a file included by the excludedFiles regexp

What actually happened?

Eslint is still checking a file when the regexp is including an ‘alternative’ pattern (parenthesis with pipe)

This does nos work (files are not excluded), but should :

// in overrides
excludedFiles: ['./**/Storyshots.(spec|test).[jt]s?(x)'],

This does work (files are excluded) :

// in overrides
excludedFiles: ['./**/Storyshots.test.[jt]s?(x)', './**/Storyshots.spec.[jt]s?(x)'],

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Seems (spec|test) is breaking the regexp pattern in excludedFiles in an overrides

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
snitin315commented, Mar 8, 2022

@tewarig Yes, let us know if you need any help.

1reaction
tewarigcommented, Mar 8, 2022

can i work on this issue ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make ESLint apply rules to only certain file name patterns
Is it possible to configure ESLint in a way that it only applies rules to files that names are matching certain pattern?
Read more >
Sonar.Coverage.Exclusions not excluding as expected based ...
Thank you for looking at my report. Directory is not excluded from code coverage calculations based on the regex pattern applied to the...
Read more >
Ignoring Code - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Reference information for including or excluding files for backup
The Code42 app does not back up Windows UNC file paths ... so the Remove Deleted Files After setting does not apply to...
Read more >
Configuration :: RuboCop Docs
All the previous logic does not apply if a specific configuration file is ... This means that any key-value pairs given in child...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found