-
-
Notifications
You must be signed in to change notification settings - Fork 737
feat(linter/eslint-plugin-vitest): reuse no-mocks-import jest linter rule #16540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(linter/eslint-plugin-vitest): reuse no-mocks-import jest linter rule #16540
Conversation
CodSpeed Performance ReportMerging #16540 will not alter performanceComparing Summary
Footnotes
|
connorshea
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs block in the declare_oxc_lint! should be updated to mention that this rule is compatible with Vitest as well. (we should probably consider auto-generating something in the docs for these cases as well, honestly, but for now this is how it is done).
Other rules have a note like so:
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/no-alias-methods.md),
/// to use it, add the following configuration to your `.oxlintrc.json`:
///
/// ```json
/// {
/// "rules": {
/// "vitest/no-alias-methods": "error"
/// }
/// }
/// ```
daea57d to
3ad66ee
Compare
|
@connorshea Added missing dock blocks and update the PR description to point the
Just FYI, some compatibles vitest rule are missing that doc block, for example |
Good point, if you want to open a PR for that change, I'd be happy to review/merge that :) |
3ad66ee to
ff3ba37
Compare
PR created #16679 |
camc314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
Do you mind also porting the vitest test cases for this rule to ensure that we're catching all cases?
This can be done by:
just new-vitest-rule no-mocks-import
And copying over the generated test cases to crates/oxc_linter/src/rules/jest/no_mocks_import.rs, this allows us to ensure that we're reporting all cases correctly for both vitest/jest
e.g.
oxc/crates/oxc_linter/src/rules/jest/consistent_test_it.rs
Lines 794 to 795 in 4911d60
| let fail_vitest = vec) - no-restricted-matchers - no-standalone-expect - no-test-return-statement - prefer-comparison-matcher - prefer-each - prefer-equality-matcher - prefer-expect-resolves - prefer-hooks-on-top - prefer-lowercase-title - prefer-mock-promise-shorthand - prefer-strict-equal - prefer-to-be - prefer-to-have-length - prefer-todo - require-to-throw-message - require-top-level-describe
ff3ba37 to
51019f0
Compare
|
@camc314 Updated the PR with the vitests test case but I have notice the diagnostic message is framework dependant. I'm not sure how to approach here:
|
camc314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank yoiu!
|
I pushed another commit - it just merges the two diagnostic messages together. It's tricky to know if we are in a vitest/jest file, so for simplicity, we just report the same error |
… and message based on framework
da395e9 to
9734366
Compare
stale - comment has been updated
…h vitest. (#16679) After the review @connorshea did in #16540 (review), suggested to me add a missing part of documentation in the linter rule. I hadn't added it because the reference rule I used lack of it. So this PR aims to add it in all jest rules stated as compatible. ## Before this PR The following Jest linter only had this documentation part: - consistent-test-it - expect-expect - no-alias-methods - no-commented-out-tests - no-disabled-tests - no-focused-tests - no-identical-title - no-test-prefixes - prefer-hooks-in-order - valid-describe-callback - valid-expect ## Adding in this PR - max-expects - max-nested-describe - no-conditional-expect - no-conditional-in-test - no-duplicate-hooks - no-hooks - no-interpolation-in-snapshots - no-restricted-jest-methods: I have doubts here see my comment in the [vitest-eslint-plugin issue](#4656 (comment)) - no-restricted-matchers - no-standalone-expect - no-test-return-statement - prefer-comparison-matcher - prefer-each - prefer-equality-matcher - prefer-expect-resolves - prefer-hooks-on-top - prefer-lowercase-title - prefer-mock-promise-shorthand - prefer-strict-equal - prefer-to-be - prefer-to-have-length - prefer-todo - require-to-throw-message - require-top-level-describe
…rule (#16540) Related to #4656 Implement [no-mocks-import](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md) lint ruler adding a new entry in the mapping between jest and vitest compatible rules. Oxlint-migrate PR related: oxc-project/oxlint-migrate#269 --------- Co-authored-by: Cameron Clark <[email protected]>
Related to #4656
Implement no-mocks-import lint ruler adding a new entry in the mapping between jest and vitest compatible rules.
Oxlint-migrate PR related: oxc-project/oxlint-migrate#269