Tslint: Using tslint config file with .js extension

Created on 27 Jul 2018  路  4Comments  路  Source: palantir/tslint

Feature request

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!

Tooling Feature Request

Most helpful comment

I think this should be better documented here: https://palantir.github.io/tslint/usage/configuration/

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

denkomanceski picture denkomanceski  路  3Comments

dashmug picture dashmug  路  3Comments

Ne-Ne picture Ne-Ne  路  3Comments

mrand01 picture mrand01  路  3Comments

ypresto picture ypresto  路  3Comments