Skip to content

Commit

Permalink
Merge pull request #1070 from afairb/deprecate-jsx-space-before-closing
Browse files Browse the repository at this point in the history
Deprecate jsx-space-before-closing rule (fixes #967)
  • Loading branch information
yannickcr committed Apr 23, 2017
2 parents c6c5e3b + 0505086 commit 6d1485f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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.
Expand Down
16 changes: 16 additions & 0 deletions lib/rules/jsx-space-before-closing.js
@@ -1,17 +1,20 @@
/**
* @fileoverview Validate spacing before closing bracket in JSX.
* @author ryym
* @deprecated
*/
'use strict';

var getTokenBeforeClosingBracket = require('../util/getTokenBeforeClosingBracket');
var isWarnedForDeprecation = false;

// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------

module.exports = {
meta: {
deprecated: true,
docs: {
description: 'Validate spacing before closing bracket in JSX',
category: 'Stylistic Issues',
Expand Down Expand Up @@ -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;
}
};

Expand Down

0 comments on commit 6d1485f

Please sign in to comment.