Skip to content

Commit

Permalink
[Dev Deps] update @types/eslint, @types/estree, @types/node, `@…
Browse files Browse the repository at this point in the history
…typescript-eslint/parser`, `coveralls`, `eslint-config-airbnb-base`, `eslint-plugin-import`, `typescript`

 - `npm run lint -- --quiet --fix`
  • Loading branch information
ljharb committed May 13, 2020
1 parent f94d851 commit 2598b1e
Show file tree
Hide file tree
Showing 52 changed files with 110 additions and 109 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
"consistent-return": 0,

"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],

"prefer-object-spread": 0,
"function-paren-newline": 0,
"no-plusplus": 1,
"no-param-reassign": 1,
"no-mixed-operators": 1,
"no-restricted-syntax": 1,
"strict": [2, "safe"],
"valid-jsdoc": [2, {
"requireReturn": false,
"requireParamDescription": false,
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ const allRules = {
/* eslint-enable */

function filterRules(rules, predicate) {
return fromEntries(entries(rules).filter(entry => predicate(entry[1])));
return fromEntries(entries(rules).filter((entry) => predicate(entry[1])));
}

function configureAsError(rules) {
return fromEntries(Object.keys(rules).map(key => [`react/${key}`, 2]));
return fromEntries(Object.keys(rules).map((key) => [`react/${key}`, 2]));
}

const activeRules = filterRules(allRules, rule => !rule.meta.deprecated);
const activeRules = filterRules(allRules, (rule) => !rule.meta.deprecated);
const activeRulesConfig = configureAsError(activeRules);

const deprecatedRules = filterRules(allRules, rule => rule.meta.deprecated);
const deprecatedRules = filterRules(allRules, (rule) => rule.meta.deprecated);

module.exports = {
deprecatedRules,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ module.exports = {
if (!node || !Array.isArray(args)) {
return;
}
args.filter(arg => arg.type === 'ObjectExpression').forEach(object => validatePropNaming(node, object.properties));
args.filter((arg) => arg.type === 'ObjectExpression').forEach((object) => validatePropNaming(node, object.properties));
}

// --------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/button-has-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {
}

function checkValue(node, value) {
const q = x => `"${x}"`;
const q = (x) => `"${x}"`;
if (!(value in configuration)) {
context.report({
node,
Expand Down Expand Up @@ -126,7 +126,7 @@ module.exports = {
}

const props = node.arguments[1].properties;
const typeProp = props.find(prop => prop.key && prop.key.name === 'type');
const typeProp = props.find((prop) => prop.key && prop.key.name === 'type');

if (!typeProp || typeProp.value.type !== 'Literal') {
reportMissing(node);
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/default-props-match-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
const list = components.list();

// If no defaultProps could be found, we don't report anything.
Object.keys(list).filter(component => list[component].defaultProps).forEach((component) => {
Object.keys(list).filter((component) => list[component].defaultProps).forEach((component) => {
reportInvalidDefaultProps(
list[component].declaredPropTypes,
list[component].defaultProps || {}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module.exports = {
'Program:exit'() {
const list = components.list();
// Report missing display name for all components
Object.keys(list).filter(component => !list[component].hasDisplayName).forEach((component) => {
Object.keys(list).filter((component) => !list[component].hasDisplayName).forEach((component) => {
reportMissingDisplayName(list[component]);
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/forbid-foreign-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = {
},

ObjectPattern(node) {
const propTypesNode = node.properties.find(property => property.type === 'Property' && property.key.name === 'propTypes');
const propTypesNode = node.properties.find((property) => property.type === 'Property' && property.key.name === 'propTypes');

if (propTypesNode) {
context.report({
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/function-component-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = {
if (isUnfixableBecauseOfExport(node)) return;
if (isFunctionExpressionWithName(node)) return;

return fixer => fixer.replaceTextRange(options.range, buildFunction(options.template, {
return (fixer) => fixer.replaceTextRange(options.range, buildFunction(options.template, {
typeAnnotation,
typeParams: getNodeText(node.typeParameters, source),
params: getParams(node, source),
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-boolean-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const NEVER = 'never';
const errorData = new WeakMap();
function getErrorData(exceptions) {
if (!errorData.has(exceptions)) {
const exceptionProps = Array.from(exceptions, name => `\`${name}\``).join(', ');
const exceptionProps = Array.from(exceptions, (name) => `\`${name}\``).join(', ');
const exceptionsMessage = exceptions.size > 0 ? ` for the following props: ${exceptionProps}` : '';
errorData.set(exceptions, {exceptionsMessage});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-child-element-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ module.exports = {
const TEXT_FOLLOWING_ELEMENT_PATTERN = /^\s*\n\s*\S/;
const TEXT_PRECEDING_ELEMENT_PATTERN = /\S\s*\n\s*$/;

const elementName = node => (
const elementName = (node) => (
node.openingElement
&& node.openingElement.name
&& node.openingElement.name.type === 'JSXIdentifier'
&& node.openingElement.name.name
);

const isInlineElement = node => (
const isInlineElement = (node) => (
node.type === 'JSXElement'
&& INLINE_ELEMENTS.has(elementName(node))
);
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/jsx-curly-brace-presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = {

function wrapNonHTMLEntities(text) {
const HTML_ENTITY = '<HTML_ENTITY>';
const withCurlyBraces = text.split(HTML_ENTITY_REGEX()).map(word => (
const withCurlyBraces = text.split(HTML_ENTITY_REGEX()).map((word) => (
word === '' ? '' : `{${JSON.stringify(word)}}`
)).join(HTML_ENTITY);

Expand Down Expand Up @@ -292,19 +292,19 @@ module.exports = {
if (!children) {
return false;
}
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
const childrenExcludingWhitespaceLiteral = children.filter((child) => !isWhiteSpaceLiteral(child));
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);

return adjSiblings.some(x => x.type && x.type === 'JSXExpressionContainer');
return adjSiblings.some((x) => x.type && x.type === 'JSXExpressionContainer');
}
function hasAdjacentJsx(node, children) {
if (!children) {
return false;
}
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
const childrenExcludingWhitespaceLiteral = children.filter((child) => !isWhiteSpaceLiteral(child));
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);

return adjSiblings.some(x => x.type && arrayIncludes(['JSXExpressionContainer', 'JSXElement'], x.type));
return adjSiblings.some((x) => x.type && arrayIncludes(['JSXExpressionContainer', 'JSXElement'], x.type));
}
function shouldCheckForUnnecessaryCurly(parent, node, config) {
// Bail out if the parent is a JSXAttribute & its contents aren't
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-curly-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module.exports = {
context.report({
node: leftCurly,
messageId: 'expectedAfter',
fix: fixer => fixer.insertTextAfter(leftCurly, '\n')
fix: (fixer) => fixer.insertTextAfter(leftCurly, '\n')
});
}

Expand All @@ -164,7 +164,7 @@ module.exports = {
context.report({
node: rightCurly,
messageId: 'expectedBefore',
fix: fixer => fixer.insertTextBefore(rightCurly, '\n')
fix: (fixer) => fixer.insertTextBefore(rightCurly, '\n')
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-filename-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
}

const allowedExtensions = getExtensionsConfig();
const isAllowedExtension = allowedExtensions.some(extension => filename.slice(-extension.length) === extension);
const isAllowedExtension = allowedExtensions.some((extension) => filename.slice(-extension.length) === extension);

if (isAllowedExtension) {
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ module.exports = {
const regExp = indentType === 'space' ? /\n( *)[\t ]*\S/g : /\n(\t*)[\t ]*\S/g;
const nodeIndentsPerLine = Array.from(
matchAll(String(value), regExp),
match => (match[1] ? match[1].length : 0)
(match) => (match[1] ? match[1].length : 0)
);
const hasFirstInLineNode = nodeIndentsPerLine.length > 0;
if (
hasFirstInLineNode
&& !nodeIndentsPerLine.every(actualIndent => actualIndent === indent)
&& !nodeIndentsPerLine.every((actualIndent) => actualIndent === indent)
) {
nodeIndentsPerLine.forEach((nodeIndent) => {
report(node, indent, nodeIndent);
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
}

function getReturnStatement(body) {
return body.filter(item => item.type === 'ReturnStatement')[0];
return body.filter((item) => item.type === 'ReturnStatement')[0];
}

return {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-no-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module.exports = {

function getBlockStatementAncestors(node) {
return context.getAncestors(node).reverse().filter(
ancestor => ancestor.type === 'BlockStatement'
(ancestor) => ancestor.type === 'BlockStatement'
);
}

Expand All @@ -132,7 +132,7 @@ module.exports = {

function findVariableViolation(node, name) {
getBlockStatementAncestors(node).find(
block => reportVariableViolation(node, name, block.range[0])
(block) => reportVariableViolation(node, name, block.range[0])
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-no-script-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function hasJavaScriptProtocol(attr) {

function shouldVerifyElement(node, config) {
const name = node.name && node.name.name;
return name === 'a' || config.find(i => i.name === name);
return name === 'a' || config.find((i) => i.name === name);
}

function shouldVerifyProp(node, config) {
Expand All @@ -33,7 +33,7 @@ function shouldVerifyProp(node, config) {
return true;
}

const el = config.find(i => i.name === parentName);
const el = config.find((i) => i.name === parentName);
if (!el) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-no-target-blank.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ function isTargetBlank(attr) {
}

function hasExternalLink(element, linkAttribute) {
return element.attributes.some(attr => attr.name
return element.attributes.some((attr) => attr.name
&& attr.name.name === linkAttribute
&& attr.value.type === 'Literal'
&& /^(?:\w+:|\/\/)/.test(attr.value.value));
}

function hasDynamicLink(element, linkAttribute) {
return element.attributes.some(attr => attr.name
return element.attributes.some((attr) => attr.name
&& attr.name.name === linkAttribute
&& attr.value.type === 'JSXExpressionContainer');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-props-no-spreading.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ module.exports = {
const ignoreExplicitSpread = (configuration.explicitSpread || DEFAULTS.explicitSpread) === OPTIONS.ignore;
const exceptions = configuration.exceptions || DEFAULTS.exceptions;
const isException = (tag, allExceptions) => allExceptions.indexOf(tag) !== -1;
const isProperty = property => property.type === 'Property';
const getTagNameFromMemberExpression = node => `${node.property.parent.object.name}.${node.property.name}`;
const isProperty = (property) => property.type === 'Property';
const getTagNameFromMemberExpression = (node) => `${node.property.parent.object.name}.${node.property.name}`;
return {
JSXSpreadAttribute(node) {
const jsxOpeningElement = node.parent.name;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-sort-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = {
* @returns {ASTNode|null} Return null if the variable could not be found, ASTNode otherwise.
*/
function findVariableByName(name) {
const variable = variableUtil.variablesInScope(context).find(item => item.name === name);
const variable = variableUtil.variablesInScope(context).find((item) => item.name === name);

if (!variable || !variable.defs[0] || !variable.defs[0].node) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/jsx-sort-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const generateFixerFunction = (node, context, reservedList) => {
const sortableAttributeGroups = getGroupsOfSortableAttributes(attributes);
const sortedAttributeGroups = sortableAttributeGroups
.slice(0)
.map(group => group.slice(0).sort((a, b) => contextCompare(a, b, options)));
.map((group) => group.slice(0).sort((a, b) => contextCompare(a, b, options)));

return function fixFunction(fixer) {
const fixers = [];
Expand Down Expand Up @@ -176,7 +176,7 @@ function validateReservedFirstConfig(context, reservedFirst) {
if (reservedFirst) {
if (Array.isArray(reservedFirst)) {
// Only allow a subset of reserved words in customized lists
const nonReservedWords = reservedFirst.filter(word => !isReservedPropName(
const nonReservedWords = reservedFirst.filter((word) => !isReservedPropName(
word,
RESERVED_PROPS_LIST
));
Expand Down Expand Up @@ -260,7 +260,7 @@ module.exports = {
JSXOpeningElement(node) {
// `dangerouslySetInnerHTML` is only "reserved" on DOM components
if (reservedFirst && !jsxUtil.isDOMComponent(node)) {
reservedList = reservedList.filter(prop => prop !== 'dangerouslySetInnerHTML');
reservedList = reservedList.filter((prop) => prop !== 'dangerouslySetInnerHTML');
}

node.attributes.reduce((memo, decl, idx, attrs) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/jsx-wrap-multilines.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module.exports = {
const option = getOption(type);

if ((option === true || option === 'parens') && !isParenthesised(node) && isMultilines(node)) {
report(node, MISSING_PARENS, fixer => fixer.replaceText(node, `(${sourceCode.getText(node)})`));
report(node, MISSING_PARENS, (fixer) => fixer.replaceText(node, `(${sourceCode.getText(node)})`));
}

if (option === 'parens-new-line' && isMultilines(node)) {
Expand All @@ -162,13 +162,13 @@ module.exports = {
report(
node,
MISSING_PARENS,
fixer => fixer.replaceTextRange(
(fixer) => fixer.replaceTextRange(
[tokenBefore.range[0], tokenAfter && (tokenAfter.value === ';' || tokenAfter.value === '}') ? tokenAfter.range[0] : node.range[1]],
`${trimTokenBeforeNewline(node, tokenBefore)}(\n${' '.repeat(node.loc.start.column)}${sourceCode.getText(node)}\n${' '.repeat(node.loc.start.column - 2)})`
)
);
} else {
report(node, MISSING_PARENS, fixer => fixer.replaceText(node, `(\n${sourceCode.getText(node)}\n)`));
report(node, MISSING_PARENS, (fixer) => fixer.replaceText(node, `(\n${sourceCode.getText(node)}\n)`));
}
} else {
const needsOpening = needsOpeningNewLine(node);
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-access-state-in-setstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ module.exports = {
while (current.type !== 'Program') {
if (isFirstArgumentInSetStateCall(current, node)) {
vars
.filter(v => v.scope === context.getScope() && v.variableName === node.name)
.filter((v) => v.scope === context.getScope() && v.variableName === node.name)
.forEach((v) => {
context.report({
node: v.node,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-children-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {
}

const props = node.arguments[1].properties;
const childrenProp = props.find(prop => prop.key && prop.key.name === 'children');
const childrenProp = props.find((prop) => prop.key && prop.key.name === 'children');

if (childrenProp) {
context.report({
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-danger-with-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
},
create(context) {
function findSpreadVariable(name) {
return variableUtil.variablesInScope(context).find(item => item.name === name);
return variableUtil.variablesInScope(context).find((item) => item.name === name);
}
/**
* Takes a ObjectExpression and returns the value of the prop if it has it
Expand Down Expand Up @@ -120,7 +120,7 @@ module.exports = {
let props = node.arguments[1];

if (props.type === 'Identifier') {
const variable = variableUtil.variablesInScope(context).find(item => item.name === props.name);
const variable = variableUtil.variablesInScope(context).find((item) => item.name === props.name);
if (variable && variable.defs.length && variable.defs[0].node.init) {
props = variable.defs[0].node.init;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ module.exports = {
}

values(MODULES).some((moduleNames) => {
moduleName = moduleNames.find(name => name === node.init.name);
moduleName = moduleNames.find((name) => name === node.init.name);
return moduleName;
});

Expand All @@ -153,7 +153,7 @@ module.exports = {
*/
function getLifeCycleMethods(node) {
const properties = astUtil.getComponentProperties(node);
return properties.map(property => ({
return properties.map((property) => ({
name: astUtil.getPropertyName(property),
node: astUtil.getPropertyNameNode(property)
}));
Expand All @@ -166,7 +166,7 @@ module.exports = {
function checkLifeCycleMethods(node) {
if (utils.isES5Component(node) || utils.isES6Component(node)) {
const methods = getLifeCycleMethods(node);
methods.forEach(method => checkDeprecation(node, method.name, method.node));
methods.forEach((method) => checkDeprecation(node, method.name, method.node));
}
}

Expand Down
Loading

0 comments on commit 2598b1e

Please sign in to comment.