草庐IT

javascript - 使用 mapDispatchToProps 避免 no-shadow eslint 错误

我有以下组件在FilterButtonprops上触发no-shadowESlint错误。import{setFilter}from'../actions/filter';functionFilterButton({setFilter}){return(Click);}exportdefaultconnect(null,{setFilter})(FilterButton);如何在保持mapDispatchToProps的简洁语法和ESlint规则的同时避免警告?我知道我可以添加注释来抑制警告,但对每个组件都这样做似乎是多余且乏味的。 最佳答案

eslint报错Component name “home“ should always be multi-word,文件命名规则导致问题解决方案

新建vue项目的时候,往往需要配置eslint进行代码的格式化,但使用过程中也是会遇到各种问题,就比如:Componentname“Home”shouldalwaysbemulti-word.eslintvue/multi-word-component-names其实这是eslint对命名的校验,要以多词组件名称命名,防止与现有和未来的HTML元素发生冲突。如何解决呢,如下:第一种方式>配置.eslintrc.js文件(*推荐使用)在根目录找到eslintrc.js文件,配置关闭名称的校验,在该文件中,找到rules进行配置,如下代码://关闭名称校验'vue/multi-word-compo

javascript - prettier-eslint、eslint-plugin-prettier 和 eslint-config-prettier 之间有什么区别?

我想把Prettier和ESLint一起用,但是一个接一个用就遇到了一些冲突。我看到有这三个包似乎允许它们串联使用:prettier-eslinteslint-plugin-prettiereslint-config-prettier但是,我不确定使用哪个,因为这些包名称都包含eslint和prettier。我应该使用哪个? 最佳答案 tl;dr:使用eslint-config-prettier,其他可以忽略。ESLint包含很多规则,与格式相关的规则可能会与Prettier冲突,例如arrow-parens、space-befor

javascript - prettier-eslint、eslint-plugin-prettier 和 eslint-config-prettier 之间有什么区别?

我想把Prettier和ESLint一起用,但是一个接一个用就遇到了一些冲突。我看到有这三个包似乎允许它们串联使用:prettier-eslinteslint-plugin-prettiereslint-config-prettier但是,我不确定使用哪个,因为这些包名称都包含eslint和prettier。我应该使用哪个? 最佳答案 tl;dr:使用eslint-config-prettier,其他可以忽略。ESLint包含很多规则,与格式相关的规则可能会与Prettier冲突,例如arrow-parens、space-befor

javascript - 带有 eslint-config-airbnb 的扩展名为 ' .js' 的文件中不允许使用 JSX

我已经安装了eslint-config-airbnb应该为React预配置ESLINT:OurdefaultexportcontainsallofourESLintrules,includingECMAScript6+andReact.Itrequireseslint,eslint-plugin-import,eslint-plugin-react,andeslint-plugin-jsx-a11y.我的.eslintrc扩展它的配置:{"extends":"eslint-config-airbnb","env":{"browser":true,"node":true,"mocha":

javascript - 带有 eslint-config-airbnb 的扩展名为 ' .js' 的文件中不允许使用 JSX

我已经安装了eslint-config-airbnb应该为React预配置ESLINT:OurdefaultexportcontainsallofourESLintrules,includingECMAScript6+andReact.Itrequireseslint,eslint-plugin-import,eslint-plugin-react,andeslint-plugin-jsx-a11y.我的.eslintrc扩展它的配置:{"extends":"eslint-config-airbnb","env":{"browser":true,"node":true,"mocha":

javascript - 没有受限的全局变量

我正在使用React和Redux开发一个网络应用程序,当我开始我的项目时,我得到了这个:Line13:Unexpecteduseof'location'no-restricted-globalsSearchforthekeywordstolearnmoreabouteacherror.我搜索了很多关于如何解决它的问题,但我找到的答案都没有帮助我,所以我求助于Stackoverflow。有谁知道如何解决这个错误?我感谢我能得到的所有帮助。 最佳答案 尝试在location之前添加window(即window.location)。

javascript - 没有受限的全局变量

我正在使用React和Redux开发一个网络应用程序,当我开始我的项目时,我得到了这个:Line13:Unexpecteduseof'location'no-restricted-globalsSearchforthekeywordstolearnmoreabouteacherror.我搜索了很多关于如何解决它的问题,但我找到的答案都没有帮助我,所以我求助于Stackoverflow。有谁知道如何解决这个错误?我感谢我能得到的所有帮助。 最佳答案 尝试在location之前添加window(即window.location)。

【解决ESlint的bug】return old(m, filename); Error [ERR_REQUIRE_ESM]: require() of ES Module

在使用eslint配置时,提交出现bug:C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:729returnold(m,filename);^Error[ERR_REQUIRE_ESM]:require()ofESModuleC:\Users\USER\Desktop\tindin\node_modules\node-fetch\src\index.jsfromC:\Users\USER\Desktop\tindin\src\api\services\unsplash.tsnotsupported.Ins

jsx文件eslint报错 Parsing error: Unexpected token < eslint

问题最近在使用reactnative开发app的发现一个问题:报错详情:可以看到,这是jsx的正确写法,并没有语法错误,但是eslint还是报错,大致意思就是意外的符号,可以大概推断是eslint没有正确解析jsx语法造成的,虽然程序可以正常运行,但是对于强迫症来说,确实受不了。分析原因:开发环境与ESLint当前的解析功能不兼容解决方案:使用babel-eslint解析解决安装babel-eslintnpminstallbabel-eslint--save-dev在.eslintrc.js中加入parse:'babel-eslint'问题解决,报错清除。