赞
踩
实现方法:在根目录下创建.eslintrc.json文件,然后设置自己的eslint配置
{
"extends": ["react-app"],
"rules": {
"eqeqeq": "off"
}
}
"eslintConfig": {
"extends": "react-app",
"rules": {
"no-undef": "off",
"no-restricted-globals": "off",
"no-unused-vars": "off"
}
}
{ 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, }
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', // }), // }, // }, // }),
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。