react怎么关闭eslint 或避免出现检测 整理

1.根目录下创建.eslintrc.json文件

实现方法:在根目录下创建.eslintrc.json文件,然后设置自己的eslint配置

{
    "extends": ["react-app"], 
    "rules": {
        "eqeqeq": "off"
    }
}

2.在 package.json 中修改为一下

"eslintConfig": {
    "extends": "react-app",
    "rules": {
      "no-undef": "off",
      "no-restricted-globals": "off",
      "no-unused-vars": "off"
    }
  }

3.

{
          test: /\.(js|mjs|jsx|ts|tsx)$/,
          enforce: 'pre',
          use: [
            {
              options: {
                cache: true,
                formatter: require.resolve('react-dev-utils/eslintFormatter'),
                eslintPath: require.resolve('eslint'),
                resolvePluginsRelativeTo: __dirname,
                // @remove-on-eject-begin
                ignore: isExtendingEslintConfig,
                baseConfig: isExtendingEslintConfig
                  ? undefined
                  : {
                      extends: [require.resolve('eslint-config-react-app')],
                    },
                useEslintrc: isExtendingEslintConfig,
                // @remove-on-eject-end
              },
              loader: require.resolve('eslint-loader'),
            },
          ],
          include: paths.appSrc,
        }

4.修改webpack.config.js

1. npm run eject 来暴露配置文件,(不可逆的)
  2.直接注释 或修改 extensions: [‘js’, ‘mjs’, ‘jsx’, , ‘tsx’],需要验证什么加什么

 // !disableESLintPlugin &&
      // new ESLintPlugin({
      //   // Plugin options
      //   // extensions: ['js', 'mjs', 'jsx', , 'tsx'],
      //   extensions: ['vue'],
      //   formatter: require.resolve('react-dev-utils/eslintFormatter'),
      //   eslintPath: require.resolve('eslint'),
      //   failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
      //   context: paths.appSrc,
      //   cache: true,
      //   cacheLocation: path.resolve(
      //     paths.appNodeModules,
      //     '.cache/.eslintcache'
      //   ),
      //   // ESLint class options
      //   cwd: paths.appPath,
      //   resolvePluginsRelativeTo: __dirname,
      //   baseConfig: {
      //     extends: [require.resolve('eslint-config-react-app/base')],
      //     rules: {
      //       ...(!hasJsxRuntime && {
      //         'react/react-in-jsx-scope': 'error',
      //       }),
      //     },
      //   },
      // }),
      
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值