eslint-plugin-react
Advanced tools
Comparing version 7.21.3 to 7.21.4
@@ -40,3 +40,3 @@ /** | ||
const configuration = context.options[0] || DEFAULT_OPTION; | ||
const ignoreClassFields = context.options[1] && context.options[1].ignoreClassFields === true || false; | ||
const ignoreClassFields = (context.options[1] && (context.options[1].ignoreClassFields === true)) || false; | ||
@@ -43,0 +43,0 @@ /** |
@@ -96,3 +96,3 @@ /** | ||
if ( | ||
node.property | ||
(node.property | ||
&& ( | ||
@@ -104,3 +104,3 @@ !node.computed | ||
&& !isAllowedAssignment(node) | ||
) || ( | ||
)) || ( | ||
(node.property.type === 'Literal' || node.property.type === 'JSXText') | ||
@@ -107,0 +107,0 @@ && node.property.value === 'propTypes' |
@@ -65,2 +65,6 @@ /** | ||
let indentSize = 4; | ||
const line = { | ||
isUsingOperator: false, | ||
currentOperator: false | ||
}; | ||
@@ -123,2 +127,9 @@ if (context.options.length) { | ||
const indent = regExp.exec(src); | ||
const useOperator = /^([ ]|[\t])*[:]/.test(src) || /^([ ]|[\t])*[?]/.test(src); | ||
line.currentOperator = false; | ||
if (useOperator) { | ||
line.isUsingOperator = true; | ||
line.currentOperator = true; | ||
} | ||
return indent ? indent[0].length : 0; | ||
@@ -135,2 +146,6 @@ } | ||
const nodeIndent = getNodeIndent(node); | ||
if (line.isUsingOperator && !line.currentOperator && indentSize !== 'first') { | ||
indent += indentSize; | ||
line.isUsingOperator = false; | ||
} | ||
if ( | ||
@@ -137,0 +152,0 @@ node.type !== 'ArrayExpression' && node.type !== 'ObjectExpression' |
@@ -330,3 +330,3 @@ /** | ||
// Use the parent in a list or an array | ||
if (prevToken.type === 'JSXText' || prevToken.type === 'Punctuator' && prevToken.value === ',') { | ||
if (prevToken.type === 'JSXText' || ((prevToken.type === 'Punctuator') && prevToken.value === ',')) { | ||
prevToken = sourceCode.getNodeByRangeIndex(prevToken.range[0]); | ||
@@ -333,0 +333,0 @@ prevToken = prevToken.type === 'Literal' || prevToken.type === 'JSXText' ? prevToken.parent : prevToken; |
@@ -49,3 +49,3 @@ /** | ||
function hasJSX(node) { | ||
return jsxUtil.isJSX(node) || isExpression(node) && jsxUtil.isJSX(node.expression); | ||
return jsxUtil.isJSX(node) || (isExpression(node) && jsxUtil.isJSX(node.expression)); | ||
} | ||
@@ -91,6 +91,6 @@ | ||
return jsxUtil.isJSX(writeExpr) | ||
&& writeExpr | ||
|| (writeExpr && writeExpr.type === 'Identifier') | ||
&& findJSXElementOrFragment(variables, writeExpr.name); | ||
return (jsxUtil.isJSX(writeExpr) | ||
&& writeExpr) | ||
|| ((writeExpr && writeExpr.type === 'Identifier') | ||
&& findJSXElementOrFragment(variables, writeExpr.name)); | ||
} | ||
@@ -97,0 +97,0 @@ } |
@@ -78,3 +78,3 @@ /** | ||
options.allow === 'single-child' | ||
|| options.allow === 'literal' && (child.type === 'Literal' || child.type === 'JSXText') | ||
|| (options.allow === 'literal' && (child.type === 'Literal' || child.type === 'JSXText')) | ||
) { | ||
@@ -81,0 +81,0 @@ return; |
@@ -67,3 +67,3 @@ /** | ||
const component = components.get(utils.getParentComponent()); | ||
const setStateUsages = component && component.setStateUsages || []; | ||
const setStateUsages = (component && component.setStateUsages) || []; | ||
setStateUsages.push(callee); | ||
@@ -70,0 +70,0 @@ components.set(node, { |
@@ -35,3 +35,3 @@ /** | ||
const component = components.get(utils.getParentStatelessComponent()); | ||
if (!component || component.node && component.node.parent && component.node.parent.type === 'Property') { | ||
if (!component || (component.node && component.node.parent && component.node.parent.type === 'Property')) { | ||
return; | ||
@@ -38,0 +38,0 @@ } |
@@ -242,3 +242,3 @@ /** | ||
function getIgnoreConfig() { | ||
return context.options[0] && context.options[0].ignore || DEFAULTS.ignore; | ||
return (context.options[0] && context.options[0].ignore) || DEFAULTS.ignore; | ||
} | ||
@@ -245,0 +245,0 @@ |
@@ -105,2 +105,7 @@ /** | ||
if (prop.node && prop.node.typeAnnotation && prop.node.typeAnnotation.typeAnnotation | ||
&& prop.node.typeAnnotation.typeAnnotation.type === 'TSNeverKeyword') { | ||
return; | ||
} | ||
if (prop.node && !isPropUsed(component, prop)) { | ||
@@ -107,0 +112,0 @@ context.report({ |
@@ -108,3 +108,3 @@ /** | ||
&& parent.type === 'MethodDefinition' && ( | ||
parent.static && parent.key.name === 'getDerivedStateFromProps' | ||
(parent.static && parent.key.name === 'getDerivedStateFromProps') | ||
|| classMethods.indexOf(parent.key.name) !== -1 | ||
@@ -111,0 +111,0 @@ ) |
@@ -16,3 +16,3 @@ /** | ||
function isCovariant(node) { | ||
return node.variance && node.variance.kind === 'plus' || node.parent.parent.parent.id && node.parent.parent.parent.id.name === '$ReadOnly'; | ||
return (node.variance && (node.variance.kind === 'plus')) || (node.parent.parent.parent.id && (node.parent.parent.parent.id.name === '$ReadOnly')); | ||
} | ||
@@ -19,0 +19,0 @@ |
@@ -185,3 +185,3 @@ /** | ||
const isDisplayName = name === 'displayName'; | ||
const isPropTypes = name === 'propTypes' || name === 'props' && property.typeAnnotation; | ||
const isPropTypes = name === 'propTypes' || ((name === 'props') && property.typeAnnotation); | ||
const contextTypes = name === 'contextTypes'; | ||
@@ -188,0 +188,0 @@ const defaultProps = name === 'defaultProps'; |
@@ -70,4 +70,4 @@ /** | ||
return ( | ||
configuration.component && isComponent(node) | ||
|| configuration.html && jsxUtil.isDOMComponent(node) | ||
(configuration.component && isComponent(node)) | ||
|| (configuration.html && jsxUtil.isDOMComponent(node)) | ||
) && !node.selfClosing && (childrenIsEmpty(node) || childrenIsMultilineSpaces(node)); | ||
@@ -74,0 +74,0 @@ } |
@@ -357,5 +357,5 @@ /** | ||
// 1st property is placed before the 2nd one in reference and in current component | ||
|| refIndexA < refIndexB && classIndexA < classIndexB | ||
|| ((refIndexA < refIndexB) && (classIndexA < classIndexB)) | ||
// 1st property is placed after the 2nd one in reference and in current component | ||
|| refIndexA > refIndexB && classIndexA > classIndexB | ||
|| ((refIndexA > refIndexB) && (classIndexA > classIndexB)) | ||
) { | ||
@@ -362,0 +362,0 @@ return { |
@@ -41,3 +41,3 @@ /** | ||
create(context) { | ||
const allowed = new Set(context.options.length > 0 && context.options[0].allow || []); | ||
const allowed = new Set(((context.options.length > 0) && context.options[0].allow) || []); | ||
@@ -44,0 +44,0 @@ /** |
@@ -752,4 +752,4 @@ /** | ||
const component = components.get(componentNode); | ||
let declaredPropTypes = component && component.declaredPropTypes || {}; | ||
let ignorePropsValidation = component && component.ignorePropsValidation || false; | ||
let declaredPropTypes = (component && component.declaredPropTypes) || {}; | ||
let ignorePropsValidation = (component && component.ignorePropsValidation) || false; | ||
switch (propTypes && propTypes.type) { | ||
@@ -814,4 +814,4 @@ case 'ObjectTypeAnnotation': | ||
while (n) { | ||
if (n.type === 'AssignmentExpression' && propsUtil.isPropTypesDeclaration(n.left) | ||
|| (n.type === 'ClassProperty' || n.type === 'Property') && propsUtil.isPropTypesDeclaration(n)) { | ||
if (((n.type === 'AssignmentExpression') && propsUtil.isPropTypesDeclaration(n.left)) | ||
|| ((n.type === 'ClassProperty' || n.type === 'Property') && propsUtil.isPropTypesDeclaration(n))) { | ||
// Found a propType used inside of another propType. This is not considered usage, we'll still validate | ||
@@ -818,0 +818,0 @@ // this component. |
@@ -359,4 +359,4 @@ /** | ||
const component = components.get(utils.getParentComponent()); | ||
const usedPropTypes = component && component.usedPropTypes || []; | ||
let ignoreUnusedPropTypesValidation = component && component.ignoreUnusedPropTypesValidation || false; | ||
const usedPropTypes = (component && component.usedPropTypes) || []; | ||
let ignoreUnusedPropTypesValidation = (component && component.ignoreUnusedPropTypesValidation) || false; | ||
@@ -423,3 +423,3 @@ switch (type) { | ||
param.type === 'ObjectPattern' | ||
|| param.type === 'AssignmentPattern' && param.left.type === 'ObjectPattern' | ||
|| ((param.type === 'AssignmentPattern') && (param.left.type === 'ObjectPattern')) | ||
); | ||
@@ -426,0 +426,0 @@ |
{ | ||
"name": "eslint-plugin-react", | ||
"version": "7.21.3", | ||
"version": "7.21.4", | ||
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>", | ||
@@ -36,3 +36,3 @@ "description": "React specific linting rules for ESLint", | ||
"has": "^1.0.3", | ||
"jsx-ast-utils": "^2.4.1", | ||
"jsx-ast-utils": "^2.4.1 || ^3.0.0", | ||
"object.entries": "^1.1.2", | ||
@@ -39,0 +39,0 @@ "object.fromentries": "^2.0.2", |
@@ -42,3 +42,3 @@ ESLint-plugin-React | ||
"pragma": "React", // Pragma to use, default to "React" | ||
"fragment": "React.Fragment", // Fragment to use, default to "React.Fragment" | ||
"fragment": "Fragment", // Fragment to use (may be a property of <pragma>), default to "Fragment" | ||
"version": "detect", // React version. "detect" automatically picks the version you have installed. | ||
@@ -45,0 +45,0 @@ // You can also use `16.0`, `16.3`, etc, if you want to override the detected value. |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
741048
15841
+ Addedarray.prototype.flat@1.3.2(transitive)
+ Addedjsx-ast-utils@3.3.5(transitive)
- Removedjsx-ast-utils@2.4.1(transitive)