我试图将 gulp-eslint 添加到我的构建过程中,让 gulp 监视我的文件并在文件更改时运行 eslint。但是,我收到一条错误消息:
D:\code\project\node_modules\gulp-eslint\index.js:4
const {CLIEngine} = require('eslint');
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (D:\code\project\gulpfile.js:5:16)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
当我尝试运行我编写的 ESLint 任务时。
这是 eslint 任务的代码:
gulp.task('eslint', () => {
return gulp.src(lintscripts)
.pipe(eslint({
"env": {
"browser": true,
"node": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017
},
"rules": {
'no-console': 'off',
'indent' : 'off',
"semi": [
"error",
"always"
]
}
})).pipe(eslint.format());
});