-
Notifications
You must be signed in to change notification settings - Fork 889
What is the correct syntax for defining rules in tslint.json? #3100
Comments
Yes, the newer I agree that the documentation around this is sparse and could use some updating. |
And the correct syntax for setting a rule to off is |
@BehindTheMath yep |
Will this be normalized in the future to only allow one kind of syntax? |
@ChrisMBarr yeah, I think so. It's not a high priority to deprecate the legacy syntax since it doesn't require much code to maintain, but we might start adding deprecation warnings about it in the next few months and remove support for legacy syntax in a few major versions. I'm a little hesitant about it since there are lots of configuration presets out in the wild that could be relying on the old syntax. |
On a side note, the option examples in the rule docs advertise the old config style. We'd need to change this in the metadata of every rule. |
☠️ TSLint's time has come! ☠️ TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. ✨ It was a pleasure open sourcing with you all! |
🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖 🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋 |
From the TSLint docs, it sounds like the only way to specify options for a rule is to set the rule as an object, and use the
options
property. For example:However, I've seen in many places, including the tslint:all configuration as well as TSLint's own tslint.json, where the rule is set as an array, and the options are in an array along with
true
.For example,
"comment-format": [true, "check-space"]
.It appears from this commit and this comment, that the original syntax was the array syntax, and the
options
syntax was added later. At that time,tslint:latest
andtsint:recommended
were updated to follow it, but not other files. Is that correct? It looks like from the code that both are currently supported. Is the neweroptions
syntax recommended over the legacy array syntax?I think the documentation could be clearer about this, especially since the array syntax is so common, and there's currently no mention of it.
The text was updated successfully, but these errors were encountered: