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

refactor(linter): LintContext can now only be constructed with a cfg enabled semantic. #3761

Conversation

rzvxa
Copy link
Contributor

@rzvxa rzvxa commented Jun 19, 2024

It has the same spirit as #3747 but with a much simpler approach. I've used the fact that @Boshen mentioned about linter always using CFG so now we assert semantic.cfg().is_some() in the LintContext::new because of this assertion we can have a LintContext::cfg that unwraps unchecked.
Eliminates unnecessary checks in our hot paths.

It has the best of both worlds, No complicated typing yet we still get the CFG as a non-optional value without extra ASM or branching.

Copy link

graphite-app bot commented Jun 19, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Contributor Author

rzvxa commented Jun 19, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @rzvxa and the rest of your teammates on Graphite Graphite

@github-actions github-actions bot added the A-linter Area - Linter label Jun 19, 2024
@rzvxa rzvxa requested a review from Boshen June 19, 2024 12:20
Copy link

codspeed-hq bot commented Jun 19, 2024

CodSpeed Performance Report

Merging #3761 will improve performances by 4.08%

Comparing 06-19-refactor_linter_lintcontext_can_now_only_be_constructed_with_a_cfg_enabled_semantic (4d2b7f1) with main (4fb90eb)

Summary

⚡ 2 improvements
✅ 19 untouched benchmarks

Benchmarks breakdown

Benchmark main 06-19-refactor_linter_lintcontext_can_now_only_be_constructed_with_a_cfg_enabled_semantic Change
linter[cal.com.tsx] 704.6 ms 681.2 ms +3.42%
linter[checker.ts] 1.4 s 1.3 s +4.08%

@rzvxa rzvxa marked this pull request as ready for review June 19, 2024 12:24
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jun 19, 2024
Copy link

graphite-app bot commented Jun 19, 2024

Merge activity

  • Jun 19, 8:31 AM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jun 19, 8:31 AM EDT: Boshen added this pull request to the Graphite merge queue.
  • Jun 19, 9:01 AM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jun 19, 9:01 AM EDT: rzvxa added this pull request to the Graphite merge queue.
  • Jun 19, 9:05 AM EDT: rzvxa merged this pull request with the Graphite merge queue.

