Webpack 2 eslint加载程序自动修复
在webpack 1.x中,我可以在我的webpack配置中使用eslint属性来启用自动修复我的linting错误,方法是:Webpack 2 eslint加载程序自动修复,webpack,eslint,webpack-2,Webpack,Eslint,Webpack 2,在webpack 1.x中,我可以在我的webpack配置中使用eslint属性来启用自动修复我的linting错误,方法是: ... module.exports = { devtool: 'source-map', entry: './src/app.js', eslint: { configFile: '.eslintrc', fix: true }, ... 然而,在Webpack2.x中,thusfar我无法使用自动修复功能,因为我不知道在我的We
...
module.exports = {
devtool: 'source-map',
entry: './src/app.js',
eslint: {
configFile: '.eslintrc',
fix: true
},
...
然而,在Webpack2.x中,thusfar我无法使用自动修复功能,因为我不知道在我的WebpackConfig中设置它的位置。在我的webpack配置文件中使用eslint属性会抛出一个WebpackOptionsValidationError
使用webpack v2(及更高版本)自动修复linting规则的最常见方法是使用
在webpack.config.js
中,您将执行以下操作:
module.exports={
// ...
模块:{
规则:[
{
测试://\.jsx?$//,//.js和.jsx
加载程序:“eslint加载程序”,
包括:path.resolve(process.cwd(),'src'),
强制执行:“预”,
选项:{
菲克斯:没错,
},
},
// ...
],
},
// ...
};
谢谢格伦。我在配置中设置了完全相同的规则。除了我使用的是use:'eslint loader'
而不是loader:'eslint loader'
。我的印象是这些键具有相同的功能(),但区别在于use
需要一个数组作为值,loader
只需要一个字符串。