Skip to content

Commit

Permalink
Docs: gitignore syntax updates (fixes #8139) (#10776)
Browse files Browse the repository at this point in the history
* Docs: .gitignore syntax updates (fixes #8139)
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch gitignore-syntax-updates
# Changes to be committed:
#modified:   docs/user-guide/command-line-interface.md
#modified:   docs/user-guide/configuring.md
#

Adds cross links between .eslintignore and --ignore-pattern sections.
Adds link to --ignore-pattern section directing to .gitignore specs.
Adds description to .eslintignore section that emphasizes forward slashes being necessary with examples of valid and invalid syntax.
Adds explicit statements to both sections that support this example.

* adds a comma
  • Loading branch information
santanaG authored and platinumazure committed Aug 22, 2018
1 parent cb946af commit 80c8598
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions docs/user-guide/command-line-interface.md
Expand Up @@ -254,13 +254,12 @@ Example:

#### `--ignore-pattern`

This option allows you to specify patterns of files to ignore (in addition to those in `.eslintignore`). You can repeat the option to provide multiple patterns. The supported syntax is the same as in the `.eslintignore` file. You should quote your patterns in order to avoid shell interpretation of glob patterns.
This option allows you to specify patterns of files to ignore (in addition to those in `.eslintignore`). You can repeat the option to provide multiple patterns. The supported syntax is the same as for `.eslintignore` [files](./configuring.md#.eslintignore), which use the same patterns as the `.gitignore` [specification](https://git-scm.com/docs/gitignore). You should quote your patterns in order to avoid shell interpretation of glob patterns.

Example:

eslint --ignore-pattern '/lib/' --ignore-pattern '/src/vendor/*' .


### Using stdin

#### `--stdin`
Expand Down
18 changes: 16 additions & 2 deletions docs/user-guide/configuring.md
Expand Up @@ -839,6 +839,8 @@ Currently the sole method for telling ESLint which file extensions to lint is by

## Ignoring Files and Directories

### `.eslintignore`

You can tell ESLint to ignore specific files and directories by creating an `.eslintignore` file in your project's root directory. The `.eslintignore` file is a plain text file where each line is a glob pattern indicating which paths should be omitted from linting. For example, the following will omit all JavaScript files:

```text
Expand All @@ -850,9 +852,21 @@ When ESLint is run, it looks in the current working directory to find an `.eslin
Globs are matched using [node-ignore](https://github.com/kaelzhang/node-ignore), so a number of features are available:

* Lines beginning with `#` are treated as comments and do not affect ignore patterns.
* Paths are relative to `.eslintignore` location or the current working directory. This also influences paths passed via `--ignore-pattern`.
* Ignore patterns behave according to the `.gitignore` [specification](https://git-scm.com/docs/gitignore)
* Paths are relative to `.eslintignore` location or the current working directory. This is also true of paths passed in via the `--ignore-pattern` [command](./command-line-interface.md#--ignore-pattern).
* Lines preceded by `!` are negated patterns that re-include a pattern that was ignored by an earlier pattern.
* Ignore patterns behave according to the `.gitignore` [specification](https://git-scm.com/docs/gitignore).

Of particular note is that like `.gitignore` files, all paths used as patterns for both `.eslintignore` and `--ignore-pattern` must use forward slashes as their path separators.

```text
# Valid
/root/src/*.js
# Invalid
\root\src\*.js
```

Please see `.gitignore`'s specification for further examples of valid syntax.

In addition to any patterns in a `.eslintignore` file, ESLint always ignores files in `/node_modules/*` and `/bower_components/*`.

Expand Down

0 comments on commit 80c8598

Please sign in to comment.