-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a lookWaiting for team members to take a look
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
import { useCallback } from 'react';
const [a, b, c = ''] = 'somestr'.split('.');
const _myCallback = useCallback(
(value: number[] = [], operator?: string) => [...value, operator],
[a, b, c]
);
type Params = Promise<{ x: string[] }>;
const _processParams = async (params: Params) => {
const { x: [_a, _b, _c = '123'] } = await params;
};ESLint Config
module.exports = {
"rules": {"@typescript-eslint/no-useless-default-assignment": "error"}
}tsconfig
Expected Result
None of these uses should get flagged under this rule.
Actual Result
"Default value is useless because the (parameter|property) is not optional."
Arrays are assumed to be of indefinite length
const [a, b, c = ''] = 'somestr'.split('.');
const { x: [_a, _b, _c = '123'] } = await params;
These are only useless assignments when the array is of sufficient length.
Something about useCallback makes arg defaults get flagged
(value: number[] = [], operator?: string) => [...value, operator]
This works in isolation, but inside of useCallback, it gets flagged.
Additional Info
No response
kirkwaiblinger, ulrichstark, joshswan, doberkofler and silverwind
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a lookWaiting for team members to take a look
{ "compilerOptions": { "strictNullChecks": true } }