8000 docs: add some more FAQ (#2011) · dandv/typescript-eslint@f3f3bf8 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3f3bf8

Browse files
authored
docs: add some more FAQ (typescript-eslint#2011)
1 parent 1875fba commit f3f3bf8

File tree

1 file changed

+17
-1
lines changed
  • docs/getting-started/linting

1 file changed

+17
-1
lines changed

docs/getting-started/linting/FAQ.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [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)
77
- [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)
88
- [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)
910

1011
---
1112

@@ -65,7 +66,16 @@ We recommend not using this rule, and instead using a tool like [`prettier`](htt
6566

6667
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.
6768

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`.
6979

7080
---
7181

@@ -101,3 +111,9 @@ The first step is to [check our list of "extension" rules here](../../../package
101111
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).
102112

103113
---
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

Comments
 (0)
0