Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parsers/es.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe("es", () => {
});

// #234
it("should ignore literals in binary expressions", () => {
it("should ignore literals in binary comparisons", () => {
lint(noUnnecessaryWhitespace, {
valid: [
{
Expand Down
8 changes: 4 additions & 4 deletions src/parsers/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
findMatchingParentNodes,
getLiteralNodesByMatchers,
isIndexedAccessLiteral,
isInsideBinaryExpression,
isInsideConditionalExpressionTest,
isInsideDisallowedBinaryExpression,
isInsideLogicalExpressionLeft,
isInsideMemberExpression,
matchesPathPattern
Expand Down Expand Up @@ -619,7 +619,7 @@ function getESMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunctions<ES
!isESNode(node) ||
!hasESNodeParentExtension(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isIndexedAccessLiteral(node) ||
Expand All @@ -641,7 +641,7 @@ function getESMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunctions<ES
!hasESNodeParentExtension(node) ||
!isESObjectKey(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isInsideMemberExpression(node) ||
Expand All @@ -667,7 +667,7 @@ function getESMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunctions<ES
!hasESNodeParentExtension(node) ||
!isInsideObjectValue(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isESObjectKey(node) ||
Expand Down
8 changes: 4 additions & 4 deletions src/parsers/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { MatcherType } from "better-tailwindcss:types/rule.js";
import {
getLiteralNodesByMatchers,
isIndexedAccessLiteral,
isInsideBinaryExpression,
isInsideConditionalExpressionTest,
isInsideDisallowedBinaryExpression,
isInsideLogicalExpressionLeft,
isInsideMemberExpression,
matchesPathPattern
Expand Down Expand Up @@ -321,7 +321,7 @@ function getSvelteMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunction
!isESNode(node) ||
!hasESNodeParentExtension(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isIndexedAccessLiteral(node) ||
Expand All @@ -344,7 +344,7 @@ function getSvelteMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunction
!hasESNodeParentExtension(node) ||
!isESObjectKey(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isInsideMemberExpression(node) ||
Expand All @@ -370,7 +370,7 @@ function getSvelteMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunction
!hasESNodeParentExtension(node) ||
!isInsideObjectValue(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isESObjectKey(node) ||
Expand Down
8 changes: 4 additions & 4 deletions src/parsers/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { MatcherType } from "better-tailwindcss:types/rule.js";
import {
getLiteralNodesByMatchers,
isIndexedAccessLiteral,
isInsideBinaryExpression,
isInsideConditionalExpressionTest,
isInsideDisallowedBinaryExpression,
isInsideLogicalExpressionLeft,
isInsideMemberExpression,
matchesPathPattern
Expand Down Expand Up @@ -192,7 +192,7 @@ function getVueMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunctions<E
!isESNode(node) ||
!hasESNodeParentExtension(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isIndexedAccessLiteral(node) ||
Expand All @@ -214,7 +214,7 @@ function getVueMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunctions<E
!hasESNodeParentExtension(node) ||
!isESObjectKey(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isInsideMemberExpression(node) ||
Expand All @@ -240,7 +240,7 @@ function getVueMatcherFunctions(matchers: SelectorMatcher[]): MatcherFunctions<E
!hasESNodeParentExtension(node) ||
!isInsideObjectValue(node) ||

isInsideBinaryExpression(node) ||
isInsideDisallowedBinaryExpression(node) ||
isInsideConditionalExpressionTest(node) ||
isInsideLogicalExpressionLeft(node) ||
isESObjectKey(node) ||
Expand Down
9 changes: 6 additions & 3 deletions src/utils/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ export function isInsideConditionalExpressionTest(node: WithParent<ESNode>): boo
return isInsideConditionalExpressionTest(node.parent);
}

export function isInsideBinaryExpression(node: WithParent<ESNode>): boolean {
export function isInsideDisallowedBinaryExpression(node: WithParent<ESNode>): boolean {
if(!hasESNodeParentExtension(node)){ return false; }
if(node.parent.type === "BinaryExpression"){ return true; }
return isInsideBinaryExpression(node.parent);
if(
node.parent.type === "BinaryExpression" &&
node.parent.operator !== "+" // allow string concatenation
){ return true; }
return isInsideDisallowedBinaryExpression(node.parent);
}

export function isInsideLogicalExpressionLeft(node: WithParent<ESNode>): boolean {
Expand Down
Loading