is the primary communication tool between you and your peers Code is written once but read many (many) times And you don't want to see things like this i f ( f o o = = = t r u e ) { r e t u r n t r u e ; } e l s e r e t u r n ! 1
make your codebase more coherent Easy to apply to existing code Can be used to evaluate workflow integration Can be used to evaluate how open your team is to change
to manage: The Good: I don't care about the rule but pick one The Bad: Use THIS rule! The Ugly: We don't need a rule, let everyone do what they want You should end up with a mashup of: Your team preferences The patterns commonly used by the community The rules followed by the legacy code
l l ( ' d e e z e r . e m a i l C h e c k ' , { E M A I L : s t r } , f u n c t i o n ( r e s u l t ) { } ) ; AST: { " t y p e " : " P r o g r a m " , " b o d y " : [ { " t y p e " : " E x p r e s s i o n S t a t e m e n t " , " e x p r e s s i o n " : { " t y p e " : " C a l l E x p r e s s i o n " , " c a l l e e " : { " t y p e " : " M e m b e r E x p r e s s i o n " , " c o m p u t e d " : f a l s e , " o b j e c t " : { " t y p e " : " I d e n t i f i e r " , " n a m e " : " a p i " } , " p r o p e r t y " : { " t y p e " : " I d e n t i f i e r " , " n a m e " : " c a l l " } } , Esprima AST Demo Parser API
i c t ' ; m o d u l e . e x p o r t s = f u n c t i o n ( c o n t e x t ) { r e t u r n { ' M e m b e r E x p r e s s i o n ' : f u n c t i o n ( n o d e ) { i f ( n o d e . o b j e c t . n a m e ! = = ' a p i ' | | ( n o d e . p r o p e r t y . n a m e ! = = ' c a l l ' ) ) { r e t u r n ; } i f ( n o d e . p a r e n t . a r g u m e n t s . l e n g t h & & n o d e . p a r e n t . a r g u m e n t s [ 0 ] . t y p e = = = ' L i t e r a l ' c o n t e x t . r e p o r t ( n o d e , ' u s e t h e n e w a p i . c a l l ( ) s i g n a t u r e , s e e h t t p s : / / w i k i . d e e z e r . c o } } } ; } ; ESLint Developer Guide
: Calculates code complexity/maintenability : Avoids usage of magic numbers : Checks if your dependencies are up to date : Warns you about dependencies security issues JSInspect JSCPD ESComplex Plato Buddy.js David Node Security Project