![](/img/trans.png)
[英]ESLint: prefer-const doesn't throw an error even if variable is not reassigned
[英]Eslint fix throw error even on json file?
所以我使用 eslint 來修復我的文件格式,這是我的依賴項。
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.12.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.2",
"husky": "^4.3.0",
"lint-staged": "^10.4.0",
"prettier": "^2.1.1"
},
這是我的 lint 上演
"lint-staged": {
"!(node_modules|build)/**/*.{js,tsx,json,css,scss,html}": [
"prettier --write",
"eslint --fix"
]
}
但是它在我的 json 文件上拋出錯誤說
1:1 error Expected an assignment or function call and instead saw an expression no-unused-
expressions
而我的 JSON 文件是這個
{
"homeTitle": "Hello <br/> <strong>World</strong>"
}
我可以知道我的 JSON 文件有什么問題嗎?
如果你想 lint json 文件,你需要使用 eslint-plugin-json。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.