Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robinblomberg/prettier-config
Opinionated Prettier configuration.
https://github.com/robinblomberg/prettier-config
Last synced: 1 day ago
JSON representation
Opinionated Prettier configuration.
- Host: GitHub
- URL: https://github.com/robinblomberg/prettier-config
- Owner: RobinBlomberg
- Created: 2021-03-08T16:08:47.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T09:10:45.000Z (about 1 year ago)
- Last Synced: 2025-01-09T09:39:46.467Z (7 days ago)
- Language: JavaScript
- Homepage:
- Size: 175 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Prettier config
## Installation
```sh
npm install -D @robinblomberg/prettier-config
```## Configuration
Create a file called **.eslintrc.js** at the project root:
```js
module.exports = {
extends: '@robinblomberg/robinblomberg'
}
```## NPM scripts
Add the following scripts to your package.json (assuming that ESLint is enabled):
```json
{
"scripts": {
"format:scripts": "prettier --write src/**/*.{ts,tsx,js,jsx} && eslint src/**/*.{ts,tsx,js,jsx} --fix",
}
}
```Adjust the paths according to your project/file structure as necessary.
To run a script, enter the following in your command line:
```sh
npm run format:scripts
```## VS Code settings
Add the following to **.vscode/settings.json** in the root of your project:
```json
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.insertSpaces": true,
"editor.rulers": [100],
"editor.tabSize": 2,
"eslint.format.enable": false,
"files.encoding": "utf8",
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true
}
```This will check the formatting in VS Code, and also format on save.