Same as eslint, It would be great if you could use a file with .js extension to define the rules and thus be able to use environment variables. Something like:
'no-console': process.env.NODE_ENV === 'production'? 'error': 'off'
Or is there an alternative way to do this?
Thanks!
This already works - just name your file tslint.js and use module.exports = { ... }. For example:
module.exports = {
defaultSeverity: "error",
extends: [
"tslint:recommended"
],
jsRules: {},
rules: {},
rulesDirectory: []
}
I think this should be better documented here: https://palantir.github.io/tslint/usage/configuration/
This doesn't seem to work at all...the configuration documentation doesn't mention using a js file at all apart from custom rules. I need to be able to specify a regex in the rules section of my tsconfig, so it needs to be js. Tslint only seems to look for .json files by default, if I specify my .js config with the -c flag, then it works fine.
Tslint 5.15.0
I need to be able to specify a regex in the rules section of my tsconfig, so it needs to be js.
the rule options which allow regexes all work in JSON. for example: https://github.com/palantir/tslint/blob/59f894216ba29cf461512fe9ed0f8e3434bc0984/tslint.json#L70
Tslint only seems to look for .json files by default, if I specify my .js config with the -c flag, then it works fine.
yes, that's the intended behavior. open to documentation PRs
Most helpful comment
I think this should be better documented here: https://palantir.github.io/tslint/usage/configuration/