-
Notifications
You must be signed in to change notification settings - Fork 241
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
ts-migration/everything-else #363
Conversation
@SimenB I was planning on doing some minor clean up before bed, but by the time I hit the "create" button it was 1am 😂 Feel free to review & request changes, but as I said in the PR body I think at this point it's probably best to merge first & cleanup after, just b/c of the share size of the PR. oh and btw I migrated the Would you be able to check that out for me?
I created an issue for |
4358e44
to
9c5bb95
Compare
Error SyntaxError
Dangerfile
Generated by 🚫 dangerJS |
@SimenB errrrr I'm going to defer this to you rather than jump to straight to reporting it to
|
Just retrigger the build - you should have the correct rights as you have push access to the repo. The failure looks transient. I'll review this tomorrow or Wednesday (I'm currently on vacation, but in transit tomorrow, so might have some time then) |
Yeah that's what I figured. Sorry about the sudden email spam btw 😬 Feel free to take your time on responding - I've got more than enough things on my plate that I'm in no rush 😂 |
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 super exciting! I'm not done reviewing, I just did a quick pass 🙂 Will come back to it later, but might as well submit in the meantime
src/rules/prefer-called-with.ts
Outdated
|
||
const { modifier, matcher } = parseExpectCall(node); | ||
|
||
// Could check resolves/rejects here but not a likely idiom. |
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.
if anything it should be an error...
Awesome, thanks for the first-pass review! I figured you'd like some of that stuff broken out into PRs, but at the time just wanted to get it all committed 😂 I'll start cherry-picking. I've also got an idea on how to implement a |
defc039
to
8097c7b
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.
This is amazing work, thank you so much for tackling this. This has many hours invested in it, and I highly appreciate it! ❤️
My only real comment is that I think the utils are hard to navigate, even though they seem well documented. While we could deal with that in a follow-up, I'd prefer it if we could figure something out with them before landing this
src/rules/no-large-snapshots.ts
Outdated
propertyName === 'toThrowErrorMatchingInlineSnapshot' | ||
'property' in node.callee && | ||
isSupportedAccessor(node.callee.property) && | ||
[ |
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.
extract this array into a const outside of the scope of this function?
src/rules/utils.ts
Outdated
* | ||
* @return {node is StringLiteral} | ||
*/ | ||
export const isStringLiteral = (node: TSESTree.Node): node is StringLiteral => |
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.
don't export this, it's not used. Mind going over all exports and just keeping the ones actually used outside of this file as export
s?
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.
Yup that's at the top of my list of things to do during the week - same w/ checking all the generics :)
src/rules/utils.ts
Outdated
| NotNegatableParsedModifier<NotNegatableModifierName> | ||
| NegatableParsedModifier<NegatableModifierName>; | ||
|
||
interface Expectation<ExpectNode extends ExpectCall = ValidExpectCall> { |
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.
Should we have some sort of expect-utils
file? I think this file is big and unwieldy so I'd like to split it up somehow. Navigating the helpers might be difficult if you're not familiar with them already.
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.
If that's hard, could we group types and their type guards separately from the parsers etc?
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.
That's exactly what I'm thinking, and planning to look into.
Glad we're on the same page :)
src/rules/utils.ts
Outdated
|
||
/* istanbul ignore next */ | ||
if ( | ||
!( |
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.
way too many parens
if (
!isSpecificMember(parsedMember, ModifierName.resolves) &&
!isSpecificMember(parsedMember, ModifierName.rejects)
) {
throw
}
Maybe even isSpecificMember
should take varargs at the end so you can do isSpecificMember(parsedMember, ModifierName.resolves, ModifierName.rejects)
?
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.
Agreed - I'm not sure I went w/ that in the first place 😂
While varargs would work, I didn't use them b/c I think it's not worth it - this is the only place that method is used, and w/ using varargs you've got to & string[]
for .includes
to work properly; I don't think the mess is worth the gain here.
Overall the whole reason we need this check is that TypeScript knows that while compile time we enforce name
& getAccessorValue(node)
to be the "same" (since name
is meant to be literally the result of getAccessorValue(node)
), at runtime there is no such enforcement.
It's a bit of a messy situation, that I think is partly due to how I've structured the typings to account for negation, but imo it's an acceptable trade-off: this is as unsound as we get relative to the other types, and they should be as stable as they can get.
The alternative types would likely be very confusing & drawn out, for the same result minus having to do this check at runtime.
I think this will be solvable (or at least improvable) once negated types land, of which this library is one I've got earmarked as a nice place to play around w/ them in b/c there's some clear places they could be used, so hopefully they'll land soon.
Thanks again for the review! Looking over it I think the majority of your comments are what I had when I self-reviewed, and are on my radar as part of the clean up, which is awesome :D I'll tackle it during the week - should have it all cleaned by the weekend at the latest :) |
That's awesome, looking forward to it! |
Thanks, me too. In the meantime if you're feeling daring, might be worth releasing the stuff we just merged (after the snapshot processor & index are merged) just so that any (hopefully small) breaks trickle through now to be tackled. My work schedule is such that I can handle triaging & tackling any smaller issues that pop up, but will be limited on core hours until Friday (hence why the major clean will probs be mainly on the weekend). Up to you :) |
405b2e8
to
d896302
Compare
044db14
to
7bc69ac
Compare
invalid: [ | ||
/* |
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.
failing tests? If yes, open up an issue so we don't forget?
@SimenB your rebase had the same results as mine. Either we'll have to interactively rebase to resolve it manually, or just make a new commit. I'm happy if you've got the time to do the former, otherwise I can just do the latter & call it a day :) |
Just a new commit is fine. I'll probably rewrite a bunch of the cleanup commits either way before merging 🙂 |
Awesome, I'll do that now then.
I'm open to being schooled if there's anything I could improve on to help reduce the need for rewriting on future work :) |
Not much to do until we're ready to merge, really 🙂 As the review is ongoing, new commits all the time are best as it's easiest to review that way. But stuff like "add comment", "rename function" and "change ternary order" (or something like that) is not useful when merged to master. |
heads up - I merged #364. Which I guess will be even simpler with the (that will also trigger the release you requested with some of the refactors extracted from this PR) |
ca9b704
to
bbe5238
Compare
fdb983e
to
a46abf9
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.
This PR is so big 😅 Do you think it'd be possible to land a few of the new guards on master outside of a 2k LOC diff?
Also, maybe we could keep tsUtils
named utils
in this PR, which should remove a bunch of the files from the diff, and just have a single commit later renaming the file and fixing the imports
@SimenB haha yeah that's what I'm thinking too. Right now I'm actually going through all the CLI options in Jest to find out which ones don't yet support being transformed ;) But yeah I think that's best - I'll whip up some PRs.
Are you saying land them w/o rules? I'm happy w/ that if you are :) |
I meant the guards that are used in the already converted rules. That way it might be easier to properly review |
8393435
to
9f3c919
Compare
src/rules/no-identical-title.ts
Outdated
@@ -1,3 +1,4 @@ | |||
import { TSESTree } from '@typescript-eslint/experimental-utils'; |
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 this import used? other changes in file seems to be just whitespace now that it landed on master, so would be cool to avoid that diff?
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.
Yeah that's weird - I'll check this out.
Those whitespace changes were in my PR to master iirc, so not sure what's happened.
Feel free to drop changes to this file when rebasing :)
9f3c919
to
24f1858
Compare
src/rules/no-identical-title.ts
Outdated
@@ -1,3 +1,4 @@ | |||
import { TSESTree } from '@typescript-eslint/experimental-utils'; |
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.
Yeah that's weird - I'll check this out.
Those whitespace changes were in my PR to master iirc, so not sure what's happened.
Feel free to drop changes to this file when rebasing :)
src/rules/no-alias-methods.ts
Outdated
@@ -1,19 +1,25 @@ | |||
import { expectCaseWithParent, getDocsUrl, method } from './util'; | |||
import { createRule, isExpectCall, parseExpectCall } from './tsUtils'; |
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'll probably use this to land parseExpectCall
, followed by no-truthy-falsy
, and then the other rules can have their own PRs 🤷♂
I don't think the commits here are very atomic any more (most of the work is in (If I messed up, |
24f1858
to
904996d
Compare
That's ok - I don't think we'll be landing this PR specifically, but it's good to have for tracking work remaining. When I get a chance I'll break a few more rules out for merging :) Also: only ~1k LOC changes now :D |
Makes sense! I think it was a good idea with a huge PR though, to get a feeling of the final picture, but splitting parts out when things start settling into pieces that are actually reviewable makes sense 🙂 |
41d6088
to
c6fb4da
Compare
c6fb4da
to
26756b6
Compare
@SimenB it is done 🚀🚀🚀🚀🚀🚀🚀🚀 |
It's finally here!
This PR converts the remaining JS files to TypeScript (where possible) - All tests are passing, and coverage is 100%; as such this PR is good to go as is.
For now I'm going to do some light cleanup, which I'll commit & push to this branch, but can also be in the next PR - let me know if you'd like me to cherry pick anything out into separate PRs & what have you.
I am trying to avoid changing the already-converted rules in this PR, which is why there is definitely some redundancy, and forms a nice bridge to the second half of what is quickly becoming one of my classic overly detailed text dumps:
My immediate next step is going over every rule w/ a fine-tooth comb to make sure they're all consistent, and to fix a number of nitpicks, including:
valid
aboveinvalid
in rule tests)parseExpectCall
where possible, & other such new methodsdata
(i.ename
vspropertyName
vsmatcherName
).join('\n')
for multi-line stringsThe big massive inconsistency in the room that I'd like to get addressed is our stance on bracket accessors:
A few tests have explicit test cases showing support (i.e
describe['skip']
), but most other rules either won't work w/ that type of accessor, or - in the case of fixers - will error.The former is not a problem, as the
AccessorNode
& co (getAccessorValue
,isSpecificAccessor
, etc) types & methods are for facilitating the normalisation required for rules to support bothIdentifier
(expect.<blah>
) & literal node types (expect['blah']
).However, all the fixers currently will just error out - this is b/c the ones that this matter for are typically searching for a
propertyDot
value.It's fairly straightforward to implement support, and am happy to do it - but it's something that other maintainers should be aware of for when reviewing new rules, as we should try and ensure all rules have tests for both types of accessor.
In light of that, I'm going look to create a series of standard tests that all rules should have to be tested against, w/ things like
expect();
,expect
,expect.toBe()
, etc to make sure that all our rules can handle the same basic edge cases.I also want to review the stuff for test, describe, etc, &
getNodeName
as they're somewhat duck-taped together. Ideally it'd be cool if I could create a "parse" method for those too, but that might be a bit overkill - either way, there are some open issues relating to them so let's see what I can come up w/ :DFollowing all of this, which shouldn't take too long, I'm going to look at open issues, and try to get some of them closed, including implementing some new rules :)
In particular, I want to create a "ban-matchers" rule as it's just a form of
no-truthy-falsy
w/ an array option, but I can't nail down a good syntax for supporting modifiers which is making me super sad :( - I'll probably open up a new issue for this to discuss, while making a basic version of the rule to start w/.Fixes #256
Relates to #332
Superseeds & closes #346
Superseeds & closes #333