Skip to content

Commit c3c97e3

Browse files
committed
[Dev Deps] update eslint-config-airbnb-base
1 parent 38628ed commit c3c97e3

File tree

5 files changed

+158
-128
lines changed

5 files changed

+158
-128
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
"prefer-object-spread": 0, // until node 8 is required
3131
"prefer-rest-params": 0, // until node 6 is required
3232
"prefer-spread": 0, // until node 6 is required
33+
"function-call-argument-newline": 1, // TODO: enable
3334
"function-paren-newline": 0,
3435
"no-plusplus": 1,
3536
"no-param-reassign": 1,
37+
"no-unreachable-loop": 1, // TODO: enable
3638
"no-restricted-syntax": [2, {
3739
"selector": "ObjectPattern",
3840
"message": "Object destructuring is not compatible with Node v4"

lib/rules/jsx-equals-spacing.js

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
},
3838

3939
create(context) {
40-
const config = context.options[0];
40+
const config = context.options[0] || 'never';
4141

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

67-
switch (config) {
68-
default:
69-
case 'never':
70-
if (spacedBefore) {
71-
report(context, messages.noSpaceBefore, 'noSpaceBefore', {
72-
node: attrNode,
73-
loc: equalToken.loc.start,
74-
fix(fixer) {
75-
return fixer.removeRange([attrNode.name.range[1], equalToken.range[0]]);
76-
},
77-
});
78-
}
79-
if (spacedAfter) {
80-
report(context, messages.noSpaceAfter, 'noSpaceAfter', {
81-
node: attrNode,
82-
loc: equalToken.loc.start,
83-
fix(fixer) {
84-
return fixer.removeRange([equalToken.range[1], attrNode.value.range[0]]);
85-
},
86-
});
87-
}
88-
break;
89-
case 'always':
90-
if (!spacedBefore) {
91-
report(context, messages.needSpaceBefore, 'needSpaceBefore', {
92-
node: attrNode,
93-
loc: equalToken.loc.start,
94-
fix(fixer) {
95-
return fixer.insertTextBefore(equalToken, ' ');
96-
},
97-
});
98-
}
99-
if (!spacedAfter) {
100-
report(context, messages.needSpaceAfter, 'needSpaceAfter', {
101-
node: attrNode,
102-
loc: equalToken.loc.start,
103-
fix(fixer) {
104-
return fixer.insertTextAfter(equalToken, ' ');
105-
},
106-
});
107-
}
108-
break;
67+
if (config === 'never') {
68+
if (spacedBefore) {
69+
report(context, messages.noSpaceBefore, 'noSpaceBefore', {
70+
node: attrNode,
71+
loc: equalToken.loc.start,
72+
fix(fixer) {
73+
return fixer.removeRange([attrNode.name.range[1], equalToken.range[0]]);
74+
},
75+
});
76+
}
77+
if (spacedAfter) {
78+
report(context, messages.noSpaceAfter, 'noSpaceAfter', {
79+
node: attrNode,
80+
loc: equalToken.loc.start,
81+
fix(fixer) {
82+
return fixer.removeRange([equalToken.range[1], attrNode.value.range[0]]);
83+
},
84+
});
85+
}
86+
} else if (config === 'always') {
87+
if (!spacedBefore) {
88+
report(context, messages.needSpaceBefore, 'needSpaceBefore', {
89+
node: attrNode,
90+
loc: equalToken.loc.start,
91+
fix(fixer) {
92+
return fixer.insertTextBefore(equalToken, ' ');
93+
},
94+
});
95+
}
96+
if (!spacedAfter) {
97+
report(context, messages.needSpaceAfter, 'needSpaceAfter', {
98+
node: attrNode,
99+
loc: equalToken.loc.start,
100+
fix(fixer) {
101+
return fixer.insertTextAfter(equalToken, ' ');
102+
},
103+
});
104+
}
109105
}
110106
});
111107
},

lib/util/propTypes.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,27 +170,31 @@ module.exports = function propTypesInstructions(context, components, utils) {
170170
type: 'shape',
171171
children: {},
172172
};
173-
iterateProperties(context, annotation.properties, (childKey, childValue, propNode) => {
174-
const fullName = [parentName, childKey].join('.');
175-
if (childKey || childValue) {
176-
const types = buildTypeAnnotationDeclarationTypes(childValue, fullName, seen);
177-
types.fullName = fullName;
178-
types.name = childKey;
179-
types.node = propNode;
180-
types.isRequired = !childValue.optional;
181-
shapeTypeDefinition.children[childKey] = types;
182-
}
183-
},
184-
(spreadNode) => {
185-
const key = astUtil.getKeyValue(context, spreadNode);
186-
const types = buildTypeAnnotationDeclarationTypes(spreadNode, key, seen);
187-
if (!types.children) {
188-
containsUnresolvedObjectTypeSpread = true;
189-
} else {
190-
Object.assign(shapeTypeDefinition, types.children);
173+
iterateProperties(
174+
context,
175+
annotation.properties,
176+
(childKey, childValue, propNode) => {
177+
const fullName = [parentName, childKey].join('.');
178+
if (childKey || childValue) {
179+
const types = buildTypeAnnotationDeclarationTypes(childValue, fullName, seen);
180+
types.fullName = fullName;
181+
types.name = childKey;
182+
types.node = propNode;
183+
types.isRequired = !childValue.optional;
184+
shapeTypeDefinition.children[childKey] = types;
185+
}
186+
},
187+
(spreadNode) => {
188+
const key = astUtil.getKeyValue(context, spreadNode);
189+
const types = buildTypeAnnotationDeclarationTypes(spreadNode, key, seen);
190+
if (!types.children) {
191+
containsUnresolvedObjectTypeSpread = true;
192+
} else {
193+
Object.assign(shapeTypeDefinition, types.children);
194+
}
195+
containsSpread = true;
191196
}
192-
containsSpread = true;
193-
});
197+
);
194198

195199
// Mark if this shape has spread or an indexer. We will know to consider all props from this shape as having propTypes,
196200
// but still have the ability to detect unused children of this shape.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "React specific linting rules for ESLint",
66
"main": "index.js",
77
"scripts": {
8-
"lint": "eslint ./",
8+
"lint": "eslint .",
99
"postlint": "npm run type-check",
1010
"pretest": "npm run lint",
1111
"test": "npm run unit-test",
@@ -57,7 +57,7 @@
5757
"aud": "^1.1.5",
5858
"babel-eslint": "^8 || ^9 || ^10.1.0",
5959
"eslint": "^3 || ^4 || ^5 || ^6 || ^7",
60-
"eslint-config-airbnb-base": "^14.2.1",
60+
"eslint-config-airbnb-base": "^15.0.0",
6161
"eslint-plugin-eslint-plugin": "^2.3.0 || ^3.5.3 || ^4.0.1",
6262
"eslint-plugin-import": "^2.25.2",
6363
"eslint-remote-tester": "^2.0.1",

0 commit comments

Comments
 (0)