A Mutable Log

A blog by Devendra Tewari


Project maintained by tewarid Hosted on GitHub Pages — Theme by mattgraham

Use semistandard to lint TypeScript code

semistandard is a fork of standard that allows semicolons at end of statements. The following Docker file illustrates how to run semistandard using Docker

FROM node:lts-alpine AS base
RUN  mkdir /src
COPY ./src /src
RUN npm config set unsafe-perm true
RUN npm install -g semistandard @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint typescript
RUN semistandard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin /src/MyService/ClientApp/**/*/*.ts

npm config set unsafe-perm true works around an issue where npm fails to get gid/uid in certain environments.

To lint your own code, change ./src and /src/MyService/ClientApp appropriately.

Test code may fail to lint with errors such as

semistandard: Semicolons For All! (https://github.com/Flet/semistandard)
  /src/MyService/ClientApp/src/test/test.ts:3:1: 'it' is not defined.
The command '/bin/sh -c semistandard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin /src/MyService/ClientApp/**/*/*.ts' returned a non-zero code: 1

To fix it, you can add the following to top of each test file

/* eslint-env mocha */