diff --git a/crates/oxc_linter/src/rules/jest/expect_expect.rs b/crates/oxc_linter/src/rules/jest/expect_expect.rs index 4d4f7524c26cb..300bf33338770 100644 --- a/crates/oxc_linter/src/rules/jest/expect_expect.rs +++ b/crates/oxc_linter/src/rules/jest/expect_expect.rs @@ -56,7 +56,7 @@ declare_oxc_lint!( /// test('should assert something', () => {}); /// ``` ExpectExpect, - restriction + correctness ); impl Rule for ExpectExpect { @@ -424,5 +424,5 @@ fn test() { ), ]; - Tester::new(ExpectExpect::NAME, pass, fail).test_and_snapshot(); + Tester::new(ExpectExpect::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_alias_methods.rs b/crates/oxc_linter/src/rules/jest/no_alias_methods.rs index 6e50c2475da28..f3a21e688bc11 100644 --- a/crates/oxc_linter/src/rules/jest/no_alias_methods.rs +++ b/crates/oxc_linter/src/rules/jest/no_alias_methods.rs @@ -43,7 +43,7 @@ declare_oxc_lint!( /// expect(a).toThrowError(); /// ``` NoAliasMethods, - restriction + style ); impl Rule for NoAliasMethods { @@ -171,5 +171,8 @@ fn test() { ("expect(a).not[`toThrowError`]()", "expect(a).not[`toThrow`]()", None), ]; - Tester::new(NoAliasMethods::NAME, pass, fail).expect_fix(fix).test_and_snapshot(); + Tester::new(NoAliasMethods::NAME, pass, fail) + .with_jest_plugin(true) + .expect_fix(fix) + .test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs b/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs index 7e16635bf7cf3..4c18c908d26c8 100644 --- a/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs +++ b/crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs @@ -39,7 +39,7 @@ declare_oxc_lint!( /// // test.skip('foo', () => {}); /// ``` NoCommentedOutTests, - restriction + suspicious ); impl Rule for NoCommentedOutTests { @@ -171,5 +171,5 @@ fn test() { ), ]; - Tester::new(NoCommentedOutTests::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoCommentedOutTests::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs b/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs index 731b5f453aad1..1dff6d28f38de 100644 --- a/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs +++ b/crates/oxc_linter/src/rules/jest/no_conditional_expect.rs @@ -49,7 +49,7 @@ declare_oxc_lint!( // }); /// ``` NoConditionalExpect, - restriction + correctness ); impl Rule for NoConditionalExpect { @@ -807,5 +807,5 @@ fn test() { ), ]; - Tester::new(NoConditionalExpect::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoConditionalExpect::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs b/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs index 5c38d6227e5b8..60b715abd7b60 100644 --- a/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs +++ b/crates/oxc_linter/src/rules/jest/no_confusing_set_timeout.rs @@ -83,7 +83,7 @@ declare_oxc_lint!( /// }); /// ``` NoConfusingSetTimeout, - restriction + style ); impl Rule for NoConfusingSetTimeout { @@ -481,5 +481,5 @@ fn test() { ), ]; - Tester::new(NoConfusingSetTimeout::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoConfusingSetTimeout::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs b/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs index 816ed3865569e..262d8706c8fca 100644 --- a/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs +++ b/crates/oxc_linter/src/rules/jest/no_disabled_tests.rs @@ -50,7 +50,7 @@ declare_oxc_lint!( /// }); /// ``` NoDisabledTests, - restriction + correctness ); #[derive(Debug, Error, Diagnostic)] @@ -206,5 +206,5 @@ fn test() { ("import { test } from '@jest/globals';test('something');", None), ]; - Tester::new(NoDisabledTests::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoDisabledTests::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_done_callback.rs b/crates/oxc_linter/src/rules/jest/no_done_callback.rs index d1209a8435926..f61fda3c2627c 100644 --- a/crates/oxc_linter/src/rules/jest/no_done_callback.rs +++ b/crates/oxc_linter/src/rules/jest/no_done_callback.rs @@ -70,7 +70,7 @@ declare_oxc_lint!( /// ``` NoDoneCallback, // TODO: add suggestion (see jest-community/eslint-plugin-jest#586) - restriction + style ); impl Rule for NoDoneCallback { @@ -303,5 +303,5 @@ fn test() { ("it.each``('something', ({ a, b }, done) => { done(); })", None), ]; - Tester::new(NoDoneCallback::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoDoneCallback::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_export.rs b/crates/oxc_linter/src/rules/jest/no_export.rs index 983fff237b726..c811f1baa070c 100644 --- a/crates/oxc_linter/src/rules/jest/no_export.rs +++ b/crates/oxc_linter/src/rules/jest/no_export.rs @@ -34,7 +34,7 @@ declare_oxc_lint!( /// }); /// ``` NoExport, - restriction + correctness ); impl Rule for NoExport { @@ -112,5 +112,5 @@ fn test() { // ("module.export.invalid = function() {}; ; test('a test', () => { expect(1).toBe(1);});", None) ]; - Tester::new(NoExport::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoExport::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_focused_tests.rs b/crates/oxc_linter/src/rules/jest/no_focused_tests.rs index 34e8f47c8c753..6d893d80b5637 100644 --- a/crates/oxc_linter/src/rules/jest/no_focused_tests.rs +++ b/crates/oxc_linter/src/rules/jest/no_focused_tests.rs @@ -54,7 +54,7 @@ declare_oxc_lint!( /// `(); /// ``` NoFocusedTests, - restriction + correctness ); impl Rule for NoFocusedTests { @@ -143,5 +143,8 @@ fn test() { ("fdescribe('foo', () => {})", "describe('foo', () => {})", None), ]; - Tester::new(NoFocusedTests::NAME, pass, fail).expect_fix(fix).test_and_snapshot(); + Tester::new(NoFocusedTests::NAME, pass, fail) + .with_jest_plugin(true) + .expect_fix(fix) + .test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_identical_title.rs b/crates/oxc_linter/src/rules/jest/no_identical_title.rs index 8c27553019a93..631bb103c5e24 100644 --- a/crates/oxc_linter/src/rules/jest/no_identical_title.rs +++ b/crates/oxc_linter/src/rules/jest/no_identical_title.rs @@ -50,7 +50,7 @@ declare_oxc_lint!( /// }); /// ``` NoIdenticalTitle, - restriction + style ); impl Rule for NoIdenticalTitle { @@ -488,5 +488,5 @@ fn test() { // ), ]; - Tester::new(NoIdenticalTitle::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoIdenticalTitle::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs b/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs index b81fd1e2cff71..4745c85991452 100644 --- a/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs +++ b/crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs @@ -52,7 +52,7 @@ declare_oxc_lint!( /// ); /// ``` NoInterpolationInSnapshots, - restriction + style ); impl Rule for NoInterpolationInSnapshots { @@ -110,5 +110,7 @@ fn test() { ("expect(something).not.toThrowErrorMatchingInlineSnapshot(`${interpolated}`);", None), ]; - Tester::new(NoInterpolationInSnapshots::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoInterpolationInSnapshots::NAME, pass, fail) + .with_jest_plugin(true) + .test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs b/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs index 818967a0498fb..bc4e8ec04467f 100644 --- a/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs +++ b/crates/oxc_linter/src/rules/jest/no_jasmine_globals.rs @@ -39,7 +39,7 @@ declare_oxc_lint!( /// }); /// ``` NoJasmineGlobals, - restriction + style ); const NON_JASMINE_PROPERTY_NAMES: [&str; 4] = ["spyOn", "spyOnProperty", "fail", "pending"]; @@ -293,5 +293,8 @@ fn test() { ), ]; - Tester::new(NoJasmineGlobals::NAME, pass, fail).expect_fix(fix).test_and_snapshot(); + Tester::new(NoJasmineGlobals::NAME, pass, fail) + .with_jest_plugin(true) + .expect_fix(fix) + .test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_mocks_import.rs b/crates/oxc_linter/src/rules/jest/no_mocks_import.rs index a354abf1e00fe..6ffea5ef9a2c3 100644 --- a/crates/oxc_linter/src/rules/jest/no_mocks_import.rs +++ b/crates/oxc_linter/src/rules/jest/no_mocks_import.rs @@ -37,7 +37,7 @@ declare_oxc_lint!( /// require('__mocks__'); /// NoMocksImport, - restriction + style ); impl Rule for NoMocksImport { @@ -112,5 +112,5 @@ fn test() { ("import thing from './__mocks__/index'", None), ]; - Tester::new(NoMocksImport::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoMocksImport::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs b/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs index 31fbe9879ea0f..086ff31b4af1e 100644 --- a/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs +++ b/crates/oxc_linter/src/rules/jest/no_standalone_expect.rs @@ -44,7 +44,7 @@ declare_oxc_lint!( /// }); /// ``` NoStandaloneExpect, - restriction + correctness ); impl Rule for NoStandaloneExpect { @@ -315,5 +315,5 @@ fn test() { ) ]; - Tester::new(NoStandaloneExpect::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoStandaloneExpect::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs b/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs index 716df3f74dd43..b55b89a1f3906 100644 --- a/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs +++ b/crates/oxc_linter/src/rules/jest/no_test_prefixes.rs @@ -48,7 +48,7 @@ declare_oxc_lint!( /// xdescribe('foo'); // invalid /// ``` NoTestPrefixes, - restriction + style ); fn get_preferred_node_names(jest_fn_call: &ParsedGeneralJestFnCall) -> Atom { @@ -159,5 +159,5 @@ fn test() { ), ]; - Tester::new(NoTestPrefixes::NAME, pass, fail).test_and_snapshot(); + Tester::new(NoTestPrefixes::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs b/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs index 277eb0a46183d..5a0654ac6dfed 100644 --- a/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs +++ b/crates/oxc_linter/src/rules/jest/valid_describe_callback.rs @@ -59,7 +59,7 @@ declare_oxc_lint!( /// })); /// ``` ValidDescribeCallback, - restriction + correctness ); impl Rule for ValidDescribeCallback { @@ -326,5 +326,5 @@ fn test() { ("describe('foo', async function (done) {})", None), ]; - Tester::new(ValidDescribeCallback::NAME, pass, fail).test_and_snapshot(); + Tester::new(ValidDescribeCallback::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/valid_expect.rs b/crates/oxc_linter/src/rules/jest/valid_expect.rs index 4673ec5db1077..353ce10ef4262 100644 --- a/crates/oxc_linter/src/rules/jest/valid_expect.rs +++ b/crates/oxc_linter/src/rules/jest/valid_expect.rs @@ -55,7 +55,7 @@ declare_oxc_lint!( /// expect(Promise.resolve('Hi!')).resolves.toBe('Hi!'); /// ``` ValidExpect, - restriction + correctness ); impl Rule for ValidExpect { @@ -369,7 +369,7 @@ fn test_1() { ]; let fail = vec![]; - Tester::new(ValidExpect::NAME, pass, fail).test_and_snapshot(); + Tester::new(ValidExpect::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } #[test] @@ -739,5 +739,5 @@ fn test() { ) ]; - Tester::new(ValidExpect::NAME, pass, fail).test_and_snapshot(); + Tester::new(ValidExpect::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jest/valid_title.rs b/crates/oxc_linter/src/rules/jest/valid_title.rs index 0177b9230ad5d..c02e4f5f485cb 100644 --- a/crates/oxc_linter/src/rules/jest/valid_title.rs +++ b/crates/oxc_linter/src/rules/jest/valid_title.rs @@ -56,7 +56,7 @@ declare_oxc_lint!( /// xtest('', () => {}); /// ``` ValidTitle, - restriction + correctness ); impl Rule for ValidTitle { @@ -860,5 +860,5 @@ fn test() { ), ]; - Tester::new(ValidTitle::NAME, pass, fail).test_and_snapshot(); + Tester::new(ValidTitle::NAME, pass, fail).with_jest_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs b/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs index ec80a839e9b0f..853b418fc1d00 100644 --- a/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs +++ b/crates/oxc_linter/src/rules/jsx_a11y/alt_text.rs @@ -542,5 +542,5 @@ fn test() { (r#""#, None), ]; - Tester::new(AltText::NAME, pass, fail).test_and_snapshot(); + Tester::new(AltText::NAME, pass, fail).with_jsx_a11y_plugin(true).test_and_snapshot(); } diff --git a/crates/oxc_linter/src/tester.rs b/crates/oxc_linter/src/tester.rs index 5968f7d58db65..6002d532ec072 100644 --- a/crates/oxc_linter/src/tester.rs +++ b/crates/oxc_linter/src/tester.rs @@ -86,6 +86,16 @@ impl Tester { self } + pub fn with_jest_plugin(mut self, yes: bool) -> Self { + self.jest_plugin = yes; + self + } + + pub fn with_jsx_a11y_plugin(mut self, yes: bool) -> Self { + self.jsx_a11y_plugin = yes; + self + } + pub fn expect_fix>(mut self, expect_fix: Vec<(S, S, Option)>) -> Self { self.expect_fix = expect_fix.into_iter().map(|(s1, s2, r)| (s1.into(), s2.into(), r)).collect::>();