-
Notifications
You must be signed in to change notification settings - Fork 660
feat(rome_js_analyze): no shadow restricted lint rule #2975
Conversation
Deploying with Cloudflare Pages
|
c5b9fbf
to
9d37d5b
Compare
9d37d5b
to
196e4fd
Compare
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
Would you mind adding |
And also I would recommend benching our suite using |
Results using criterion
and running
|
Nice |
but quite boring! I was expecting to use fst with transducers and SIMD running in multiple GPU with Raytracing. Everything mega fast. In the end: |
lol |
crates/rome_js_analyze/src/semantic_analyzers/js/no_shadow_restricted_names.rs
Outdated
Show resolved
Hide resolved
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.
I just realized now that this rule was removed from rome classic (the documentation was not deleted). I can't remember why it was removed though. Should we keep the rule? @sebmck , do you remember why it was removed?
crates/rome_js_analyze/Cargo.toml
Outdated
@@ -19,15 +19,35 @@ rome_console = { path = "../rome_console" } | |||
rome_diagnostics = { path = "../rome_diagnostics" } | |||
roaring = "0.9.0" | |||
rustc-hash = "1.1.0" | |||
iai = "0.1.1" | |||
regex = { version = "1.6.0" } |
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.
This crate should be moved in dev-dependencies
} | ||
} | ||
|
||
const RESTRICTEDNAMES: [&str; 9] = [ |
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.
RESTRICED_NAMES
"NaN", | ||
"undefined", | ||
"Infinity", | ||
"arguments", | ||
"eval", | ||
"Set", | ||
"Object", | ||
"Array", | ||
"JSON", |
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.
I believe the list of restricted names is not enough. Here's what we had in rome classic: https://github.com/rome/tools/blob/archived-js/internal/compiler/scope/globals.ts
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.
And which version do we want? Does the configuration file have the version?
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.
We don't have it yet, I suppose it will become more important once we have transformations.
So for the moment we should use the latest version, because we target/support up to ES2022.
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.
Woah, awesome work on the extensive benchmark !
crates/rome_js_analyze/Cargo.toml
Outdated
@@ -19,15 +19,35 @@ rome_console = { path = "../rome_console" } | |||
rome_diagnostics = { path = "../rome_diagnostics" } | |||
roaring = "0.9.0" | |||
rustc-hash = "1.1.0" | |||
iai = "0.1.1" | |||
regex = { version = "1.6.0" } |
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.
Is it necessary to add regex as a prod dependency. Isn't it only used as part of the benchmarks?
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.
I moved everything to another crate.
crates/rome_js_analyze/Cargo.toml
Outdated
fastbloom-rs = "0.3.0" | ||
qp-trie = "0.8.0" | ||
fst = "0.4.7" | ||
criterion = "0.3.5" | ||
memchr = "2.5.0" | ||
|
||
[[bench]] | ||
name = "to_camel_case" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "iai" | ||
name = "contains_iai" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "contains_criterion" | ||
harness = false | ||
|
||
[[bin]] | ||
name = "contains_iai" | ||
path = "bins/contains_iai.rs" | ||
test = false | ||
bench = false |
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.
This is adding a lot of dependencies only for the sake fo the benchmark. How about you split out the benchmark out into its own PR and close it (without merging). This would keep the benchmark around for historic sake (you could e.g. add a link in a comment) without pulling in a large number of new dependencies.
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.
agree
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.
I can move this to xtask/bench, given that this is a generic benchmark. I think will be nice to keep this around, as we will have multiple cases of these "micro benchmarks"
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.
I moved everything to another crate.
d5d0451
to
3969553
Compare
!bench_analyzer |
Analyzer Benchmark Results
|
* no shadow restricted lint rule
Summary
Closes #2897.
I created this benchmark https://github.com/rome/tools/pull/2975/files#diff-02554aa7d6b22992e92b6b8fe6366b78706e2a98f0f421cfd4641f79fa7fec8c expecting that a fancy algorithm would be faster, but end up testifying that cache rules and a simple slice::contains was the faster for the small number os strings we test.
The binary that calls this benchmark is only because
iai
do not support setup yet (bheisler/iai#24) Basically it runs the test twice. First only the setup, and second the whole test and take the difference.Codegen
I changed the codegen for analyzers prefixing it with "self" to avoid collisions with some crates. "regex" is an example.
I also implemented a "codegen all" to make it simpler to update everything. But running changed things in the formatted and the parser.
Parser errors
Some examples are commented because they generate parser errors.
I think our parser should accept these, and let the linter complain. I can change this in another PR.
Test Plan