-
Notifications
You must be signed in to change notification settings - Fork 660
useOptionalChain #2748
Comments
foo && foo.bar;
-> foo?.bar;
Would you mind assigning me this task?🙏🏽 |
@denbezrukov Done! |
There is a conditional which is used to check We need it for the case then it's necessary to add parentheses around left part of
I found tools/crates/rome_js_parser/src/syntax/util.rs Lines 8 to 30 in 282bda4
I was wondering if I could make it public and port What do you think?🙏🏽 |
@denbzrukov yes, it makes total sense! Ideally, the precedence should be built using Rust's trait system ( Inside the formatter we created an enum called What we could do, is to move Let me know what you think. |
@ematipico I guess that It seems that tools/crates/rome_js_parser/src/syntax/util.rs Lines 7 to 8 in 282bda4
We can implement this function and use it in E.g.
|
Yes, but there's also the fact that this precedence has a context. The idea is that you have two nodes, the current node and its parent, then you pass An example: a[(a + b) * 3] Here the the parent of the Instead: const a = (3 + 4); Here it's safe to remove the parenthesis. The parent here is a |
@ematipico What do you think about:
We can use the function for
|
@denbezrukov I think there's some misunderstanding, or I don't really understand some point. The parenthesis logic that we have in the formatter doesn't have any correlation with what we want to do inside the linter, I was just suggesting an alternative solution of how we created a precedence ordering based on the context. If I understood correctly, you wanted to use what we already have in the formatter for this rule? I strongly suggest to not use it inside the linter. Let's just use the port from eslint and create the parenthesis expression using the mutation API. Of course we can use the |
@ematipico Sorry😅 Maybe it's better to port the function in another PR? |
Yes, I suppose so. We can start by implementing the rule by itself, without "dependencies". We can check afterwards what we can do with the formatter. The formatter has still an open issue around parenthesis, so it's not fixed/ready yet. |
Hi, I've handle cases with nullish coalescing and logical or: Now I'm working on: |
Hi, I've handle cases with logical and. I'm going to double check test cases, clean code and make MR🥳 |
Glad to see that! |
remove dbg macro
fix doc typo
fix docs and rename new constructor to from_expression
add logical and cases with comments
move is_empty inside collect node fn
suppress suggestion if we have syntax error
No description provided.
The text was updated successfully, but these errors were encountered: