Skip to content

Commit 2600a9f

Browse files
ThomasdenHbradzacher
authored andcommitted
feat(eslint-plugin): Add new config "eslint-recommended" (#488)
1 parent c3061f9 commit 2600a9f

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

packages/eslint-plugin/src/configs/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ These configs exist for your convenience. They contain configuration intended to
66

77
TODO when all config is added.
88

9+
## eslint-recommended
10+
11+
The `eslint-recommended` ruleset is meant to be used after extending `eslint:recommended`. It disables rules that are already checked by the Typescript compiler and enables rules that promote using more the more modern constructs Typescript allows for.
12+
13+
```cjson
14+
{
15+
"extends": [
16+
"eslint:recommended",
17+
"plugin:@typescript-eslint/eslint-recommended"
18+
]
19+
}
20+
```
21+
922
## Recommended
1023

1124
The recommended set is an **_opinionated_** set of rules that we think you should use because:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* The goal of this ruleset is to update the eslint:recommended config to better
3+
* suit Typescript. There are two main reasons to change the configuration:
4+
* 1. The Typescript compiler natively checks some things that therefore don't
5+
* need extra rules anymore.
6+
* 2. Typescript allows for more modern Javascript code that can thus be
7+
* enabled.
8+
*/
9+
export default {
10+
overrides: [
11+
{
12+
files: ['*.ts', '*.tsx'],
13+
rules: {
14+
/**
15+
* 1. Disable things that are checked by Typescript
16+
*/
17+
//Checked by Typescript - ts(2378)
18+
'getter-return': false,
19+
// Checked by Typescript - ts(2300)
20+
'no-dupe-args': false,
21+
// Checked by Typescript - ts(1117)
22+
'no-dupe-keys': false,
23+
// Checked by Typescript - ts(7027)
24+
'no-unreachable': false,
25+
// Checked by Typescript - ts(2367)
26+
'valid-typeof': false,
27+
// Checked by Typescript - ts(2588)
28+
'no-const-assign': false,
29+
// Checked by Typescript - ts(2588)
30+
'no-new-symbol': false,
31+
// Checked by Typescript - ts(2376)
32+
'no-this-before-super': false,
33+
// This is checked by Typescript using the option `strictNullChecks`.
34+
'no-undef': false,
35+
/**
36+
* 2. Enable more ideomatic code
37+
*/
38+
// Typescript allows const and let instead of var.
39+
'no-var': 'error',
40+
'prefer-const': 'error',
41+
// The spread operator/rest parameters should be prefered in Typescript.
42+
'prefer-rest-params': 'error',
43+
'prefer-spread': 'error',
44+
// This is already checked by Typescript.
45+
'no-dupe-class-members': 'error',
46+
},
47+
},
48+
],
49+
};

packages/eslint-plugin/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import requireIndex from 'requireindex';
22
import path from 'path';
33

44
import recommended from './configs/recommended.json';
5+
import eslintRecommended from './configs/eslint-recommended';
56

67
const rules = requireIndex(path.join(__dirname, 'rules'));
78
// eslint expects the rule to be on rules[name], not rules[name].default
@@ -18,5 +19,6 @@ export = {
1819
rules: rulesWithoutDefault,
1920
configs: {
2021
recommended,
22+
eslintRecommended,
2123
},
2224
};

0 commit comments

Comments
 (0)