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

Build fails at the end after running tslint from command line #1704

Closed
xtianus79 opened this issue Nov 10, 2016 · 4 comments
Closed

Build fails at the end after running tslint from command line #1704

xtianus79 opened this issue Nov 10, 2016 · 4 comments

Comments

@xtianus79
Copy link

Bug Report

  • TSLint version: 3.15.0 or 3.15.1 or 4.0.0-dev.1`
  • TypeScript version: 2.1.1
  • Running TSLint via: (please choose one) CLI / Node.js API / grunt-tslint / Atom / Visual Studio / ***Node

TypeScript code being linted

(include if relevant)

with tslint.json configuration:

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    "class-name": true,
    "comment-format": [
      true,
      "check-space"
    ],
    "curly": true,
    "eofline": true,
    "forin": true,
    "indent": [
      true,
      "spaces"
    ],
    "label-position": true,
    "max-line-length": [
      true,
      140
    ],
    "member-access": false,
    "member-ordering": [
      true,
      "static-before-instance",
      "variables-before-functions"
    ],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-eval": true,
    "no-inferrable-types": true,
    "no-shadowed-variable": true,
    "no-string-literal": false,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": true,
    "no-unused-expression": true,
    "no-unreachable": true,
    "no-use-before-declare": true,
    "no-var-keyword": true,
    "object-literal-sort-keys": false,
    "one-line": [
      true,
      "check-open-brace",
      "check-catch",
      "check-else",
      "check-whitespace"
    ],
    "quotemark": [
      true,
      "single"
    ],
    "radix": true,
    "semicolon": [
        true,
      "always"
    ],
    "triple-equals": [
      true,
      "allow-null-check"
    ],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "variable-name": false,
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],

    "directive-selector-name": [true, "camelCase"],
    "component-selector-name": [true, "kebab-case"],
    "directive-selector-type": [true, "attribute"],
    "component-selector-type": [true, "element"],
    "directive-selector-prefix": [true, "sg"],
    "component-selector-prefix": [true, "sg"],
    "use-input-property-decorator": true,
    "use-output-property-decorator": true,
    "use-host-property-decorator": true,
    "no-attribute-parameter-decorator": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "no-forward-ref": true,
    "use-life-cycle-interface": true,
    "use-pipe-transform-interface": true,
    "pipe-naming": [true, "camelCase", "sg"],
    "component-class-suffix": true,
    "directive-class-suffix": true,
    "import-destructuring-spacing": true,
    "templates-use-public": true,
    "no-access-missing-member": true,
    "invoke-injectable": true
  }
}

Actual behavior

Anything that causes a lint error the lint error performs but an error occurs when it is finished.

`npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/my/.nvm/versions/node/v6.2.2/bin/node" "/Users/my/.nvm/versions/node/v6.2.2/bin/npm" "run" "lint"
npm ERR! node v6.2.2
npm ERR! npm  v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! my-application@1.0.0 lint: `tslint "src/**/*.ts"`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the my-application@1.0.0 lint script 'tslint "src/**/*.ts"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-application package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tslint "src/**/*.ts"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs my-application
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls my-application
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/my/my/my/frontend/npm-debug.log

Expected behavior

The error shouldn't occur when it is finished.

@IllusionMH
Copy link
Contributor

Exit code equals 2 if there are lint errors and non zero exit code always fails build. Do you have list of lint errors above this error in console?

If you just want to see list of lint errors but don't want failed builds - you should specify --force flag (see CLI usage)

@xtianus79
Copy link
Author

xtianus79 commented Nov 10, 2016

IllusionMH
Yes I do have lint errors above... but why would it release such a horrible message after finding errors? but yes --force works... why not a summary or something... rather than exit 2

@IllusionMH
Copy link
Contributor

IllusionMH commented Nov 10, 2016

@xt0rted this is standard npm error (in this case npm script error) if launched process exits with code other than 0.
You can try to run TSLint directly from CLI to see that it only reports lint errors: ./node_modules/.bin/tslint "src/**/*.ts"

You can also check this comment from GitHub Issue in npm repository npm/npm#6124 (comment) and use -s/--silent flag to suppress that verbose error.

So this issue is not related to TSLint directly.

UPD. Exit codes are established practice to control execution flow of several commands. And it is regular practice to avoid long compilation and tests execution if your code doesn't pass code style checks.

@adidahiya
Copy link
Contributor

@IllusionMH is right (thanks for the comments here!). Closing this out as this is working as intended and the NPM script questions are external to this project.

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