我一直在关注React课程 . 下一步是使用 npm run eject
,以便可以使用css模块 .
因为弹出我不能使用npm start . 页面无法编译 . 出现一长串linting警告(实际上似乎来自webpack配置文件) .
我为这些文件和其他文件创建了一个.eslintignore文件:
./reactNotes.jsx
./nodeTest.js
./config
./scripts
但我的代码编辑器(vs代码)或webpack似乎都没有注意到这个文件 . eslint全局安装 .
我还调查了eslint的webpack配置,其中包括exclude:
{
test: /\.(js|jsx|mjs)$/,
enforce: 'pre',
use: [
{
options: {
formatter: eslintFormatter,
eslintPath: require.resolve('eslint'),
},
loader: require.resolve('eslint-loader'),
},
],
include: paths.appSrc,
exclude: /config/
}
VS Code在我的用户设置中启用了eslint .
如何设置webpack(甚至可能是vs代码)来忽略目录和文件?
更新:这是.eslintrc:
{
"parser": "babel-eslint",
"extends": "react-app",
"plugins": [
"react",
"jsx-a11y",
"import"
],
"rules": {
"linebreak-style": [
"error",
"windows"
],
"indent": [
"error",
4
],
"react/prop-types": 0,
"react/jsx-indent": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/no-noninteractive-element-interactions": 0,
"max-len": 0,
"arrow-body-style": 0,
"react/jsx-indent-props": 0,
"react/no-unescaped-entities": 0,
"react/jsx-no-bind": 0,
"arrow-parens": 0,
"react/no-array-index-key": 0
}
}
此外,npm安装并重新启动浏览器不起作用 .
2 回答
在你的eslintigonre,尝试改变
至
在ESLint的文档中,它的统计数据:
你可以找到完整的规格here
loveky的答案修复了VS代码 .
要修复构建,请将exclude属性添加到包含服务工作文件的webpack.config: