Skip to content
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

[FEATURE REQUEST] Add options to no-useless-rest-spread rule #48

Open
gauthieramano opened this issue Mar 3, 2023 · 0 comments
Open

Comments

@gauthieramano
Copy link

gauthieramano commented Mar 3, 2023

It would be great if this rule could be disabled for arguments in function declarations (it seems to be the most relevant case I encounter), like:

"mysticatea/no-useless-rest-spread": ["error", { "ignoreFunctionArgs": true }],

In TypeScript, we can type the arguments of a function like so:

// Let's consider that this type is used many times in a codebase
type SomeTuple = [a: string, b: number];

const foo = (...[a, b]: SomeTuple) => {
  // someting
};

(Note: I took a simple example, but it's not rare having to use the spread syntax to type variables in order to be DRY)

As no-useless-rest-spread rule is auto-fixable, if we don't pay attention, we get this (on save for instance):

// both arguments are now typed as `any`
const foo = (a, b) => {
  // something
};

It's annoying having to:

  • add // eslint-disable-next-line mysticatea/no-useless-rest-spread everywhere this case occurs
  • search where are the mistakes when we enable this rule and lint the whole codebase with eslint --fix .

Notes:

  1. I opened an issue in typescript-eslint/typescript-eslint repository (but it won't go anywhere):
  1. I also opened an issue in eslint-community/eslint-plugin-mysticatea repository:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant