4.4.12.1.6I run the command with
node_modules/tslint/bin/tslint --config ./tslint.json --project ./src/tsconfig.json
I am trying to use the verbose formatter (crazy that it's not the default one, why would people NOT want to know the rule name, anyway). I have no idea where to put that information and what the key should be called (format? formatter? something else?)
Tried both formatter / format in the examples below. Also tried adding it to tslint.json. It is simply ignored.
{
"format": "verbose",
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"format": "verbose",
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
Any hints?
If I run it with
node_modules/tslint/bin/tslint --config ./tslint.json --project ./src/tsconfig.json -t verbose
then it works. So it's simply a matter of telling us how to do it, since the documentation lacks that information.
What you pasted above is your tsconfig.json, not your tslint.json...
However, you pass the formatter on the command line as described in the docs:
-t, --format output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist) [default: "prose"]`
so for your example it would be this: node_modules/.bin/tslint -c ./tslint.json -t verbose --project ./src/tsconfig.json
Regarding your docs request, there are several sources that state exactly what you are searching for:
https://github.com/palantir/tslint#cli-1
https://palantir.github.io/tslint/usage/cli/
tslint --help
Are you saying that formatters can only be changed by passing arguments on the command line, and not by adding them to the config files?
By looking at the tslint.json docs I would say it is currently not possible to configure the formatter or the formatterDirectory in tslint.json.
You keep mentioning tslint.json, but I was under the impression the tslint options are in tsconfig.json, this is what I have been trying to work with. Sadly there doesn't seem to be any documentation for that
@gotofritz not sure how we can make that any clearer. it is the second section in the README. https://github.com/palantir/tslint#usage
In the second section in the README it says tslint.json is used to configure the rules. Yet there are a lot of rules in the tsconfig.json too - sourceMaps, target, etc. It's absolutely not clear why some options are in one file and some in the other. In fact I didn't see the tsconfig.json options listed anywhere, I only know of it because angular-cli generates it.
@gotofritz tsconfig.json controls the TypeScript compiler; BUT tslint will also use part of tsconfig.json when you use --project option to define which files should be linted (instead of passing every filename on the command line). Its just a shortcut to identifying the files to be linted, and thats the only thing tslint pulls from tsconfig.json. Only the "files" option from that file is used, as documented at http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
Every other setting needs to control tslint must be in the tslint.json file.
But I would agree that more options that are only on the command line should be able to be specified in tslint.json, especially the formatter. I believe typically tools similar to this allow options to be set in a settings json file, and then can be overridden on the command line.
Great, I finally understand how it all fits together, thanks.
is there a way to set formatter in tslint.json instead of cli?
Most helpful comment
@gotofritz tsconfig.json controls the TypeScript compiler; BUT tslint will also use part of tsconfig.json when you use --project option to define which files should be linted (instead of passing every filename on the command line). Its just a shortcut to identifying the files to be linted, and thats the only thing tslint pulls from tsconfig.json. Only the "files" option from that file is used, as documented at http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
Every other setting needs to control tslint must be in the tslint.json file.
But I would agree that more options that are only on the command line should be able to be specified in tslint.json, especially the formatter. I believe typically tools similar to this allow options to be set in a settings json file, and then can be overridden on the command line.