Novaleaf / xlib

Your isomorphic toolbox
MIT License
20 stars 1 forks source link

code quality: ensure tslint can catch accidental function references (vs calls) #12

Closed jasonswearingen closed 5 years ago

jasonswearingen commented 5 years ago

in some private code I found some accidental calls like such:

const loadAvg = ( nlib.os.loadavg[ 0 ] / nlib.os.cpus.length );

this is a bug because cpus is actually a function that needs to be called as such: cpus().length

same with loadavg. it's a function.

however it is valid JS code so compiler didn't catch it. find a tslint rule that can catch these mistakes and set it to error

jasonswearingen commented 5 years ago

as shown here, no solution: https://stackoverflow.com/questions/53639295/tslint-ban-usage-of-the-function-length-property

however partial fix via "implicit any with no index signature" for os.loadavg[0]