npm tslint don't give error
Asked Answered
D

1

6

Hey all got a issue with npm and tslint I was hoping you could help me with. Ok here comes my situation and code:

package.json

"scripts": {
    "lint": "tslint -c tslint.json 'src/app/**/*.ts'",
    "pretest": "npm run lint ",
    "test": "echo 'No test are made'",
...
  },

When I run command npm test this is the output:

input terminal

$ npm test

output terminal

> [email protected] pretest c:\Users\Hjorth\Documents\github\keoom-angular
> npm run lint


> [email protected] lint c:\Users\Hjorth\Documents\github\keoom-angular
> tslint -c tslint.json 'src/app/**/*.ts'


> [email protected] test c:\Users\Hjorth\Documents\github\keoom-angular
> echo 'No test are made'

'No test are made'

If I only run command tslint -c tslint.json 'src/app/**/*.ts' I on the other hand see the linting error.

input terminal

$ tslint -c tslint.json 'src/app/**/*.ts'

output terminal

src/app/app.component.ts[1, 27]: " should be '

So as you can see there is a linting error in my code, but if I am not running the script directly It will not show. What I am expecting is this:

When I run npm test the script pretest will run, and that script will run the script lint, it will then exit with exit 0 before test script is run as it will find the linting error.

Anyone that can be of assistance.

Disjoined answered 10/8, 2016 at 18:38 Comment(0)
G
10

It's the quotes around the file spec in the tslint command that are the problem:

"lint": "tslint -c tslint.json 'src/app/**/*.ts'"
                               ^               ^

If you remove those, you should see the expected error reported by tslint.

Glimpse answered 10/8, 2016 at 21:32 Comment(3)
I will check when I get home from work, but is it possible to get a explanation why the single quotes should silence the output? and only silence it when I am running the script from another script?Baseless
Because when you run it via the terminal, the shell is interpreting what's inside the quotes and is passing the enclosed string as the file spec argument to tslint. However, when NPM is interpreting the script command, that's not happening and tslint receives a file spec that includes the quotes - and doesn't match anything.Glimpse
It now brakes horrible at the tslint error, thanks :)Baseless

© 2022 - 2024 — McMap. All rights reserved.