Skip to content

Instantly share code, notes, and snippets.

@Rasinzz
Last active July 24, 2024 04:12
Show Gist options
  • Select an option

  • Save Rasinzz/a75f05db09727dfc81096ac6ca6e2545 to your computer and use it in GitHub Desktop.

Select an option

Save Rasinzz/a75f05db09727dfc81096ac6ca6e2545 to your computer and use it in GitHub Desktop.
NPM Format All Files Using Prettier

Guide to automatically format all files using an NPM script

Install Prettier

npm install --save-dev prettier

Create .prettierrc File

{
    "tabWidth": 4,
    "useTabs": false,
    "singleQuote": true,
    "jsxSingleQuote": true
}

Update package.json Scripts

"scripts": {
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,css,scss,md,json}\""
}

Run Script

npm run format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment