8000 feat(eslint-plugin)!: change recommended config (#729) · ajmacd/typescript-eslint@428567d · GitHub
[go: up one dir, main page]

Skip to content

Commit 428567d

Browse files
bradzacherJamesHenry
authored andcommitted
feat(eslint-plugin)!: change recommended config (typescript-eslint#729)
BREAKING CHANGE: recommended config changes are considered breaking
1 parent de6cc1d commit 428567d

File tree

100 files changed

+470
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+470
-341
lines changed

.eslintrc.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,12 @@ module.exports = {
2121
// our plugin :D
2222
//
2323

24-
'@typescript-eslint/ban-ts-ignore': 'error',
25-
'@typescript-eslint/consistent-type-definitions': 'error',
26-
'@typescript-eslint/explicit-function-return-type': 'off',
27-
'@typescript-eslint/explicit-member-accessibility': 'off',
28-
'@typescript-eslint/indent': 'off',
29-
'@typescript-eslint/no-explicit-any': 'warn',
30-
'@typescript-eslint/no-inferrable-types': 'error',
31-
'@typescript-eslint/no-misused-promises': 'error',
24+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
25+
'@typescript-eslint/no-explicit-any': 'error',
3226
'@typescript-eslint/no-non-null-assertion': 'off',
33-
'@typescript-eslint/no-object-literal-type-assertion': 'off',
34-
'@typescript-eslint/no-parameter-properties': 'off',
35-
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
3627
'@typescript-eslint/no-use-before-define': 'off',
3728
'@typescript-eslint/no-var-requires': 'off',
38-
'@typescript-eslint/prefer-includes': 'error',
39-
'@typescript-eslint/prefer-regexp-exec': 'error',
40-
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
29+
'@typescript-eslint/unbound-method': 'off',
4130

4231
//
4332
// eslint base
@@ -110,12 +99,12 @@ module.exports = {
11099
'import/no-mutable-exports': 'error',
111100
// Prevent importing the default as if it were named
112101
'import/no-named-default': 'error',
113-
// Prohibit named exports // we want everything to be a named export
114-
'import/no-named-export': 'off',
102+
// Prohibit named exports
103+
'import/no-named-export': 'off', // we want everything to be a named export
115104
// Forbid a module from importing itself
116105
'import/no-self-import': 'error',
117-
// Require modules with a single export to use a default export // we want everything to be named
118-
'import/prefer-default-export': 'off',
106+
// Require modules with a single export to use a default export
107+
'import/prefer-default-export': 'off', // we want everything to be named
119108
},
120109
parserOptions: {
121110
sourceType: 'module',
File renamed without changes.

packages/eslint-plugin-tslint/src/custom-linter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ILinterOptions, Linter, LintResult } from 'tslint';
2-
import { Program } from 'typescript';
2+
import { Program, SourceFile } from 'typescript';
33

44
// We need to access the program, but Linter has private program already
55
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -14,7 +14,7 @@ export class CustomLinter extends TSLintLinter {
1414
return super.getResult();
1515
}
1616

17-
getSourceFile(fileName: string) {
17+
getSourceFile(fileName: string): SourceFile | undefined {
1818
return this.program.getSourceFile(fileName);
1919
}
2020
}

packages/eslint-plugin/README.md

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

packages/eslint-plugin/docs/rules/no-inferrable-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ The default options are:
2424

2525
```JSON
2626
{
27-
"ignoreParameters": true,
28-
"ignoreProperties": true,
27+
"ignoreParameters": false,
28+
"ignoreProperties": false,
2929
}
3030
```
3131

packages/eslint-plugin/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
"devDependencies": {
5050
"@types/json-schema": "^7.0.3",
5151
"@types/marked": "^0.6.5",
52+
"@types/prettier": "^1.18.0",
5253
"chalk": "^2.4.2",
5354
"marked": "^0.7.0",
55+
"prettier": "*",
5456
"typescript": "*"
5557
},
5658
"peerDependencies": {

packages/eslint-plugin/src/configs/all.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@typescript-eslint/member-ordering": "error",
2525
"no-array-constructor": "off",
2626
"@typescript-eslint/no-array-constructor": "error",
27+
"no-empty-function": "off",
2728
"@typescript-eslint/no-empty-function": "error",
2829
"@typescript-eslint/no-empty-interface": "error",
2930
"@typescript-eslint/no-explicit-any": "error",
@@ -62,6 +63,7 @@
6263
"@typescript-eslint/prefer-string-starts-ends-with": "error",
6364
"@typescript-eslint/promise-function-async": "error",
6465
"@typescript-eslint/require-array-sort-compare": "error",
66+
"require-await": "off",
6567
"@typescript-eslint/require-await": "error",
6668
"@typescript-eslint/restrict-plus-operands": "error",
6769
"semi": "off",
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"parser": "@typescript-eslint/parser",
3-
"parserOptions": {
4-
"sourceType": "module"
5-
},
6-
"plugins": [
7-
"@typescript-eslint"
8-
]
3+
"parserOptions": { "sourceType": "module" },
4+
"plugins": ["@typescript-eslint"]
95
}
Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,48 @@
11
{
22
"extends": "./configs/base.json",
33
"rules": {
4-
"no-var": "error",
5-
"prefer-const": "error",
6-
"prefer-rest-params": "error",
7-
"prefer-spread": "error",
84
"@typescript-eslint/adjacent-overload-signatures": "error",
9-
"@typescript-eslint/array-type": "error",
5+
"@typescript-eslint/await-thenable": "error",
6+
"@typescript-eslint/ban-ts-ignore": "error",
107
"@typescript-eslint/ban-types": "error",
118
"camelcase": "off",
129
"@typescript-eslint/camelcase": "error",
1310
"@typescript-eslint/class-name-casing": "error",
1411
"@typescript-eslint/consistent-type-assertions": "error",
1512
"@typescript-eslint/explicit-function-return-type": "warn",
16-
"@typescript-eslint/explicit-member-accessibility": "error",
17-
"indent": "off",
18-
"@typescript-eslint/indent": "error",
1913
"@typescript-eslint/interface-name-prefix": "error",
2014
"@typescript-eslint/member-delimiter-style": "error",
2115
"no-array-constructor": "off",
2216
"@typescript-eslint/no-array-constructor": "error",
17+
"no-empty-function": "off",
18+
"@typescript-eslint/no-empty-function": "error",
2319
"@typescript-eslint/no-empty-interface": "error",
2420
"@typescript-eslint/no-explicit-any": "warn",
21+
"@typescript-eslint/no-for-in-array": "error",
2522
"@typescript-eslint/no-inferrable-types": "error",
2623
"@typescript-eslint/no-misused-new": "error",
24+
"@typescript-eslint/no-misused-promises": "error",
2725
"@typescript-eslint/no-namespace": "error",
28-
"@typescript-eslint/no-non-null-assertion": "error",
29-
"@typescript-eslint/no-parameter-properties": "error",
26+
"@typescript-eslint/no-non-null-assertion": "warn",
27+
"@typescript-eslint/no-this-alias": "error",
28+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
3029
"no-unused-vars": "off",
3130
"@typescript-eslint/no-unused-vars": "warn",
3231
"no-use-before-define": "off",
3332
"@typescript-eslint/no-use-before-define": "error",
3433
"@typescript-eslint/no-var-requires": "error",
34+
"@typescript-eslint/prefer-includes": "error",
3535
"@typescript-eslint/prefer-namespace-keyword": "error",
36-
"@typescript-eslint/type-annotation-spacing": "error"
36+
"@typescript-eslint/prefer-regexp-exec": "error",
37+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
38+
"require-await": "off",
39+
"@typescript-eslint/require-await": "error",
40+
"@typescript-eslint/triple-slash-reference": "error",
41+
"@typescript-eslint/type-annotation-spacing": "error",
42+
"@typescript-eslint/unbound-method": "error",
43+
"no-var": "error",
44+
"prefer-const": "error",
45+
"prefer-rest-params": "error",
46+
"prefer-spread": "error"
3747
}
3848
}

packages/eslint-plugin/src/rules/array-type.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export default util.createRule<Options, MessageIds>({
9494
docs: {
9595
description: 'Requires using either `T[]` or `Array<T>` for arrays',
9696
category: 'Stylistic Issues',
97-
recommended: 'error',
97+
// too opinionated to be recommended
98+
recommended: false,
9899
},
99100
fixable: 'code',
100101
messages: {
@@ -168,7 +169,7 @@ export default util.createRule<Options, MessageIds>({
168169
}
169170

170171
return {
171-
TSArrayType(node: TSESTree.TSArrayType) {
172+
TSArrayType(node): void {
172173
if (
173174
isArrayOption ||
174175
(isArraySimpleOption && isSimpleType(node.elementType))
@@ -241,7 +242,7 @@ export default util.createRule<Options, MessageIds>({
241242
});
242243
},
243244

244-
TSTypeReference(node: TSESTree.TSTypeReference) {
245+
TSTypeReference(node): void {
245246
if (
246247
isGenericOption ||
247248
node.typeName.type !== AST_NODE_TYPES.Identifier

0 commit comments

Comments
 (0)
0