我在使用 Next.js 设置 eslint 时遇到问题。当我运行时,它实际上正确地对我的所有文件进行了 lints next build,但是当我在开发模式 ( ) 下运行应用程序时next,eslint 实际上仅对我的所有文件进行了 lints pages/_app.js,并完全忽略了我的所有其他文件(例如pages/index.js)。
我的next.config.js看起来像这样:
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
if (dev) {
config.module.rules.push({
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
loader: 'eslint-loader',
})
}
return config
},
}
Run Code Online (Sandbox Code Playgroud)
看起来.eslintrc.js像这样:
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
}, …Run Code Online (Sandbox Code Playgroud)