1 year ago

#366547

test-img

Bryan Hain

eslint-webpack-plugin not using its defined plugins in eslintrc.js

i am currently working on integrating eslint-webpack-plugin in my TS project. I installed eslint locally with npm i eslint --save-dev and after i initialiazed eslint with npx eslint --init. Also, i want to use plugins like eslint-testing-library and eslint-storybook. However, eslint is not linting the *.test.tsx and *.stories.tsx files, only the typescript files.

.eslintrc.js

module.exports = {
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:testing-library/react",
        "plugin:storybook/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": "latest",
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "@typescript-eslint",
        "testing-library",
        "storybook"
    ],
    "rules": {},
    "settings": {
        "react": {
            "version": "detect"
        }
    },
    "overrides": [
        {
            "files": ["**/?(*.)+(spec|test).[jt]s?(x)"],
            "extends": ["plugin:testing-library/react"]
        },
        {
            "files": ['*.stories.@(ts|tsx|js|jsx)'],
            "extends": ["plugin:storybook/recommended"]
        }
    ]
}

webpack.config:

const ESLintPlugin = require('eslint-webpack-plugin')

module.exports = {
  entry: './src/index.ts',
  plugins: [
    new ESLintPlugin(
      {
        context: path.resolve(__dirname, 'src'),
        extensions: ['ts', 'tsx', 'js', 'jsx', '.test.tsx', '.stories.tsx'],
        overrideConfigFile: path.resolve(__dirname, '.eslintrc.js')
      }
    )
  ],

I want my testing-library and storybook files to get linted aswell. Any ideas what i am missing? Thanks in advance.

typescript

eslint

storybook

testing-library

0 Answers

Your Answer

Accepted video resources