Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(eslint-plugin): [no-inferrable] fix optional param to valid code#5342
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nx-cloudbot commentedJul 13, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for the PR,@Josh-Cena! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitorsper day. |
netlifybot commentedJul 13, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site settings. |
codecovbot commentedJul 13, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## main #5342 +/- ##==========================================+ Coverage 91.67% 93.77% +2.09%========================================== Files 363 287 -76 Lines 12227 9875 -2352 Branches 3549 2956 -593 ==========================================- Hits 11209 9260 -1949+ Misses 668 335 -333+ Partials 350 280 -70
Flags with carried forward coverage won't be shown.Click here to find out more. |
{ | ||
// This is invalid TS semantic, but it's trivial to make valid anyway | ||
code: 'const fn = (a?: number = 5) => {};', |
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.
not sure if we want to handle this in here, but there is one more use case that is broken.
classTest{x!:number=5abstracty!:number=5}
maybe something like this could be better:
if(node.type===AST_NODE_TYPES.AssignmentPattern&&node.left.optional){yieldfixer.remove(sourceCode.getTokenBefore(typeNode)!);}elseif((node.type===AST_NODE_TYPES.TSAbstractPropertyDefinition||node.type===AST_NODE_TYPES.PropertyDefinition)&&node.definite){yieldfixer.remove(sourceCode.getTokenBefore(typeNode)!);}
we can make separate ticket for this, if you like
there is also
classTest2{constructor(privatea:number=5){}}
witch is currently not reported
Josh-CenaJul 14, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 add definite assignment to this PR, but theprivate
one seems tangential to this. Does this one also seem worth reporting?
classTest2{x?:number=5;}
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.
Also, theabstract y!: number = 5
is too messed up to be autofixed. The initializer needs to be removed as well. It isn't even reported by the rule under the status quo, so I'll just ignore that.
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.
thanks for fixing this!
This PR contains the following updates:| Package | Type | Update | Change ||---|---|---|---|| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | patch | [`5.30.6` -> `5.30.7`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/5.30.6/5.30.7) || [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | patch | [`5.30.6` -> `5.30.7`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/5.30.6/5.30.7) |---### Release Notes<details><summary>typescript-eslint/typescript-eslint (@​typescript-eslint/eslint-plugin)</summary>### [`v5.30.7`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#​5307-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5306v5307-2022-07-18)[Compare Source](typescript-eslint/typescript-eslint@v5.30.6...v5.30.7)##### Bug Fixes- **eslint-plugin:** \[no-inferrable] fix optional param to valid code ([#​5342](typescript-eslint/typescript-eslint#5342)) ([98f6d5e](typescript-eslint/typescript-eslint@98f6d5e))- **eslint-plugin:** \[no-unused-vars] highlight last write reference ([#​5267](typescript-eslint/typescript-eslint#5267)) ([c3f199a](typescript-eslint/typescript-eslint@c3f199a))</details><details><summary>typescript-eslint/typescript-eslint (@​typescript-eslint/parser)</summary>### [`v5.30.7`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#​5307-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5306v5307-2022-07-18)[Compare Source](typescript-eslint/typescript-eslint@v5.30.6...v5.30.7)##### Bug Fixes- expose types supporting old versions of typescript ([#​5339](typescript-eslint/typescript-eslint#5339)) ([4ba9bdb](typescript-eslint/typescript-eslint@4ba9bdb))</details>---### Configuration📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.--- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.---This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMTguMCIsInVwZGF0ZWRJblZlciI6IjMyLjExOC4wIn0=-->Co-authored-by: cabr2-bot <cabr2.help@gmail.com>Reviewed-on:https://codeberg.org/Calciumdibromid/CaBr2/pulls/1467Reviewed-by: 6543 <6543@noreply.codeberg.org>Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
This PR contains the following updates:| Package | Type | Update | Change ||---|---|---|---|| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`5.30.7` -> `5.31.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/5.30.7/5.31.0) || [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`5.30.7` -> `5.31.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/5.30.7/5.31.0) |---### Release Notes<details><summary>typescript-eslint/typescript-eslint (@​typescript-eslint/eslint-plugin)</summary>### [`v5.31.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#​5310-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5307v5310-2022-07-25)[Compare Source](typescript-eslint/typescript-eslint@v5.30.7...v5.31.0)##### Bug Fixes- **eslint-plugin:** \[typedef] Support nested array destructuring with type annotation ([#​5311](typescript-eslint/typescript-eslint#5311)) ([6d19efe](typescript-eslint/typescript-eslint@6d19efe))- **scope-manager:** handle typeParameters of TSInstantiationExpression ([#​5355](typescript-eslint/typescript-eslint#5355)) ([2595ccf](typescript-eslint/typescript-eslint@2595ccf))##### Features- **eslint-plugin:** \[consistent-generic-ctors] check class field declaration ([#​5288](typescript-eslint/typescript-eslint#5288)) ([48f996e](typescript-eslint/typescript-eslint@48f996e))- **eslint-plugin:** \[prefer-nullish-coalescing] add ignoreTernaryTests option ([#​4965](typescript-eslint/typescript-eslint#4965)) ([f82727f](typescript-eslint/typescript-eslint@f82727f))#### [5.30.7](typescript-eslint/typescript-eslint@v5.30.6...v5.30.7) (2022-07-18)##### Bug Fixes- **eslint-plugin:** \[no-inferrable] fix optional param to valid code ([#​5342](typescript-eslint/typescript-eslint#5342)) ([98f6d5e](typescript-eslint/typescript-eslint@98f6d5e))- **eslint-plugin:** \[no-unused-vars] highlight last write reference ([#​5267](typescript-eslint/typescript-eslint#5267)) ([c3f199a](typescript-eslint/typescript-eslint@c3f199a))#### [5.30.6](typescript-eslint/typescript-eslint@v5.30.5...v5.30.6) (2022-07-11)**Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin)#### [5.30.5](typescript-eslint/typescript-eslint@v5.30.4...v5.30.5) (2022-07-04)##### Bug Fixes- **eslint-plugin:** \[consistent-indexed-object-style] fix record mode fixer for generics with a default value ([#​5280](typescript-eslint/typescript-eslint#5280)) ([57f032c](typescript-eslint/typescript-eslint@57f032c))#### [5.30.4](typescript-eslint/typescript-eslint@v5.30.3...v5.30.4) (2022-07-03)**Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin)#### [5.30.3](typescript-eslint/typescript-eslint@v5.30.2...v5.30.3) (2022-07-01)**Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin)#### [5.30.2](typescript-eslint/typescript-eslint@v5.30.1...v5.30.2) (2022-07-01)**Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin)#### [5.30.1](typescript-eslint/typescript-eslint@v5.30.0...v5.30.1) (2022-07-01)##### Bug Fixes- **eslint-plugin:** \[no-base-to-string] add missing apostrophe to message ([#​5270](typescript-eslint/typescript-eslint#5270)) ([d320174](typescript-eslint/typescript-eslint@58034e3))</details><details><summary>typescript-eslint/typescript-eslint (@​typescript-eslint/parser)</summary>### [`v5.31.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#​5310-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5307v5310-2022-07-25)[Compare Source](typescript-eslint/typescript-eslint@v5.30.7...v5.31.0)**Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser)#### [5.30.7](typescript-eslint/typescript-eslint@v5.30.6...v5.30.7) (2022-07-18)##### Bug Fixes- expose types supporting old versions of typescript ([#​5339](typescript-eslint/typescript-eslint#5339)) ([4ba9bdb](typescript-eslint/typescript-eslint@4ba9bdb))#### [5.30.6](typescript-eslint/typescript-eslint@v5.30.5...v5.30.6) (2022-07-11)**Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser)#### [5.30.5](typescript-eslint/typescript-eslint@v5.30.4...v5.30.5) (2022-07-04)**Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser)#### [5.30.4](typescript-eslint/typescript-eslint@v5.30.3...v5.30.4) (2022-07-03)**Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser)#### [5.30.3](typescript-eslint/typescript-eslint@v5.30.2...v5.30.3) (2022-07-01)**Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser)#### [5.30.2](typescript-eslint/typescript-eslint@v5.30.1...v5.30.2) (2022-07-01)**Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser)#### 5.30.1 (2022-07-01)**Note:** Version bump only for package [@​typescript-eslint/parser](https://github.com/typescript-eslint/parser)</details>---### Configuration📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.--- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.---This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjMyLjEyNy4wIn0=-->Co-authored-by: cabr2-bot <cabr2.help@gmail.com>Reviewed-on:https://codeberg.org/Calciumdibromid/CaBr2/pulls/1480Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
PR Checklist
?
when removing the type #5340Overview
(I have a feeling we need more test cases, but I can't think of any edge-cases.)