-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Configs: Allow strict configs to have more strict options than recommended? #7318
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
Comments
This sounds like a must-do! As a user who wants a maximally strict linting config, I'd be super interested to know which rules that I'm using that are inherited from |
Hmm, very interesting. I like the root ask of knowing which rules have opt-in "more strict" options... |
I'm of two minds - I like the idea but I also dislike it because it does make things quite a bit more complicated to define and strictly type. The options type we use is not for the config inputs - it's for the "after defaults" merging - which is one reason we haven't added strict types for user configs with our options types. The last thing I'd want is for us to define a stricter config, roll it out, then find we misconfigured it and it's broken! |
Here's a list of rules I'd propose:
Maybe we could make Sent #8364 as reference. |
strict-boolean-expressions also has some weird defaults that could be stricter: "@typescript-eslint/strict-boolean-expressions": [
"error",
{
allowString: false,
allowNumber: false,
allowNullableObject: false,
allowNullableBoolean: false,
allowNullableString: false,
allowNullableNumber: false,
allowNullableEnum: false,
allowAny: false,
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
},
], |
Also here: /**
* The `allowDefaultCaseForExhaustiveSwitch` option is disabled and the
* `requireDefaultForNonUnion` option is enabled to make the rule stricter.
*/
"@typescript-eslint/switch-exhaustiveness-check": [
"error",
{
allowDefaultCaseForExhaustiveSwitch: false,
requireDefaultForNonUnion: true,
},
], |
And this: /** The `capIsConstructor` option is disabled to make the rule stricter. */
"@typescript-eslint/no-invalid-this": [
"error",
{
capIsConstructor: false,
},
], And this: /**
* The `args` option is set to `all` make the rule stricter. Additionally, we ignore things that
* begin with an underscore, since this matches the behavior of the `--noUnusedLocals` TypeScript
* compiler flag.
*/
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all", // "after-used" is the default.
argsIgnorePattern: "^_", // Optional, this line makes the rule less strict, but is idiomatic
varsIgnorePattern: "^_", // Optional, this line makes the rule less strict, but is idiomatic
},
], |
Oh @Zamiell just looking at those now: none of those are in the |
Before You File a Proposal Please Confirm You Have Done The Following...
Description
Coming over from comment thread #7110 (comment): rules are occasionally in a situation where:
What if we added to the
defaultOptions
and/ormeta.docs
sections of rules so that different configs can have different default options?Impacted Configurations
strict
strict-type-checked
Additional Info
The example from the thread is https://typescript-eslint.io/rules/restrict-plus-operands/#options.
The text was updated successfully, but these errors were encountered: