UNPKG

5.15 kBJavaScriptView Raw
1var config = require('./config');
2var ERROR = config.ERROR;
3var WARNING = config.WARNING;
4var IGNORE = config.IGNORE;
5
6/**
7 * ### Ruleset: Best Practices
8 *
9 * These are rules designed to prevent you from making mistakes.
10 * They either prescribe a better way of doing something or
11 * help you avoid footguns.
12 *
13 * @see http://eslint.org/docs/rules/#best-practices
14 */
15module.exports = {
16 rules: {
17 // Enforces getter/setter pairs in objects
18 'accessor-pairs': IGNORE,
19 // treat var statements as if they were block scoped
20 'block-scoped-var': ERROR,
21 // specify the maximum cyclomatic complexity allowed in a program
22 complexity: [ERROR, 11],
23 // require return statements to either always or never specify values
24 'consistent-return': ERROR,
25 // specify curly brace conventions for all control statements
26 curly: [ERROR, 'multi-line'],
27 // require default case in switch statements
28 'default-case': ERROR,
29 // encourages use of dot notation whenever possible
30 'dot-notation': [ERROR, {
31 allowKeywords: true
32 }],
33 // enforces consistent newlines before or after dots
34 'dot-location': IGNORE,
35 // require the use of === and !==
36 eqeqeq: ERROR,
37 // make sure for-in loops have an if statement
38 'guard-for-in': ERROR,
39 // disallow the use of alert, confirm, and prompt
40 'no-alert': WARNING,
41 // disallow use of arguments.caller or arguments.callee
42 'no-caller': ERROR,
43 // disallow division operators explicitly at beginning of regular expression
44 'no-div-regex': IGNORE,
45 // disallow else after a return in an if
46 'no-else-return': ERROR,
47 // disallow use of labels for anything other then loops and switches
48 'no-labels': ERROR,
49 // disallow comparisons to null without a type-checking operator
50 'no-eq-null': IGNORE,
51 // disallow use of eval()
52 'no-eval': ERROR,
53 // disallow adding to native types
54 'no-extend-native': ERROR,
55 // disallow unnecessary function binding
56 'no-extra-bind': ERROR,
57 // disallow fallthrough of case statements
58 'no-fallthrough': ERROR,
59 // disallow the use of leading or trailing decimal points in numeric literals
60 'no-floating-decimal': ERROR,
61 // disallow the type conversions with shorter notations
62 'no-implicit-coercion': IGNORE,
63 // disallow use of eval()-like methods
64 'no-implied-eval': ERROR,
65 // disallow this keywords outside of classes or class-like objects
66 'no-invalid-this': 0,
67 // disallow usage of __iterator__ property
68 'no-iterator': ERROR,
69 // disallow use of labeled statements
70 'no-labels': ERROR,
71 // disallow unnecessary nested blocks
72 'no-lone-blocks': ERROR,
73 // disallow creation of functions within loops
74 'no-loop-func': ERROR,
75 // disallow use of multiple spaces
76 'no-multi-spaces': ERROR,
77 // disallow use of multiline strings
78 'no-multi-str': ERROR,
79 // disallow reassignments of native objects
80 'no-native-reassign': ERROR,
81 // disallow use of new operator when not part of the assignment or comparison
82 'no-new': ERROR,
83 // disallow use of new operator for Function object
84 'no-new-func': ERROR,
85 // disallows creating new instances of String,Number, and Boolean
86 'no-new-wrappers': ERROR,
87 // disallow use of (old style) octal literals
88 'no-octal': ERROR,
89 // disallow use of octal escape sequences in string literals, such as
90 // var foo = 'Copyright \251';
91 'no-octal-escape': ERROR,
92 // disallow reassignment of function parameters
93 /**
94 * @differ - Breaks `module.exports = function(opts, fn){}` convention.
95 */
96 'no-param-reassign': IGNORE,
97 // disallow use of process.env
98 'no-process-env': IGNORE,
99 // disallow usage of __proto__ property
100 'no-proto': ERROR,
101 // disallow declaring the same variable more then once
102 'no-redeclare': ERROR,
103 // disallow use of assignment in return statement
104 'no-return-assign': ERROR,
105 // disallow use of `javascript:` urls.
106 'no-script-url': ERROR,
107 // disallow comparisons where both sides are exactly the same
108 'no-self-compare': ERROR,
109 // disallow use of comma operator
110 'no-sequences': ERROR,
111 // restrict what can be thrown as an exception
112 'no-throw-literal': ERROR,
113 // disallow usage of expressions in statement position
114 'no-unused-expressions': ERROR,
115 // disallow unnecessary .call() and .apply()
116 'no-useless-call': IGNORE,
117 // disallow use of void operator
118 'no-void': IGNORE,
119 // disallow usage of configurable warning terms in comments: e.g. todo
120 'no-warning-comments': [IGNORE, {
121 terms: ['todo', 'note'],
122 location: 'start'
123 }],
124 // disallow use of the with statement
125 'no-with': ERROR,
126 // require use of the second argument for parseInt()
127 radix: ERROR,
128 // requires to declare all vars on top of their containing scope
129 /**
130 * @differ - YOU BE YOU, DEVELOPER.
131 */
132 'vars-on-top': IGNORE,
133 // require immediate function invocation to be wrapped in parentheses
134 'wrap-iife': [ERROR, 'any'],
135 // require or disallow Yoda conditions
136 yoda: ERROR
137 }
138};