简体   繁体   English

如果div为空,则Eslint airbnb gets强制执行自我关闭div标签。 如何禁用此规则?

[英]Eslint airbnb gets enforces self closing div tag if the div is empy. How can I disable this rule?

Airbnb linting rules are removing the closing div tag if the div element is empty eg: 如果div元素为空,则Airbnb的掉毛规则将删除结束div标签,例如:

<div></div>

Is replaced by 被替换为

<div/>

My .eslintrc file is this: 我的.eslintrc文件是这样的:

 { "extends": ["airbnb", "plugin:prettier/recommended"], "parser": "babel-eslint", "parserOptions": { "ecmaVersion": 9, "ecmaFeatures": { "impliedStrict": true, "jsx": true } }, "env": { "node": true, "es6": true }, "plugins": ["react"], "rules": { "react/jsx-filename-extension": ["off"], "react/prefer-stateless-function": ["off"], "arrow-body-style": ["error", "always"], "react/self-closing-comp": [ "error", { "component": true, "html": false } ] } } 

Set "react/self-closing-comp" to "off". “ react / self-closing-comp”设置为“ off”。

 {
  "extends": ["airbnb", "plugin:prettier/recommended"],
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 9,
    "ecmaFeatures": {
      "impliedStrict": true,
      "jsx": true
    }
  },
  "env": {
    "node": true,
    "es6": true
  },
  "plugins": ["react"],
  "rules": {
    "react/jsx-filename-extension": ["off"],
    "react/prefer-stateless-function": ["off"],
    "arrow-body-style": ["error", "always"],
    "react/self-closing-comp": "off"
  }
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM