|
6 | 6 | - [I get errors telling me "The file must be included in at least one of the projects provided"](#i-get-errors-telling-me-the-file-must-be-included-in-at-least-one-of-the-projects-provided)
|
7 | 7 | - [I use a framework (like Vue) that requires custom file extensions, and I get errors like "You should add `parserOptions.extraFileExtensions` to your config"](#i-use-a-framework-like-vue-that-requires-custom-file-extensions-and-i-get-errors-like-you-should-add-parseroptionsextrafileextensions-to-your-config)
|
8 | 8 | - [I am using a rule from ESLint core, and it doesn't work correctly with TypeScript code](#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code)
|
| 9 | +- [One of my lint rules isn't working correctly on a pure JavaScript file](#one-of-my-lint-rules-isnt-working-correctly-on-a-pure-javascript-file) |
9 | 10 |
|
10 | 11 | ---
|
11 | 12 |
|
@@ -65,7 +66,16 @@ We recommend not using this rule, and instead using a tool like [`prettier`](htt
|
65 | 66 |
|
66 | 67 | This error means that the file that's being linted is not included in any of the tsconfig files you provided us. A lot of the time this happens when users have test files or similar that are not included.
|
67 | 68 |
|
68 |
| -To fix this, simply make sure the `include` option in your tsconfig includes every single file you want to lint. |
| 69 | +There are a couple of solutions to this, depending on what you want to achieve. |
| 70 | + |
| 71 | +- If you **do not** want to lint the file: |
| 72 | + - Use [one of the options ESLint offers](https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories) to ignore files, like a `.eslintignore` file, or `ignorePatterns` config. |
| 73 | +- If you **do** want to lint the file: |
| 74 | + - If you **do not** want to lint the file with [type-aware linting](./TYPED_LINTING.md): |
| 75 | + - Use [ESLint's `overrides` configuration](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns) to configure the file to not be parsed with type information. |
| 76 | + - If you **do** want to lint the file with [type-aware linting](./TYPED_LINTING.md): |
| 77 | + - Check the `include` option of each of the tsconfigs that you provide to `parserOptions.project` - you must ensure that all files match an `include` glob, or else our tooling will not be able to find it. |
| 78 | + - If your file shouldn't be a part of one of your existing tsconfigs (for example, it is a script/tool local to the repo), then consider creating a new tsconfig (we advise calling it `tsconfig.eslint.json`) in your project root which lists this file in its `include`. |
69 | 79 |
|
70 | 80 | ---
|
71 | 81 |
|
@@ -101,3 +111,9 @@ The first step is to [check our list of "extension" rules here](../../../package
|
101 | 111 | If you don't find an existing extension rule, or the extension rule doesn't work for your case, then you can go ahead and check our issues. [The contributing guide outlines the best way to raise an issue](../../../CONTRIBUTING.md#raising-issues).
|
102 | 112 |
|
103 | 113 | ---
|
| 114 | + |
| 115 | +## One of my lint rules isn't working correctly on a pure JavaScript file |
| 116 | + |
| 117 | +This is to be expected - ESLint rules do not check file extensions on purpose, as it causes issues in environments that use non-standard extensions (for example, a `.vue` and a `.md` file can both contain TypeScript code to be linted). |
| 118 | + |
| 119 | +If you have some pure JavaScript code that you do not want to apply certain lint rules to, then you can use [ESLint's `overrides` configuration](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns) to turn off certain rules, or even change the parser based on glob patterns. |
0 commit comments