Skip to content

Comments

feat(linter): eslint/no-fallthrough [BLOCKED]#633

Merged
Boshen merged 11 commits intooxc-project:mainfrom
suica:feat/no-fallthrough
Oct 21, 2023
Merged

feat(linter): eslint/no-fallthrough [BLOCKED]#633
Boshen merged 11 commits intooxc-project:mainfrom
suica:feat/no-fallthrough

Conversation

@suica
Copy link
Contributor

@suica suica commented Jul 26, 2023

Blocked by control flow analysis

For #597

Summary

In eslint: https://eslint.org/docs/latest/rules/no-fallthrough

TODOs:

  • Implement reachability analysis first...which should be in another PR.
  • Pass basic cases
  • Support commentPattern option. Ref:
impl Rule for NoUnsafeNegation {
    fn from_configuration(value: serde_json::Value) -> Self {
        let enforce_for_ordering_relations = value
            .get(0)
            .and_then(|config| config.get("enforceForOrderingRelations"))
            .and_then(serde_json::Value::as_bool)
            .unwrap_or_default();
        Self { enforce_for_ordering_relations }
    }

    fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
        let AstKind::BinaryExpression(expr) = node.kind() else { return; };
        if self.should_check(expr.operator) {
            let Expression::UnaryExpression(left) = &expr.left else { return; };
            if left.operator == UnaryOperator::LogicalNot {
                Self::report_with_fix(expr, ctx);
            }
        }
    }
}

@suica suica force-pushed the feat/no-fallthrough branch from cc997d1 to 1e1876e Compare July 26, 2023 09:45
@github-actions github-actions bot added the A-linter Area - Linter label Jul 26, 2023
@suica suica changed the title feat(linter): eslint/no-fallthrough feat(linter): eslint/no-fallthrough [BLOCKED] Jul 26, 2023
@Boshen
Copy link
Member

Boshen commented Jul 27, 2023

Blocked by needing the fallthrough cases computed from the semantic pass.

@Boshen
Copy link
Member

Boshen commented Oct 21, 2023

CFG will unlikely happen in a short period of time so I'll close this for now to happen the PR list clean, I'll reopen this PR when CFG is ready.

@Boshen Boshen closed this Oct 21, 2023
@Boshen Boshen reopened this Oct 21, 2023
@github-actions github-actions bot added the A-ast Area - AST label Oct 21, 2023
@Boshen
Copy link
Member

Boshen commented Oct 21, 2023

Instead of closing, I should merge some of this.

@Boshen Boshen self-requested a review October 21, 2023 01:30
@Boshen Boshen force-pushed the feat/no-fallthrough branch from 649f731 to 37a983c Compare October 21, 2023 15:02
@Boshen Boshen marked this pull request as ready for review October 21, 2023 15:22
@Boshen Boshen merged commit 25247e3 into oxc-project:main Oct 21, 2023
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 21, 2023

CodSpeed Performance Report

Merging #633 will not alter performance

Comparing suica:feat/no-fallthrough (23ed39a) with main (72cf9ec)

Summary

✅ 22 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants