Socket
Socket
Sign inDemoInstall

@stylistic/eslint-plugin-jsx

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stylistic/eslint-plugin-jsx - npm Package Compare versions

Comparing version 2.6.5 to 2.7.0-beta.0

8

dist/jsx-wrap-multilines.js

@@ -82,3 +82,3 @@ 'use strict';

const previousToken = context.sourceCode.getTokenBefore(node);
if (!utils.isParenthesized(context, node))
if (!utils.isParenthesized(node, context.sourceCode))
return false;

@@ -91,3 +91,3 @@ if (previousToken.loc.end.line === node.loc.start.line)

const nextToken = context.sourceCode.getTokenAfter(node);
if (!utils.isParenthesized(context, node))
if (!utils.isParenthesized(node, context.sourceCode))
return false;

@@ -110,3 +110,3 @@ if (node.loc.end.line === nextToken.loc.end.line)

const option = getOption(type);
if ((option === true || option === "parens") && !utils.isParenthesized(context, node) && isMultilines(node)) {
if ((option === true || option === "parens") && !utils.isParenthesized(node, context.sourceCode) && isMultilines(node)) {
context.report({

@@ -119,3 +119,3 @@ node,

if (option === "parens-new-line" && isMultilines(node)) {
if (!utils.isParenthesized(context, node)) {
if (!utils.isParenthesized(node, context.sourceCode)) {
const tokenBefore = sourceCode.getTokenBefore(node, { includeComments: true });

@@ -122,0 +122,0 @@ const tokenAfter = sourceCode.getTokenAfter(node, { includeComments: true });

@@ -64,2 +64,5 @@ 'use strict';

function isOpeningParenToken(token) {
return token.value === "(" && token.type === "Punctuator";
}
function getFirstNodeInLine(context, node) {

@@ -81,8 +84,2 @@ const sourceCode = context.sourceCode;

}
function isParenthesized(context, node) {
const sourceCode = context.sourceCode;
const previousToken = sourceCode.getTokenBefore(node);
const nextToken = sourceCode.getTokenAfter(node);
return !!previousToken && !!nextToken && previousToken.value === "(" && previousToken.range[1] <= node.range[0] && nextToken.value === ")" && nextToken.range[0] >= node.range[1];
}
function getTokenBeforeClosingBracket(node) {

@@ -94,2 +91,61 @@ const attributes = "attributes" in node && node.attributes;

}
function getParentSyntaxParen(node, sourceCode) {
const parent = node.parent;
if (!parent)
return null;
switch (parent.type) {
case "CallExpression":
case "NewExpression":
if (parent.arguments.length === 1 && parent.arguments[0] === node) {
return sourceCode.getTokenAfter(
parent.callee,
isOpeningParenToken
);
}
return null;
case "DoWhileStatement":
if (parent.test === node) {
return sourceCode.getTokenAfter(
parent.body,
isOpeningParenToken
);
}
return null;
case "IfStatement":
case "WhileStatement":
if (parent.test === node) {
return sourceCode.getFirstToken(parent, 1);
}
return null;
case "ImportExpression":
if (parent.source === node) {
return sourceCode.getFirstToken(parent, 1);
}
return null;
case "SwitchStatement":
if (parent.discriminant === node) {
return sourceCode.getFirstToken(parent, 1);
}
return null;
case "WithStatement":
if (parent.object === node) {
return sourceCode.getFirstToken(parent, 1);
}
return null;
default:
return null;
}
}
function isParenthesized(node, sourceCode, times = 1) {
let maybeLeftParen, maybeRightParen;
if (node == null || node.parent == null || node.parent.type === "CatchClause" && node.parent.param === node) {
return false;
}
maybeLeftParen = maybeRightParen = node;
do {
maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
} while (maybeLeftParen != null && maybeRightParen != null && (maybeLeftParen.type === "Punctuator" && maybeLeftParen.value === "(") && (maybeRightParen.type === "Punctuator" && maybeRightParen.value === ")") && maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && --times > 0);
return times === 0;
}

@@ -96,0 +152,0 @@ function getVariable(variables, name) {

{
"name": "@stylistic/eslint-plugin-jsx",
"type": "commonjs",
"version": "2.6.5",
"version": "2.7.0-beta.0",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",

@@ -63,8 +63,7 @@ "license": "MIT",

"dependencies": {
"@types/eslint": "^9.6.0",
"@types/eslint": "^9.6.1",
"eslint-visitor-keys": "^4.0.0",
"espree": "^10.1.0",
"estraverse": "^5.3.0",
"picomatch": "^4.0.2",
"@stylistic/eslint-plugin-js": "^2.6.5"
"picomatch": "^4.0.2"
},

@@ -71,0 +70,0 @@ "scripts": {

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