Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Matching does not work in bash #1082

Closed
domoritz opened this issue Apr 4, 2016 · 4 comments
Closed

Matching does not work in bash #1082

domoritz opened this issue Apr 4, 2016 · 4 comments

Comments

@domoritz
Copy link
Contributor

domoritz commented Apr 4, 2016

Bug Report

  • TSLint version: 3.7.0
  • TypeScript version: 1.8.9
  • Running TSLint via: CLI (bash) and npm

TypeScript code being linted

Multiple 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.

Actual behavior

tslint src/**.ts only matches the files inside src (not subfolders). tslint src/**/*.ts matches files exactly one directory deep. And so on.

Expected behavior

tslint src/**.ts should match all files inside src.

domoritz added a commit to vega/vega-lite that referenced this issue Apr 4, 2016
@adidahiya
Copy link
Contributor

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 #827 (comment)). This uses the node glob expansion algorithm.

@domoritz
Copy link
Contributor Author

domoritz commented Apr 4, 2016

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?

@domoritz domoritz closed this as completed Apr 4, 2016
@jkillian
Copy link
Contributor

jkillian commented Apr 4, 2016

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.

@domoritz
Copy link
Contributor Author

domoritz commented Apr 4, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants