Skip to content

Commit 885afc3

Browse files
bmishljharb
authored andcommitted
[Docs] Standardize deprecated rule notice
1 parent 13d23b8 commit 885afc3

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
3838
* [Docs] [`jsx-no-target-blank`]: Fix link to link-type-noreferrer ([#3319][] @Luccasoli)
3939
* [Docs] document which rules provide suggestions ([#3359][] @bmish)
4040
* [Docs] Consistent rule descriptions and doc sections ([#3361][] @bmish)
41+
* [Docs] Standardize deprecated rule notice ([#3364][] @bmish)
4142

43+
[#3364]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3364
4244
[#3361]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3361
4345
[#3359]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3359
4446
[#3355]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3355

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ Enable the rules that you would like to use.
218218
| | | | [react/jsx-props-no-spreading](docs/rules/jsx-props-no-spreading.md) | Disallow JSX prop spreading |
219219
| | | | [react/jsx-sort-default-props](docs/rules/jsx-sort-default-props.md) | Enforce defaultProps declarations alphabetical sorting |
220220
| | 🔧 | | [react/jsx-sort-props](docs/rules/jsx-sort-props.md) | Enforce props alphabetical sorting |
221-
| | 🔧 | | [react/jsx-space-before-closing](docs/rules/jsx-space-before-closing.md) | Enforce spacing before closing bracket in JSX |
221+
| | 🔧 | | [react/jsx-space-before-closing](docs/rules/jsx-space-before-closing.md) | Enforce spacing before closing bracket in JSX. ❌ This rule is deprecated. |
222222
| | 🔧 | | [react/jsx-tag-spacing](docs/rules/jsx-tag-spacing.md) | Enforce whitespace in and around the JSX opening and closing brackets |
223223
|| | | [react/jsx-uses-react](docs/rules/jsx-uses-react.md) | Disallow React to be incorrectly marked as unused |
224224
|| | | [react/jsx-uses-vars](docs/rules/jsx-uses-vars.md) | Disallow variables used in JSX to be incorrectly marked as unused |

docs/rules/jsx-space-before-closing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enforce spacing before closing bracket in JSX (react/jsx-space-before-closing)
22

3-
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
3+
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.
44

5-
**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.
5+
🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.
66

77
Enforce or forbid spaces before the closing bracket of self-closing JSX elements.
88

markdown.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const ruleTableRows = Object.keys(rules)
1414
fixable ? '🔧' : '',
1515
hasSuggestions ? '💡' : '',
1616
`[react/${id}](docs/rules/${id}.md)`,
17-
docs.description,
17+
`${docs.description}${meta.deprecated ? '. ❌ This rule is deprecated.' : ''}`,
1818
].join(' | ');
1919
});
2020

tests/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('all rule files should be exported by the plugin', () => {
2424

2525
describe('rule documentation files have the correct content', () => {
2626
const MESSAGES = {
27+
deprecated: '❌ This rule is deprecated.',
2728
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.',
2829
hasSuggestions: '💡 This rule provides editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).',
2930
};
@@ -42,6 +43,11 @@ describe('rule documentation files have the correct content', () => {
4243
// Decide which notices should be shown at the top of the doc.
4344
const expectedNotices = [];
4445
const unexpectedNotices = [];
46+
if (rule.meta.deprecated) {
47+
expectedNotices.push('deprecated');
48+
} else {
49+
unexpectedNotices.push('deprecated');
50+
}
4551
if (rule.meta.fixable) {
4652
expectedNotices.push('fixable');
4753
} else {
@@ -57,7 +63,13 @@ describe('rule documentation files have the correct content', () => {
5763
let currentLineNumber = 1;
5864
expectedNotices.forEach((expectedNotice) => {
5965
assert.strictEqual(documentLines[currentLineNumber], '', `includes blank line ahead of ${expectedNotice} notice`);
60-
assert.strictEqual(documentLines[currentLineNumber + 1], MESSAGES[expectedNotice], `includes ${expectedNotice} notice`);
66+
if (expectedNotice === 'deprecated' && documentLines[currentLineNumber + 1] !== MESSAGES[expectedNotice] && documentLines[currentLineNumber + 1].startsWith(MESSAGES[expectedNotice])) {
67+
// Allow additional rule-specific information at the end of the deprecation notice line.
68+
assert.ok(true, `includes ${expectedNotice} notice`);
69+
} else {
70+
// Otherwise, just check the whole line.
71+
assert.strictEqual(documentLines[currentLineNumber + 1], MESSAGES[expectedNotice], `includes ${expectedNotice} notice`);
72+
}
6173
currentLineNumber += 2;
6274
});
6375

0 commit comments

Comments
 (0)