-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use at() instead of direct access #104
Conversation
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.
Some things I noticed in this PR:
- Tests in the repo are failing. One is related to
tests/use-periods-error-messages.test.js
file (which I think we don't need to fix right now), and for the other one we need to upgradejest
to latest version (29.7.0
) in order to fix it, we could do in this PR. - We need a good way to determine if we are dealing with a object or an array, since I can use the same
[]
notation to access object's properties but we don't want the rule to apply to objects. I think we can use the parser services from@typescript-eslint/utils
to help us identify an array in the project, for example something like this.You will also need to useconst { ESLintUtils } = require("@typescript-eslint/utils"); ... function checkNode(node) { const parserServices = ESLintUtils.getParserServices(context); const typeChecker = parserServices.program.getTypeChecker(); function isArrayType(node) { const type = typeChecker.getTypeAtLocation( parserServices.esTreeNodeToTSNodeMap.get(node) ); return typeChecker.isArrayType(type) || typeChecker.isTupleType(type); } ...
RuleTester
from@typescript-eslint/rule-tester
in your test file. Here is an interesting doc.
Is
|
@ShridharGoel you must upgrade
|
Thanks, but consistently getting this issue:
In the test file, this is included:
tsconfig.json:
I've also tried adding |
@fabioh8010 Can you have a look at the above? |
Please let me know if it works or not. |
It did not work:
Also, it is in JS. So do we need TS compatibility here? |
@ShridharGoel I don't understand your comment, please provide more information about the error:
|
@fabioh8010 The test suite fails with the above message. I've pushed the changes in this branch itself: baf7d27 |
Thanks @ShridharGoel , will take a look tomorrow! |
@ShridharGoel I checked your PR and as I said before you need to upgrade |
@fabioh8010 Thanks, I had missed that. It is working now, can you check the updated code? |
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.
Looking good, left few comments!
Updated but it wouldn't pass the |
@fabioh8010 @eh2077 Can you have a look? Edit: Some extra files got added, I'll remove them. |
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.
My final comments I believe, looks really great now 🚀 Please remove the additional files and I will approve
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.
two minor comments, besides that LGTM 🚀
Updated. |
I'll take a look and test it soon |
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.
LGTM, just a small comment
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.
do you think we could also verify that this case with as const
is considered valid?
const myArr = ['a', 'b', 'c'] as const;
myArr[0]; // good, type should be `a`
myArr[1]; // good, type should be `b`
myArr[2]; // good, type should be `c`
myArr[3]; // error
@ShridharGoel heads-up that I am unable to merge this because it contains unsigned commits |
b86841c
to
36b12be
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.
can you please add .idea
to the gitignore?
Updated. |
Added .idea and *.iml files to gitignore. |
🚀 Published in 2.0.56 |
@ShridharGoel @roryabraham question: we've been trying with @MonilBhavsar to bump the eslint version in the App but we've been getting this error, which seems to be related to this rule added here? Any advice on how we should proceed? |
I'll be bumping the ESlint version soon, and will handle it then.
… Message ID: ***@***.***
.com>
|
Got it, would you please let me know when it's ready? thank you! |
@ShridharGoel small bump :) |
Fix has been identified, opening the PR in few minutes.
|
@ShridharGoel Merged, thank you! Question though, do you know why this may be failing still with these period rules? I can see that the rule is updated already here and tests as well. |
@ShridharGoel @roryabraham I see that the version hasn't been bumped yet and it's been over a week since this comment, do we know when are we going to do this? It's holding this PR, but not sure if there's something that's holding it back that I'm unaware of 🙏 |
Will be doing it soon. I don't have access to a Mac since few days, and
this needs many manual changes as well so setting up WSL. But it shouldn't
be a blocker, you can update the version I think without enabling this
rule.
|
Expensify/App#43055