Skip to content

Commit

Permalink
Change "spaces" to "when"
Browse files Browse the repository at this point in the history
  • Loading branch information
fatfisz committed Jun 11, 2017
1 parent c9e9ded commit 7b9d9ad
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 103 deletions.
14 changes: 7 additions & 7 deletions lib/rules/jsx-curly-spacing.js
Expand Up @@ -36,7 +36,7 @@ module.exports = {
basicConfig: {
type: 'object',
properties: {
spaces: {
when: {
enum: SPACING_VALUES
},
allowMultiline: {
Expand Down Expand Up @@ -78,30 +78,30 @@ module.exports = {

function normalizeConfig(configOrTrue, defaults, lastPass) {
var config = configOrTrue === true ? {} : configOrTrue;
var spaces = config.spaces || defaults.spaces;
var when = config.when || defaults.when;
var allowMultiline = has(config, 'allowMultiline') ? config.allowMultiline : defaults.allowMultiline;
var spacing = config.spacing || {};
var objectLiteralSpaces = spacing.objectLiterals || defaults.objectLiteralSpaces;
if (lastPass) {
// On the final pass assign the values that should be derived from others if they are still undefined
objectLiteralSpaces = objectLiteralSpaces || spaces;
objectLiteralSpaces = objectLiteralSpaces || when;
}

return {
spaces,
when,
allowMultiline,
objectLiteralSpaces
};
}

var DEFAULT_SPACING = SPACING.never;
var DEFAULT_WHEN = SPACING.never;
var DEFAULT_ALLOW_MULTILINE = true;
var DEFAULT_ATTRIBUTES = true;

var sourceCode = context.getSourceCode();
var originalConfig = context.options[0] || {};
var defaultConfig = normalizeConfig(originalConfig, {
spaces: DEFAULT_SPACING,
when: DEFAULT_WHEN,
allowMultiline: DEFAULT_ALLOW_MULTILINE
});
var attributes = has(originalConfig, 'attributes') ? originalConfig.attributes : DEFAULT_ATTRIBUTES;
Expand Down Expand Up @@ -261,7 +261,7 @@ module.exports = {
}

var isObjectLiteral = first.value === second.value;
var spacing = isObjectLiteral ? config.objectLiteralSpaces : config.spaces;
var spacing = isObjectLiteral ? config.objectLiteralSpaces : config.when;
if (spacing === SPACING.always) {
if (!sourceCode.isSpaceBetweenTokens(first, second)) {
reportRequiredBeginningSpace(node, first);
Expand Down

0 comments on commit 7b9d9ad

Please sign in to comment.