首先,我们需要安装插件react。打开终端并导航到项目的根目录,运行以下命令: npm install eslint-plugin-react save-dev 然后,在你的配置文件中找到`plugins`部分,将`eslint-plugin-react`添加到数组中。 { "plugins": [ "eslint-plugin-react" ], ... } 接下来,我们需要在`rules`部分添加我们想要启用或禁用...
"extends": ["eslint:recommended","plugin:react/recommended"] If you are using thenew JSX transform from React 17, extendreact/jsx-runtimein your eslint config (add"plugin:react/jsx-runtime"to"extends") to disable the relevant rules. ...
"react/no-set-state": 0, //防止使用setState "react/no-unknown-property": 2, //防止使用未知的DOM属性 "react/prefer-es6-class": 2, //为React组件强制执行ES5或ES6类 "react/prop-types": 0, //防止在React组件定义中丢失props验证 "react/react-in-jsx-scope": 2, //使用JSX时防止丢失React ...
(edit: ah https://docs.pmnd.rs/react-three-fiber/advanced/pitfalls goes into it, all good) Can you give an example of no-hooks-outside-of-canvas? That sounds like a hard rule to lint against, can it be statically known if there is a violation? What is the args prop for use-...
可以看到,手动配置rules工作量很大,所以一般可以使用已预设配置好lint的扩展包,即根据eslint定义好一套lint规则。 extends——使用预设lint包 这些扩展预设包直接配置到extends即可,eslint本身也提供一些内置预设规则,如eslint:recommended,具体可看官方文档。
yarn add eslint-plugin-react-require-testid --dev Usage After installation, you need to configure ESLint to use this rule. Here's an example configuration: { "plugins": ["react-require-testid"], "rules": { "react-require-testid/testid-missing": ["error", { "disableDefaultComponents"...
"babel-eslint":"^8.0.3","eslint":"^4.13.1","eslint-plugin-react":"^7.5.1", 配置详情 下面的配置涵盖了开发者所需要的绝大部分信息,rules中的值0、1、2分别表示不开启检查、警告、错误。你可以看到下面有些是0,如果有需要开启检查,可以自己修改为1或者2。
"extends": ["eslint:recommended","plugin:react/recommended"] If you are using thenew JSX transform from React 17, extendreact/jsx-runtimein your eslint config (add"plugin:react/jsx-runtime"to"extends") to disable the relevant rules. ...
"extends": [ "eslint:recommended", "plugin:react/recommended" ] You should also specify settings that will be shared across all the plugin rules. 您还应该指定将在所有插件规则之间共享的设置。 {"settings":{"react":{"createClass":"createReactClass",// Regex for Component Factory to use, //...
rules: {}, } 三、plugin 可以使用 plugin 定义自己的规则 eslint-plugin-react, eslint-plugin-vue 引入plugin 可以理解为引入了额外的 rules,需要在 rules、extends 中定义后才会生效 module.exports = { extends: [ 'myconfig' //缩写 'plugin:myplugin/recommended' //插件中的规则 extends ...