microsoft / tslint-microsoft-contrib

A set of TSLint rules used on some Microsoft projects.
MIT License
702 stars 198 forks source link

Rule "no-function-expression" shall pass on named function expressions. #867

Closed negin-z closed 4 years ago

negin-z commented 5 years ago

Bug Report

TypeScript code being linted

protected traverseTree() {
        const rootObjects = this.objects();
        // Arrow function cannot replace the following named function expression.
        rootObjects.forEach(function doSomthing(o: ObjectType) {
            o.processNode();
            o.children.forEach(doSomthing);
        });
    }

Actual behavior

ERROR: (no-function-expression) /path/to/code[x, y]: Use arrow function instead of function expression

Expected behavior

tslint passes

The need for recursive call is a legit case of preferring named function expression against arrow functions.

JoshuaKGoldberg commented 4 years ago

☠️ It's time! ☠️

Per #876, this repository is no longer accepting feature pull requests. TSLint is being deprecated and we recommend you switch to https://typescript-eslint.io.

Thanks for open sourcing with us, everyone!