3.7.01.8.9Multiple typescript files in many directories. When I'm linting in my native shell (fish), this work as expected. But in bash or when I put tslint in a run script in my package.json, the linter does not work as expected.
tslint src/**.ts only matches the files inside src (not subfolders). tslint src/**/*.ts matches files exactly one directory deep. And so on.
tslint src/**.ts should match all files inside src.
Hi @domoritz, you should be able to use globs in a platform-independent way by supplying the glob as a string, i.e. tslint 'src/**/*.ts' (see https://github.com/palantir/tslint/pull/827#issuecomment-161101555). This uses the node glob expansion algorithm.
Thanks @adidahiya! That works like a charm. Is there any way to make this less confusing/more consistent? Could you always use the node glob expansion algorithm?
Just a note @domoritz, the ** syntax is a Bash 4 feature that may need to be enabled with shopt -s globstar. It should work as you expect then. Unfortunately, OSX ships with Bash 3 I think.
What happens is that your shell expands the glob before TSLint ever touches it. When you put it in quotes, your shell passes it on to TSLint as is, then we can expand it with node-glob. As far as I know, there's no way to change TSLint to make it tell the shell "don't expand globs", but if there is, we could consider adding that, although it might mess things up for users who want their shell to expand the glob.
Unfortunately, OSX ships with Bash 3 I think.
I was using bash 4.3 from homebrew but the problem was that I'm using fish shell but npm seems to use bash. It was a bit odd to debug but it's totally a problem with how npm/bash/other shells work.
It would be great to document that tslint takes glob strings in addition to just files (in tslint --help). I also think I would not have run into this issue if tslint directly read the files to lint from the tsconfig.json.
Most helpful comment
Hi @domoritz, you should be able to use globs in a platform-independent way by supplying the glob as a string, i.e.
tslint 'src/**/*.ts'(see https://github.com/palantir/tslint/pull/827#issuecomment-161101555). This uses the node glob expansion algorithm.