Skip to content

Commit

Permalink
change test order
Browse files Browse the repository at this point in the history
  • Loading branch information
baseballyama committed Dec 29, 2024
1 parent 6cd9420 commit 68b1863
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
42 changes: 21 additions & 21 deletions crates/oxc_linter/src/rules/eslint/no_negated_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}",
Expand All @@ -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 {;}",
Expand All @@ -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)
Expand Down
84 changes: 42 additions & 42 deletions crates/oxc_linter/src/snapshots/eslint_no_negated_condition.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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]
1if (!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]
1if (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]
1if (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]
1a != 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]
1a !== 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
Expand Down Expand Up @@ -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]
1if (!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]
1if (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]
1if (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]
1a != 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]
1a !== b ? c : d
· ───────
╰────
help: Remove the negation operator and switch the consequent and alternate branches.

0 comments on commit 68b1863

Please sign in to comment.