VS Code编写html、php文件,eslint报错Parsing error: Unexpected token <
,怎么解决呢?
方法一:
需要安装babel-eslint
,执行:
npm install --save-dev babel-eslint
然后在.eslintrc.js
中的rules
插入parser: 'babel-eslint'
rules: {
parser: 'babel-eslint'
}
方法二:
在.eslintrc.json
中加入"plugins": ["html"],
,如:
{
"env": {
"browser": true,
"es2021": true,
"node": true,
"jquery": true
},
"plugins": ["lodash", "html"],
"extends": ["eslint:recommended", "plugin:lodash/recommended"],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"quotes": [1, "single"],
"semi": [2, "never"]
}
}