eslint-webpack-plugin 未使用其在 eslintrc.js 中定义的插件

发布于 2025-01-18 09:08:50 字数 1808 浏览 2 评论 0原文

我目前正在致力于将 eslint-webpack-plugin 集成到我的 TS 项目中。我使用 npm i eslint --save-dev 在本地安装了 eslint,然后使用 npx eslint --init 初始化了 eslint。另外,我想使用 eslint-testing-library 和 eslint-storybook 等插件。但是,eslint 不会对 *.test.tsx 和 *.stories.tsx 文件进行 linting,而只会对 typescript 文件进行 linting。

.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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文