eslint-plugin-react
Advanced tools
Comparing version 7.33.1 to 7.33.2
@@ -9,2 +9,4 @@ /** | ||
const values = require('object.values'); | ||
const filter = require('es-iterator-helpers/Iterator.prototype.filter'); | ||
const forEach = require('es-iterator-helpers/Iterator.prototype.forEach'); | ||
@@ -274,4 +276,6 @@ const Components = require('../util/Components'); | ||
// Report missing display name for all context objects | ||
const contextsList = Array.from(contextObjects.values()).filter((v) => !v.hasDisplayName); | ||
contextsList.forEach((contextObj) => reportMissingContextDisplayName(contextObj)); | ||
forEach( | ||
filter(contextObjects.values(), (v) => !v.hasDisplayName), | ||
(contextObj) => reportMissingContextDisplayName(contextObj) | ||
); | ||
} | ||
@@ -278,0 +282,0 @@ }, |
@@ -8,2 +8,5 @@ /** | ||
const find = require('es-iterator-helpers/Iterator.prototype.find'); | ||
const from = require('es-iterator-helpers/Iterator.from'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -139,3 +142,3 @@ const report = require('../util/report'); | ||
const validStrategies = new Set(config.validStrategies || DEFAULT_VALID_STRATEGIES); | ||
const fixStrategy = Array.from(validStrategies)[0]; | ||
const fixStrategy = find(from(validStrategies), () => true); | ||
@@ -142,0 +145,0 @@ return { |
@@ -9,2 +9,5 @@ /** | ||
const iterFrom = require('es-iterator-helpers/Iterator.from'); | ||
const map = require('es-iterator-helpers/Iterator.prototype.map'); | ||
const docsUrl = require('../util/docsUrl'); | ||
@@ -71,3 +74,3 @@ const report = require('../util/report'); | ||
const config = Object.assign({}, defaults, context.options[0] || {}); | ||
config.allowedStrings = new Set(config.allowedStrings.map(trimIfString)); | ||
config.allowedStrings = new Set(map(iterFrom(config.allowedStrings), trimIfString)); | ||
@@ -74,0 +77,0 @@ function defaultMessageId() { |
@@ -10,3 +10,3 @@ /** | ||
const values = require('object.values'); | ||
const entries = require('object.entries'); | ||
const astUtil = require('../util/ast'); | ||
@@ -166,7 +166,18 @@ const componentUtil = require('../util/componentUtil'); | ||
if (!node.init) { | ||
return moduleName; | ||
return false; | ||
} | ||
values(MODULES).some((moduleNames) => { | ||
moduleName = moduleNames.find((name) => name === node.init.name); | ||
entries(MODULES).some((entry) => { | ||
const key = entry[0]; | ||
const moduleNames = entry[1]; | ||
if ( | ||
node.init.arguments | ||
&& node.init.arguments.length > 0 | ||
&& node.init.arguments[0] | ||
&& key === node.init.arguments[0].value | ||
) { | ||
moduleName = MODULES[key][0]; | ||
} else { | ||
moduleName = moduleNames.find((name) => name === node.init.name); | ||
} | ||
return moduleName; | ||
@@ -220,3 +231,3 @@ }); | ||
node.specifiers.filter(((s) => s.imported)).forEach((specifier) => { | ||
checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`); | ||
checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier); | ||
}); | ||
@@ -241,3 +252,3 @@ }, | ||
node.id.properties.filter((p) => p.type !== 'RestElement' && p.key).forEach((property) => { | ||
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`); | ||
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`, property); | ||
}); | ||
@@ -244,0 +255,0 @@ }, |
@@ -222,4 +222,5 @@ /** | ||
*/ | ||
const COMPONENT_ATTRIBUTE_MAP = new Map(); | ||
COMPONENT_ATTRIBUTE_MAP.set('rel', new Set(['link', 'a', 'area', 'form'])); | ||
const COMPONENT_ATTRIBUTE_MAP = new Map([ | ||
['rel', new Set(['link', 'a', 'area', 'form'])], | ||
]); | ||
@@ -393,3 +394,3 @@ const messages = { | ||
report(context, messages.onlyMeaningfulFor, 'onlyMeaningfulFor', { | ||
node, | ||
node: node.name, | ||
data: { | ||
@@ -413,3 +414,3 @@ attributeName: attribute, | ||
report(context, messages.emptyIsMeaningless, 'emptyIsMeaningless', { | ||
node, | ||
node: node.name, | ||
data: { attributeName: attribute }, | ||
@@ -440,3 +441,3 @@ suggest: [ | ||
report(context, messages.onlyStrings, 'onlyStrings', { | ||
node, | ||
node: node.value, | ||
data: { attributeName: attribute }, | ||
@@ -452,3 +453,3 @@ suggest: [ | ||
report(context, messages.onlyStrings, 'onlyStrings', { | ||
node, | ||
node: node.value, | ||
data: { attributeName: attribute }, | ||
@@ -539,3 +540,3 @@ suggest: [ | ||
report(context, messages.onlyMeaningfulFor, 'onlyMeaningfulFor', { | ||
node, | ||
node: prop.key, | ||
data: { | ||
@@ -542,0 +543,0 @@ attributeName: attribute, |
@@ -111,4 +111,7 @@ /** | ||
const propertyNode = astUtil.getComponentProperties(node) | ||
.find((property) => astUtil.getPropertyName(property) === method); | ||
report(context, messages.unsafeMethod, 'unsafeMethod', { | ||
node, | ||
node: propertyNode, | ||
data: { | ||
@@ -139,3 +142,5 @@ method, | ||
const methods = getLifeCycleMethods(node); | ||
methods.forEach((method) => checkUnsafe(node, method)); | ||
methods | ||
.sort((a, b) => a.localeCompare(b)) | ||
.forEach((method) => checkUnsafe(node, method)); | ||
} | ||
@@ -142,0 +147,0 @@ } |
@@ -11,2 +11,4 @@ /** | ||
const values = require('object.values'); | ||
const iterFrom = require('es-iterator-helpers/Iterator.from'); | ||
const map = require('es-iterator-helpers/Iterator.prototype.map'); | ||
@@ -271,13 +273,11 @@ const variableUtil = require('./variable'); | ||
/** @type {{[key: string]: Function}} */ | ||
const rule = {}; | ||
handlersByKey.forEach((fns, key) => { | ||
rule[key] = function mergedHandler(node) { | ||
fns.forEach((fn) => { | ||
/** @type {{ [key: string]: Function }} */ | ||
return fromEntries(map(iterFrom(handlersByKey), (entry) => [ | ||
entry[0], | ||
function mergedHandler(node) { | ||
entry[1].forEach((fn) => { | ||
fn(node); | ||
}); | ||
}; | ||
}); | ||
return rule; | ||
}, | ||
])); | ||
} | ||
@@ -284,0 +284,0 @@ |
@@ -7,2 +7,5 @@ /** | ||
const iterFrom = require('es-iterator-helpers/Iterator.from'); | ||
const map = require('es-iterator-helpers/Iterator.prototype.map'); | ||
/** TODO: type {(string | { name: string, linkAttribute: string })[]} */ | ||
@@ -23,3 +26,3 @@ /** @type {any} */ | ||
); | ||
return new Map(formComponents.map((value) => { | ||
return new Map(map(iterFrom(formComponents), (value) => { | ||
if (typeof value === 'string') { | ||
@@ -37,3 +40,3 @@ return [value, DEFAULT_FORM_ATTRIBUTE]; | ||
); | ||
return new Map(linkComponents.map((value) => { | ||
return new Map(map(iterFrom(linkComponents), (value) => { | ||
if (typeof value === 'string') { | ||
@@ -40,0 +43,0 @@ return [value, DEFAULT_LINK_ATTRIBUTE]; |
@@ -7,5 +7,8 @@ /** | ||
const filter = require('es-iterator-helpers/Iterator.prototype.filter'); | ||
const some = require('es-iterator-helpers/Iterator.prototype.some'); | ||
function searchPropWrapperFunctions(name, propWrapperFunctions) { | ||
const splitName = name.split('.'); | ||
return Array.from(propWrapperFunctions).some((func) => { | ||
return some(propWrapperFunctions.values(), (func) => { | ||
if (splitName.length === 2 && func.object === splitName[0] && func.property === splitName[1]) { | ||
@@ -32,3 +35,3 @@ return true; | ||
const propWrapperFunctions = getPropWrapperFunctions(context); | ||
const exactPropWrappers = Array.from(propWrapperFunctions).filter((func) => func.exact === true); | ||
const exactPropWrappers = filter(propWrapperFunctions.values(), (func) => func.exact === true); | ||
return new Set(exactPropWrappers); | ||
@@ -35,0 +38,0 @@ } |
{ | ||
"name": "eslint-plugin-react", | ||
"version": "7.33.1", | ||
"version": "7.33.2", | ||
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>", | ||
@@ -32,2 +32,3 @@ "description": "React specific linting rules for ESLint", | ||
"doctrine": "^2.1.0", | ||
"es-iterator-helpers": "^1.0.12", | ||
"estraverse": "^5.3.0", | ||
@@ -34,0 +35,0 @@ "jsx-ast-utils": "^2.4.1 || ^3.0.0", |
794972
21403
17
+ Addedes-iterator-helpers@^1.0.12
+ Addedes-iterator-helpers@1.0.19(transitive)
+ Addedis-async-function@2.0.0(transitive)
+ Addedis-finalizationregistry@1.0.2(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-map@2.0.3(transitive)
+ Addedis-set@2.0.3(transitive)
+ Addedis-weakmap@2.0.2(transitive)
+ Addedis-weakset@2.0.3(transitive)
+ Addediterator.prototype@1.1.2(transitive)
+ Addedreflect.getprototypeof@1.0.6(transitive)
+ Addedwhich-builtin-type@1.1.3(transitive)
+ Addedwhich-collection@1.0.2(transitive)