From 68b1863c46d1d2641c3043e394ea4d1e81067f36 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sun, 29 Dec 2024 11:18:14 +0900 Subject: [PATCH] change test order --- .../src/rules/eslint/no_negated_condition.rs | 42 +++++----- .../eslint_no_negated_condition.snap | 84 +++++++++---------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs b/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs index ffdf1251ddeff..60ffa1770a169 100644 --- a/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs +++ b/crates/oxc_linter/src/rules/eslint/no_negated_condition.rs @@ -106,20 +106,6 @@ fn test() { use crate::tester::Tester; let pass = vec![ - r"if (a) {}", - r"if (a) {} else {}", - r"if (!a) {}", - r"if (!a) {} else if (b) {}", - r"if (!a) {} else if (b) {} else {}", - r"if (a == b) {}", - r"if (a == b) {} else {}", - r"if (a != b) {}", - r"if (a != b) {} else if (b) {}", - r"if (a != b) {} else if (b) {} else {}", - r"if (a !== b) {}", - r"if (a === b) {} else {}", - r"a ? b : c", - // Test cases from ESLint "if (a) {}", "if (a) {} else {}", "if (!a) {}", @@ -133,9 +119,30 @@ fn test() { "if (a !== b) {}", "if (a === b) {} else {}", "a ? b : c", + // Test cases from eslint-plugin-unicorn + r"if (a) {}", + r"if (a) {} else {}", + r"if (!a) {}", + r"if (!a) {} else if (b) {}", + r"if (!a) {} else if (b) {} else {}", + r"if (a == b) {}", + r"if (a == b) {} else {}", + r"if (a != b) {}", + r"if (a != b) {} else if (b) {}", + r"if (a != b) {} else if (b) {} else {}", + r"if (a !== b) {}", + r"if (a === b) {} else {}", + r"a ? b : c", ]; let fail = vec![ + "if (!a) {;} else {;}", + "if (a != b) {;} else {;}", + "if (a !== b) {;} else {;}", + "!a ? b : c", + "a != b ? c : d", + "a !== b ? c : d", + // Test cases from eslint-plugin-unicorn r"if (!a) {;} else {;}", r"if (a != b) {;} else {;}", r"if (a !== b) {;} else {;}", @@ -154,13 +161,6 @@ fn test() { r"if(!a) {b()} else {c()}", r"if(!!a) b(); else c();", r"(!!a) ? b() : c();", - // Test cases from ESLint - "if (!a) {;} else {;}", - "if (a != b) {;} else {;}", - "if (a !== b) {;} else {;}", - "!a ? b : c", - "a != b ? c : d", - "a !== b ? c : d", ]; Tester::new(NoNegatedCondition::NAME, NoNegatedCondition::CATEGORY, pass, fail) diff --git a/crates/oxc_linter/src/snapshots/eslint_no_negated_condition.snap b/crates/oxc_linter/src/snapshots/eslint_no_negated_condition.snap index 606a9eac3f812..88967b97f4f88 100644 --- a/crates/oxc_linter/src/snapshots/eslint_no_negated_condition.snap +++ b/crates/oxc_linter/src/snapshots/eslint_no_negated_condition.snap @@ -44,6 +44,48 @@ snapshot_kind: text ╰──── help: Remove the negation operator and switch the consequent and alternate branches. + ⚠ eslint(no-negated-condition): Unexpected negated condition. + ╭─[no_negated_condition.tsx:1:5] + 1 │ if (!a) {;} else {;} + · ── + ╰──── + help: Remove the negation operator and switch the consequent and alternate branches. + + ⚠ eslint(no-negated-condition): Unexpected negated condition. + ╭─[no_negated_condition.tsx:1:5] + 1 │ if (a != b) {;} else {;} + · ────── + ╰──── + help: Remove the negation operator and switch the consequent and alternate branches. + + ⚠ eslint(no-negated-condition): Unexpected negated condition. + ╭─[no_negated_condition.tsx:1:5] + 1 │ if (a !== b) {;} else {;} + · ─────── + ╰──── + help: Remove the negation operator and switch the consequent and alternate branches. + + ⚠ eslint(no-negated-condition): Unexpected negated condition. + ╭─[no_negated_condition.tsx:1:1] + 1 │ !a ? b : c + · ── + ╰──── + help: Remove the negation operator and switch the consequent and alternate branches. + + ⚠ eslint(no-negated-condition): Unexpected negated condition. + ╭─[no_negated_condition.tsx:1:1] + 1 │ a != b ? c : d + · ────── + ╰──── + help: Remove the negation operator and switch the consequent and alternate branches. + + ⚠ eslint(no-negated-condition): Unexpected negated condition. + ╭─[no_negated_condition.tsx:1:1] + 1 │ a !== b ? c : d + · ─────── + ╰──── + help: Remove the negation operator and switch the consequent and alternate branches. + ⚠ eslint(no-negated-condition): Unexpected negated condition. ╭─[no_negated_condition.tsx:1:4] 1 │ (( !a )) ? b : c @@ -127,45 +169,3 @@ snapshot_kind: text · ─── ╰──── help: Remove the negation operator and switch the consequent and alternate branches. - - ⚠ eslint(no-negated-condition): Unexpected negated condition. - ╭─[no_negated_condition.tsx:1:5] - 1 │ if (!a) {;} else {;} - · ── - ╰──── - help: Remove the negation operator and switch the consequent and alternate branches. - - ⚠ eslint(no-negated-condition): Unexpected negated condition. - ╭─[no_negated_condition.tsx:1:5] - 1 │ if (a != b) {;} else {;} - · ────── - ╰──── - help: Remove the negation operator and switch the consequent and alternate branches. - - ⚠ eslint(no-negated-condition): Unexpected negated condition. - ╭─[no_negated_condition.tsx:1:5] - 1 │ if (a !== b) {;} else {;} - · ─────── - ╰──── - help: Remove the negation operator and switch the consequent and alternate branches. - - ⚠ eslint(no-negated-condition): Unexpected negated condition. - ╭─[no_negated_condition.tsx:1:1] - 1 │ !a ? b : c - · ── - ╰──── - help: Remove the negation operator and switch the consequent and alternate branches. - - ⚠ eslint(no-negated-condition): Unexpected negated condition. - ╭─[no_negated_condition.tsx:1:1] - 1 │ a != b ? c : d - · ────── - ╰──── - help: Remove the negation operator and switch the consequent and alternate branches. - - ⚠ eslint(no-negated-condition): Unexpected negated condition. - ╭─[no_negated_condition.tsx:1:1] - 1 │ a !== b ? c : d - · ─────── - ╰──── - help: Remove the negation operator and switch the consequent and alternate branches.