tslint not working as expected

Created on 4 Mar 2016  路  5Comments  路  Source: palantir/tslint

Hi,

I have this tslint.json in my project and some typescript files in the src folder.
When I run tslint in my terminal it gives me the following output:

> tslint

Usage: /Volumes/Data/Kwerri/playground/angular2-webpack-starter/node_modules/.bin/tslint [options] [file ...]

Options:
  -c, --config          configuration file                                                      
  -h, --help            display detailed help                                                   
  -i, --init            generate a tslint.json config file in the current working directory     
  -o, --out             output file                                                             
  -r, --rules-dir       rules directory                                                         
  -s, --formatters-dir  formatters directory                                                    
  -t, --format          output format (prose, json, verbose)                                      [default: "prose"]
  --test                test that tslint produces the correct output for the specified directory
  -v, --version         current version                                                         

Missing files

npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/Cellar/node/4.2.1/bin/node" "/usr/local/bin/npm" "run" "lint"
npm ERR! node v4.2.1
npm ERR! npm  v3.3.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] lint: `tslint`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] lint script 'tslint'.
npm ERR! This is most likely a problem with the angular2-webpack-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tslint
npm ERR! You can get their info via:
npm ERR!     npm owner ls angular2-webpack-starter
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Volumes/Data/Kwerri/playground/angular2-webpack-starter/npm-debug.log
{
  "rules": {
    "class-name": true,
    "curly": false,
    "eofline": true,
    "indent": [
      true,
      "spaces"
    ],
    "max-line-length": [
      true,
      100
    ],
    "member-ordering": [
      true,
      "public-before-private",
      "static-before-instance",
      "variables-before-functions"
    ],
    "no-arg": true,
    "no-construct": true,
    "no-duplicate-key": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-eval": true,
    "trailing-comma": true,
    "no-trailing-whitespace": true,
    "no-unused-expression": true,
    "no-unused-variable": false,
    "no-unreachable": true,
    "no-use-before-declare": true,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "quotemark": [
      true,
      "single"
    ],
    "semicolon": true,
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef": [
      false,
      "parameter",
      "arrow-parameter",
      "property-declaration",
      "variable-declaration",
      "member-variable-declaration"
    ],
    "variable-name": false,
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ]
  }
}

Or I am overlooking something in the docs or this behaviour is not expected if you follow the docs
Can somebody help me out here please?

tslint -v && tsc -v
3.5.0
Version 1.8.7

Kind regards
Sam V.

Question

Most helpful comment

Ok playing around with this, it seems that you need to quote the glob..

$ tslint -c tslint.json "src/**/*.ts"
src/app/app.ts[9, 33]: missing semicolon
src/main.ts[58, 39]: missing whitespace
src/polyfills.ts[7, 37]: missing semicolon

Is this already some where in the docs? Otherwise I'll provide a PR

All 5 comments

I can provide a file like this: tslint src/main.ts
but what if I want to check all ts files in the project? using a glob doesn't seem to work

$ tslint -c tslint.json src/main.ts
src/main.ts[58, 39]: missing whitespace
$ tslint -c tslint.json src/**/*.ts
-- no output ..

But this works tough..

$ tslint -c tslint.json src/*.ts
src/main.ts[58, 39]: missing whitespace
src/polyfills.ts[7, 37]: missing semicolon

Ok playing around with this, it seems that you need to quote the glob..

$ tslint -c tslint.json "src/**/*.ts"
src/app/app.ts[9, 33]: missing semicolon
src/main.ts[58, 39]: missing whitespace
src/polyfills.ts[7, 37]: missing semicolon

Is this already some where in the docs? Otherwise I'll provide a PR

@samvloeberghs seems like your shell isn't expanding globs with a ** in them correctly for you. When you put it in quotes, it gets passed through to node-glob and then expanded internally inside TSLint. Both are valid ways for things to work in my opinion

@samvloeberghs we'd be happy to look at a PR that makes the documentation around this more clear

@JKillian why are both ways valid? It seems like ** acting like ** should be the expected behaviour.

Was this page helpful?
0 / 5 - 0 ratings