Skip to content

Commit 40b7793

Browse files
authored
Prepare release v5.19.0 (palantir#4826)
1 parent 05cfde7 commit 40b7793

File tree

10 files changed

+69
-18
lines changed

10 files changed

+69
-18
lines changed

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Change Log
22

3+
## v5.19.0
4+
5+
- [bugfix] relax [`promise-function-async`](https://palantir.github.io/tslint/rules/promise-function-async/) for short parenthesized arrow functions (#4765)
6+
- [bugfix] fix [`no-async-without-await`](https://palantir.github.io/tslint/rules/no-async-without-await/) false positive for abstract methods (#4782)
7+
- [bugfix] fix [`strict-comparison`](https://palantir.github.io/tslint/rules/strict-comparison/) false positive for `null` and `undefined` literals (#4786)
8+
- [bugfix] improve [`no-angle-bracket-type-assertion`](https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/) autofix semantics with more parentheses (#4823)
9+
- [enhancement] add BigInt support to [`restrict-plus-operands`](https://palantir.github.io/tslint/rules/restrict-plus-operands/) rule (#4814)
10+
- [enhancement] [`await-promise`](https://palantir.github.io/tslint/rules/await-promise/) now supports new TypeScript 3.6 AST API symbols for async iterators (#4800)
11+
- [new-rule-option] `check-strings` and `check-regex` options for [`max-line-length`](https://palantir.github.io/tslint/rules/max-line-length/) rule (#4798)
12+
- [new-rule-option] `variable-declaration-ignore-function` option for [`typedef`](https://palantir.github.io/tslint/rules/typedef/) rule (#4769)
13+
- [new-rule-option] `ignore-blank-lines` option for [`object-literal-sort-keys`](https://palantir.github.io/tslint/rules/object-literal-sort-keys/) rule (#4808)
14+
- [new-rule] [`no-for-in`](https://palantir.github.io/tslint/rules/no-for-in/) (#4747)
15+
- [new-rule] [`no-invalid-void`](https://palantir.github.io/tslint/rules/no-invalid-void/) (#4736)
16+
- [new-rule] [`strict-string-expressions`](https://palantir.github.io/tslint/rules/strict-string-expressions/) reports errors on type coercions found in string expressions (#4807)
17+
- [new-rule] ['no-promise-as-boolean'](https://palantir.github.io/tslint/rules/no-promise-as-boolean/) (#4790)
18+
- [docs] link to OSS fellowship medium post in README (#4821)
19+
20+
Thanks to our contributors!
21+
22+
- Josh Pike
23+
- Tanmoy Bhowmik
24+
- Michael Withagen
25+
- Evgeniy Timokhov
26+
- Vitalij Krotov
27+
- Josh Goldberg
28+
- Veda
29+
- Guido
30+
- Robert Fink
31+
- Max Sysoev
32+
33+
334
## v5.18.0
435

536
- [feature] New `--print-config` CLI flag (#4744)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tslint",
3-
"version": "5.18.0",
3+
"version": "5.19.0",
44
"description": "An extensible static analysis linter for the TypeScript language",
55
"bin": {
66
"tslint": "./bin/tslint"

src/linter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { arrayify, dedent, flatMap, mapDefined } from "./utils";
4242
* Linter that can lint multiple files in consecutive runs.
4343
*/
4444
export class Linter {
45-
public static VERSION = "5.18.0";
45+
public static VERSION = "5.19.0";
4646

4747
public static findConfiguration = findConfiguration;
4848
public static findConfigurationPath = findConfigurationPath;

src/rules/returnUndefinedRule.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker) {
6161
});
6262

6363
function check(node: ts.ReturnStatement): void {
64-
const actualReturnKind = returnKindFromReturn(node);
64+
const actualReturnKind = getReturnKindFromReturnStatement(node);
6565
if (actualReturnKind === undefined) {
6666
return;
6767
}
@@ -72,7 +72,7 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker) {
7272
return;
7373
}
7474

75-
const returnKindFromType = getReturnKind(functionReturningFrom, checker);
75+
const returnKindFromType = getReturnKindFromFunction(functionReturningFrom, checker);
7676
if (returnKindFromType !== undefined && returnKindFromType !== actualReturnKind) {
7777
ctx.addFailureAtNode(
7878
node,
@@ -84,7 +84,7 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker) {
8484
}
8585
}
8686

87-
function returnKindFromReturn(node: ts.ReturnStatement): ReturnKind | undefined {
87+
function getReturnKindFromReturnStatement(node: ts.ReturnStatement): ReturnKind | undefined {
8888
if (node.expression === undefined) {
8989
return ReturnKind.Void;
9090
} else if (isIdentifier(node.expression) && node.expression.text === "undefined") {
@@ -94,9 +94,9 @@ function returnKindFromReturn(node: ts.ReturnStatement): ReturnKind | undefined
9494
}
9595
}
9696

97-
enum ReturnKind {
98-
Void,
99-
Value,
97+
const enum ReturnKind {
98+
Void = "void",
99+
Value = "value",
100100
}
101101

102102
type FunctionLike =
@@ -108,7 +108,10 @@ type FunctionLike =
108108
| ts.GetAccessorDeclaration
109109
| ts.SetAccessorDeclaration;
110110

111-
function getReturnKind(node: FunctionLike, checker: ts.TypeChecker): ReturnKind | undefined {
111+
function getReturnKindFromFunction(
112+
node: FunctionLike,
113+
checker: ts.TypeChecker,
114+
): ReturnKind | undefined {
112115
switch (node.kind) {
113116
case ts.SyntaxKind.Constructor:
114117
case ts.SyntaxKind.SetAccessor:
@@ -134,13 +137,15 @@ function getReturnKind(node: FunctionLike, checker: ts.TypeChecker): ReturnKind
134137
if (returnType === undefined || isTypeFlagSet(returnType, ts.TypeFlags.Any)) {
135138
return undefined;
136139
}
137-
if (
138-
(hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)
139-
? isEffectivelyVoidPromise
140-
: isEffectivelyVoid)(returnType)
141-
) {
140+
141+
const effectivelyVoidChecker = hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)
142+
? isEffectivelyVoidPromise
143+
: isEffectivelyVoid;
144+
145+
if (effectivelyVoidChecker(returnType)) {
142146
return ReturnKind.Void;
143147
}
148+
144149
return ReturnKind.Value;
145150
}
146151

test/rules/return-undefined/test.ts.lint test/rules/return-undefined/default/test.ts.lint

-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ async function promiseValue(): Promise<number | undefined> {
6666
~~~~~~~ [UNDEFINED]
6767
}
6868

69-
declare function f<T>(action: () => T | undefined): void;
70-
f(() => { return undefined; });
71-
~~~~~~~~~~~~~~~~~ [VOID]
72-
7369
declare function test(cb: () => Promise<void> | void): void;
7470

7571
test(async () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[typescript]: <= 3.6.0
2+
3+
// in TS 3.6 and later, the type checker infers this anonymous function as returning 'unknown'
4+
declare function f<T>(action: () => T | undefined): void;
5+
f(() => { return undefined; });
6+
~~~~~~~~~~~~~~~~~ [VOID]
7+
8+
[VOID]: `void` function should use `return;`, not `return undefined;`.
9+
[UNDEFINED]: Value-returning function should use `return undefined;`, not just `return;`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"strictNullChecks": true
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"return-undefined": true
4+
}
5+
}

0 commit comments

Comments
 (0)