eslint-webpack-plugin 未使用其在 eslintrc.js 中定义的插件
我目前正在致力于将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论