Skip to content

Commit

Permalink
[Dev Deps] update eslint-config-airbnb-base
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 10, 2021
1 parent 38628ed commit c3c97e3
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 128 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"prefer-object-spread": 0, // until node 8 is required
"prefer-rest-params": 0, // until node 6 is required
"prefer-spread": 0, // until node 6 is required
"function-call-argument-newline": 1, // TODO: enable
"function-paren-newline": 0,
"no-plusplus": 1,
"no-param-reassign": 1,
"no-unreachable-loop": 1, // TODO: enable
"no-restricted-syntax": [2, {
"selector": "ObjectPattern",
"message": "Object destructuring is not compatible with Node v4"
Expand Down
82 changes: 39 additions & 43 deletions lib/rules/jsx-equals-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
},

create(context) {
const config = context.options[0];
const config = context.options[0] || 'never';

/**
* Determines a given attribute node has an equal sign.
Expand All @@ -64,48 +64,44 @@ module.exports = {
const spacedBefore = sourceCode.isSpaceBetweenTokens(attrNode.name, equalToken);
const spacedAfter = sourceCode.isSpaceBetweenTokens(equalToken, attrNode.value);

switch (config) {
default:
case 'never':
if (spacedBefore) {
report(context, messages.noSpaceBefore, 'noSpaceBefore', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.removeRange([attrNode.name.range[1], equalToken.range[0]]);
},
});
}
if (spacedAfter) {
report(context, messages.noSpaceAfter, 'noSpaceAfter', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.removeRange([equalToken.range[1], attrNode.value.range[0]]);
},
});
}
break;
case 'always':
if (!spacedBefore) {
report(context, messages.needSpaceBefore, 'needSpaceBefore', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.insertTextBefore(equalToken, ' ');
},
});
}
if (!spacedAfter) {
report(context, messages.needSpaceAfter, 'needSpaceAfter', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.insertTextAfter(equalToken, ' ');
},
});
}
break;
if (config === 'never') {
if (spacedBefore) {
report(context, messages.noSpaceBefore, 'noSpaceBefore', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.removeRange([attrNode.name.range[1], equalToken.range[0]]);
},
});
}
if (spacedAfter) {
report(context, messages.noSpaceAfter, 'noSpaceAfter', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.removeRange([equalToken.range[1], attrNode.value.range[0]]);
},
});
}
} else if (config === 'always') {
if (!spacedBefore) {
report(context, messages.needSpaceBefore, 'needSpaceBefore', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.insertTextBefore(equalToken, ' ');
},
});
}
if (!spacedAfter) {
report(context, messages.needSpaceAfter, 'needSpaceAfter', {
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.insertTextAfter(equalToken, ' ');
},
});
}
}
});
},
Expand Down
44 changes: 24 additions & 20 deletions lib/util/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,31 @@ module.exports = function propTypesInstructions(context, components, utils) {
type: 'shape',
children: {},
};
iterateProperties(context, annotation.properties, (childKey, childValue, propNode) => {
const fullName = [parentName, childKey].join('.');
if (childKey || childValue) {
const types = buildTypeAnnotationDeclarationTypes(childValue, fullName, seen);
types.fullName = fullName;
types.name = childKey;
types.node = propNode;
types.isRequired = !childValue.optional;
shapeTypeDefinition.children[childKey] = types;
}
},
(spreadNode) => {
const key = astUtil.getKeyValue(context, spreadNode);
const types = buildTypeAnnotationDeclarationTypes(spreadNode, key, seen);
if (!types.children) {
containsUnresolvedObjectTypeSpread = true;
} else {
Object.assign(shapeTypeDefinition, types.children);
iterateProperties(
context,
annotation.properties,
(childKey, childValue, propNode) => {
const fullName = [parentName, childKey].join('.');
if (childKey || childValue) {
const types = buildTypeAnnotationDeclarationTypes(childValue, fullName, seen);
types.fullName = fullName;
types.name = childKey;
types.node = propNode;
types.isRequired = !childValue.optional;
shapeTypeDefinition.children[childKey] = types;
}
},
(spreadNode) => {
const key = astUtil.getKeyValue(context, spreadNode);
const types = buildTypeAnnotationDeclarationTypes(spreadNode, key, seen);
if (!types.children) {
containsUnresolvedObjectTypeSpread = true;
} else {
Object.assign(shapeTypeDefinition, types.children);
}
containsSpread = true;
}
containsSpread = true;
});
);

// Mark if this shape has spread or an indexer. We will know to consider all props from this shape as having propTypes,
// but still have the ability to detect unused children of this shape.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "React specific linting rules for ESLint",
"main": "index.js",
"scripts": {
"lint": "eslint ./",
"lint": "eslint .",
"postlint": "npm run type-check",
"pretest": "npm run lint",
"test": "npm run unit-test",
Expand Down Expand Up @@ -57,7 +57,7 @@
"aud": "^1.1.5",
"babel-eslint": "^8 || ^9 || ^10.1.0",
"eslint": "^3 || ^4 || ^5 || ^6 || ^7",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-eslint-plugin": "^2.3.0 || ^3.5.3 || ^4.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-remote-tester": "^2.0.1",
Expand Down
Loading

0 comments on commit c3c97e3

Please sign in to comment.