Boshen pushed a commit that referenced this pull request Jun 19, 2024
…g enabled semantic. (#3761)

It has the same spirit as #3747 but with a much simpler approach. I've used the fact that @Boshen mentioned about linter always using CFG so now we assert `semantic.cfg().is_some()` in the `LintContext::new` because of this assertion we can have a `LintContext::cfg` that unwraps unchecked.
Eliminates unnecessary checks in our hot paths.

It has the best of both worlds, No complicated typing yet we still get the CFG as a non-optional value without extra ASM or branching.
@Boshen Boshen force-pushed the 06-19-refactor_linter_lintcontext_can_now_only_be_constructed_with_a_cfg_enabled_semantic branch from 53bc803 to 8175771 Compare June 19, 2024 12:39
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jun 19, 2024
@rzvxa
Copy link
Contributor Author

rzvxa commented Jun 19, 2024

@Boshen does graphite have an arbitrary limit on the number of stacks that can be in the merge queue at any moment? I've noticed it removed the merge label from this PR after you've added 2 other PRs to the merge queue. It's just an observation, If that is the case and we have an order dependant PR getting merged we should be more careful about this.

@rzvxa rzvxa added the 0-merge Merge with Graphite Merge Queue label Jun 19, 2024
…g enabled semantic. (#3761)

It has the same spirit as #3747 but with a much simpler approach. I've used the fact that @Boshen mentioned about linter always using CFG so now we assert `semantic.cfg().is_some()` in the `LintContext::new` because of this assertion we can have a `LintContext::cfg` that unwraps unchecked.
Eliminates unnecessary checks in our hot paths.

It has the best of both worlds, No complicated typing yet we still get the CFG as a non-optional value without extra ASM or branching.
@rzvxa rzvxa force-pushed the 06-19-refactor_linter_lintcontext_can_now_only_be_constructed_with_a_cfg_enabled_semantic branch from 8175771 to 4d2b7f1 Compare June 19, 2024 13:01
@Boshen
Copy link
Member

Boshen commented Jun 19, 2024

I'm not sure, this graphite merge queue is confusing sometimes (probably due to interacting with github).

@graphite-app graphite-app bot merged commit 4d2b7f1 into main Jun 19, 2024
22 checks passed
@graphite-app graphite-app bot deleted the 06-19-refactor_linter_lintcontext_can_now_only_be_constructed_with_a_cfg_enabled_semantic branch June 19, 2024 13:05
Boshen added a commit that referenced this pull request Jun 27, 2024
## [0.5.0] - 2024-06-27

- 6796891 ast: [**BREAKING**] Rename all instances of `BigintLiteral` to
`BigIntLiteral`. (#3898) (rzvxa)

- ae09a97 ast: [**BREAKING**] Remove `Modifiers` from ts nodes (#3846)
(Boshen)

- 1af5ed3 ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`const` on `EnumDeclaration` (#3845) (Boshen)

- ee6ec4e ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`abstract` on `Class` (#3841) (Boshen)

- 4456034 ast: [**BREAKING**] Add `IdentifierReference` to
`ExportSpecifier` (#3820) (Boshen)

- 0537d29 cfg: [**BREAKING**] Move control flow to its own crate.
(#3728) (rzvxa)

- 5c38a0f codegen: [**BREAKING**] New code gen API (#3740) (Boshen)

- 4bce59d semantic/cfg: [**BREAKING**] Re-export `petgraph` as
`control_flow::graph`. (#3722) (rzvxa)

### Features

- 3ae2628 linter: Change `no-import-assign` to correctness (#3928)
(Boshen)
- a89d501 linter: Implement
@typescript-eslint/no-non-null-asserted-nulli… (#3850) (kaykdm)
- fc48cb4 linter: �eslint-plugin-jest/prefer-jest-mocked (#3865)
(cinchen)
- 63b98bd linter: Accept multiple fixes when fix code (#3842)
(mysteryven)
- 328445b linter: Support `vitest/no-disabled-tests` (#3717)
(mysteryven)
- 8c61f9c linter: Implement @typescript-eslint/no-non-null-assertion
(#3825) (kaykdm)
- 080ecbd linter: Add `no-fallthrough`. (#3673) (rzvxa)
- 9493fbe linter: Add `oxc/no-optional-chaining` rule (#3700)
(mysteryven)
- 139adfe linter: Add `@typescript-eslint/no-import-type-side_effects`
(#3699) (mysteryven)
- 5f84500 linter/eslint-plugin-react: Implement prefer-es6-class (#3812)
(Jelle van der Waa)
- fafe67c linter/import: Implement max-dependencies (#3814) (Jelle van
der Waa)
- d5f6aeb semantic: Check for illegal symbol modifiers (#3838) (Don
Isaac)

### Bug Fixes

- 4bd2c88 linter: Fix and promote `getter-return` to correctness.
(#3777) (rzvxa)
- 1190dee linter: False positives with setters in the `getter-return`
rule. (#3714) (rzvxa)
- de0690f linter: Do not run getter-return in typescript (#3693)
(Boshen)
- cf71c23 linter: Edge case with infinite loops. (#3672) (rzvxa)
- 5902331 oxlint: Properly report error (#3889) (Luca Bruno)
- 99a40ce semantic: `export default foo` should have
`ExportLocalName::Default(NameSpan)` entry (#3823) (Boshen)
- abd6ac8 semantic/cfg: Discrete finalization path after `NewFunction`s.
(#3671) (rzvxa)

### Performance
- 4f7ff7e Do not pass `&Atom` to functions (#3818) (overlookmotel)

### Refactor

- 4d2b7f1 linter: `LintContext` can now only be constructed with a cfg
enabled semantic. (#3761) (rzvxa)
- 7302429 linter/prefer_number_properties: Remove the unused
`IdentifierName` check (#3822) (Boshen)
- d8ad321 semantic: Make control flow generation optional. (#3737)
(rzvxa)

### Testing

- 887da40 linter: Enable `no-fallthrough` test with `disable-next-line`.
(#3766) (rzvxa)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants