を使用しています。
あなたのwebpack.config.js
あなたはこれのconfigsが与えるESLint
module.exports = {
loaders: [
{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /(node_modules|bower_components)/
},
// ...
],
eslint: {
failOnError: true, // block build on non passed linting
configFile: '.eslintrc', // path to your .eslintrc
formatter: require('eslint-friendly-formatter') // better error report
},
// ...
};
とリンティングをサポートするために、この行を追加する必要がありますで.eslintrc
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"no-undef": 2 // <-- ERROR on not defined variables
}
}
を設定する必要があります。このソリューション
npm install eslint eslint-loader eslint-friendly-formatter --save-dev
のパッケージを準備この種のエラー
ERROR in ./src/example.js
Module build failed: Error: Module failed because of a eslint error.
✘ http://eslint.org/docs/rules/no-undef 'bar' is not defined
/yourpath/src/example.js:2:11
var foo = bar;
^
✘ 1 problem (1 error, 0 warnings)
あなたは無undefをルールにESLintを試すことができます。http://eslint.org/docs/rules/no-undef – Everettss
それはあなたが求めるものをESLintで達成するのは簡単ですが、「strict''条件を使用せずに ' (ESLintルールは '' use strict''を指定しても指定できません)。 – Everettss
パーフェクト。私はすでにeslintを使っていましたが、何らかの理由でeslintルールをチェックすることは考えていませんでした。 – chrisp