Skip to content

Commit 60385c8

Browse files
committed
docs: improve rule descriptions and error messages
1 parent d0e7628 commit 60385c8

File tree

54 files changed

+168
-159
lines changed

Some content is hidden

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

54 files changed

+168
-159
lines changed

packages/plugins/eslint-plugin-react-x/README.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,46 +72,48 @@ export default [
7272

7373
| Rule | Description | 💼 | 💭 ||
7474
| :--------------------------------------- | :--------------------------------------------------------------------------------------------------- | :-: | :-: | :-: |
75-
| `avoid-shorthand-boolean` | Enforces the use of shorthand syntax for boolean attributes. | 🎨 | | |
76-
| `avoid-shorthand-fragment` | Enforces the use of shorthand syntax for fragments. | 🎨 | | |
75+
| `avoid-shorthand-boolean` | Enforces using shorthand syntax for boolean attributes. | 🎨 | | |
76+
| `avoid-shorthand-fragment` | Enforces using shorthand syntax for fragments. | 🎨 | | |
7777
| `ensure-forward-ref-using-ref` | Requires that components wrapped with `forwardRef` must have a `ref` parameter. | ✔️ | | |
7878
| `no-access-state-in-setstate` | Prevents accessing `this.state` inside `setState` calls. | ✔️ | | |
79-
| `no-array-index-key` | Warns when an array `index` is used as a `key` prop. | 🧐 | | |
80-
| `no-children-count` | Prevents usage of `Children.count`. || | |
81-
| `no-children-for-each` | Prevents usage of `Children.forEach`. || | |
82-
| `no-children-map` | Prevents usage of `Children.map`. || | |
83-
| `no-children-only` | Prevents usage of `Children.only`. || | |
84-
| `no-children-prop` | Prevents usage of `children` as a prop. || | |
85-
| `no-children-to-array` | Prevents usage of `Children.toArray`. || | |
86-
| `no-class-component` | Prevents usage of class component. || | |
87-
| `no-clone-element` | Prevents usage of `cloneElement`. || | |
79+
| `no-array-index-key` | Prevents using array `index` as `key`. | 🧐 | | |
80+
| `no-children-count` | Prevents using `Children.count`. || | |
81+
| `no-children-for-each` | Prevents using `Children.forEach`. || | |
82+
| `no-children-map` | Prevents using `Children.map`. || | |
83+
| `no-children-only` | Prevents using `Children.only`. || | |
84+
| `no-children-prop` | Prevents using `children` as a prop. || | |
85+
| `no-children-to-array` | Prevents using `Children.toArray`. || | |
86+
| `no-class-component` | Prevents using class component. || | |
87+
| `no-clone-element` | Prevents using `cloneElement`. || | |
8888
| `no-comment-textnodes` | Prevents comments from being inserted as text nodes. | 🧐 | | |
89-
| `no-component-will-mount` | Prevents usage of `componentWillMount`. || | |
90-
| `no-component-will-receive-props` | Prevents usage of `componentWillReceiveProps`. || | |
91-
| `no-component-will-update` | Prevents usage of `componentWillUpdate`. || | |
92-
| `no-create-ref` | Prevents usage of `createRef`. || | |
93-
| `no-default-props` | Prevents usage of `defaultProps`. || | |
89+
| `no-complicated-conditional-rendering` | Prevents complicated conditional rendering in JSX. | 🤯 | ||
90+
| `no-component-will-mount` | Prevents using `componentWillMount`. || | |
91+
| `no-component-will-receive-props` | Prevents using `componentWillReceiveProps`. || | |
92+
| `no-component-will-update` | Prevents using `componentWillUpdate`. || | |
93+
| `no-create-ref` | Prevents using `createRef`. || | |
94+
| `no-default-props` | Prevents using `defaultProps` property in favor of ES6 default parameters. | ✔️ | | |
9495
| `no-direct-mutation-state` | Prevents direct mutation of `this.state`. | ✔️ | | |
9596
| `no-duplicate-key` | Prevents duplicate `key` props on elements in the same array or a list of `children`. | ✔️ | | |
97+
| `no-implicit-key` | Prevents `key` prop from not being explicitly specified (e.g. spreading `key` prop from objects). | 🧐 | ||
9698
| `no-leaked-conditional-rendering` | Prevents problematic leaked values from being rendered. | 🧐 | 💭 | |
9799
| `no-missing-component-display-name` | Enforces that all components have a `displayName` which can be used in devtools. | 🐞 | | |
98100
| `no-missing-key` | Prevents missing `key` prop on items in list rendering. | ✔️ | | |
99101
| `no-nested-components` | Prevents nesting component definitions inside other components. | ✔️ | | |
100-
| `no-prop-types` | Prevents usage of `propTypes`. || | |
101-
| `no-redundant-should-component-update` | Prevents usage of `shouldComponentUpdate` when extending `React.PureComponent`. | ✔️ | | |
102-
| `no-set-state-in-component-did-mount` | Disallows calling `this.setState` in `componentDidMount` outside of functions, such as callbacks. | 🧐 | | |
103-
| `no-set-state-in-component-did-update` | Disallows calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks. | 🧐 | | |
104-
| `no-set-state-in-component-will-update` | Disallows calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks. | 🧐 | | |
105-
| `no-string-refs` | Disallows using deprecated string `refs`. || | |
106-
| `no-unsafe-component-will-mount` | Warns usage of `UNSAFE_componentWillMount` in class components. | 🧐 | | |
107-
| `no-unsafe-component-will-receive-props` | Warns usage of `UNSAFE_componentWillReceiveProps` in class components. | 🧐 | | |
108-
| `no-unsafe-component-will-update` | Warns usage of `UNSAFE_componentWillUpdate` in class components. | 🧐 | | |
102+
| `no-props-types` | Prevents using `propTypes` in favor of TypeScript or another type-checking solution. || | |
103+
| `no-redundant-should-component-update` | Prevents using `shouldComponentUpdate` when extending `React.PureComponent`. | ✔️ | | |
104+
| `no-set-state-in-component-did-mount` | Prevents calling `this.setState` in `componentDidMount` outside of functions, such as callbacks. | 🧐 | | |
105+
| `no-set-state-in-component-did-update` | Prevents calling `this.setState` in `componentDidUpdate` outside of functions, such as callbacks. | 🧐 | | |
106+
| `no-set-state-in-component-will-update` | Prevents calling `this.setState` in `componentWillUpdate` outside of functions, such as callbacks. | 🧐 | | |
107+
| `no-string-refs` | Prevents using deprecated string `refs`. || | |
108+
| `no-unsafe-component-will-mount` | Warns the usage of `UNSAFE_componentWillMount` in class components. | 🧐 | | |
109+
| `no-unsafe-component-will-receive-props` | Warns the usage of `UNSAFE_componentWillReceiveProps` in class components. | 🧐 | | |
110+
| `no-unsafe-component-will-update` | Warns the usage of `UNSAFE_componentWillUpdate` in class components. | 🧐 | | |
109111
| `no-unstable-context-value` | Prevents non-stable values (i.e. object literals) from being used as a value for `Context.Provider`. | 🚀 | | |
110-
| `no-unstable-default-props` | Prevents usage of referential-type values as default props in object destructuring. | 🚀 | | |
112+
| `no-unstable-default-props` | Prevents using referential-type values as default props in object destructuring. | 🚀 | | |
111113
| `no-unused-class-component-members` | Warns unused class component methods and properties. | ✔️ | | |
112114
| `no-unused-state` | Warns unused class component state. | ✔️ | | |
113-
| `no-useless-fragment` | Prevents the use of useless `fragment` components or `<>` syntax. | ✔️ | | |
114-
| `prefer-read-only-props` | Enforces that function components props are readonly. | ✔️ | 💭 | |
115-
| `prefer-destructuring-assignment` | Enforces the use of destructuring assignment over property assignment. | 🎨 | | |
116-
| `prefer-shorthand-boolean` | Enforces the use of shorthand syntax for boolean attributes. | 🎨 | | |
117-
| `prefer-shorthand-fragment` | Enforces the use of shorthand syntax for fragments. | 🎨 | | |
115+
| `no-useless-fragment` | Prevents using useless `fragment` components or `<>` syntax. | ✔️ | | |
116+
| `prefer-destructuring-assignment` | Enforces using destructuring assignment over property assignment. | 🎨 | | |
117+
| `prefer-read-only-props` | Enforce read-only props in components. | ✔️ | 💭 | |
118+
| `prefer-shorthand-boolean` | Enforces using shorthand syntax for boolean attributes. | 🎨 | | |
119+
| `prefer-shorthand-fragment` | Enforces using shorthand syntax for fragments. | 🎨 | | |

packages/plugins/eslint-plugin-react-x/src/rules/avoid-shorthand-boolean.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ export default createRule<[], MessageID>({
1212
meta: {
1313
type: "problem",
1414
docs: {
15-
description: "enforce boolean attributes notation in JSX",
15+
description: "avoid using shorthand boolean attribute",
1616
},
1717
messages: {
18-
AVOID_SHORTHAND_BOOLEAN: "Avoid using shorthand boolean attribute '{{propName}}'.",
18+
AVOID_SHORTHAND_BOOLEAN:
19+
"Avoid using shorthand boolean attribute '{{propName}}'. Use '{{propName}}={true}' instead.",
1920
},
2021
schema: [],
2122
},

packages/plugins/eslint-plugin-react-x/src/rules/avoid-shorthand-fragment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export default createRule<[], MessageID>({
1111
meta: {
1212
type: "problem",
1313
docs: {
14-
description: "enforce using fragment component instead of shorthand fragment syntax",
14+
description: "avoid using shorthand fragment syntax",
1515
},
1616
messages: {
17-
AVOID_SHORTHAND_FRAGMENT: "Avoid shorthand fragment syntax, use fragment component instead.",
17+
AVOID_SHORTHAND_FRAGMENT: "Avoid using shorthand fragment syntax. Use 'Fragment' component instead.",
1818
},
1919
schema: [],
2020
},

packages/plugins/eslint-plugin-react-x/src/rules/ensure-forward-ref-using-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default createRule<[], MessageID>({
1414
meta: {
1515
type: "problem",
1616
docs: {
17-
description: "require all 'forwardRef' components include a 'ref' parameter",
17+
description: "require a 'ref' parameter to be set when using 'forwardRef'",
1818
},
1919
messages: {
2020
ENSURE_FORWARD_REF_USING_REF: "A 'forwardRef' is used with this component but no 'ref' parameter is set.",

packages/plugins/eslint-plugin-react-x/src/rules/no-access-state-in-setstate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default createRule<[], MessageID>({
4545
description: "disallow accessing 'this.state' within 'setState'",
4646
},
4747
messages: {
48-
NO_ACCESS_STATE_IN_SETSTATE: "Do not access 'this.state' within 'setState'. Use 'setState' callback instead.",
48+
NO_ACCESS_STATE_IN_SETSTATE: "Do not access 'this.state' within 'setState'. Use the update function instead.",
4949
},
5050
schema: [],
5151
},

packages/plugins/eslint-plugin-react-x/src/rules/no-array-index-key.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ export default createRule<[], MessageID>({
8585
meta: {
8686
type: "problem",
8787
docs: {
88-
description: "disallow using Array index as key",
88+
description: "disallow using Array index as 'key'",
8989
},
9090
messages: {
91-
NO_ARRAY_INDEX_KEY: "Do not use Array index as key.",
91+
NO_ARRAY_INDEX_KEY: "Do not use Array index as 'key'.",
9292
},
9393
schema: [],
9494
},

packages/plugins/eslint-plugin-react-x/src/rules/no-children-count.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default createRule<[], MessageID>({
1212
meta: {
1313
type: "problem",
1414
docs: {
15-
description: "disallow 'Children.count'",
15+
description: "disallow using 'Children.count'",
1616
},
1717
messages: {
1818
NO_CHILDREN_COUNT: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead.",

packages/plugins/eslint-plugin-react-x/src/rules/no-children-for-each.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default createRule<[], MessageID>({
1212
meta: {
1313
type: "problem",
1414
docs: {
15-
description: "disallow 'Children.forEach'",
15+
description: "disallow using 'Children.forEach'",
1616
},
1717
messages: {
1818
NO_CHILDREN_FOR_EACH:

packages/plugins/eslint-plugin-react-x/src/rules/no-children-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default createRule<[], MessageID>({
1212
meta: {
1313
type: "problem",
1414
docs: {
15-
description: "disallow 'Children.map'",
15+
description: "disallow using 'Children.map'",
1616
},
1717
messages: {
1818
NO_CHILDREN_MAP: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead.",

packages/plugins/eslint-plugin-react-x/src/rules/no-children-only.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default createRule<[], MessageID>({
1212
meta: {
1313
type: "problem",
1414
docs: {
15-
description: "disallow 'Children.only'",
15+
description: "disallow using 'Children.only'",
1616
},
1717
messages: {
1818
NO_CHILDREN_ONLY: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead.",

0 commit comments

Comments
 (0)