Skip to content

Commit 6d1485f

Browse files
authored
Merge pull request #1070 from afairb/deprecate-jsx-space-before-closing
Deprecate jsx-space-before-closing rule (fixes #967)
2 parents c6c5e3b + 0505086 commit 6d1485f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Validate spacing before closing bracket in JSX (jsx-space-before-closing)
22

3+
**Deprecation notice**: This rule is deprecated. Please use the `"beforeSelfClosing"` option of the [jsx-tag-spacing](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md) rule instead.
4+
35
Enforce or forbid spaces before the closing bracket of self-closing JSX elements.
46

57
**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.

lib/rules/jsx-space-before-closing.js

+16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
/**
22
* @fileoverview Validate spacing before closing bracket in JSX.
33
* @author ryym
4+
* @deprecated
45
*/
56
'use strict';
67

78
var getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket');
9+
var isWarnedForDeprecation = false;
810

911
// ------------------------------------------------------------------------------
1012
// Rule Definition
1113
// ------------------------------------------------------------------------------
1214

1315
module.exports = {
1416
meta: {
17+
deprecated: true,
1518
docs: {
1619
description: 'Validate spacing before closing bracket in JSX',
1720
category: 'Stylistic Issues',
@@ -67,6 +70,19 @@ module.exports = {
6770
}
6871
});
6972
}
73+
},
74+
75+
Program: function() {
76+
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
77+
return;
78+
}
79+
80+
/* eslint-disable no-console */
81+
console.log('The react/jsx-space-before-closing rule is deprecated. ' +
82+
'Please use the react/jsx-tag-spacing rule with the ' +
83+
'"beforeSelfClosing" option instead.');
84+
/* eslint-enable no-console */
85+
isWarnedForDeprecation = true;
7086
}
7187
};
7288

0 commit comments

Comments
 (0)