[英]eslint 2.x and babel-eslint Doesn't Recognize Decorators
我正在尝试升级到eslint
2.x和最新版本的babel-eslint
。 我一直无法正确获得装饰器或类属性。 我创建了如下所示的最小再现:
test.js
import {decorator} from 'foo';
@decorator('test')
export class Test {
testProperty = 'a string';
}
package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel": "^6.5.2",
"babel-eslint": "^6.0.4",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2017": "^1.4.0",
"babel-preset-stage-1": "^6.5.0",
"eslint": "^2.10.1"
}
}
.babelrc
{
"presets": ["es2017", "stage-1"],
"plugins": ["transform-decorators-legacy"]
}
.eslintrc.json
{“ parser”:“ babel-eslint”,“ parserOptions”:{“ sourceType”:“ module”},“ rules”:{“ strict”:0}}
当我运行eslint test.js
我得到以下信息:
3:1 error Parsing error: Unexpected character '@'
✖ 1 problem (1 error, 0 warnings)
如果我注释掉第3行,则会得到以下信息:
5:16 error Parsing error: Unexpected token =
✖ 1 problem (1 error, 0 warnings)
似乎正在使用babel-eslint来解析文件,但并未从.babelrc
文件中获取任何信息。
如何使eslint和babel-eslint能够成功解析然后将这个文件抹平?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.