Skip to content

Add typescript linter

Michiya requested to merge add-ts-linter into master

BugFix Merge Request

Related Issue

resolves #55

Description of Bug and Fix

The bug was that we were unable to lint our typescript files in bridger using standardJS. Even following the TypeScript modifications, as outlined in the StandardJS docs, did not fix the problem. (why? unsure)

The fix was to install TSLint, the leading linting library for TypeScript. I installed it both globally and locally:

  • Global Install: $ npm install -g tslint tslint typescript // note: typescript is also installed as a peer dependency
  • Local Install: $ npm install tslint typescript --save-dev

Next, initialize a tslint.json config file: $ tslint --init

While the linter could now be run, it would yield many more errors than we're interested in -- due to style clashes with standardJS, the style we've adopted.

So the next step was to augment TSLint with tslint-config-standard, which configures TSLint rules to a subset that aligns with StandardJS style.

Note: running the lint script (npm run lint) now outputs an appropriate list of typescript linting errors. However, for me, it also ends with a string of npm errors. Not sure why. I'm able to get around that by running the lint script (as articulated in package.json) directly from the command line, using globally installed TSLint.

Screenshots, Code, Links

Next

  • After this MR is merged, a separate issue/MR should actually run TSLint and fix the errors it outputs

Merge request reports