Skip to content
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): add eslint-plugin-jest/no-conditional-expect rule #832

Merged
merged 7 commits into from
Sep 2, 2023

Conversation

mysteryven
Copy link
Member

@github-actions github-actions bot added the A-linter Area - Linter label Sep 1, 2023
Copy link
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snapshot needs to be updated?

@mysteryven
Copy link
Member Author

mysteryven commented Sep 2, 2023

Even though cargo test in CI passed, I encountered these errors in my local:

failures:

---- rules::eslint::no_control_regex::tests::test stdout ----
thread 'rules::eslint::no_control_regex::tests::test' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
    ([\x00-\x1f]|(?:\\x\w{2})|(?:\\u\w{4})|(?:\\u\{\w{1,4}\}))
                       ^^
error: Unicode-aware Perl class not found (make sure the unicode-perl feature is enabled)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)', crates/oxc_linter/src/rules/eslint/no_control_regex.rs:254:11
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- rules::eslint::no_control_regex::tests::test_unicode_brackets stdout ----
thread 'rules::eslint::no_control_regex::tests::test_unicode_brackets' panicked at 'Once instance has previously been poisoned', /Users/wenzhe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:30:16

---- rules::eslint::no_control_regex::tests::test_unicode_literals stdout ----
thread 'rules::eslint::no_control_regex::tests::test_unicode_literals' panicked at 'Once instance has previously been poisoned', /Users/wenzhe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:30:16

---- rules::eslint::no_control_regex::tests::test_hex_literals stdout ----
thread 'rules::eslint::no_control_regex::tests::test_hex_literals' panicked at 'Once instance has previously been poisoned', /Users/wenzhe/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.4.0/src/inline_lazy.rs:30:16

---- rules::jest::no_commented_out_tests::test stdout ----
thread 'rules::jest::no_commented_out_tests::test' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
    (?mu)^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(
          ^^
error: Unicode-aware Perl class not found (make sure the unicode-perl feature is enabled)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)', crates/oxc_linter/src/rules/jest/no_commented_out_tests.rs:51:92

---- rules::jest::expect_expect::test stdout ----
thread 'rules::jest::expect_expect::test' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
    (?ui)^expect(\.|$)
          ^
error: Unicode-aware case insensitivity matching is not available (make sure the unicode-case feature is enabled)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)', crates/oxc_linter/src/rules/jest/expect_expect.rs:186:55

---- rules::typescript::ban_ts_comment::test stdout ----
thread 'rules::typescript::ban_ts_comment::test' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
    ^/*\s*@ts-(?P<directive>expect-error|ignore|check|nocheck)(?P<description>.*)
       ^^
error: Unicode-aware Perl class not found (make sure the unicode-perl feature is enabled)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)', crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs:176:10


failures:
    rules::eslint::no_control_regex::tests::test
    rules::eslint::no_control_regex::tests::test_hex_literals
    rules::eslint::no_control_regex::tests::test_unicode_brackets
    rules::eslint::no_control_regex::tests::test_unicode_literals
    rules::jest::expect_expect::test
    rules::jest::no_commented_out_tests::test
    rules::typescript::ban_ts_comment::test

test result: FAILED. 116 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.19s

error: test failed, to rerun pass `--lib`

https://github.com/web-infra-dev/oxc/blob/6ae6532245aad7d1848d804f3a3b6734807b32d1/Cargo.toml#L69

Seems I need to change this:

regex              = { version = "1.9.4", default-features = false, features = ["std", "perf", "unicode"] } # remove unicode for smaller binary

@Boshen
Copy link
Member

Boshen commented Sep 2, 2023

Seems like a problem with feature unification, I'll take a look.

@Boshen Boshen merged commit fa1d7da into oxc-project:main Sep 2, 2023
17 checks passed
@mysteryven mysteryven deleted the feat/no-conditional-expect branch September 2, 2023 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants