Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Docs: Establish preference for objects over strings in rule options #5119

Closed
2 tasks done
JoshuaKGoldberg opened this issue May 31, 2022 · 1 comment
Closed
2 tasks done
Labels
documentation Documentation ("docs") that needs adding/updating

Comments

@JoshuaKGoldberg
Copy link
Member

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Following up on a couple of threads:

I feel moderately strongly that we should standardize on always using the object in new rules. It's more self-documenting and is the format most rules end up using as they gain more options.

Affected URL(s)

https://github.com/typescript-eslint/typescript-eslint/blob/main/CONTRIBUTING.md

@JoshuaKGoldberg JoshuaKGoldberg added documentation Documentation ("docs") that needs adding/updating accepting prs Go ahead, send a pull request that resolves this issue labels May 31, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title Docs: Establish preference for objects over strings in config settings Docs: Establish preference for objects over strings in rule options May 31, 2022
@Josh-Cena
Copy link
Member

Josh-Cena commented May 31, 2022

I still hold my dissent. Think about function calls:

parseCode(code, { failfast: true });

We can refactor that into parseCode({ code, failfast: true }), but do we want to?

Differentiating between a primary option and a secondary option highlights the former's importance. The primary option isn't just any option: it determines the entire behavior of the rule. Having "consistent-generic-constructors": ["error", "type-annotation"] is synonymous to "parameter-properties": ["error", "always"]—if we change the primary option, the rule's reports will be completely inverted. This should not happen with secondary options, which refine the existing reports (e.g. check more positions, or ignore some cases).

Rules that have a primary option are, really, two rules smashed together, with a string option to toggle between two modes. For example, we can imagine splitting consistent-generic-constructors into prefer-constructor-type-arguments and no-constructor-type-arguments, with completely opposite reports. The only reason we are not doing that is because this is against ESLint's API design norms of "don't have opposing rules".

@JoshuaKGoldberg JoshuaKGoldberg added triage Waiting for maintainers to take a look and removed accepting prs Go ahead, send a pull request that resolves this issue triage Waiting for maintainers to take a look labels May 31, 2022
@typescript-eslint typescript-eslint locked and limited conversation to collaborators Nov 19, 2022
@JoshuaKGoldberg JoshuaKGoldberg converted this issue into discussion #6040 Nov 19, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
documentation Documentation ("docs") that needs adding/updating
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants