Closed wenhua-lee closed 2 years ago
cc @chenshuai2144
手动运行eslint检查看看有用吗
+1
我也遇到了这个问题 哈哈哈 如果我解决了 我再来给你留言
注意eslint-loader已经废弃,换eslint-webpack-plugin
config.local.js
const ESLintPlugin = require('eslint-webpack-plugin');
const config = {
chainWebpack: (config: any) => {
config
.plugin('eslint')
.use(ESLintPlugin, [
{
extensions: ['js', 'jsx', 'ts', 'tsx', 'less'], // 不再使用use
fix: true,
emitError: true,
emitWarning: true,
},
])
.end();
},
};
export default config;
我加了两个插件就对了: eslint-plugin-prettier
和@umijs/fabric
然后把 .eslintrc.js
改成了下面这样:
module.exports = {
extends: [require.resolve('@umijs/fabric/dist/eslint')],
globals: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
page: true,
REACT_APP_ENV: true,
},
plugins: ['prettier'],
rules: {
'prettier/prettier': 'error',
},
};
代码检测、保存自动格式化都起作用了,具体原因不晓得为啥
我加了两个插件就对了:
eslint-plugin-prettier
和@umijs/fabric
然后把
.eslintrc.js
改成了下面这样:module.exports = { extends: [require.resolve('@umijs/fabric/dist/eslint')], globals: { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true, page: true, REACT_APP_ENV: true, }, plugins: ['prettier'], rules: { 'prettier/prettier': 'error', }, };
代码检测、保存自动格式化都起作用了,具体原因不晓得为啥
麻了,搞了一下午还是不生效
注意eslint-loader已经废弃,换eslint-webpack-plugin
config.local.js
const ESLintPlugin = require('eslint-webpack-plugin'); const config = { chainWebpack: (config: any) => { config .plugin('eslint') .use(ESLintPlugin, [ { extensions: ['js', 'jsx', 'ts', 'tsx', 'less'], // 不再使用use fix: true, emitError: true, emitWarning: true, }, ]) .end(); }, }; export default config;
我用的v4版本 就是此方法解决的
umi3.x 如何开启eslint检查
环境说明
umi@3.5.13 windows10 @umijs/fabric": "^2.6.2"
搭建项目日期:2021/7/21