eslint 报错 Parsing error: Unexpected token
问题
出错代码:(import的文件省略)
<script lang="ts" setup>
const addNewQuestion = (): void => {
const selection = window.getSelection();
if (subjectProcess.checkSelection(subject.value.questions, selection)) {
// * 合法
let textStart = Math.min(
(<Selection>selection).focusOffset,
(<Selection>selection).anchorOffset
)
let textEnd = Math.max(
(<Selection>selection).focusOffset,
(<Selection>selection).anchorOffset
)
let questionOrigin = {
start: textStart,
end: textEnd,
text: (<Selection>selection).toString()
}
subjectProcess.addNewQuestion(subject.value, questionOrigin)
}
}
</script>
.eslintrc.js配置:
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true
},
extends: [
'eslint:recommended',
'@vue/typescript/recommended',
'plugin:vue/recommended',
'plugin:@typescript-eslint/recommended',
'eslint-config-alloy/vue'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2020,
parser: '@typescript-eslint/parser',
sourceType: 'module'
},
plugins: ['vue', '@typescript-eslint'],
rules: {
semi: [2, 'never'],
'no-debugger': 2,
quotes: ['error', 'single', { allowTemplateLiterals: true }],
"comma-dangle": ["error", {
"arrays": "never",
"objects": "never",
"imports": "never",
"exports": "never",
"functions": "never"
}],
"vue/html-indent": ["error", "tab", {
"attribute": 1,
"baseIndent": 1,
"closeBracket": 0,
"alignAttributesVertically": true,
"ignores": []
}],
"@typescript-eslint/indent": ["error", "tab"],
'eqeqeq': 2,
"@typescript-eslint/no-explicit-any": ["off"]
},
overrides: [
{
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
env: {
mocha: true
}
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论