Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

JoshuaKGoldberg started this conversation in Technical Discussions
Discussion options

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

You must be logged in to vote

Replies: 1 comment

Comment options

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".

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation ("docs") that needs adding/updating
2 participants
Converted from issue

This discussion was converted from issue #5119 on November 19, 2022 06:01.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.