小编Jer*_*ier的帖子

Next.js - Eslint 不会在开发模式下检查任何页面(pages/_app.js 除外)

我在使用 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)

javascript reactjs eslint webpack next.js

5
推荐指数
2
解决办法
7804
查看次数

标签 统计

eslint ×1

javascript ×1

next.js ×1

reactjs ×1

webpack ×1