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:
"comment-format": {
options: ["check-space"],
}
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 and tsint: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 newer options 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.
Yes, the newer options syntax added in TSLint v5 is preferred over the legacy array syntax, since it makes tslint.json easier to read.
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 "align": false?
@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.
For example: "quotemark": [true, "single", "avoid-escape", "avoid-template"]
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! ๐