Skip to content

Commit

Permalink
Update FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Jul 29, 2024
1 parent 3865ab6 commit 6e0f3fa
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion designs/2024-config-lookup-from-file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,30 @@ Here's the structure in question:
└── eslint.config.js
```

When `eslint subdir/foo.js` is called, no files will be linted because the root `eslint.config.js` file ignores `subdir`.
In this scenario, it matters how ESLint is called:

1. `eslint .` - ESLint first reads `./eslint.config.js`, which says to ignore `subdir`. Because ESLint must recursively traverse `.`, it skips `subdir`. Only `./eslint.config.js` is linted.
1. `eslint subdir` - ESLint first reads `./subdir/eslint.config.js` and lints `./subdir/foo.js` and `./subdir/eslint.config.js`. The `./eslint.config.js` file is never read because config lookup starts and stops in `subdir` due to the presence of `./subdir/eslint.config.js`.
1. `eslint subdir/foo.js` - ESLint first reads `./subdir/eslint.config.js` and lints `./subdir/foo.js`.

A more complicated example:

```
/usr/tmp/
├── eslint.config.js <-- ignores: ['**/subsubdir1']
└── subdir/
├── eslint.config.js <-- ignores: ['**/subsubdir2']
├── subsubdir1/
│ └── file.js
└── subsubdir2/
└── file.js
```

In this scenario:

1. `eslint .` - ESLint first reads `./eslint.config.js`, which has an `ignores` pattern that doesn't match any of the child directories, so ESLint traverses into each child directory. Once in `subdir`, ESLint reads `./subdir/eslint.config.js`, which says to ignore `subsubdir2`, so ESLint skips traversing into `subsubdir2` but still traverses into `subsubdir1`. ESLint lints `./eslint.config.js`, `./subdir/eslint.config.js`, and `./subdir/subsubdir1/file.js`.
1. `eslint subdir` - ESLint first reads `./subdir/eslint.config.js` which says to ignore `subsubdir2`, so ESLint skips traversing into `subsubdir2` but still traverses into `subsubdir1`. ESLint lints `./subdir/eslint.config.js`, and `./subdir/subsubdir1/file.js`.


## Related Discussions

Expand Down

0 comments on commit 6e0f3fa

Please sign in to comment.