Socket
Socket
Sign inDemoInstall

eslint-plugin-react

Package Overview
Dependencies
Maintainers
2
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react - npm Package Compare versions

Comparing version 7.31.8 to 7.31.9

33

lib/rules/jsx-key.js

@@ -158,6 +158,29 @@ /**

const childrenToArraySelector = `:matches(
CallExpression
[callee.object.object.name=${reactPragma}]
[callee.object.property.name=Children]
[callee.property.name=toArray],
CallExpression
[callee.object.name=Children]
[callee.property.name=toArray]
)`.replace(/\s/g, '');
let isWithinChildrenToArray = false;
const seen = new WeakSet();
return {
[childrenToArraySelector]() {
isWithinChildrenToArray = true;
},
[`${childrenToArraySelector}:exit`]() {
isWithinChildrenToArray = false;
},
'ArrayExpression, JSXElement > JSXElement'(node) {
if (isWithinChildrenToArray) {
return;
}
const jsx = (node.type === 'ArrayExpression' ? node.elements : node.parent.children).filter((x) => x && x.type === 'JSXElement');

@@ -209,3 +232,3 @@ if (jsx.length === 0) {

JSXFragment(node) {
if (!checkFragmentShorthand) {
if (!checkFragmentShorthand || isWithinChildrenToArray) {
return;

@@ -231,2 +254,6 @@ }

OptionalCallExpression[callee.type="OptionalMemberExpression"][callee.property.name="map"]'(node) {
if (isWithinChildrenToArray) {
return;
}
const fn = node.arguments.length > 0 && node.arguments[0];

@@ -244,2 +271,6 @@ if (!fn || !astUtil.isFunctionLikeExpression(fn)) {

'CallExpression[callee.type="MemberExpression"][callee.property.name="from"]'(node) {
if (isWithinChildrenToArray) {
return;
}
const fn = node.arguments.length > 1 && node.arguments[1];

@@ -246,0 +277,0 @@ if (!astUtil.isFunctionLikeExpression(fn)) {

10

lib/rules/jsx-no-constructed-context-values.js

@@ -9,2 +9,3 @@ /**

const Components = require('../util/Components');
const docsUrl = require('../util/docsUrl');

@@ -143,3 +144,4 @@ const report = require('../util/report');

create(context) {
// eslint-disable-next-line arrow-body-style
create: Components.detect((context, components, utils) => {
return {

@@ -189,2 +191,6 @@ JSXOpeningElement(node) {

if (!utils.getParentComponent(node)) {
return;
}
// Report found error

@@ -220,3 +226,3 @@ const constructType = constructInfo.type;

};
},
}),
};

@@ -97,3 +97,4 @@ /**

(previousComment.length > 0 ? previousComment[0] : body).range[0],
(nextComment.length > 0 ? nextComment[nextComment.length - 1] : body).range[1],
(nextComment.length > 0 ? nextComment[nextComment.length - 1] : body).range[1]
+ (node.value.body.type === 'ObjectExpression' ? 1 : 0), // to account for a wrapped end paren
];

@@ -105,2 +106,3 @@ }

];
const hasSemi = node.value.expression && sourceCode.getText(node).slice(node.value.range[1] - node.range[0]) === ';';

@@ -124,3 +126,3 @@ report(

isBlockBody ? [] : fixer.replaceTextRange(
bodyRange,
[bodyRange[0], bodyRange[1] + (hasSemi ? 1 : 0)],
`{ return ${previousComment.map((x) => sourceCode.getText(x)).join('')}${sourceCode.getText(body)}${nextComment.map((x) => sourceCode.getText(x)).join('')}; }`

@@ -127,0 +129,0 @@ )

@@ -32,2 +32,3 @@ /**

abbr: ['th', 'td'],
charset: ['meta'],
checked: ['input'],

@@ -74,4 +75,6 @@ // image is required for SVG support, all other tags are HTML.

onAbort: ['audio', 'video'],
onCancel: ['dialog'],
onCanPlay: ['audio', 'video'],
onCanPlayThrough: ['audio', 'video'],
onClose: ['dialog'],
onDurationChange: ['audio', 'video'],

@@ -106,5 +109,10 @@ onEmptied: ['audio', 'video'],

playsInline: ['video'],
allowFullScreen: ['video'],
webkitAllowFullScreen: ['video'],
mozAllowFullScreen: ['video'],
poster: ['video'],
preload: ['audio', 'video'],
scrolling: ['iframe'],
returnValue: ['dialog'],
webkitDirectory: ['input'],
};

@@ -309,3 +317,3 @@

const DOM_PROPERTIES_IGNORE_CASE = ['charset', 'allowFullScreen', 'webkitAllowFullScreen', 'mozAllowFullScreen'];
const DOM_PROPERTIES_IGNORE_CASE = ['charset', 'allowFullScreen', 'webkitAllowFullScreen', 'mozAllowFullScreen', 'webkitDirectory'];

@@ -398,2 +406,18 @@ const ARIA_PROPERTIES = [

/**
* Checks if the attribute name is included in the attributes that are excluded
* from the camel casing.
*
* // returns 'charSet'
* @example normalizeAttributeCase('charset')
*
* Note - these exclusions are not made by React core team, but `eslint-plugin-react` community.
*
* @param {String} name - Attribute name to be normalized
* @returns {String} Result
*/
function normalizeAttributeCase(name) {
return DOM_PROPERTIES_IGNORE_CASE.find((element) => element.toLowerCase() === name.toLowerCase()) || name;
}
/**
* Checks if an attribute name is a valid `data-*` attribute:

@@ -424,19 +448,2 @@ * if the name starts with "data-" and has alphanumeric words (browsers require lowercase, but React and TS lowercase them),

/**
* Checks if the attribute name is included in the attributes that are excluded
* from the camel casing.
*
* // returns true
* @example isCaseIgnoredAttribute('charSet')
*
* Note - these exclusions are not made by React core team, but `eslint-plugin-react` community.
*
* @param {String} name - Attribute name to be tested
* @returns {Boolean} Result
*/
function isCaseIgnoredAttribute(name) {
return DOM_PROPERTIES_IGNORE_CASE.some((element) => element.toLowerCase() === name.toLowerCase());
}
/**
* Extracts the tag name for the JSXAttribute

@@ -529,6 +536,7 @@ * @param {JSXAttribute} node - JSXAttribute being tested.

const ignoreNames = getIgnoreConfig();
const name = context.getSourceCode().getText(node.name);
if (ignoreNames.indexOf(name) >= 0) {
const actualName = context.getSourceCode().getText(node.name);
if (ignoreNames.indexOf(actualName) >= 0) {
return;
}
const name = normalizeAttributeCase(actualName);

@@ -544,4 +552,2 @@ // Ignore tags like <Foo.bar />

if (isCaseIgnoredAttribute(name)) { return; }
const tagName = getTagName(node);

@@ -563,3 +569,3 @@

data: {
name,
name: actualName,
tagName,

@@ -590,3 +596,3 @@ allowedTags: allowedTags.join(', '),

data: {
name,
name: actualName,
standardName,

@@ -605,3 +611,3 @@ },

data: {
name,
name: actualName,
},

@@ -608,0 +614,0 @@ });

@@ -131,3 +131,9 @@ /**

// If name is set but the configured rule does not match expected then report error
if (name && config[name] !== expectedRule) {
if (
name
&& (
config[name] !== expectedRule
|| (!node.static && (config[name] === STATIC_PUBLIC_FIELD || config[name] === STATIC_GETTER))
)
) {
const messageId = ERROR_MESSAGES[config[name]];

@@ -134,0 +140,0 @@ report(context, messages[messageId], messageId, {

@@ -24,3 +24,3 @@ /**

function getId(node) {
return node && node.range.join(':');
return node ? `${node.range[0]}:${node.range[1]}` : '';
}

@@ -27,0 +27,0 @@

@@ -13,3 +13,2 @@ 'use strict';

module.exports = function isCreateElement(node, context) {
const pragma = pragmaUtil.getFromContext(context);
if (

@@ -20,3 +19,3 @@ node.callee

&& node.callee.object
&& node.callee.object.name === pragma
&& node.callee.object.name === pragmaUtil.getFromContext(context)
) {

@@ -23,0 +22,0 @@ return true;

{
"name": "eslint-plugin-react",
"version": "7.31.8",
"version": "7.31.9",
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>",

@@ -44,4 +44,4 @@ "description": "React specific linting rules for ESLint",

"devDependencies": {
"@babel/core": "^7.19.0",
"@babel/eslint-parser": "^7.18.9",
"@babel/core": "^7.19.3",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-syntax-decorators": "^7.19.0",

@@ -55,3 +55,3 @@ "@babel/plugin-syntax-do-expressions": "^7.18.6",

"@typescript-eslint/parser": "^2.34.0 || ^3.10.1 || ^4.0.0 || ^5.0.0",
"aud": "^2.0.0",
"aud": "^2.0.1",
"babel-eslint": "^8 || ^9 || ^10.1.0",

@@ -63,3 +63,3 @@ "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8",

"eslint-remote-tester": "^3.0.0",
"eslint-remote-tester-repositories": "^0.0.6",
"eslint-remote-tester-repositories": "^0.0.7",
"eslint-scope": "^3.7.3",

@@ -66,0 +66,0 @@ "espree": "^3.5.4",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc