Skip to content

Conversation

@connorshea
Copy link
Contributor

@connorshea connorshea commented Dec 6, 2025

This is part of #16023.

See the tests for the original rule.

We have a test in the eqeqeq.rs implementation like so:

// Issue: <https://github.com/oxc-project/oxc/issues/8773>
("href != null", Some(json!([{"null": "ignore"}]))),

The problem is that this test has an incorrect shape for the config object, see here:

// Should always be in one of these three formats, all three work in the original rule as well:
"eslint/eqeqeq": ["error", "always", { "null": "never" }],
"eslint/eqeqeq": ["error", "always"],
"eslint/eqeqeq": ["error"],

// But right now the tests have a case where the string arg is skipped, while the ESLint rule does not allow this:
"eslint/eqeqeq": ["error", { "null": "ignore" }],

The problem is that the code did previously handle this config array as invalid. However, because the implementation of from on NullType would fall back to ignore if it received bad data, it looked like it worked:

impl NullType {
    pub fn from(raw: &str) -> Self {
        match raw {
            "always" => Self::Always,
            "never" => Self::Never,
            _ => Self::Ignore,
        }
    }
}

Because always is marked as the default value (and is also the default value in the original ESLint rule), and so should be the default case. The test was just hitting the fallback value, so it looked like it worked, but really the fallback value was incorrect previously and did not match the docs or the ESLint behavior.

This fixes that issue by correcting the fallback value, and also fixes the auto-generated config shape/docs, so it correctly represents itself as taking a tuple.

Generated docs:

## Configuration

### The 1st option

type: `"always" | "smart"`

#### `"always"`

Always require triple-equal comparisons, `===`/`!==`.
This is the default.

#### `"smart"`

Allow certain safe comparisons to use `==`/`!=` (`typeof`, literals, nullish).

### The 2nd option

This option is an object with the following properties:

#### null

type: `"always" | "never" | "ignore"`

##### `"always"`

Always require triple-equals when comparing with null, `=== null`/`!== null`.
This is the default.

##### `"never"`

Never require triple-equals when comparing with null, always use `== null`/`!= null`

##### `"ignore"`

Ignore null comparisons, allow either `== null`/`!= null` and `=== null`/`!== null`

@connorshea connorshea requested a review from camc314 as a code owner December 6, 2025 19:40
@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Dec 6, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 6, 2025

CodSpeed Performance Report

Merging #16560 will not alter performance

Comparing more-tuple-docs (2ba5292) with handle-tuple-rules-better (19b5d40)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 self-assigned this Dec 6, 2025
@connorshea connorshea force-pushed the handle-tuple-rules-better branch from ca59885 to 962bfe2 Compare December 6, 2025 22:52
The test only worked because the fallback logic was bad previously. This config object was always wrong, and never should have worked.

This is, however, technically a breaking change. If any users were reliant on the behavior of the rule defaulting to `ignore` if you gave it a bad value, this fix may break things?
@camchenry camchenry merged commit 48cda35 into handle-tuple-rules-better Dec 10, 2025
20 checks passed
@camchenry camchenry deleted the more-tuple-docs branch December 10, 2025 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants