Dan*_*ani 18 eslint webpack webpack-2
在webpack 1.x中,我可以使用webpack配置中的eslint属性来启用自动修复我的linting错误:
...
module.exports = {
devtool: 'source-map',
entry: './src/app.js',
eslint: {
configFile: '.eslintrc',
fix: true
},
...
Run Code Online (Sandbox Code Playgroud)
但是,在webpack 2.x中,因此我无法使用自动修复功能,因为我不知道在我的webpack配置中将它设置在何处.在我的webpack中使用eslint属性configFile抛出一个WebpackOptionsValidationError.
gle*_*yes 35
使用webpack v2(及更高版本)自动修复linting规则的最常用方法是使用eslint-loader.
在你webpack.config.js,你会怎么做:
module.exports = {
// ...
module: {
rules: [
{
test: /\.jsx?$/, // both .js and .jsx
loader: 'eslint-loader',
include: path.resolve(process.cwd(), 'src'),
enforce: 'pre',
options: {
fix: true,
},
},
// ...
],
},
// ...
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9638 次 |
| 最近记录: |