Eslint修复甚至在json文件上抛出错误?

问题描述

所以我正在使用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-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文件出了什么问题吗?

解决方法

如果要插入json文件,则需要使用eslint-plugin-json。