@studyworld/code
Version:
Набор конфигов для `prettier` и `eslint`
55 lines (37 loc) • 1.6 kB
Markdown
# @studyworld/code
Набор конфигов для `prettier` и `eslint`
## Как использовать
```
npm i --save-dev @studyworld/code
```
**package.json**
```
{
// ...
"prettier": "@studyworld/code/prettier",
"eslintConfig": {
"extends": "./node_modules/@studyworld/code/eslint"
},
// ...
}
```
## Prettier
### WebStorm
Go to *Preferences | Tools | File Watchers* and click **+** to add a new watcher.
In Webstorm 2018.2, select Prettier from the list, review the configuration, add any additional arguments if needed, and click OK.
In older IDE versions, select Custom and do the following configuration:
* **Name:** Prettier or any other name
* **File Type:** JavaScript (or Any if you want to run Prettier on all files)
* **Scope:** Project Files
* **Program:** full path to `.bin/prettier` or `.bin\prettier.cmd` in the project’s `node_module` folder. Or, if Prettier is installed globally, select `prettier` on macOS and Linux or `C:\Users\user_name\AppData\Roaming\npm\prettier.cmd` on Windows (or whatever `npm prefix -g` returns).
* **Arguments:** `--write $FilePath$`
* **Output paths to refresh:** `$FilePathRelativeToProjectRoot$`
* **Working directory:** `$ProjectFileDir$`
* **Auto-save edited files to trigger the watcher:** Uncheck to reformat on Save only.
## ESLint
### WebStorm
* In the *Settings/Preferences* dialog go to *Languages and Frameworks | JavaScript | Code Quality Tools | ESLint*.
* Select **Automatic ESLint configuration**.
### VS Code
* Install ESLint plugin from the *extensions marketplace*
* Enjoy!