ESLint: Parsing error: Unexpected token, expected "," (
时间: 2023-09-23 19:05:37 浏览: 242
回答: 这个错误是由于代码中的括号没有被解析为字符串,而被单独识别为特殊标识所导致的。为了解决这个问题,你可以在括号周围加上单引号或双引号,将其标记为字符串。推荐使用单引号。例如,你可以将代码修改为以下形式:
```javascript
export const pathMapHKOpen = {
用户明细查看: '/userDetail',
'定时任务管理(现金)': '/timingTaskManageList',
'定时任务管理(保证金)': '/timingBZJTaskManageList',
合规审核: 'p',
};
```
此外,你还可以通过修改`.prettierrc.json`文件来配置ESLint,增加`overrides`选项,以配置HTML的解析器。具体的配置可以参考以下示例:
```json
{
"printWidth": 120,
"singleQuote": true,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"htmlWhitespaceSensitivity": "ignore",
"overrides": \[
{
"files": "*.html",
"options": {
"parser": "html"
}
}
\]
}
```
这样做可以解决ESLint的解析错误,避免出现意外的标记错误。
#### 引用[.reference_title]
- *1* [前端VUE使用报错 { expected ESLint: Parsing error: Unexpected token, expected “{](https://blog.csdn.net/m0_50367192/article/details/124010491)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [ESLint: Parsing error: Unexpected token(prettier/prettier)](https://blog.csdn.net/lty1010/article/details/124611184)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文