-
-
Notifications
You must be signed in to change notification settings - Fork 511
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(deserialize): generic config deserialization #683
Conversation
crates/biome_service/tests/invalid/vcs_missing_client.json.snap
Outdated
Show resolved
Hide resolved
c3ae4b3
to
f0971d3
Compare
f0971d3
to
1f8f98f
Compare
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
1f8f98f
to
6cef658
Compare
6cef658
to
6f80809
Compare
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 like this refactor. I am looking forward to getting this shipped. I left some suggestions and questions, feel free to address them or not.
Here are some things that we should do (now or after we merge the PR):
- Documentation: things now require a different implementation, especially for custom types where we require the usage of some external visitors (Unsize... types for example). Let's craft good documentation with some examples, especially how to deserialize enums, numbers and custom types, e.g.
StringSet
- Explain when to use
Deserializable
and when to useVisitor
. Even though we took a lot of inspiration fromserde
, we can't assume that people know how to use it, especially new contributors that want to create rules with options.
crates/biome_js_analyze/src/analyzers/complexity/no_excessive_cognitive_complexity.rs
Show resolved
Hide resolved
crates/biome_js_analyze/src/analyzers/complexity/no_excessive_cognitive_complexity.rs
Outdated
Show resolved
Hide resolved
6f80809
to
98530ed
Compare
98530ed
to
c18ab3d
Compare
c18ab3d
to
f71327c
Compare
f71327c
to
13aec5a
Compare
13aec5a
to
a423a8c
Compare
e03fb06
to
38e2d3d
Compare
38e2d3d
to
3cd5b13
Compare
3cd5b13
to
c9ed86a
Compare
dfe94a3
to
99d2aac
Compare
99d2aac
to
9fbd1f1
Compare
9fbd1f1
to
c84ebba
Compare
c84ebba
to
7137909
Compare
7137909
to
3edaa51
Compare
@ematipico I think I addressed all your concerns., but one: I am still unsure what to do when a member of an array or a map has a parsing error or a deserialization error. I see several possibilities:
I think (1) is the best, or maybe (2) as a tradeoff. |
I also think the first option is the best! |
3edaa51
to
4e887ba
Compare
4e887ba
to
ef72b07
Compare
Summary
This PR is an application of #620.
In contrast to #620, this proposal is closer to the implementation of serde.
In particular, the visitors are dedicated instances that can hold a state. This allows to support more complex use cases such as deserializing the configuration based on a rule name (The rule name is held by the visitor).
The system relies on 3 main traits:
Deserializable
that allows to deserialize a type (this is analog to theDeserialize
trait of serde).DeserializableValue
that allows deserializing a value. This is the trait implemented to support the deserialization of a new data formatDeserializationVisitor
which allows visiting a value (array, map, boolean ,string, ...)One advantage of separating
Deserializable
andDeserializationVisitor
is the possibility of reusing a visitor for several types, or just implementingDeserializable
by reusing other derializable types.Tasks:
Macros for auto-implement(future)Deserializable
Test Plan
CI should pass.