Skip to content

Commit 1656707

Browse files
committed
[Docs] Add config notice to rule docs
1 parent 6207a04 commit 1656707

File tree

99 files changed

+227
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+227
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
4141
* [Docs] Standardize deprecated rule notice ([#3364][] @bmish)
4242
* [Docs] Fix typos ([#3366][] @bmish)
4343
* [Docs] Add markdownlint for documentation formatting consistency ([#3367][] @bmish)
44+
* [Docs] Add config notice to rule docs ([#3362][] @bmish)
4445

4546
[#3367]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3367
4647
[#3366]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3366
4748
[#3365]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3365
4849
[#3364]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3364
50+
[#3362]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3362
4951
[#3361]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3361
5052
[#3359]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3359
5153
[#3355]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3355

docs/rules/boolean-prop-naming.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforces consistent naming for boolean props (react/boolean-prop-naming)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
Allows you to enforce a consistent naming pattern for props which expect a boolean value.
46

57
> **Note**: You can provide types in runtime types using [PropTypes] and/or

docs/rules/button-has-type.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of `button` elements without an explicit `type` attribute (react/button-has-type)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
The default value of `type` attribute for `button` HTML element is `"submit"` which is often not the desired behavior and may lead to unexpected page reloads.
46
This rules enforces an explicit `type` attribute for all the `button` elements and checks that its value is valid per spec (i.e., is one of `"button"`, `"submit"`, and `"reset"`).
57

docs/rules/default-props-match-prop-types.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce all defaultProps have a corresponding non-required PropType (react/default-props-match-prop-types)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
This rule aims to ensure that any prop in `defaultProps` has a non-required type
46
definition.
57

docs/rules/destructuring-assignment.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce consistent usage of destructuring assignment of props, state, and context (react/destructuring-assignment)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Rule can be set to either of `always` or `never`;

docs/rules/display-name.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow missing displayName in a React component definition (react/display-name)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`, `recommended`.
4+
35
DisplayName allows you to name your component. This name is used by React in debugging messages.
46

57
## Rule Details

docs/rules/forbid-component-props.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow certain props on components (react/forbid-component-props)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
By default this rule prevents passing of [props that add lots of complexity](https://medium.com/brigade-engineering/don-t-pass-css-classes-between-components-e9f7ab192785) (`className`, `style`) to Components. This rule only applies to Components (e.g. `<Foo />`) and not DOM nodes (e.g. `<div />`). The list of forbidden props can be customized with the `forbid` option.
46

57
## Rule Details

docs/rules/forbid-dom-props.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow certain props on DOM Nodes (react/forbid-dom-props)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
This rule prevents passing of props to elements. This rule only applies to DOM Nodes (e.g. `<div />`) and not Components (e.g. `<Component />`).
46
The list of forbidden props can be customized with the `forbid` option.
57

docs/rules/forbid-elements.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow certain elements (react/forbid-elements)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
You may want to forbid usage of certain elements in favor of others, (e.g. forbid all `<div />` and use `<Box />` instead). This rule allows you to configure a list of forbidden elements and to specify their desired replacements.
46

57
## Rule Details

docs/rules/forbid-foreign-prop-types.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow using another component's propTypes (react/forbid-foreign-prop-types)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
This rule forbids using another component's prop types unless they are explicitly imported/exported. This allows people who want to use [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) to remove propTypes from their components in production builds, to do so safely.
46

57
In order to ensure that imports are explicitly exported it is recommended to use the ["named" rule in eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import/blob/HEAD/docs/rules/named.md) in conjunction with this rule.

docs/rules/forbid-prop-types.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow certain propTypes (react/forbid-prop-types)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
By default this rule prevents vague prop types with more specific alternatives available (`any`, `array`, `object`), but any prop type can be disabled if desired. The defaults are chosen because they have obvious replacements. `any` should be replaced with, well, anything. `array` and `object` can be replaced with `arrayOf` and `shape`, respectively.
46

57
## Rule Details

docs/rules/function-component-definition.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce a specific function type for function components (react/function-component-definition)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
This option enforces a specific function type for function components.

docs/rules/hook-use-state.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Ensure destructuring and symmetric naming of useState hook value and setter variables (react/hook-use-state)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
46

57
## Rule Details

docs/rules/iframe-missing-sandbox.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce sandbox attribute on iframe elements (react/iframe-missing-sandbox)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using sandbox attribute is considered a good security practice.
46

57
See <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox>

docs/rules/jsx-boolean-value.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce boolean attributes notation in JSX (react/jsx-boolean-value)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
[When using a boolean attribute in JSX](https://facebook.github.io/react/docs/jsx-in-depth.html#boolean-attributes), you can set the attribute value to `true` or omit the value.

docs/rules/jsx-child-element-spacing.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce or disallow spaces inside of curly braces in JSX attributes and expressions (react/jsx-child-element-spacing)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
## Rule Details
46

57
Since React removes extraneous new lines between elements when possible, it is possible to end up with inline elements that are not rendered with spaces between them and adjacent text. This is often indicative of an error, so this rule attempts to detect JSX markup with ambiguous spacing.

docs/rules/jsx-closing-bracket-location.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce closing bracket location in JSX (react/jsx-closing-bracket-location)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Enforce the closing bracket location for JSX multiline elements.

docs/rules/jsx-closing-tag-location.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce closing tag location for multiline JSX (react/jsx-closing-tag-location)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Enforce the closing tag location for multiline JSX elements.

docs/rules/jsx-curly-brace-presence.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes (react/jsx-curly-brace-presence)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
This rule allows you to enforce curly braces or disallow unnecessary curly braces in JSX props and/or children.

docs/rules/jsx-curly-newline.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce consistent linebreaks in curly braces in JSX attributes and expressions (react/jsx-curly-newline)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Many style guides require or disallow newlines inside of jsx curly expressions.

docs/rules/jsx-curly-spacing.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce or disallow spaces inside of curly braces in JSX attributes and expressions (react/jsx-curly-spacing)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
While formatting preferences are very personal, a number of style guides require or disallow spaces between curly braces.

docs/rules/jsx-equals-spacing.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce or disallow spaces around equal signs in JSX attributes (react/jsx-equals-spacing)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Some style guides require or disallow spaces around equal signs.

docs/rules/jsx-filename-extension.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow file extensions that may contain JSX (react/jsx-filename-extension)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
## Rule Details
46

57
Examples of **incorrect** code for this rule:

docs/rules/jsx-first-prop-new-line.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce proper position of the first property in JSX (react/jsx-first-prop-new-line)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Ensure correct position of the first property.

docs/rules/jsx-fragments.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce shorthand or standard form for React fragments (react/jsx-fragments)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
In JSX, a React [fragment] is created either with `<React.Fragment>...</React.Fragment>`, or, using the shorthand syntax, `<>...</>`.

docs/rules/jsx-handler-names.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce event handler naming conventions in JSX (react/jsx-handler-names)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
Ensures that any component or prop methods used to handle events are correctly prefixed.
46

57
## Rule Details

docs/rules/jsx-indent-props.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce props indentation in JSX (react/jsx-indent-props)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
This option validates a specific indentation style for props.

docs/rules/jsx-indent.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce JSX indentation (react/jsx-indent)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
This option validates a specific indentation style for JSX.

docs/rules/jsx-key.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow missing `key` props in iterators/collection literals (react/jsx-key)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`, `recommended`.
4+
35
Warn if an element that likely requires a `key` prop--namely, one present in an
46
array literal or an arrow function expression.
57

docs/rules/jsx-max-depth.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce JSX maximum depth (react/jsx-max-depth)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
This option validates a specific depth for JSX.
46

57
## Rule Details

docs/rules/jsx-max-props-per-line.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Enforce maximum of props on a single line in JSX (react/jsx-max-props-per-line)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Limiting the maximum of props on a single line can improve readability.

docs/rules/jsx-newline.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Require or prevent a new line after jsx elements and expressions. (react/jsx-newline)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
## Rule Details

docs/rules/jsx-no-bind.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow `.bind()` or arrow functions in JSX props (react/jsx-no-bind)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
A `bind` call or [arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) in a JSX prop will create a brand new function on every single render. This is bad for performance, as it may cause unnecessary re-renders if a brand new function is passed as a prop to a component that uses reference equality check on the prop to determine if it should update.
46

57
Note that this behavior is different for `ref` props, which is a special case in React that **does not** cause re-renders when a brand new function is passed. See [`ignore-refs`](#ignorerefs) below for more information.

docs/rules/jsx-no-comment-textnodes.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow comments from being inserted as text nodes (react/jsx-no-comment-textnodes)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`, `recommended`.
4+
35
This rule prevents comment strings (e.g. beginning with `//` or `/*`) from being accidentally
46
injected as a text node in JSX statements.
57

docs/rules/jsx-no-constructed-context-values.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallows JSX context provider values from taking values that will cause needless rerenders (react/jsx-no-constructed-context-values)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
This rule prevents non-stable values (i.e. object identities) from being used as a value for `Context.Provider`.
46

57
## Rule Details

docs/rules/jsx-no-duplicate-props.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow duplicate properties in JSX (react/jsx-no-duplicate-props)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`, `recommended`.
4+
35
Creating JSX elements with duplicate props can cause unexpected behavior in your application.
46

57
## Rule Details

docs/rules/jsx-no-leaked-render.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow problematic leaked values from being rendered (react/jsx-no-leaked-render)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
Using the `&&` operator to render some element conditionally in JSX can cause unexpected values being rendered, or even crashing the rendering.

docs/rules/jsx-no-literals.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of string literals in JSX (react/jsx-no-literals)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
There are a few scenarios where you want to avoid string literals in JSX. You may want to enforce consistency, reduce syntax highlighting issues, or ensure that strings are part of a translation system.
46

57
## Rule Details

docs/rules/jsx-no-script-url.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow usage of `javascript:` URLs (react/jsx-no-script-url)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.
4+
35
**In React 16.9** any URLs starting with `javascript:` [scheme](https://wiki.whatwg.org/wiki/URL_schemes#javascript:_URLs) log a warning.
46
React considers the pattern as a dangerous attack surface, see [details](https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#deprecating-javascript-urls).
57
**In a future major release**, React will throw an error if it encounters a `javascript:` URL.

docs/rules/jsx-no-target-blank.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow `target="_blank"` attribute without `rel="noreferrer"` (react/jsx-no-target-blank)
22

3+
💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`, `recommended`.
4+
35
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
46

57
When creating a JSX element that has an `a` tag, it is often desired to have the link open in a new tab using the `target='_blank'` attribute. Using this attribute unaccompanied by `rel='noreferrer'`, however, is a severe security vulnerability (see [noreferrer docs](https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer) and [noopener docs](https://html.spec.whatwg.org/multipage/links.html#link-type-noopener) for more details)

0 commit comments

Comments
 (0)