We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We have enabled https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-array-destructuring.md
To disallow things like const [,,,, foo] = parts;
const [,,,, foo] = parts;
Which prefers const foo = parts[3].
const foo = parts[3]
But this clashes with https://eslint.org/docs/latest/rules/prefer-destructuring
As no-unreadable-array-destructuring says at the bottom of their page, it's advised to disable the preference of array destructuring.
no-unreadable-array-destructuring
It would be nice if we could only force destructuring for array[0] and array[1], but maybe that will be an option in the future.
array[0]
array[1]
Overview of what we like, especially for tuples.
const t: [string, number, boolean] = ['hello', 42, true]; const s1 = t[0]; // unfortunately allowed const s2 = t.at(0); const [s3] = t;// always preferred const n1 = t[1]; // unfortunately allowed const n2 = t.at(1); const [,n3] = t; // always preferred const b1 = t[2]; // preferred for tuples, since it keeps type information of the tuple slots const b2 = t.at(2); // preferred for arrays (especially when using negative indexes, and works better for typing when length is unknown) const [,,b3] = t; // lint error
The text was updated successfully, but these errors were encountered:
No branches or pull requests
We have enabled https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-array-destructuring.md
To disallow things like
const [,,,, foo] = parts;
Which prefers
const foo = parts[3]
.But this clashes with https://eslint.org/docs/latest/rules/prefer-destructuring
As
no-unreadable-array-destructuring
says at the bottom of their page, it's advised to disable the preference of array destructuring.It would be nice if we could only force destructuring for
array[0]
andarray[1]
, but maybe that will be an option in the future.Overview of what we like, especially for tuples.
The text was updated successfully, but these errors were encountered: