Skip to content

Commit 6808f06

Browse files
authored
docs: corrects minor typos and grammar in README (#964)
1 parent 101ad5e commit 6808f06

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

README.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Run linters against staged git files and don't let :poop: slip into your code ba
66

77
## Why
88

9-
Linting makes more sense when run before committing your code. By doing so you can ensure no errors go into the repository and enforce code style. But running a lint process on a whole project is slow and linting results can be irrelevant. Ultimately you only want to lint files that will be committed.
9+
Linting makes more sense when run before committing your code. By doing so you can ensure no errors go into the repository and enforce code style. But running a lint process on a whole project is slow, and linting results can be irrelevant. Ultimately you only want to lint files that will be committed.
1010

1111
This project contains a script that will run arbitrary shell tasks with a list of staged files as an argument, filtered by a specified glob pattern.
1212

13-
## Related blogs posts and talks
13+
## Related blog posts and talks
1414

1515
- [Introductory Medium post - Andrey Okonetchnikov, 2016](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8#.8qepn2b5l)
1616
- [Running Jest Tests Before Each Git Commit - Ben McCormick, 2017](https://benmccormick.org/2017/02/26/running-jest-tests-before-each-git-commit/)
@@ -22,23 +22,23 @@ This project contains a script that will run arbitrary shell tasks with a list o
2222
2323
## Installation and setup
2424

25-
The fastest way to start using lint-staged is to run following command in your terminal:
25+
The fastest way to start using lint-staged is to run the following command in your terminal:
2626

2727
```bash
2828
npx mrm lint-staged
2929
```
3030

31-
It will install and configure [husky](https://github.com/typicode/husky) and lint-staged depending on code quality tools from `package.json` dependencies so please make sure you install (`npm install --save-dev`) and configure all code quality tools like [Prettier](https://prettier.io), [ESlint](https://eslint.org) prior that.
31+
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.
3232

3333
Don't forget to commit changes to `package.json` and `.husky` to share this setup with your team!
3434

35-
Now change a few files, `git add` or `git add --patch` some of them to your commit and try to `git commit` them.
35+
Now change a few files, `git add` or `git add --patch` some of them to your commit, and try to `git commit` them.
3636

3737
See [examples](#examples) and [configuration](#configuration) for more information.
3838

3939
## Changelog
4040

41-
See [Releases](https://github.com/okonet/lint-staged/releases)
41+
See [Releases](https://github.com/okonet/lint-staged/releases).
4242

4343
### Migration
4444

@@ -48,10 +48,10 @@ See [Releases](https://github.com/okonet/lint-staged/releases)
4848
If your task previously contained a `git add` step, please remove this.
4949
The automatic behaviour ensures there are less race-conditions,
5050
since trying to run multiple git operations at the same time usually results in an error.
51-
- From `v10.0.0` onwards _lint-staged_ uses git stashes to improve speed and provide backups while running.
52-
Since git stashes require at least an initial commit, you shouldn't run _lint-staged_ in an empty repo.
53-
- From `v10.0.0` onwards _lint-staged_ requires Node.js version 10.13.0 or later.
54-
- From `v10.0.0` onwards _lint-staged_ will abort the commit if linter tasks undo all staged changes. To allow creating empty commit, please use the `--allow-empty` option.
51+
- From `v10.0.0` onwards, lint-staged uses git stashes to improve speed and provide backups while running.
52+
Since git stashes require at least an initial commit, you shouldn't run lint-staged in an empty repo.
53+
- From `v10.0.0` onwards, lint-staged requires Node.js version 10.13.0 or later.
54+
- From `v10.0.0` onwards, lint-staged will abort the commit if linter tasks undo all staged changes. To allow creating an empty commit, please use the `--allow-empty` option.
5555

5656
## Command line flags
5757

@@ -79,7 +79,7 @@ Options:
7979
```
8080
8181
- **`--allow-empty`**: By default, when linter tasks undo all staged changes, lint-staged will exit with an error and abort the commit. Use this flag to allow creating empty git commits.
82-
- **`--config [path]`**: Manually specify a path to a config file or npm package name. Note: when used, lint-staged won't perform the config file search and print an error if the specified file cannot be found. If '-' is provided as the filename then the config will be read from stdin, allowing piping in the config like `cat my-config.json | npx lint-staged --config -`.
82+
- **`--config [path]`**: Manually specify a path to a config file or npm package name. Note: when used, lint-staged won't perform the config file search and will print an error if the specified file cannot be found. If '-' is provided as the filename then the config will be read from stdin, allowing piping in the config like `cat my-config.json | npx lint-staged --config -`.
8383
- **`--debug`**: Run in debug mode. When set, it does the following:
8484
- uses [debug](https://github.com/visionmedia/debug) internally to log additional information about staged files, commands being executed, location of binaries, etc. Debug logs, which are automatically enabled by passing the flag, can also be enabled by setting the environment variable `$DEBUG` to `lint-staged*`.
8585
- uses [`verbose` renderer](https://github.com/SamVerschueren/listr-verbose-renderer) for `listr`; this causes serial, uncoloured output to the terminal, instead of the default (beautified, dynamic) output.
@@ -95,7 +95,7 @@ Options:
9595
9696
## Configuration
9797
98-
Starting with v3.1 you can now use different ways of configuring it:
98+
Starting with v3.1 you can now use different ways of configuring lint-staged:
9999
100100
- `lint-staged` object in your `package.json`
101101
- `.lintstagedrc` file in JSON or YML format, or you can be explicit with the file extension:
@@ -135,7 +135,7 @@ So, considering you did `git add file1.ext file2.ext`, lint-staged will run the
135135
136136
## Filtering files
137137
138-
Linter commands work on a subset of all staged files, defined by a _glob pattern_. `lint-staged´ uses [micromatch](https://github.com/micromatch/micromatch) for matching files with the following rules:
138+
Linter commands work on a subset of all staged files, defined by a _glob pattern_. lint-staged uses [micromatch](https://github.com/micromatch/micromatch) for matching files with the following rules:
139139
140140
- If the glob pattern contains no slashes (`/`), micromatch's `matchBase` option will enabled, so globs match a file's basename regardless of directory:
141141
- **`"*.js"`** will match all JS files, like `/test.js` and `/foo/bar/test.js`
@@ -144,7 +144,7 @@ Linter commands work on a subset of all staged files, defined by a _glob pattern
144144
- **`"./*.js"`** will match all JS files in the git repo root, so `/test.js` but not `/foo/bar/test.js`
145145
- **`"foo/**/\*.js"`** will match all JS files inside the`/foo`directory, so`/foo/bar/test.js`but not`/test.js`
146146
147-
When matching, `lint-staged` will do the following
147+
When matching, lint-staged will do the following
148148
149149
- Resolve the git root automatically, no configuration needed.
150150
- Pick the staged files which are present inside the project directory.
@@ -153,11 +153,11 @@ When matching, `lint-staged` will do the following
153153
154154
**NOTE:** `lint-staged` will pass _absolute_ paths to the linters to avoid any confusion in case they're executed in a different working directory (i.e. when your `.git` directory isn't the same as your `package.json` directory).
155155
156-
Also see [How to use `lint-staged` in a multi package monorepo?](#how-to-use-lint-staged-in-a-multi-package-monorepo)
156+
Also see [How to use `lint-staged` in a multi-package monorepo?](#how-to-use-lint-staged-in-a-multi-package-monorepo)
157157
158158
### Ignoring files
159159
160-
The concept of `lint-staged` is to run configured linter (or other) tasks on files that are staged in git. `lint-staged` will always pass a list of all staged files to the task, and ignoring any files should be configured in the task itself.
160+
The concept of `lint-staged` is to run configured linter tasks (or other tasks) on files that are staged in git. `lint-staged` will always pass a list of all staged files to the task, and ignoring any files should be configured in the task itself.
161161
162162
Consider a project that uses [`prettier`](https://prettier.io/) to keep code format consistent across all files. The project also stores minified 3rd-party vendor libraries in the `vendor/` directory. To keep `prettier` from throwing errors on these files, the vendor directory should be added to prettier's ignore configuration, the `.prettierignore` file. Running `npx prettier .` will ignore the entire vendor directory, throwing no errors. When `lint-staged` is added to the project and configured to run prettier, all modified and staged files in the vendor directory will be ignored by prettier, even though it receives them as input.
163163
@@ -167,7 +167,7 @@ In advanced scenarios, where it is impossible to configure the linter task itsel
167167
168168
Supported are any executables installed locally or globally via `npm` as well as any executable from your \$PATH.
169169
170-
> Using globally installed scripts is discouraged, since lint-staged may not work for someone who doesnt have it installed.
170+
> Using globally installed scripts is discouraged, since lint-staged may not work for someone who doesn't have it installed.
171171
172172
`lint-staged` uses [execa](https://github.com/sindresorhus/execa#preferlocal) to locate locally installed scripts. So in your `.lintstagedrc` you can write:
173173
@@ -195,11 +195,11 @@ going to execute `eslint` and if it exits with `0` code, it will execute `pretti
195195
196196
## Using JS configuration file
197197
198-
Writing the configuration file in JavaScript is the most powerful way to configure _lint-staged_ (`lint-staged.config.js`, [similar](https://github.com/okonet/lint-staged/README.md#configuration), or passed via `--config`). From the configuration file, you can export either a single function, or an object.
198+
Writing the configuration file in JavaScript is the most powerful way to configure lint-staged (`lint-staged.config.js`, [similar](https://github.com/okonet/lint-staged/README.md#configuration), or passed via `--config`). From the configuration file, you can export either a single function or an object.
199199
200-
If the `exports` value is a function, it will receive an array of all staged filenames. You can then build your own matchers for the files, and return a command string, or an array or command strings. These strings are considered complete and should include the filename arguments, if wanted.
200+
If the `exports` value is a function, it will receive an array of all staged filenames. You can then build your own matchers for the files and return a command string or an array of command strings. These strings are considered complete and should include the filename arguments, if wanted.
201201
202-
If the `exports` value is an object, its keys should be glob matches (like in the normal non-js config format). The values can either be like in the normal config, or individual functions like described above. Instead of receiving all matched files, the functions in the exported object will only receive the staged files matching the corresponding glob key.
202+
If the `exports` value is an object, its keys should be glob matches (like in the normal non-js config format). The values can either be like in the normal config or individual functions like described above. Instead of receiving all matched files, the functions in the exported object will only receive the staged files matching the corresponding glob key.
203203
204204
### Function signature
205205
@@ -259,7 +259,7 @@ module.exports = {
259259
260260
</details>
261261
262-
### Example: Run eslint on entire repo if more than 10 staged files
262+
### Example: Run ESLint on entire repo if more than 10 staged files
263263
264264
<details>
265265
<summary>Click to expand</summary>
@@ -353,7 +353,7 @@ Prior to version 10, tasks had to manually include `git add` as the final step.
353353
354354
## Examples
355355
356-
All examples assuming youve already set up lint-staged in the `package.json` and [husky](https://github.com/typicode/husky).
356+
All examples assume you've already set up lint-staged in the `package.json` file and [husky](https://github.com/typicode/husky) in its own config file.
357357
358358
```json
359359
{
@@ -375,7 +375,7 @@ In `.husky/pre-commit`
375375
npx lint-staged
376376
```
377377
378-
_Note we dont pass a path as an argument for the runners. This is important since lint-staged will do this for you._
378+
_Note: we don't pass a path as an argument for the runners. This is important since lint-staged will do this for you._
379379
380380
### ESLint with default parameters for `*.js` and `*.jsx` running as a pre-commit hook
381381
@@ -472,13 +472,15 @@ module.exports = (allStagedFiles) => {
472472
allStagedFiles,
473473
prettierSupportedExtensions.map((extension) => `**/*${extension}`)
474474
)
475-
return prettierFiles.length > 0 ? [`prettier --write ${prettierFiles.map(addQuotes).join(' ')}`] : []
475+
return prettierFiles.length > 0
476+
? [`prettier --write ${prettierFiles.map(addQuotes).join(' ')}`]
477+
: []
476478
}
477479
```
478480
479481
</details>
480482
481-
### Automatically fix code style with `prettier` for javascript, typescript, markdown, HTML, or CSS
483+
### Automatically fix code style with `prettier` for JavaScript, TypeScript, Markdown, HTML, or CSS
482484
483485
<details>
484486
<summary>Click to expand</summary>
@@ -652,7 +654,7 @@ _Thanks to [this comment](https://youtrack.jetbrains.com/issue/IDEA-135454#comme
652654
653655
</details>
654656
655-
### How to use `lint-staged` in a multi package monorepo?
657+
### How to use `lint-staged` in a multi-package monorepo?
656658
657659
<details>
658660
<summary>Click to expand</summary>
@@ -684,7 +686,7 @@ Example repo: [sudo-suhas/lint-staged-django-react-demo](https://github.com/sudo
684686
685687
</details>
686688
687-
### How can i ignore files from `.eslintignore` ?
689+
### How can I ignore files from `.eslintignore`?
688690
689691
<details>
690692
<summary>Click to expand</summary>
@@ -715,16 +717,16 @@ module.exports = {
715717
716718
</details>
717719
718-
#### ESlint >= 7
720+
#### ESLint >= 7
719721
720722
<details>
721723
<summary>Click to expand</summary>
722724
723-
In versions of ESlint > 7, [isPathIgnored](https://eslint.org/docs/developer-guide/nodejs-api#-eslintispathignoredfilepath) is an async function and now returns a promise. The code below can be used to reinstate the above functionality.
725+
In versions of ESLint > 7, [isPathIgnored](https://eslint.org/docs/developer-guide/nodejs-api#-eslintispathignoredfilepath) is an async function and now returns a promise. The code below can be used to reinstate the above functionality.
724726
725727
This particular code uses a tiny package, [node-filter-async](https://www.npmjs.com/package/node-filter-async), to filter the files array with an async function. If you prefer to not have an extra dependency, it is quite simple to write a similar function.
726728
727-
Since [10.5.3](https://github.com/okonet/lint-staged/releases), any errors due to a bad eslint config will come through to the console.
729+
Since [10.5.3](https://github.com/okonet/lint-staged/releases), any errors due to a bad ESLint config will come through to the console.
728730
729731
```js
730732
const { ESLint } = require('eslint')

0 commit comments

Comments
 (0)