eslint-plugin-react
Advanced tools
Comparing version 7.34.0 to 7.34.1
@@ -8,2 +8,3 @@ /** | ||
const flatMap = require('array.prototype.flatmap'); | ||
const values = require('object.values'); | ||
@@ -22,3 +23,3 @@ | ||
const messages = { | ||
patternMismatch: 'Prop name ({{propName}}) doesn\'t match rule ({{pattern}})', | ||
patternMismatch: 'Prop name `{{propName}}` doesn’t match rule `{{pattern}}`', | ||
}; | ||
@@ -269,3 +270,3 @@ | ||
function findAllTypeAnnotations(identifier, node) { | ||
if (node.type === 'TSTypeLiteral' || node.type === 'ObjectTypeAnnotation') { | ||
if (node.type === 'TSTypeLiteral' || node.type === 'ObjectTypeAnnotation' || node.type === 'TSInterfaceBody') { | ||
const currentNode = [].concat( | ||
@@ -369,2 +370,6 @@ objectTypeAnnotations.get(identifier.name) || [], | ||
TSInterfaceDeclaration(node) { | ||
findAllTypeAnnotations(node.id, node.body); | ||
}, | ||
// eslint-disable-next-line object-shorthand | ||
@@ -383,6 +388,8 @@ 'Program:exit'() { | ||
propType = objectTypeAnnotations.get(annotation.id.name); | ||
} else if (annotation.type === 'ObjectTypeAnnotation') { | ||
} else if (annotation.type === 'ObjectTypeAnnotation' || annotation.type === 'TSTypeLiteral') { | ||
propType = annotation; | ||
} else if (annotation.type === 'TSTypeReference') { | ||
propType = objectTypeAnnotations.get(annotation.typeName.name); | ||
} else if (annotation.type === 'TSIntersectionType') { | ||
propType = flatMap(annotation.types, (type) => objectTypeAnnotations.get(type.typeName.name)); | ||
} | ||
@@ -394,3 +401,3 @@ | ||
component.node, | ||
prop.properties || prop.members | ||
prop.properties || prop.members || prop.body | ||
); | ||
@@ -397,0 +404,0 @@ }); |
@@ -22,4 +22,4 @@ /** | ||
const defaultOptions = { | ||
ignoreMissingProperties: true, | ||
ignoreExclusiveCheckedAttribute: true, | ||
ignoreMissingProperties: false, | ||
ignoreExclusiveCheckedAttribute: false, | ||
}; | ||
@@ -97,3 +97,3 @@ | ||
if (options.ignoreExclusiveCheckedAttribute && propSet.has('defaultChecked')) { | ||
if (!options.ignoreExclusiveCheckedAttribute && propSet.has('defaultChecked')) { | ||
reportExclusiveCheckedAttribute(node); | ||
@@ -103,3 +103,3 @@ } | ||
if ( | ||
options.ignoreMissingProperties | ||
!options.ignoreMissingProperties | ||
&& !(propSet.has('onChange') || propSet.has('readOnly')) | ||
@@ -106,0 +106,0 @@ ) { |
@@ -249,3 +249,3 @@ /** | ||
if (node.arguments.length > 0 && astUtil.isFunctionLikeExpression(node.arguments[0])) { | ||
// Skip over React.forwardRef declarations that are embeded within | ||
// Skip over React.forwardRef declarations that are embedded within | ||
// a React.memo i.e. React.memo(React.forwardRef(/* ... */)) | ||
@@ -252,0 +252,0 @@ // This means that we raise a single error for the call to React.memo |
@@ -82,3 +82,3 @@ /** | ||
if (rightNode.type === 'ConditionalExpression') { | ||
if (rightNode.type === 'ConditionalExpression' || rightNode.type === 'LogicalExpression') { | ||
return fixer.replaceText(reportedNode, `${newText} && (${rightSideText})`); | ||
@@ -85,0 +85,0 @@ } |
@@ -241,2 +241,4 @@ /** | ||
'controls', | ||
// popovers | ||
'popover', 'popovertarget', 'popovertargetaction', | ||
]; | ||
@@ -433,3 +435,3 @@ | ||
function isValidDataAttribute(name) { | ||
return !/^data-xml/i.test(name) && /^data(-?[^:]*)$/.test(name); | ||
return !/^data-xml/i.test(name) && /^data-[^:]*$/.test(name); | ||
} | ||
@@ -436,0 +438,0 @@ |
{ | ||
"name": "eslint-plugin-react", | ||
"version": "7.34.0", | ||
"version": "7.34.1", | ||
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "React specific linting rules for ESLint", |
808592
21762
1