Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Prepare release v5.19.0 (#4826)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Aug 20, 2019
1 parent 05cfde7 commit 40b7793
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 18 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Change Log

## v5.19.0

- [bugfix] relax [`promise-function-async`](https://palantir.github.io/tslint/rules/promise-function-async/) for short parenthesized arrow functions (#4765)
- [bugfix] fix [`no-async-without-await`](https://palantir.github.io/tslint/rules/no-async-without-await/) false positive for abstract methods (#4782)
- [bugfix] fix [`strict-comparison`](https://palantir.github.io/tslint/rules/strict-comparison/) false positive for `null` and `undefined` literals (#4786)
- [bugfix] improve [`no-angle-bracket-type-assertion`](https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/) autofix semantics with more parentheses (#4823)
- [enhancement] add BigInt support to [`restrict-plus-operands`](https://palantir.github.io/tslint/rules/restrict-plus-operands/) rule (#4814)
- [enhancement] [`await-promise`](https://palantir.github.io/tslint/rules/await-promise/) now supports new TypeScript 3.6 AST API symbols for async iterators (#4800)
- [new-rule-option] `check-strings` and `check-regex` options for [`max-line-length`](https://palantir.github.io/tslint/rules/max-line-length/) rule (#4798)
- [new-rule-option] `variable-declaration-ignore-function` option for [`typedef`](https://palantir.github.io/tslint/rules/typedef/) rule (#4769)
- [new-rule-option] `ignore-blank-lines` option for [`object-literal-sort-keys`](https://palantir.github.io/tslint/rules/object-literal-sort-keys/) rule (#4808)
- [new-rule] [`no-for-in`](https://palantir.github.io/tslint/rules/no-for-in/) (#4747)
- [new-rule] [`no-invalid-void`](https://palantir.github.io/tslint/rules/no-invalid-void/) (#4736)
- [new-rule] [`strict-string-expressions`](https://palantir.github.io/tslint/rules/strict-string-expressions/) reports errors on type coercions found in string expressions (#4807)
- [new-rule] ['no-promise-as-boolean'](https://palantir.github.io/tslint/rules/no-promise-as-boolean/) (#4790)
- [docs] link to OSS fellowship medium post in README (#4821)

Thanks to our contributors!

- Josh Pike
- Tanmoy Bhowmik
- Michael Withagen
- Evgeniy Timokhov
- Vitalij Krotov
- Josh Goldberg
- Veda
- Guido
- Robert Fink
- Max Sysoev


## v5.18.0

- [feature] New `--print-config` CLI flag (#4744)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tslint",
"version": "5.18.0",
"version": "5.19.0",
"description": "An extensible static analysis linter for the TypeScript language",
"bin": {
"tslint": "./bin/tslint"
Expand Down
2 changes: 1 addition & 1 deletion src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { arrayify, dedent, flatMap, mapDefined } from "./utils";
* Linter that can lint multiple files in consecutive runs.
*/
export class Linter {
public static VERSION = "5.18.0";
public static VERSION = "5.19.0";

public static findConfiguration = findConfiguration;
public static findConfigurationPath = findConfigurationPath;
Expand Down
29 changes: 17 additions & 12 deletions src/rules/returnUndefinedRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker) {
});

function check(node: ts.ReturnStatement): void {
const actualReturnKind = returnKindFromReturn(node);
const actualReturnKind = getReturnKindFromReturnStatement(node);
if (actualReturnKind === undefined) {
return;
}
Expand All @@ -72,7 +72,7 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker) {
return;
}

const returnKindFromType = getReturnKind(functionReturningFrom, checker);
const returnKindFromType = getReturnKindFromFunction(functionReturningFrom, checker);
if (returnKindFromType !== undefined && returnKindFromType !== actualReturnKind) {
ctx.addFailureAtNode(
node,
Expand All @@ -84,7 +84,7 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker) {
}
}

function returnKindFromReturn(node: ts.ReturnStatement): ReturnKind | undefined {
function getReturnKindFromReturnStatement(node: ts.ReturnStatement): ReturnKind | undefined {
if (node.expression === undefined) {
return ReturnKind.Void;
} else if (isIdentifier(node.expression) && node.expression.text === "undefined") {
Expand All @@ -94,9 +94,9 @@ function returnKindFromReturn(node: ts.ReturnStatement): ReturnKind | undefined
}
}

enum ReturnKind {
Void,
Value,
const enum ReturnKind {
Void = "void",
Value = "value",
}

type FunctionLike =
Expand All @@ -108,7 +108,10 @@ type FunctionLike =
| ts.GetAccessorDeclaration
| ts.SetAccessorDeclaration;

function getReturnKind(node: FunctionLike, checker: ts.TypeChecker): ReturnKind | undefined {
function getReturnKindFromFunction(
node: FunctionLike,
checker: ts.TypeChecker,
): ReturnKind | undefined {
switch (node.kind) {
case ts.SyntaxKind.Constructor:
case ts.SyntaxKind.SetAccessor:
Expand All @@ -134,13 +137,15 @@ function getReturnKind(node: FunctionLike, checker: ts.TypeChecker): ReturnKind
if (returnType === undefined || isTypeFlagSet(returnType, ts.TypeFlags.Any)) {
return undefined;
}
if (
(hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)
? isEffectivelyVoidPromise
: isEffectivelyVoid)(returnType)
) {

const effectivelyVoidChecker = hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)
? isEffectivelyVoidPromise
: isEffectivelyVoid;

if (effectivelyVoidChecker(returnType)) {
return ReturnKind.Void;
}

return ReturnKind.Value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ async function promiseValue(): Promise<number | undefined> {
~~~~~~~ [UNDEFINED]
}

declare function f<T>(action: () => T | undefined): void;
f(() => { return undefined; });
~~~~~~~~~~~~~~~~~ [VOID]

declare function test(cb: () => Promise<void> | void): void;

test(async () => {
Expand Down
9 changes: 9 additions & 0 deletions test/rules/return-undefined/pre-ts-3.6/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[typescript]: <= 3.6.0

// in TS 3.6 and later, the type checker infers this anonymous function as returning 'unknown'
declare function f<T>(action: () => T | undefined): void;
f(() => { return undefined; });
~~~~~~~~~~~~~~~~~ [VOID]

[VOID]: `void` function should use `return;`, not `return undefined;`.
[UNDEFINED]: Value-returning function should use `return undefined;`, not just `return;`.
5 changes: 5 additions & 0 deletions test/rules/return-undefined/pre-ts-3.6/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"strictNullChecks": true
}
}
5 changes: 5 additions & 0 deletions test/rules/return-undefined/pre-ts-3.6/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"return-undefined": true
}
}

0 comments on commit 40b7793

Please sign in to comment.