Closed zepumph closed 2 years ago
There were 1000 lint errors when I turned this rule on. Let's chip away at this!
What do we do for mixin/trait with this?
/* eslint-disable bad-typescript-text */
at the top of the file?
I think just a line directive at every comment where we have those texts.
Should @returns
be added to this rule?
EDIT: The answer is no, because we want to be able to optionally document the return type, like in CarouselButton.ts:
/**
...
* @returns the pointer area, null if no dilation is necessary, i.e. x === 0 && y === 0
*/
function computePointerArea( button: CarouselButton, arrowDirection: ArrowDirection, x: number, y: number ): Bounds2 | null {
EDIT: How about making @returns
by itself (no additional doc) an error?
Yes good plan. Commit coming soon.
Alright. I liked this regex best to allow for extra doc:
/(@returns \{)|(@returns$)/
There were something like 250 lint errors. So it isn't on right now.
From 5/9 supplemental TypeScript meeting:
PSA delivered that this is a chip-away for everyone to work on.
For the lint rule preventing instanceof
or typeof
asserts, we think that most of the offending cases are likely redundant and leftover from JS, but looked at some good usages. Those should be able to pass by opting out of lint for that line.
@zepumph is going to make a commit to allow for disabling by line.
You can now opt out of rules like // eslint-disable-line bad-typescript-text
as needed. @pixelzoom mentioned multiple good reasons to allow checking instanceof or typeof assertions in TypeScript files, so we can disable that line accordingly.
You can now opt out of rules like // eslint-disable-line bad-typescript-text as needed.
Excellent, nice work @zepumph !
geometric-optics and vegas are passing all bad-typescript-text. sun and scenery-phet are close, not a problem in code that I've converted. Self unassigning.
We are down to 143 of these errors. For those coming back to this issue the way to enable this rule is to uncomment https://github.com/phetsims/chipper/blob/f7e06eea7ddb40dde8a8ba010a236566f634ac0b/eslint/rules/bad-typescript-text.js#L25
and
Rules blocking @public
and @protected
have since been enabled in master.
I fixed a bunch of the @private
problems in the above commits. @samreid note that the majority of these were in bending-light and circuit-construction-kit-common. See also https://github.com/phetsims/chipper/issues/1258.
I've fixed most of the @private
problems, with these exceptions:
private
? readonly
?@private
in mixins@private
in mixins@zepumph volunteered to handle these. Then @private
can be turned on in bad-typescript-text.js.
@private
has been enabled in bad-typescript-text.js, so it's no longer relevant for ts-status. Tracking removal of @private
from ts-status in https://github.com/phetsims/chipper/issues/1259.
There are 141 usages of @returns with no extra doc afterwards, we can work on this next.
I also was able to add @param {
as bad text, since we shouldn't be providing type info via jsdoc. There are still two commented out rules:
options = merge
After converting a few merge
s in the above commits... I'm seeing mostly conversions of merge
to optionize
that have been "deferred", no real legitimate need to use merge
. So I think we should definitely address this by adding merge
to bad-typescript-text.
Here's the status of merge
:
From 6/16/22 dev meeting:
We checked in on this issue.
Today we decided that we want to turn on the useless assert instanceof/typeof check for all repos but scenery. Here is the current chip-away for it. Basically 2/3rds are in scenery, and javascript files will use this code for long enough that it isn't worth removing these assertions. This will involve moving this particular rule out of bad-typescript-text so that scenery can opt out of it.
I felt the same way about kite and dot as I did for scenery, I also made the regex more specific, only testing an exact, single type check. Commit coming soon.
Alright, no-simple-type-checking-assertions is now on, and a separate rule in which kite, dot, and scenery opt out. I ended up putting ~10 eslint-disable-lines in place because they seemed good and important.
All that is left for this issue is to get merge
out of our options in typescript.
We are down to 69 merge issues:
✖ 54 problems (54 errors, 0 warnings)
I updated the comment above, just 54 conversions left.
I assigned the remaining repos to responsible devs
In the above commits, I replaced so more occurrences of merge
in sun. The remaining cases are more involved.
Here's a chip-away report of the remaining parts:
Handled all merges in density-buoyancy-common.
Updated chip-away result:
Results from chipAway:
combineOptions
We have good progress on this issue. Everything seems complete except:
@pixelzoom or @jbphet, I went for the ButtonModel usages, can you please review my commit https://github.com/phetsims/sun/commit/0d543c76d7256e1cfc3694ff45c1be3fe9716f93
Back to @zepumph because I'm not sure where this issue is at.
All that is left is ~20 usages of merge in greenhouse.
The greenhouse-effect usages have now all been addressed, and I've turned the rule on. I think we can close this!
We would like
@public
,@private
, and@protected
to be forbidden in typescript files. I think a bad text rule just in the ts overrides section will work here.