[英]Unexpected token ILLEGAL with @inject
I'm using gulp-jshint and receiving this message with a javascript file.我正在使用 gulp-jshint 并通过 javascript 文件接收此消息。 The file is a simple service class in my Aurelia app.
该文件是我的 Aurelia 应用程序中的一个简单服务类。 Here is the code:
这是代码:
import {inject} from 'aurelia-framework';
import {MyService} from './app/service/MyService';
/* jshint ignore:start */
@inject(MyService)
/* jshint ignore:end */
export class App {
constructor(MyService) {
this.message = MyService.message;
}
}
Here is my gulp task (gulp-jshint is getting loaded using gulp-load-plugins):这是我的 gulp 任务(gulp-jshint 正在使用 gulp-load-plugins 加载):
gulp.task('vet', function() {
return gulp.src(config.alljs)
.pipe($.if(args.verbose, $.print()))
.pipe($.jscs())
.pipe($.jshint())
.pipe($.jscsStylish.combineWithHintResults())
.pipe($.jshint.reporter('jshint-stylish', {verbose: true}))
.pipe($.jshint.reporter('fail'));
});
I have "esversion": 6
in my .jshintrc我的
"esversion": 6
有"esversion": 6
This is the result of running gulp vet
(in both Powershell and cmd)这是运行
gulp vet
的结果(在 Powershell 和 cmd 中)
PS C:\_files\programming\MyProj> gulp vet
[11:42:21] Using gulpfile C:\_files\programming\MyProj\gulpfile.js
[11:42:21] Starting 'vet'...
web\app.js
line 5 col 1 Unexpected token ILLEGAL (W parseError)
‼ 1 warning
[11:42:23] 'vet' errored after 1.79 s
[11:42:23] Error in plugin 'gulp-jshint'
Message:
JSHint failed for: web\app.js
PS C:\_files\programming\MyProj>
The Aurelia app works just fine. Aurelia 应用程序运行良好。 JSHint is ignoring the
@inject
within VSCode also, no problem there. JSHint 也忽略了
@inject
中的 @inject,没问题。 For some reason, though, gulp-jshint won't let it go.但是,出于某种原因,gulp-jshint 不会放手。 I've deleted and retyped the line after searching and finding a lot of issues with non-printable characters.
在搜索并发现许多不可打印字符的问题后,我删除并重新键入了该行。 I've tried switching the jshint ignore to
// jshint ignore:line
syntax.我试过将 jshint ignore 切换为
// jshint ignore:line
语法。 Still nothing.依然没有。
Is there something I'm missing?有什么我想念的吗?
JSHint does not support decorators ("@whatever") yet, so esversion: 6
will not affect this issue. JSHint 尚不支持装饰器(“@whatever”),因此
esversion: 6
不会影响此问题。
The policy of JSHint is to support features that are Stage 2 of standardization process, which is not the case yet for decorators.
JSHint 的策略是支持标准化过程的第 2 阶段的功能,而装饰器还不是这种情况。
https://github.com/jshint/jshint/issues/2310 https://github.com/jshint/jshint/issues/2310
Not sure why your "ignore" directive is failing, though.不过,不确定为什么您的“忽略”指令失败。 Maybe try the single-line ignore directive?
也许尝试单行忽略指令?
@inject(MyService)// jshint ignore:line
Edit: Ignoring a single line doesn't work for me either.编辑:忽略一行对我也不起作用。 Sorry, this answer probably won't be helpful.
抱歉,这个答案可能不会有帮助。 :-(
:-(
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.