阻止eslint被typescript';s非空断言运算符?
正在引用的意外标记是阻止eslint被typescript';s非空断言运算符?,typescript,eslint,Typescript,Eslint,正在引用的意外标记是,非空断言运算符。我怎样才能仍然使用非空断言操作符并消除这个错误呢 46:43 error Parsing error: Unexpected token 16 | export default class MyComponent extends Vue { > 18 | @Prop({ default: 'Default Title' }) title!: string .eslintrc.js: module.exports = { root
代码>,非空断言运算符。我怎样才能仍然使用非空断言操作符并消除这个错误呢
46:43 error Parsing error: Unexpected token
16 | export default class MyComponent extends Vue {
> 18 | @Prop({ default: 'Default Title' }) title!: string
.eslintrc.js:
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint',
ecmaFeatures: {
legacyDecorators: true
}
},
extends: [
'@nuxtjs',
'plugin:nuxt/recommended'
],
rules: {
"quotemark": 0,
"whitespace": [0, "check-branch", "check-operator", "check-typecast", "check-preblock", "check-postbrace", "check-type"],
"interface-name": 0,
"ordered-imports": 0,
"object-literal-sort-keys": 0,
"no-consecutive-blank-lines": 0,
"semicolon": 0,
"vue/html-self-closing": ["error", {
"html": {
"void": "any",
"normal": "any",
"component": "always"
},
"svg": "never",
"math": "never"
}],
"trailing-comma": 0,
"no-console": 0,
"no-string-literal": 0,
"no-var-requires": 0,
"ban-types": 0,
}
}
这可能只是一个bug或错误配置,与babel eslint
有关,但如果您将Typescript与eslint
一起使用,则最好使用-这是一个专门用于处理TS代码的解析器
使用该解析器,您还可以使用,它有一些特定于linting Typescript代码的eslint规则,以及一些基本lint规则的更新版本,以便更好地处理Typescript代码
您可以看到@typescript eslint
monorepo;有关将ESLint与Typescript一起使用的更多信息。@T.J.Crowder是正确的-它很可能不喜欢@
@T.J.Crowder,我确实通过删除它来“证明”。编辑问题…@VLAZ不,它像@just fine你能分享你的eslint配置吗?@TimPerry我已经编辑了这个问题以包含配置