Skip to content

Commit

Permalink
rename isParenthesized util
Browse files Browse the repository at this point in the history
  • Loading branch information
Belco90 committed Feb 28, 2022
1 parent 36edd13 commit f4339d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/rules/jsx-no-leaked-zero.js
Expand Up @@ -7,7 +7,7 @@

const docsUrl = require('../util/docsUrl');
const report = require('../util/report');
const isParenthesised = require('../util/ast').isParenthesised;
const isParenthesized = require('../util/ast').isParenthesized;

//------------------------------------------------------------------------------
// Rule Definition
Expand Down Expand Up @@ -62,7 +62,7 @@ module.exports = {
function ruleFixer(fixer, logicalExpressionNode) {
if (fixStrategy === CAST_FIX_STRATEGY) {
let leftSideRange = logicalExpressionNode.left.range;
if (isParenthesised(context, logicalExpressionNode.left)) {
if (isParenthesized(context, logicalExpressionNode.left)) {
const [leftSideStart, leftSideEnd] = leftSideRange;
leftSideRange = [leftSideStart - 1, leftSideEnd + 1];
}
Expand All @@ -72,7 +72,7 @@ module.exports = {
const sourceCode = context.getSourceCode();
const rightSideText = sourceCode.getText(logicalExpressionNode.right);
let leftSideText = sourceCode.getText(logicalExpressionNode.left);
if (isParenthesised(context, logicalExpressionNode.left)) {
if (isParenthesized(context, logicalExpressionNode.left)) {
leftSideText = `(${leftSideText})`;
}
return fixer.replaceText(logicalExpressionNode, `${leftSideText} ? ${rightSideText} : null`);
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/jsx-wrap-multilines.js
Expand Up @@ -9,7 +9,7 @@ const has = require('object.hasown/polyfill')();
const docsUrl = require('../util/docsUrl');
const jsxUtil = require('../util/jsx');
const reportC = require('../util/report');
const isParenthesised = require('../util/ast').isParenthesised;
const isParenthesized = require('../util/ast').isParenthesized;

// ------------------------------------------------------------------------------
// Constants
Expand Down Expand Up @@ -93,7 +93,7 @@ module.exports = {
function needsOpeningNewLine(node) {
const previousToken = context.getSourceCode().getTokenBefore(node);

if (!isParenthesised(context, node)) {
if (!isParenthesized(context, node)) {
return false;
}

Expand All @@ -107,7 +107,7 @@ module.exports = {
function needsClosingNewLine(node) {
const nextToken = context.getSourceCode().getTokenAfter(node);

if (!isParenthesised(context, node)) {
if (!isParenthesized(context, node)) {
return false;
}

Expand Down Expand Up @@ -144,12 +144,12 @@ module.exports = {
const sourceCode = context.getSourceCode();
const option = getOption(type);

if ((option === true || option === 'parens') && !isParenthesised(context, node) && isMultilines(node)) {
if ((option === true || option === 'parens') && !isParenthesized(context, node) && isMultilines(node)) {
report(node, 'missingParens', (fixer) => fixer.replaceText(node, `(${sourceCode.getText(node)})`));
}

if (option === 'parens-new-line' && isMultilines(node)) {
if (!isParenthesised(context, node)) {
if (!isParenthesized(context, node)) {
const tokenBefore = sourceCode.getTokenBefore(node, { includeComments: true });
const tokenAfter = sourceCode.getTokenAfter(node, { includeComments: true });
const start = node.loc.start;
Expand Down
4 changes: 2 additions & 2 deletions lib/util/ast.js
Expand Up @@ -271,7 +271,7 @@ function getKeyValue(context, node) {
* @param {ASTNode} node - Node to be checked
* @returns {boolean}
*/
function isParenthesised(context, node) {
function isParenthesized(context, node) {
const sourceCode = context.getSourceCode();
const previousToken = sourceCode.getTokenBefore(node);
const nextToken = sourceCode.getTokenAfter(node);
Expand Down Expand Up @@ -397,7 +397,7 @@ module.exports = {
getPropertyNameNode,
getComponentProperties,
getKeyValue,
isParenthesised,
isParenthesized: isParenthesized,
isAssignmentLHS,
isClass,
isFunction,
Expand Down

0 comments on commit f4339d8

Please sign in to comment.