Skip to content

Commit

Permalink
docs: update FAQ and add issue template config (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed May 27, 2020
1 parent 9b7f4d4 commit d70fba2
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 8 deletions.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
blank_issues_enabled: false
contact_links:
-
name: FAQ
about: Please check out our FAQ before filing new issues
url: https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md
-
name: Getting Started Guide
about: If you're looking for help setting up check out our getting started guide
url: https://github.com/typescript-eslint/typescript-eslint/tree/master/docs/getting-started
55 changes: 47 additions & 8 deletions docs/getting-started/linting/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [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)
- [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)
- [TypeScript should be installed locally](#typescript-should-be-installed-locally)
- [How can I ban `<specific language feature>`?](#how-can-i-ban-specific-language-feature)

---

Expand Down Expand Up @@ -81,14 +82,7 @@ This error means that the file that's being linted is not included in any of the

There are a couple of solutions to this, depending on what you want to achieve.

- If you **do not** want to lint the file:
- 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.
- If you **do** want to lint the file:
- If you **do not** want to lint the file with [type-aware linting](./TYPED_LINTING.md):
- 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.
- If you **do** want to lint the file with [type-aware linting](./TYPED_LINTING.md):
- 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.
- 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`.
See our docs on [type aware linting](./TYPED_LINTING.md#i-get-errors-telling-me-the-file-must-be-included-in-at-least-one-of-the-projects-provided) for solutions to this.

<br />
<br />
Expand Down Expand Up @@ -169,3 +163,48 @@ If you have some pure JavaScript code that you do not want to apply certain lint

Make sure that you have installed TypeScript locally i.e. by using `npm install typescript`, not `npm install -g typescript`,
or by using `yarn add typescript`, not `yarn global add typescript`. See https://github.com/typescript-eslint/typescript-eslint/issues/2041 for more information.

<br />
<br />
<br />

---

<br />
<br />
<br />

## How can I ban `<specific language feature>`?

ESLint core contains the rule [`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax). This generic rule allows you to specify a [selector](https://eslint.org/docs/developer-guide/selectors) for the code you want to ban, along with a custom error message.

You can use a tool like [AST Explorer](https://astexplorer.net/) to help in figuring out the structure of the AST that you want to ban.

For example, you can ban enums (or some variation of) using one of the following configs:

```jsonc
{
"rules": {
"no-restricted-syntax": [
"error",
// ban all enums
{
"selector": "TSEnumDeclaration",
"message": "My reason for not using any enums at all"
},

// ban just const enums
{
"selector": "TSEnumDeclaration[const=true]",
"message": "My reason for not using const enums"
},

// ban just non-const enums
{
"selector": "TSEnumDeclaration:not([const=true])",
"message": "My reason for not using non-const enums"
}
]
}
}
```
17 changes: 17 additions & 0 deletions docs/getting-started/linting/TYPED_LINTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ Additionally, most users primarily consume lint errors via IDE plugins which, th

We strongly recommend you do use it, but the above information is included so that you can make your own, informed decision.

## I get errors telling me "The file must be included in at least one of the projects provided"

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 in their normal tsconfigs.

There are a couple of solutions to this, depending on what you want to achieve.

- If you **do not** want to lint the file:
- 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.
- If you **do** want to lint the file:
- If you **do not** want to lint the file with [type-aware linting](./TYPED_LINTING.md):
- 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.
- If you **do** want to lint the file with [type-aware linting](./TYPED_LINTING.md):
- 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.
- 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`. For an example of this, you can check out the configuration we use in this repo:
- [`tsconfig.eslint.json`](../../../tsconfig.eslint.json)
- [`.eslintrc.js`](../../../.eslintrc.js)

## FAQ

If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](./FAQ.md).

0 comments on commit d70fba2

Please sign in to comment.