diff --git a/docs/rules/jsx-space-before-closing.md b/docs/rules/jsx-space-before-closing.md index 6d5cd640c1..d9d6b45d69 100644 --- a/docs/rules/jsx-space-before-closing.md +++ b/docs/rules/jsx-space-before-closing.md @@ -1,5 +1,7 @@ # Validate spacing before closing bracket in JSX (jsx-space-before-closing) +**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. + Enforce or forbid spaces before the closing bracket of self-closing JSX elements. **Fixable:** This rule is automatically fixable using the `--fix` flag on the command line. diff --git a/lib/rules/jsx-space-before-closing.js b/lib/rules/jsx-space-before-closing.js index 8557545ea9..21e480f7e7 100644 --- a/lib/rules/jsx-space-before-closing.js +++ b/lib/rules/jsx-space-before-closing.js @@ -1,10 +1,12 @@ /** * @fileoverview Validate spacing before closing bracket in JSX. * @author ryym + * @deprecated */ 'use strict'; var getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket'); +var isWarnedForDeprecation = false; // ------------------------------------------------------------------------------ // Rule Definition @@ -12,6 +14,7 @@ var getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket module.exports = { meta: { + deprecated: true, docs: { description: 'Validate spacing before closing bracket in JSX', category: 'Stylistic Issues', @@ -67,6 +70,19 @@ module.exports = { } }); } + }, + + Program: function() { + if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) { + return; + } + + /* eslint-disable no-console */ + console.log('The react/jsx-space-before-closing rule is deprecated. ' + + 'Please use the react/jsx-tag-spacing rule with the ' + + '"beforeSelfClosing" option instead.'); + /* eslint-enable no-console */ + isWarnedForDeprecation = true; } };