Skip to content

Commit

Permalink
Merge branch 'master' into provide-all-config
Browse files Browse the repository at this point in the history
  • Loading branch information
ldrick committed Apr 30, 2019
2 parents 66944f8 + 6fd3e10 commit d91badc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/ISSUE_TEMPLATE/eslint-plugin-typescript.md
@@ -1,27 +1,32 @@
---
name: '@typescript-eslint/eslint-plugin'
about: Report an issue with the '@typescript-eslint/eslint-plugin' package
title: ''
title: '[rulename] <issue title>'
labels: 'package: eslint-plugin, triage'
assignees: ''
---

<!--
If you have a problem with a specific rule, please begin your issue title with [rulename] to make it easier to search for.
I.e. "[no-unused-vars] False positive when fooing the bar"
Please don't ignore this template.
If you ignore it, we're just going to respond asking you to fill it out, which wastes everyone's time.
The more relevant information you can include, the faster we can find the issue and fix it without asking you for more info.
-->

**Repro**

<!--
Include a minimal reproduction case.
Please try to avoid code that isn't directly related to the bug, as it makes it harder to investigate.
Include a ***minimal*** reproduction case.
The more irrelevant code/config you give, the harder it is for us to investigate.
-->

```JSON
{
"rules": {
"typescript/<rule>": "<setting>"
"typescript/<rule>": ["<setting>"]
}
}
```
Expand All @@ -36,6 +41,13 @@ Please try to avoid code that isn't directly related to the bug, as it makes it

**Additional Info**

<!--
Did eslint throw an exception?
Please run your lint again with the --debug flag, and dump the output below.
i.e. eslint --ext ".ts,.js" src --debug
-->

**Versions**

| package | version |
Expand Down
42 changes: 42 additions & 0 deletions packages/eslint-plugin/src/configs/README.md
@@ -0,0 +1,42 @@
# Premade configs

These configs exist for your convenience. They contain configuration intended to save you time and effort when configuring your project by disabling rules known to conflict with this repository, or cause issues in typesript codebases.

## All

TODO when all config is added.

## Recommended

The recommended set is an **_opinionated_** set of rules that we think you should use because:

1. They help you adhere to TypeScript best practices.
2. They help catch probable issue vectors in your code.

That being said, it is not the only way to use `@typescript-eslint/eslint-plugin`, nor is it the way that will necesasrily work 100% for your project/company. It has been built based off of two main things:

1. TypeScript best practices collected and collated from places like:
- [TypeScript repo](https://github.com/Microsoft/TypeScript).
- [TypeScript documentation](https://www.typescriptlang.org/docs/home.html).
- The style used by many OSS TypeScript projects.
2. The combined state of community contributed rulesets at the time of creation.

We will not add new rules to the recommended set unless we release a major package version (i.e. it is seen as a breaking change).

### Altering the recommended set to suit your project

If you disagree with a rule (or it disagrees with your codebase), consider using your local config to change the rule config so it works for your project.

```cjson
{
"extends": ["plugin:@typescript-eslint/recommended"],
"rules": {
// our project thinks using IPrefixedInterfaces is a good practice
"@typescript-eslint/interface-name-prefix": ["error", "always"]
}
}
```

### Suggesting changes to the recommended set

If you feel _very_, **very**, **_very_** strongly that a specific rule should (or should not) be in the recommended ruleset, please feel free to file an issue along with a **detailed** argument explaning your reasoning. We expect to see you citing concrete evidence supporting why (or why not) a rule is considered best practice. **Please note that if your reasoning is along the lines of "it's what my project/company does", or "I don't like the rule", then we will likely close the request without discussion.**
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/unbound-method.ts
Expand Up @@ -97,6 +97,7 @@ function isSafeUse(node: TSESTree.Node): boolean {
case AST_NODE_TYPES.IfStatement:
case AST_NODE_TYPES.ForStatement:
case AST_NODE_TYPES.MemberExpression:
case AST_NODE_TYPES.SwitchStatement:
case AST_NODE_TYPES.UpdateExpression:
case AST_NODE_TYPES.WhileStatement:
return true;
Expand Down
14 changes: 14 additions & 0 deletions packages/eslint-plugin/tests/rules/unbound-method.test.ts
Expand Up @@ -98,6 +98,20 @@ instane.boundStatic && 0;
ContainsMethods.boundStatic ? 1 : 0;
ContainsMethods.unboundStatic ? 1 : 0;
`,
`interface RecordA {
readonly type: "A"
readonly a: {}
}
interface RecordB {
readonly type: "B"
readonly b: {}
}
type AnyRecord = RecordA | RecordB
function test(obj: AnyRecord) {
switch (obj.type) {
}
}`,
],
invalid: [
{
Expand Down

0 comments on commit d91badc

Please sign in to comment.