Ste*_*eve 6 eslint prettier prettier-eslint
我有一个使用 vue cli 创建的 vue 应用程序,我使用的版本是 vue2(带有 eslint 和 prettier)。
我可以运行npm run serve并加载我的页面。但是在 Visual Studio Code 中,我注意到这个错误:
{
"resource": "/c:/vue/app2/public/index.html",
"owner": "eslint",
"code": {
"value": "prettier/prettier",
"target": {
"$mid": 1,
"external": "https://github.com/prettier/eslint-plugin-prettier#options",
"path": "/prettier/eslint-plugin-prettier",
"scheme": "https",
"authority": "github.com",
"fragment": "options"
}
},
"severity": 4,
"message": "Parsing error: Unexpected token",
"source": "eslint",
"startLineNumber": 1,
"startColumn": 2,
"endLineNumber": 1,
"endColumn": 2
}
Run Code Online (Sandbox Code Playgroud)
这是我.eslintrc.js创建应用程序时自动生成的,此后我没有对其进行任何更改。
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
parserOptions: {
ecmaVersion: 2020
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
}
};
Run Code Online (Sandbox Code Playgroud)
我注意到错误实际上是指这一行。有谁知道这有什么问题?
<!DOCTYPE html>
Run Code Online (Sandbox Code Playgroud)
我遇到过类似的问题。它是由 引起的<!DOCTYPE html>。
修复很容易,我们需要在 中指定一个解析器prettierrc,尽管很明显:
overrides:
- files: '*.html'
options:
parser: 'html'
- files: '*.component.html'
options:
parser: 'angular'
Run Code Online (Sandbox Code Playgroud)
之后,更漂亮的人能够使用<!DOCTYPE html>.
信用证转到krave1986
| 归档时间: |
|
| 查看次数: |
2168 次 |
| 最近记录: |