eslint Oops! Something went wrong!

eslint Oops! Something went wrong!
遇到老多次了

problem

eslint检查报错:
Oops! Something went wrong!

完整报错信息

 > running pre-commit hook: npm run precommit

> ant-design-pro@5.0.0 precommit
> lint-staged

✔ Preparing...
⚠ Running tasks...
  ↓ No staged files match **/*.less [SKIPPED]
  ❯ Running tasks for **/*.{js,jsx,ts,tsx}
    ✖ npm run lint-staged:js [FAILED]
  ✔ Running tasks for **/*.{js,jsx,tsx,ts,less,md,json}
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up...

✖ npm run lint-staged:js:

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:

    eslint --init

ESLint looked for configuration files in /path/to/src/pages/NewFun and its ancestors. If it found none, it then looked in your home directory.

If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://eslint.org/chat/help


> ant-design-pro@5.0.0 lint-staged:js
> eslint --ext .js,.jsx,.ts,.tsx  "/path/to/src/pages/NewFun/index.tsx"


pre-commit hook failed (add --no-verify to bypass)

reason

git commit 出现eslint报错
原因是工程没有 .eslintrc.js 配置文件

solution1

可能是项目拷贝过程,丢失了因此文件 .eslintrc.js

solution2

根据提示执行 eslint --init
然后再 git commit 出现语法检查提示

 22:16  error  Component definition is missing display name  react/display-name
  24:5   error  'React' must be in scope when using JSX       react/react-in-jsx-scope
  25:7   error  'React' must be in scope when using JSX       react/react-in-jsx-scope
  32:7   error  'React' must be in scope when using JSX       react/react-in-jsx-scope

方法

  1. 根据语法提示 修复问题
  2. .eslintrc.js rule中关闭规则
  3. .eslintignore 添加忽略检查的文件
// .eslintrc.js
module.exports = {
    //...
    "rules": {
        "react/react-in-jsx-scope":0,
        "@typescript-eslint/ban-ts-comment": 0,
        "react/prop-types": 0,
        "@typescript-eslint/no-explicit-any": 0,
        "@typescript-eslint/no-non-null-assertion": 0,
        "react/display-name": 0,
    }
};
// .eslintignore
src/e2e/baseLayout.e2e.js
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值