eslint Oops! Something went wrong!

 2023-09-05 阅读 82 评论 0

摘要: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

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.0ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:eslint --initESLint 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-name24:5   error  'React' must be in scope when using JSX       react/react-in-jsx-scope25:7   error  'React' must be in scope when using JSX       react/react-in-jsx-scope32: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

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/866.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息