Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 615 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 615 Bytes

tslint-no-closures

A typescript linting rule to discourage the usage of closures.

THIS PROJECT IS STILL A WORK IN PROGRESS

Closures in javascript can cause memory leaks in certain situations. Most closures can be avoided. This linting rule attempts to find closures and log them as either warnings or errors in order to help avoid memory leaks.

"rules": {
    "no-closures": true
}

With this rule enabled, common closure bugs will be marked as errors:

BAD:

for (var i = 0; i < 100; i++) {
    setTimeout(() => {
        // i was not defined in this function
        alert(i);
    });
}