|
2 | 2 |
|
3 | 3 | Run linters against staged git files and don't let :poop: slip into your code base!
|
4 | 4 |
|
| 5 | +```bash |
| 6 | +npm install --save-dev lint-staged # requires further setup |
| 7 | +``` |
| 8 | + |
5 | 9 | ```
|
6 | 10 | $ git commit
|
7 | 11 |
|
@@ -44,13 +48,17 @@ This project contains a script that will run arbitrary shell tasks with a list o
|
44 | 48 |
|
45 | 49 | ## Installation and setup
|
46 | 50 |
|
47 |
| -The fastest way to start using lint-staged is to run the following command in your terminal: |
48 |
| - |
49 |
| -```bash |
50 |
| -npx mrm@2 lint-staged |
51 |
| -``` |
| 51 | +To install _lint-staged_ in the recommended way, you need to: |
52 | 52 |
|
53 |
| -This command will install and configure [husky](https://github.com/typicode/husky) and lint-staged depending on the code quality tools from your project's `package.json` dependencies, so please make sure you install (`npm install --save-dev`) and configure all code quality tools like [Prettier](https://prettier.io) and [ESLint](https://eslint.org) prior to that. |
| 53 | +1. Install _lint-staged_ itself: |
| 54 | + - `npm install --save-dev lint-staged` |
| 55 | +1. Set up the `pre-commit` git hook to run _lint-staged_ |
| 56 | + - [Husky](https://github.com/typicode/husky) is a popular choice for configuring git hooks |
| 57 | + - Read more about git hooks [here](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) |
| 58 | +1. Install some linters, like [ESLint](https://eslint.org) or [Prettier](https://prettier.io) |
| 59 | +1. Configure _lint-staged_ to run linters and other tasks: |
| 60 | + - for example: `{ "*.js": "eslint" }` to run ESLint for all staged JS files |
| 61 | + - See [Configuration](#Configuration) for more info |
54 | 62 |
|
55 | 63 | Don't forget to commit changes to `package.json` and `.husky` to share this setup with your team!
|
56 | 64 |
|
@@ -130,7 +138,7 @@ Options:
|
130 | 138 |
|
131 | 139 | ## Configuration
|
132 | 140 |
|
133 |
| -Starting with v3.1 you can now use different ways of configuring lint-staged: |
| 141 | +_Lint-staged_ can be configured in many ways: |
134 | 142 |
|
135 | 143 | - `lint-staged` object in your `package.json`
|
136 | 144 | - `.lintstagedrc` file in JSON or YML format, or you can be explicit with the file extension:
|
|
0 commit comments