eslint-plugin-react
Advanced tools
Comparing version 7.34.3 to 7.34.4
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -64,2 +64,3 @@ const getText = require('../util/eslint').getText; | ||
/** @type {Record<string, { element: string, message?: string }>} */ | ||
const indexedForbidConfigs = {}; | ||
@@ -66,0 +67,0 @@ |
@@ -8,3 +8,5 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const repeat = require('string.prototype.repeat'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -172,3 +174,3 @@ const getSourceCode = require('../util/eslint').getSourceCode; | ||
let indentation; | ||
let spaces = []; | ||
let spaces = ''; | ||
switch (expectedLocation) { | ||
@@ -187,5 +189,5 @@ case 'props-aligned': | ||
// Non-whitespace characters were included in the column offset | ||
spaces = new Array(+correctColumn + 1 - indentation.length); | ||
spaces = repeat(' ', +correctColumn - indentation.length); | ||
} | ||
return indentation + spaces.join(' '); | ||
return indentation + spaces; | ||
} | ||
@@ -192,0 +194,0 @@ |
@@ -8,2 +8,4 @@ /** | ||
const repeat = require('string.prototype.repeat'); | ||
const astUtil = require('../util/ast'); | ||
@@ -57,3 +59,3 @@ const docsUrl = require('../util/docsUrl'); | ||
fix(fixer) { | ||
const indent = Array(opening.loc.start.column + 1).join(' '); | ||
const indent = repeat(' ', opening.loc.start.column); | ||
if (astUtil.isNodeFirstInLine(context, node)) { | ||
@@ -60,0 +62,0 @@ return fixer.replaceTextRange( |
@@ -14,3 +14,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -17,0 +17,0 @@ const getSourceCode = require('../util/eslint').getSourceCode; |
@@ -33,2 +33,4 @@ /** | ||
const repeat = require('string.prototype.repeat'); | ||
const astUtil = require('../util/ast'); | ||
@@ -134,3 +136,4 @@ const docsUrl = require('../util/docsUrl'); | ||
return fixer.replaceTextRange([node.range[0] - node.loc.start.column, node.range[0]], | ||
Array(needed + 1).join(indentType === 'space' ? ' ' : '\t')); | ||
repeat(indentType === 'space' ? ' ' : '\t', needed) | ||
); | ||
}, | ||
@@ -137,0 +140,0 @@ }); |
@@ -34,2 +34,3 @@ /** | ||
const matchAll = require('string.prototype.matchall'); | ||
const repeat = require('string.prototype.repeat'); | ||
@@ -113,3 +114,3 @@ const astUtil = require('../util/ast'); | ||
function getFixerFunction(node, needed) { | ||
const indent = Array(needed + 1).join(indentChar); | ||
const indent = repeat(indentChar, needed); | ||
@@ -116,0 +117,0 @@ if (node.type === 'JSXText' || node.type === 'Literal') { |
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const includes = require('array-includes'); | ||
@@ -11,0 +11,0 @@ const variableUtil = require('../util/variable'); |
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -11,0 +11,0 @@ const report = require('../util/report'); |
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -11,0 +11,0 @@ const eslintUtil = require('../util/eslint'); |
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const astUtil = require('../util/ast'); | ||
@@ -121,2 +121,4 @@ const docsUrl = require('../util/docsUrl'); | ||
const name = /** @type {keyof iteratorFunctionsToIndexParamPosition} */ (callee.property.name); | ||
const callbackArg = isUsingReactChildren(node) | ||
@@ -136,3 +138,3 @@ ? node.arguments[1] | ||
const indexParamPosition = iteratorFunctionsToIndexParamPosition[callee.property.name]; | ||
const indexParamPosition = iteratorFunctionsToIndexParamPosition[name]; | ||
if (params.length < indexParamPosition + 1) { | ||
@@ -139,0 +141,0 @@ return null; |
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const fromEntries = require('object.fromentries/polyfill')(); | ||
@@ -11,0 +11,0 @@ |
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -495,6 +495,6 @@ const getText = require('../util/eslint').getText; | ||
if (has(DOM_ATTRIBUTE_NAMES, name)) { | ||
return DOM_ATTRIBUTE_NAMES[name]; | ||
return DOM_ATTRIBUTE_NAMES[/** @type {keyof DOM_ATTRIBUTE_NAMES} */ (name)]; | ||
} | ||
if (has(SVGDOM_ATTRIBUTE_NAMES, name)) { | ||
return SVGDOM_ATTRIBUTE_NAMES[name]; | ||
return SVGDOM_ATTRIBUTE_NAMES[/** @type {keyof SVGDOM_ATTRIBUTE_NAMES} */ (name)]; | ||
} | ||
@@ -597,3 +597,3 @@ const names = getDOMPropertyNames(context); | ||
// Some attributes are allowed on some tags only | ||
const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[name] : null; | ||
const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[/** @type {keyof ATTRIBUTE_TAGS_MAP} */ (name)] : null; | ||
if (tagName && allowedTags) { | ||
@@ -600,0 +600,0 @@ // Scenario 1A: Allowed attribute found where not supposed to, report it |
@@ -8,3 +8,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
const entries = require('object.entries'); | ||
@@ -128,2 +128,3 @@ const values = require('object.values'); | ||
create: Components.detect((context, components) => { | ||
/** @satisfies {Record<string, { node: ASTNode, score: number, closest: { distance: number, ref: { node: null | ASTNode, index: number } } }>} */ | ||
const errors = {}; | ||
@@ -292,14 +293,15 @@ const methodsOrder = getMethodsOrder(context.options[0]); | ||
function dedupeErrors() { | ||
for (const i in errors) { | ||
if (has(errors, i)) { | ||
const index = errors[i].closest.ref.index; | ||
if (errors[index]) { | ||
if (errors[i].score > errors[index].score) { | ||
delete errors[index]; | ||
} else { | ||
delete errors[i]; | ||
} | ||
entries(errors).forEach((entry) => { | ||
const i = entry[0]; | ||
const error = entry[1]; | ||
const index = error.closest.ref.index; | ||
if (errors[index]) { | ||
if (error.score > errors[index].score) { | ||
delete errors[index]; | ||
} else { | ||
delete errors[i]; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
@@ -306,0 +308,0 @@ |
@@ -233,3 +233,6 @@ /** | ||
function handleFunctionComponent(node) { | ||
const firstArg = node.params[0].typeAnnotation && node.params[0].typeAnnotation.typeAnnotation; | ||
const firstArg = node.params | ||
&& node.params.length > 0 | ||
&& node.params[0].typeAnnotation | ||
&& node.params[0].typeAnnotation.typeAnnotation; | ||
if (firstArg && firstArg.type === 'TSTypeReference') { | ||
@@ -236,0 +239,0 @@ const propType = typeAnnotations.get(firstArg.typeName.name) |
@@ -9,3 +9,3 @@ /** | ||
const has = require('object.hasown/polyfill')(); | ||
const has = require('hasown'); | ||
@@ -12,0 +12,0 @@ const docsUrl = require('../util/docsUrl'); |
@@ -648,2 +648,13 @@ /** | ||
const rightMostName = getRightMostTypeName(node.typeName); | ||
if ( | ||
leftMostName === 'React' | ||
&& ( | ||
rightMostName === 'HTMLAttributes' | ||
|| rightMostName === 'HTMLElement' | ||
|| rightMostName === 'HTMLProps' | ||
) | ||
) { | ||
this.shouldSpecifyClassNameProp = true; | ||
} | ||
const importedName = localToImportedMap[rightMostName]; | ||
@@ -839,2 +850,10 @@ const idx = genericTypeParamIndexWherePropsArePresent[ | ||
} | ||
if (this.shouldSpecifyClassNameProp) { | ||
this.declaredPropTypes.className = { | ||
fullName: 'className', | ||
name: 'className', | ||
isRequired: false, | ||
}; | ||
} | ||
this.foundDeclaredPropertiesList.forEach((tsInterfaceBody) => { | ||
@@ -841,0 +860,0 @@ if (tsInterfaceBody && (tsInterfaceBody.type === 'TSPropertySignature' || tsInterfaceBody.type === 'TSMethodSignature')) { |
{ | ||
"name": "eslint-plugin-react", | ||
"version": "7.34.3", | ||
"version": "7.34.4", | ||
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>", | ||
@@ -36,2 +36,3 @@ "description": "React specific linting rules for ESLint", | ||
"estraverse": "^5.3.0", | ||
"hasown": "^2.0.2", | ||
"jsx-ast-utils": "^2.4.1 || ^3.0.0", | ||
@@ -41,3 +42,2 @@ "minimatch": "^3.1.2", | ||
"object.fromentries": "^2.0.8", | ||
"object.hasown": "^1.1.4", | ||
"object.values": "^1.2.0", | ||
@@ -47,3 +47,4 @@ "prop-types": "^15.8.1", | ||
"semver": "^6.3.1", | ||
"string.prototype.matchall": "^4.0.11" | ||
"string.prototype.matchall": "^4.0.11", | ||
"string.prototype.repeat": "^1.0.0" | ||
}, | ||
@@ -69,3 +70,3 @@ "devDependencies": { | ||
"eslint-remote-tester": "^3.0.1", | ||
"eslint-remote-tester-repositories": "^2.0.0", | ||
"eslint-remote-tester-repositories": "^1.0.1", | ||
"eslint-scope": "^3.7.3", | ||
@@ -110,5 +111,6 @@ "espree": "^3.5.4", | ||
"tsconfig.json", | ||
".markdownlint*" | ||
".markdownlint*", | ||
"types" | ||
] | ||
} | ||
} |
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
821936
22102
20
+ Addedhasown@^2.0.2
+ Addedstring.prototype.repeat@1.0.0(transitive)
- Removedobject.hasown@^1.1.4
- Removedobject.hasown@1.1.4(transitive)