Tslint: using tslint cli as npm script has inconsistent path behavior for windows and linux

Created on 18 Oct 2016  路  2Comments  路  Source: palantir/tslint

Bug Report

  • TSLint version: ~3.15.1
  • TypeScript version: ~2.0.3
  • Running TSLint via: CLI via NPM script

TypeScript code being linted: (irrelevant)
with tslint.json configuration: (irrelevant)

package.json configuration:

  "scripts": {
    "unquoted": "tslint src/**/*.ts",
     "quoted": "tslint 'src/**/*.ts'"
  },

Actual behavior

Unconsistend behavior when running @ windows or linux (and not working at all on windows).

Expected behavior

Consistent behavior across platforms.

Workaround

Use both, I guess:

  "scripts": {
    "unquoted_and_quoted": "tslint src/**/*.ts && tslint 'src/**/*.ts'"
  },

How to reproduce:

Check readme and files: https://github.com/acdcjunior/tslint-windows-path-inconsistency
(pasting README here for reference:)

Unquoted path (npm run unquoted)

  • @windows 10

    • All good: three linting errors!
    $ npm run unquoted
    
    > [email protected] unquoted D:\github\tslint-windows-path-inconsistency
    > tslint src/**/*.ts
    
    src/FirstLevel.ts[1, 12]: " should be '
    src/second/SecondLevel.ts[1, 12]: " should be '
    src/second/third/ThirdLevel.ts[1, 12]: " should be '
    
    npm ERR! Windows_NT 10.0.14393
    ...
    
  • @centos 7

    md5-30bf8fa1f4f5c81c78cee26869cbf622
    [box@box tslint-windows-path-inconsistency]$ npm run unquoted
    
    > [email protected] unquoted /box/github/tslint-windows-path-inconsistency
    > tslint src/**/*.ts
    
    src/second/SecondLevel.ts[1, 12]: " should be '
    
    npm ERR! Linux 3.10.0-229.el7.x86_64
    ...
    

    Quoted path (npm run quoted)


  • @windows 10

    • Bad: no error whatsoever!

    $ npm run quoted
    
    > [email protected] quoted D:\github\tslint-windows-path-inconsistency
    > tslint 'src/**/*.ts'
    
    $

  • @centos 7

    • All good!

    [box@box tslint-windows-path-inconsistency]$ npm run quoted
    
    > [email protected] quoted /box/github/tslint-windows-path-inconsistency
    > tslint 'src/**/*.ts'
    
    src/FirstLevel.ts[1, 12]: " should be '
    src/second/SecondLevel.ts[1, 12]: " should be '
    src/second/third/ThirdLevel.ts[1, 12]: " should be '
    
    npm ERR! Linux 3.10.0-229.el7.x86_64
    ...

API Question

Most helpful comment

@acdcjunior you can use double quotes "聽(escaped)聽as workaround to ensure consistency between platforms.

"scripts": {
  "lint": "tslint \"src/**/*.ts\""
},

I have idea聽how to fix it, but need more time to ensure that fix for running TSLint from npm scripts won't break anything when聽it is used directly from terminal.

All 2 comments

@acdcjunior you can use double quotes "聽(escaped)聽as workaround to ensure consistency between platforms.

"scripts": {
  "lint": "tslint \"src/**/*.ts\""
},

I have idea聽how to fix it, but need more time to ensure that fix for running TSLint from npm scripts won't break anything when聽it is used directly from terminal.

Hi @acdcjunior, this answer and this comment should provide context for the different behavior you're seeing.

When running in centos unquoted, perhaps you don't have the globstar option enabled in your shell and thus the glob isn't matching the files you expect. @IllusionMH's recommendation is good, use double-quotes so that node-glob processes the glob.

I actually don't think this is a bug, it's just how shells work, so I'm going to close this. If you have an idea to change stuff for the better @IllusionMH, happy to reopen / accept that change.

Was this page helpful?
0 / 5 - 0 ratings