前言
同事给我一个前端包,需要我在其他项目中复用该项目中的某些功能。拿到包之后就是npm install安装依赖。解决了node版本与依赖之间的冲突,到后面出现eslint监测运行不了项目,因此写下文章来记录。

解决方案:
在网上也同样找了很多方法,有些没有效果。
方法一
在项目中找到该文件:config->webpack.config.js,将下面内容注释掉
!disableESLintPlugin &&new ESLintPlugin({// Plugin optionsextensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],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 optionscwd: paths.appPath,resolvePluginsRelativeTo: __dirname,baseConfig: {extends: [require.resolve('eslint-config-react-app/base')],rules: {...(!hasJsxRuntime && {'react/react-in-jsx-scope': 'error',}),},},}),
方法二
在项目中找到package.json文件,找到eslintConfig配置项,添加rules规则:

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

















