import 错误
// 错误信息
Parsing error: The keyword 'import' is reservedeslint
解决
// 1 项目根目录创建 .eslintrc.js 文件
// 2 添加以下内容
module.exports = {
root: true,
parserOptions: {
sourceType: "module",
},
// required to lint *.vue files
plugins: ["html"],
// add your custom rules here
rules: {
// allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
},
};
async await错误
// 错误信息
(method) getTipsShopNameMode(): Promise<void>
Parsing error: Unexpected token getTipsShopNameModeeslint
解决
// .eslintrc.js 文件
"parserOptions": { "ecmaVersion": 8 },
vscode配置setting.json
仅供参考
{
"workbench.activityBar.visible": true,
"workbench.colorTheme": "Default Light+",
"code-runner.runInTerminal": true,
"dart.previewHotReloadOnSaveWatcher": true,
"git.confirmSync": true,
"git.autofetch": true,
"git.showCommitInput": true,
"git.path": "D:/Git/bin/git.exe",
"scm.alwaysShowActions": true,
"editor.fontSize": 18,
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"eslint.validate": ["javascript", "javascriptreact", "html", "vue", "typescript"],
"eslint.options": {
"plugins": ["html"]
},
// "files.eol": "\n",
"files.associations": {
"*.wxml": "wxml"
},
"prettier.endOfLine": "auto",
"prettier.printWidth": 120,
"prettier.singleQuote": true,
"prettier.jsxBracketSameLine": false,
"prettier.trailingComma": "none",
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "force-expand-multiline"
},
"prettyhtml": {
"printWidth": 120,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
},
"prettier": {
"semi": true,
"singleQuote": true
}
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"less.compile": {
"outExt": ".wxss"
},
"vetur.validation.script": false
}
去掉末行尾随的逗号
// .prettierrc.js
// 是否在任何可能的多行中输入尾逗号
trailingComma: 'none',