Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

yasu-s/tslint-prettier-sample

Repository files navigation

Overview

  • A sample that executes the code format using tslint-plugin-prettier.
  • By using Visual Studio Code and TSLint extensions, automatic formatting can be done when saving files.

System requirements

  • Node.js - 10.x
  • Yarn - 1.13.x
  • Visual Studio Code - 1.31.x

Used library

  • TypeScript - 3.2.x
  • TSLint - 5.11.x
  • prettier - 1.16.x
  • tslint-plugin-prettier - 2.0.x
  • tslint-config-prettier - 1.18.x

Operation check

1. Download Sample

git clone git@github.com:yasu-s/tslint-prettier-sample.git

2. Installing packages

cd tslint-prettier-sample
yarn

3. Launch sample application

yarn lint:fix

4. Execution result of VSCode

tslint

Various settings

.vscode/settings/json

{
  "tslint.configFile": "tslint.json",
  "editor.codeActionsOnSave": {
    "source.fixAll.tslint": true
  }
}

tslint.json

{
  "rulesDirectory": [
    "tslint-plugin-prettier"
  ],
  "extends": [
    "tslint:latest",
    "tslint-config-prettier"
  ],
  "rules": {
    "prettier": [
      true, {
        "printWidth": 140,
        "tabWidth": 2,
        "useTabs": false,
        "semi": true,
        "singleQuote": true,
        "trailingComma": "all",
        "bracketSpacing": true,
        "arrowParens": "always"
      }
    ]
  }
}