Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gordey4doronin/4b20bcf9960fb85da685054d60103734 to your computer and use it in GitHub Desktop.
Save gordey4doronin/4b20bcf9960fb85da685054d60103734 to your computer and use it in GitHub Desktop.
Configuration for TSLint's "ban" rule for modern Angular applications
"ban": [
true,
[ "angular", "each", "Don't rely on angular to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ],
[ "jQuery", "each", "Don't rely on jQuery to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ],
[ "$", "each", "Don't rely on jQuery to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ],
[ "_", "each", "Don't rely on Underscore to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ],
[ "_", "forEach", "Don't rely on Underscore to perform loops. Either use a 'for of' loop or the native 'array.forEach': https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_each" ],
[ "$", "ajax", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "jQuery", "ajax", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "$", "get", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "jQuery", "get", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "$", "getJSON", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "jQuery", "getJSON", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "$", "post", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "jQuery", "post", "Don't rely on jQuery to make AJAX calls. $inject the Angular '$http' service instead" ],
[ "jQuery", "extend", "Don't rely on jQuery to extend an object, use 'angular.merge', 'angular.extend', or 'angular.copy' instead: http://davidcai.github.io/blog/posts/copy-vs-extend-vs-merge" ],
[ "$", "extend", "Don't rely on jQuery to extend an object, use 'angular.merge', 'angular.extend', or 'angular.copy' instead: http://davidcai.github.io/blog/posts/copy-vs-extend-vs-merge" ],
[ "_", "extend", "Don't rely on Underscore to extend an object, use 'angular.merge', 'angular.extend', or 'angular.copy' instead: http://davidcai.github.io/blog/posts/copy-vs-extend-vs-merge" ],
[ "_", "clone", "Don't rely on Underscore to shallow copy an object, either use 'angular.extend' to shallow copy, or 'angular.copy' to deep copy: http://davidcai.github.io/blog/posts/copy-vs-extend-vs-merge" ],
[ "_", "indexOf", "Use the native 'array.indexOf' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_indexof" ],
[ "_", "lastIndexOf", "Use the native 'array.lastIndexOf' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_lastindexof" ],
[ "_", "every", "Use the native 'array.every' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_every" ],
[ "_", "all", "Use the native 'array.every' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_every" ],
[ "_", "filter", "Use the native 'array.filter' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_filter" ],
[ "_", "select", "Use the native 'array.filter' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_filter" ],
[ "_", "includes", "Use the native 'array.indexOf' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_includes" ],
[ "_", "contains", "Use the native 'array.indexOf' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_includes" ],
[ "_", "map", "Use the native 'array.map' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_map" ],
[ "_", "collect", "Use the native 'array.map' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_map" ],
[ "_", "reduce", "Use the native 'array.reduce' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_reduce" ],
[ "_", "inject", "Use the native 'array.reduce' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_reduce" ],
[ "_", "foldl", "Use the native 'array.reduce' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_reduce" ],
[ "_", "reduceRight", "Use the native 'array.reduceRight' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_reduceright" ],
[ "_", "foldr", "Use the native 'array.reduceRight' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_reduceright" ],
[ "_", "some", "Use the native 'array.some' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_some" ],
[ "_", "any", "Use the native 'array.some' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_some" ],
[ "_", "isNaN", "Use the native 'isNaN' function instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_isnan" ],
[ "_", "keys", "Use the native 'Object.keys(myObj)' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_keys" ],
[ "_", "size", "Use the native 'array.length' or 'Object.keys(myObj).length' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_size" ],
[ "_", "values", "Use 'Object.keys(obj).map(key => obj[key])' instead of using the Underscore library" ],
[ "_", "pluck", "Use the native 'array.map(x => x.prop)' instead of using the Underscore library: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_pluck" ],
[ "_", "isNull", "Use the native 'someVar == null', or even simpler 'if(!someVar)', instead of using the Underscore library" ],
[ "_", "isUndefined", "Use the native 'someVar == undefined', or even simpler 'if(!someVar)', instead of using the Underscore library" ],
[ "_", "reverse", "Use the native 'array.reverse' instead of using the Underscore library - https://github.com/cht8687/You-Dont-Need-Lodash-Underscore#_reverse" ],
[ "_", "join", "Use the native 'array.join' instead of using the Underscore library - https://github.com/cht8687/You-Dont-Need-Lodash-Underscore#_join" ],
[ "_", "toUpper", "Use the native 'string.toUpperCase()' instead of using the Underscore library - https://github.com/cht8687/You-Dont-Need-Lodash-Underscore#_reverse" ],
[ "_", "toLower", "Use the native 'string.toLowerCase()' instead of using the Underscore library - https://github.com/cht8687/You-Dont-Need-Lodash-Underscore#_tolower" ],
[ "_", "trim", "Use the native 'string.trim()' instead of using the Underscore library - https://github.com/cht8687/You-Dont-Need-Lodash-Underscore#_trim" ],
[ "_", "after", "This can be done natively without using the Underscore library - https://github.com/cht8687/You-Dont-Need-Lodash-Underscore#_after" ]
],
@totszwai
Copy link

totszwai commented Nov 6, 2019

This ban rules are bad. You cannot just lump _.filter and just use array.filter, because they are not even the same thing.
_.filter works on either array or object. similarly for many other functions lodash has to offer.

@gordey4doronin
Copy link
Author

@totszwai Hi, thanks for your comment!

  1. This is a forked gist. I'd recommend you to share your thoughts in the original gist for clarity.
  2. The main point of these rules is to minimize 3rd party libraries usage. We successfully applied some of these rules in our NodeJS code and get rid of lodash in favor of native array functions. And in our codebase we haven't used _.filter for objects ever. Which could not be true for your case though.
  3. I never used Angular 😄 just liked this set of ban rules and forked to keep it in my profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment