Skip to content

Commit

Permalink
docs: tweak rule notices
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Aug 18, 2022
1 parent a766255 commit 4ccb5cc
Show file tree
Hide file tree
Showing 31 changed files with 39 additions and 41 deletions.
2 changes: 1 addition & 1 deletion docs/rules/destructuring-assignment.md
@@ -1,6 +1,6 @@
# Enforce consistent usage of destructuring assignment of props, state, and context (react/destructuring-assignment)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Rule can be set to either of `always` or `never`;
```js
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/function-component-definition.md
@@ -1,6 +1,6 @@
# Enforce a specific function type for function components (react/function-component-definition)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

This option enforces a specific function type for function components.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/hook-use-state.md
@@ -1,6 +1,6 @@
# Ensure destructuring and symmetric naming of useState hook value and setter variables (react/hook-use-state)

💡 This rule provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

## Rule Details

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-boolean-value.md
@@ -1,6 +1,6 @@
# Enforce boolean attributes notation in JSX (react/jsx-boolean-value)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

[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. This rule will enforce one or the other to keep consistency in your code.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-closing-bracket-location.md
@@ -1,6 +1,6 @@
# Validate closing bracket location in JSX (react/jsx-closing-bracket-location)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Enforce the closing bracket location for JSX multiline elements.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-closing-tag-location.md
@@ -1,6 +1,6 @@
# Validate closing tag location in JSX (react/jsx-closing-tag-location)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Enforce the closing tag location for multiline JSX elements.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-curly-brace-presence.md
@@ -1,6 +1,6 @@
# Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children. (react/jsx-curly-brace-presence)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

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

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-curly-newline.md
@@ -1,6 +1,6 @@
# Enforce linebreaks in curly braces in JSX attributes and expressions. (react/jsx-curly-newline)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

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

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-curly-spacing.md
@@ -1,6 +1,6 @@
# Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. (react/jsx-curly-spacing)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

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

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-equals-spacing.md
@@ -1,6 +1,6 @@
# Enforce or disallow spaces around equal signs in JSX attributes. (react/jsx-equals-spacing)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Some style guides require or disallow spaces around equal signs.

Expand Down
4 changes: 2 additions & 2 deletions docs/rules/jsx-first-prop-new-line.md
@@ -1,10 +1,10 @@
# Configure the position of the first property (react/jsx-first-prop-new-line)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Ensure correct position of the first property.

Note: The autofixer does not include indentation. Please rerun lint to correct those errors.
Note: The fixer does not include indentation. Please rerun lint to correct those errors.

## Rule Details

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-fragments.md
@@ -1,6 +1,6 @@
# Enforce shorthand or standard form for React fragments (react/jsx-fragments)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

In JSX, a React fragment is created either with `<React.Fragment>...</React.Fragment>`, or, using the shorthand syntax, `<>...</>`. This rule allows you to enforce one way or the other.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-indent-props.md
@@ -1,6 +1,6 @@
# Validate props indentation in JSX (react/jsx-indent-props)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

This option validates a specific indentation style for props.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-indent.md
@@ -1,6 +1,6 @@
# Validate JSX indentation (react/jsx-indent)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

This option validates a specific indentation style for JSX.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-max-props-per-line.md
@@ -1,6 +1,6 @@
# Limit maximum of props on a single line in JSX (react/jsx-max-props-per-line)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

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

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-newline.md
@@ -1,6 +1,6 @@
# Require or prevent a new line after jsx elements and expressions. (react/jsx-newline)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

## Rule Details

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-no-leaked-render.md
@@ -1,6 +1,6 @@
# Prevent problematic leaked values from being rendered (react/jsx-no-leaked-render)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

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

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-no-target-blank.md
@@ -1,6 +1,6 @@
# Prevent usage of unsafe `target='_blank'` (react/jsx-no-target-blank)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

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)
This rules requires that you accompany `target='_blank'` attributes with `rel='noreferrer'`.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-no-useless-fragment.md
@@ -1,6 +1,6 @@
# Disallow unnecessary fragments (react/jsx-no-useless-fragment)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a [keyed fragment](https://reactjs.org/docs/fragments.html#keyed-fragments).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-one-expression-per-line.md
@@ -1,6 +1,6 @@
# One JSX Element Per Line (react/jsx-one-expression-per-line)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

This option limits every line in JSX to one expression each.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-props-no-multi-spaces.md
@@ -1,6 +1,6 @@
# Disallow multiple spaces between inline JSX props (react/jsx-props-no-multi-spaces)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Enforces that there is exactly one space between all attributes and after tag name and the first attribute in the same line.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-sort-props.md
@@ -1,6 +1,6 @@
# Enforce props alphabetical sorting (react/jsx-sort-props)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Some developers prefer to sort props names alphabetically to be able to find necessary props easier at the later time. Others feel that it adds complexity and becomes burden to maintain.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-space-before-closing.md
@@ -1,6 +1,6 @@
# Validate spacing before closing bracket in JSX (react/jsx-space-before-closing)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

**Deprecation notice**: This rule is deprecated. Please use the `"beforeSelfClosing"` option of the [jsx-tag-spacing](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md) rule instead.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-tag-spacing.md
@@ -1,6 +1,6 @@
# Validate whitespace in and around the JSX opening and closing brackets (react/jsx-tag-spacing)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Enforce or forbid spaces after the opening bracket, before the closing bracket, before the closing bracket of self-closing elements, and between the angle bracket and slash of JSX closing or self-closing elements.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/jsx-wrap-multilines.md
@@ -1,6 +1,6 @@
# Prevent missing parentheses around multiline JSX (react/jsx-wrap-multilines)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Wrapping multiline JSX in parentheses can improve readability and/or convenience.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-arrow-function-lifecycle.md
@@ -1,6 +1,6 @@
# Lifecycle methods should be methods on the prototype, not class fields (react/no-arrow-function-lifecycle)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

It is not neccessary to use arrow function for lifecycle methods. This makes things harder to test, conceptually less performant (although in practice, performance will not be affected, since most engines will optimize efficiently), and can break hot reloading patterns.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-invalid-html-attribute.md
@@ -1,6 +1,6 @@
# Prevent usage of invalid attributes (react/no-invalid-html-attribute)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Some HTML elements have a specific set of valid values for some attributes.
For instance the elements: `a`, `area`, `link`, or `form` all have an attribute called `rel`.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unknown-property.md
@@ -1,6 +1,6 @@
# Prevent usage of unknown DOM property (react/no-unknown-property)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

In JSX all DOM properties and attributes should be camelCased to be consistent with standard JavaScript style. This can be a possible source of error if you are used to writing plain HTML.

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/prefer-read-only-props.md
@@ -1,6 +1,6 @@
# Enforce that props are read-only (react/prefer-read-only-props)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Using Flow, one can define types for props. This rule enforces that prop types are read-only (covariant).

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/self-closing-comp.md
@@ -1,6 +1,6 @@
# Prevent extra closing tags for components without children (react/self-closing-comp)

🔧 This rule is automatically fixable using the `--fix` flag on the command line.
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Components without children can be self-closed to avoid unnecessary extra closing tag.

Expand Down
18 changes: 8 additions & 10 deletions tests/index.js
Expand Up @@ -24,13 +24,11 @@ describe('all rule files should be exported by the plugin', () => {

describe('rule documentation files have the correct content', () => {
const MESSAGES = {
fixable:
'🔧 This rule is automatically fixable using the `--fix` flag on the command line.',
hasSuggestions:
'💡 This rule provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).',
fixable: '🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.',
hasSuggestions: '💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).',
};

for (const ruleFile of ruleFiles) {
ruleFiles.forEach((ruleFile) => {
const ruleName = path.basename(ruleFile, '.js');
const rule = plugin.rules[ruleName];
const documentPath = path.join('docs/rules', `${ruleName}.md`);
Expand All @@ -53,17 +51,17 @@ describe('rule documentation files have the correct content', () => {

// Ensure that expected notices are present in the correct order.
let currentLineNumber = 1;
for (const expectedNotice of expectedNotices) {
expectedNotices.forEach((expectedNotice) => {
assert.strictEqual(documentLines[currentLineNumber], '', `${ruleName} includes blank line ahead of ${expectedNotice} notice`);
assert.strictEqual(documentLines[currentLineNumber + 1], MESSAGES[expectedNotice], `${ruleName} includes ${expectedNotice} notice`);
currentLineNumber += 2;
}
});

// Ensure that unexpected notices are not present.
for (const unexpectedNotice of unexpectedNotices) {
unexpectedNotices.forEach((unexpectedNotice) => {
assert.ok(!documentContents.includes(MESSAGES[unexpectedNotice]), `${ruleName} does not include unexpected ${unexpectedNotice} notice`);
}
}
});
});
});

describe('deprecated rules', () => {
Expand Down

0 comments on commit 4ccb5cc

Please sign in to comment.