我正在尝试遵循此说明https://webpack.js.org/loaders/jshint-loader/ https://webpack.js.org/loaders/jshint-loader/并得到一个错误:
我的配置文件:
const path = require('path');
module.exports = {
entry: {
app: './index.js'
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.js$/, // include .js files
enforce: "pre", // preload the jshint loader
exclude: /node_modules/, // exclude any and all files in the node_modules folder
use: [
{
loader: "jshint-loader"
}
]
}
]
},
// more options in the optional jshint object
jshint: {
// any jshint option http://www.jshint.com/docs/options/
// i. e.
camelcase: true,
// jshint errors are displayed by default as warnings
// set emitErrors to true to display them as errors
emitErrors: false,
// jshint to not interrupt the compilation
// if you want any file with jshint errors to fail
// set failOnHint to true
failOnHint: false,
// custom reporter function
reporter: function(errors) { }
}
};
错误文本:
配置对象无效。 Webpack 已使用与 API 架构不匹配的配置对象进行初始化。
- 配置具有未知属性“jshint”。这些属性是有效的:
对象 { amd?, bail?, 缓存?, 上下文?, 依赖项?, devServer?, devtool?, 入口, 外部?, 加载器?, 模块?, 名称?, 节点?, 输出?, 性能?, 插件?, 教授
ile?、recordsInputPath?、recordsOutputPath?、recordsPath?、resolve?、resolveLoader?、stats?、target?、watch?、watchOptions? }
对于错别字:请更正。
对于加载器选项:webpack 2 不再允许在配置中自定义属性。
他们网站上的说明似乎已经过时,因为这确实不起作用。有一个关于此的开放问题Github https://github.com/webpack-contrib/jshint-loader/issues/30.
此配置应该有效:
const path = require('path');
module.exports = {
entry: {
app: './index.js'
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [{
test: /\.js$/, // include .js files
enforce: "pre", // preload the jshint loader
exclude: /node_modules/, // exclude any and all files in the node_modules folder
use: [{
loader: "jshint-loader",
// more options in the optional jshint object
options: { // ⬅ formally jshint property
camelcase: true,
emitErrors: false,
failOnHint: false
}
}]
}]
},
};
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)