clean-slate-lint v1.0.9
clean-slate
Prettier & ESLint with commit hooks. Without any pain.
Follows the Standard Style Guide and supports React out of the box.
Installation
$ npm install --save-dev clean-slate-lint
✅ clean-slate post-commit hooks setup succeeded.
A post-install script should run automatically and setup your commit hooks. If it didn’t work, add the following to your package.json
:
"husky": {
"hooks": {
"pre-commit": "./node_modules/.bin/clean-slate-lint",
"pre-rewrite": "./node_modules/.bin/clean-slate-lint"
}
}
Adding to an existing project
If you’re adding clean-slate
to an existing project, run the following commands to lint your whole codebase in a single commit and avoid messy git
diffs everytime you commit:
$ ./node_modules/.bin/prettier --config ./node_modules/clean-slate-lint/prettier.config.js --write "./**/*.{js,ts,tsx,css,less,scss,sass,vue,json,graphql,md}"
$ ./node_modules/.bin/eslint --config ./node_modules/clean-slate-lint/.eslintrc.js --fix .
$ git add -A
$ git commit -n -m "Running clean-slate on the whole codebase"
You should obviously adapt the file globs to your own needs. Your ignore configuration files should be automatically picked up if you have some, but you can also pass them using the --ignore-path
flags.
Usage tips
By default, clean-slate
runs whenever you commit (git commit
and git commit --amend
). If you want to run clean-slate
at other points in time, please refer to the husky documentation. Note that there are no git hooks for git rebase --continue
.
If you want to skip the linting, simply commit with the -n
flag, short for --no-verify
. For instance, you could run:
$ git commit -n -m "Skipping clean-slate!"
Customization
If you want to ignore specific files, clean-slate
will respect your .prettierignore
and .eslintignore
files. If you want to ignore linting for a specific line, please refer to ESLint’s inline comments documentation. For Prettier, you can use the // prettier-ignore
comment.
clean-slate
follows the opionionated Standard Style Guide and is meant to be used without any configuration. If you want to customize the ESLint rules or the Prettier config, you’ll have to use your own setup. We recommend using a combination of husky
and lint-staged
, two packages on which clean-slate
heavily relies. Note that overriding some ESLint rules or adding new plugins may work but no support will be provided.
For any specific request about code formatting, please open an issue in the Prettier, ESLint or Standard repositories. If you think clean-slate
should support customization, feel free to open an issue so that we can discuss it.
VS Code integration
Because the ESLint configuration used by clean-slate
does not live at the root of your project, the vscode-eslint
extension might not find the configuration file automatically. You’ll need to specify it. If you’re only using clean-slate
on a specific project, you can create a workspace configuration file: https://code.visualstudio.com/docs/getstarted/settings.
For instance, in /.vscode/settings.json
, add this:
{
"eslint.options": {
"configFile": "./node_modules/clean-slate-lint/.eslintrc.js"
}
}