Skip to content

Prettier

Install

npm install -D prettier

Setup

Config

.prettierrc
{
    "printWidth": 100,
    "tabWidth": 4,
    "useTabs": false,
    "semi": true,
    "singleQuote": false,
    "trailingComma": "none",
    "bracketSpacing": true,
    "bracketSameLine": false,
    "arrowParens": "avoid",
    "htmlWhitespaceSensitivity": "ignore"
}

Application

{
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "watch": "ng build --watch --configuration development",
        "test": "ng test",
        "format:test": "prettier --list-different \"./src/**/*.{ts,html,css,scss,json}\"", 
        "format:write": "prettier --write \"./src/**/*.{ts,html,css,scss,json}\""
    },
}

Workspace Project

{
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "watch": "ng build --watch --configuration development",
        "test": "ng test",
        "format:test": "prettier --list-different \"./projects/**/*.{ts,html,css,scss,json}\"",
        "format:write": "prettier --write \"./projects/**/*.{ts,html,css,scss,json}\"",
    },
}