mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor: change jest rule's category (#1155)
This commit is contained in:
parent
4e9260ec03
commit
3b88f748fd
20 changed files with 59 additions and 38 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -542,5 +542,5 @@ fn test() {
|
|||
(r#"<Input type="image" />"#, None),
|
||||
];
|
||||
|
||||
Tester::new(AltText::NAME, pass, fail).test_and_snapshot();
|
||||
Tester::new(AltText::NAME, pass, fail).with_jsx_a11y_plugin(true).test_and_snapshot();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<S: Into<String>>(mut self, expect_fix: Vec<(S, S, Option<Value>)>) -> Self {
|
||||
self.expect_fix =
|
||||
expect_fix.into_iter().map(|(s1, s2, r)| (s1.into(), s2.into(), r)).collect::<Vec<_>>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue