简体   繁体   English

Eslint 修复即使在 json 文件上也抛出错误?

[英]Eslint fix throw error even on json file?

so I am using eslint to fix my file formats and here are my dependencies.所以我使用 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"
},

and here are my lint staged这是我的 lint 上演

 "lint-staged": {
   "!(node_modules|build)/**/*.{js,tsx,json,css,scss,html}": [
    "prettier --write",
    "eslint --fix"
   ]
  }

However it throws error on my json file saying that但是它在我的 json 文件上抛出错误说

  1:1  error  Expected an assignment or function call and instead saw an expression  no-unused- 
expressions

while my JSON file is this而我的 JSON 文件是这个

{
  "homeTitle": "Hello <br/> <strong>World</strong>"
}

May I know what is wrong with my JSON file?我可以知道我的 JSON 文件有什么问题吗?

如果你想 lint json 文件,你需要使用 eslint-plugin-json。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ESLint:即使未重新分配变量,prefer-const也不会抛出错误 - ESLint: prefer-const doesn't throw an error even if variable is not reassigned 我如何安全地修复 ESLint`no-fallthrough` 错误,以防止 break/return/throw 的故意 switch case 遗漏? - How do I safely fix ESLint`no-fallthrough` error for intentional switch case ommissions of break/return/throw? 如何修复 nodejs 抛出错误; ^ 错误:ENOENT:没有这样的文件或目录,打开 - How to fix nodejs throw err; ^ Error: ENOENT: no such file or directory, open 如何修复ESLint错误使用数组解构 - How to fix ESLint error Use array destructuring 如何修复此ESLint / JSDoc语法错误? - How to fix this ESLint/JSDoc syntax error? 如何修复 Eslint 错误“prefer-destructuring”? - How to fix Eslint error “prefer-destructuring”? 如何解决“无参数重新分配”的错误? - How to fix “no-param-reassign” eslint error? ESLINT 生成 JavaScript 配置文件时出错。 怎么修? - ESLINT An error occurred while generating your JavaScript config file. How to fix? 为什么 eslint 会抛出那个错误,我该如何摆脱它? - Why eslint throw that error, and how can I get rid of it? React typescript eslint 错误解析错误:意外的令牌? 如何解决这个问题? - React typescript eslint error Parsing error: Unexpected token ! How to fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM