Skip to content

lgkonline/lgk-prettier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LGK's Prettier config

Run

npx -y lgk-prettier

add the root of a project to add a .prettierrc file to it.

Add VS Code settings and extension

Adding the parameter --vscode or -c will also add this to the workspace:

  • .vscode/settings.json with "editor.formatOnSave": true
  • .vscode/settings.json with "recommendations": ["esbenp.prettier-vscode"]

Status

npm version

Why does this exist?

I like to use Prettier in all my projects to make code formatted in a consistent way. I configured my VS Code to format automatically with the Prettier extension.

I also wrote an article about this. It's in German though.

Graphic visualizing pretty formatting a code

Unfortunately I don't like the default formatting, so I always have my own .prettierc in each project, since you can't have a global Prettier config.

This script should help adding this config to a new project.

My preferred config looks like this:

{
    "tabWidth": 4,
    "useTabs": false,
    "semi": false,
    "singleQuote": false,
    "trailingComma": "none",
    "bracketSpacing": true,
    "bracketSameLine": false,
    "fluid": false
}

If you like this as well, feel free to use my command tool. Or fork this repo and change it to your own.