├── index.js
├── package.json
└── rules
├── best-practices.js
├── errors.js
├── es6.js
├── imports.js
├── node.js
├── react-a11y.js
├── react.js
├── strict.js
├── style.js
└── variables.js
/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: [
3 | './rules/best-practices',
4 | './rules/errors',
5 | './rules/es6',
6 | './rules/imports',
7 | './rules/node',
8 | './rules/react-a11y',
9 | './rules/react',
10 | './rules/strict',
11 | './rules/style',
12 | './rules/variables'
13 | ].map(require.resolve),
14 | parserOptions: {
15 | ecmaFeatures: {
16 | experimentalObjectRestSpread: true
17 | },
18 | ecmaVersion: 7,
19 | sourceType: 'module'
20 | },
21 | plugins: [
22 | 'class-property'
23 | ],
24 | parser: 'babel-eslint',
25 | rules: {
26 | 'strict': 0,
27 | 'react/jsx-no-bind': 0,
28 | 'indent': 0,
29 | 'react/prefer-es6-class': 0,
30 | 'react/jsx-uses-react': 2,
31 | 'react/jsx-uses-vars': 2,
32 | 'react/react-in-jsx-scope': 2,
33 | 'react/jsx-indent': 0,
34 | 'react/no-string-refs': 0,
35 | 'react/jsx-filename-extension': 0,
36 | 'react/jsx-indent-props': 0,
37 | 'react/prop-types': 0,
38 | 'react/no-did-mount-set-state': 0,
39 | 'react/prefer-stateless-function': 0,
40 | 'no-trailing-spaces': 0,
41 | 'import/prefer-default-export': 0,
42 | 'id-length': 0,
43 | 'comma-dangle': 0,
44 | 'new-cap': 0,
45 | 'func-names': 0,
46 | 'consistent-return': 0,
47 | 'no-use-before-define': 0,
48 | 'no-debugger': 0,
49 | 'spaced-comment': 0,
50 | 'no-console': 0,
51 | 'no-alert': 0,
52 | 'linebreak-style': 0
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-config-rallycoding",
3 | "version": "3.2.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "babel-eslint": "^6.1.2",
13 | "eslint": "^3.2.2",
14 | "eslint-plugin-import": "^1.13.0",
15 | "eslint-plugin-jsx-a11y": "^2.1.0",
16 | "eslint-plugin-react": "^6.0.0",
17 | "eslint-plugin-class-property": "^1.0.1"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/rules/best-practices.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | rules: {
3 | // enforces getter/setter pairs in objects
4 | 'accessor-pairs': 'off',
5 |
6 | // enforces return statements in callbacks of array's methods
7 | // http://eslint.org/docs/rules/array-callback-return
8 | 'array-callback-return': 'error',
9 |
10 | // treat var statements as if they were block scoped
11 | 'block-scoped-var': 'error',
12 |
13 | // specify the maximum cyclomatic complexity allowed in a program
14 | complexity: ['off', 11],
15 |
16 | // require return statements to either always or never specify values
17 | 'consistent-return': 'error',
18 |
19 | // specify curly brace conventions for all control statements
20 | curly: ['error', 'multi-line'],
21 |
22 | // require default case in switch statements
23 | 'default-case': ['error', { commentPattern: '^no default$' }],
24 |
25 | // encourages use of dot notation whenever possible
26 | 'dot-notation': ['error', { allowKeywords: true }],
27 |
28 | // enforces consistent newlines before or after dots
29 | // http://eslint.org/docs/rules/dot-location
30 | 'dot-location': ['error', 'property'],
31 |
32 | // require the use of === and !==
33 | // http://eslint.org/docs/rules/eqeqeq
34 | eqeqeq: ['error', 'allow-null'],
35 |
36 | // make sure for-in loops have an if statement
37 | 'guard-for-in': 'error',
38 |
39 | // disallow the use of alert, confirm, and prompt
40 | 'no-alert': 'warn',
41 |
42 | // disallow use of arguments.caller or arguments.callee
43 | 'no-caller': 'error',
44 |
45 | // disallow lexical declarations in case/default clauses
46 | // http://eslint.org/docs/rules/no-case-declarations.html
47 | 'no-case-declarations': 'error',
48 |
49 | // disallow division operators explicitly at beginning of regular expression
50 | // http://eslint.org/docs/rules/no-div-regex
51 | 'no-div-regex': 'off',
52 |
53 | // disallow else after a return in an if
54 | 'no-else-return': 'error',
55 |
56 | // disallow empty functions, except for standalone funcs/arrows
57 | // http://eslint.org/docs/rules/no-empty-function
58 | 'no-empty-function': ['error', {
59 | allow: [
60 | 'arrowFunctions',
61 | 'functions',
62 | 'methods',
63 | ]
64 | }],
65 |
66 | // disallow empty destructuring patterns
67 | // http://eslint.org/docs/rules/no-empty-pattern
68 | 'no-empty-pattern': 'error',
69 |
70 | // disallow comparisons to null without a type-checking operator
71 | 'no-eq-null': 'off',
72 |
73 | // disallow use of eval()
74 | 'no-eval': 'error',
75 |
76 | // disallow adding to native types
77 | 'no-extend-native': 'error',
78 |
79 | // disallow unnecessary function binding
80 | 'no-extra-bind': 'error',
81 |
82 | // disallow Unnecessary Labels
83 | // http://eslint.org/docs/rules/no-extra-label
84 | 'no-extra-label': 'error',
85 |
86 | // disallow fallthrough of case statements
87 | 'no-fallthrough': 'error',
88 |
89 | // disallow the use of leading or trailing decimal points in numeric literals
90 | 'no-floating-decimal': 'error',
91 |
92 | // disallow reassignments of native objects or read-only globals
93 | // http://eslint.org/docs/rules/no-global-assign
94 | 'no-global-assign': ['error', { exceptions: [] }],
95 |
96 | // disallow implicit type conversions
97 | // http://eslint.org/docs/rules/no-implicit-coercion
98 | 'no-implicit-coercion': ['off', {
99 | boolean: false,
100 | number: true,
101 | string: true,
102 | allow: [],
103 | }],
104 |
105 | // disallow var and named functions in global scope
106 | // http://eslint.org/docs/rules/no-implicit-globals
107 | 'no-implicit-globals': 'off',
108 |
109 | // disallow use of eval()-like methods
110 | 'no-implied-eval': 'error',
111 |
112 | // disallow this keywords outside of classes or class-like objects
113 | 'no-invalid-this': 'off',
114 |
115 | // disallow usage of __iterator__ property
116 | 'no-iterator': 'error',
117 |
118 | // disallow use of labels for anything other then loops and switches
119 | 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
120 |
121 | // disallow unnecessary nested blocks
122 | 'no-lone-blocks': 'error',
123 |
124 | // disallow creation of functions within loops
125 | 'no-loop-func': 'error',
126 |
127 | // disallow magic numbers
128 | // http://eslint.org/docs/rules/no-magic-numbers
129 | 'no-magic-numbers': ['off', {
130 | ignore: [],
131 | ignoreArrayIndexes: true,
132 | enforceConst: true,
133 | detectObjects: false,
134 | }],
135 |
136 | // disallow use of multiple spaces
137 | 'no-multi-spaces': 'error',
138 |
139 | // disallow use of multiline strings
140 | 'no-multi-str': 'error',
141 |
142 | // disallow reassignments of native objects
143 | // TODO: deprecated in favor of no-global-assign
144 | 'no-native-reassign': 'off',
145 |
146 | // disallow use of new operator when not part of the assignment or comparison
147 | 'no-new': 'error',
148 |
149 | // disallow use of new operator for Function object
150 | 'no-new-func': 'error',
151 |
152 | // disallows creating new instances of String, Number, and Boolean
153 | 'no-new-wrappers': 'error',
154 |
155 | // disallow use of (old style) octal literals
156 | 'no-octal': 'error',
157 |
158 | // disallow use of octal escape sequences in string literals, such as
159 | // var foo = 'Copyright \251';
160 | 'no-octal-escape': 'error',
161 |
162 | // disallow reassignment of function parameters
163 | // disallow parameter object manipulation
164 | // rule: http://eslint.org/docs/rules/no-param-reassign.html
165 | 'no-param-reassign': ['error', { props: true }],
166 |
167 | // disallow usage of __proto__ property
168 | 'no-proto': 'error',
169 |
170 | // disallow declaring the same variable more then once
171 | 'no-redeclare': 'error',
172 |
173 | // disallow use of assignment in return statement
174 | 'no-return-assign': 'error',
175 |
176 | // disallow use of `javascript:` urls.
177 | 'no-script-url': 'error',
178 |
179 | // disallow self assignment
180 | // http://eslint.org/docs/rules/no-self-assign
181 | 'no-self-assign': 'error',
182 |
183 | // disallow comparisons where both sides are exactly the same
184 | 'no-self-compare': 'error',
185 |
186 | // disallow use of comma operator
187 | 'no-sequences': 'error',
188 |
189 | // restrict what can be thrown as an exception
190 | 'no-throw-literal': 'error',
191 |
192 | // disallow unmodified conditions of loops
193 | // http://eslint.org/docs/rules/no-unmodified-loop-condition
194 | 'no-unmodified-loop-condition': 'off',
195 |
196 | // disallow usage of expressions in statement position
197 | 'no-unused-expressions': ['error', {
198 | allowShortCircuit: false,
199 | allowTernary: false,
200 | }],
201 |
202 | // disallow unused labels
203 | // http://eslint.org/docs/rules/no-unused-labels
204 | 'no-unused-labels': 'error',
205 |
206 | // disallow unnecessary .call() and .apply()
207 | 'no-useless-call': 'off',
208 |
209 | // disallow useless string concatenation
210 | // http://eslint.org/docs/rules/no-useless-concat
211 | 'no-useless-concat': 'error',
212 |
213 | // disallow unnecessary string escaping
214 | // http://eslint.org/docs/rules/no-useless-escape
215 | 'no-useless-escape': 'error',
216 |
217 | // disallow use of void operator
218 | // http://eslint.org/docs/rules/no-void
219 | 'no-void': 'error',
220 |
221 | // disallow usage of configurable warning terms in comments: e.g. todo
222 | 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
223 |
224 | // disallow use of the with statement
225 | 'no-with': 'error',
226 |
227 | // require use of the second argument for parseInt()
228 | radix: 'error',
229 |
230 | // requires to declare all vars on top of their containing scope
231 | 'vars-on-top': 'error',
232 |
233 | // require immediate function invocation to be wrapped in parentheses
234 | // http://eslint.org/docs/rules/wrap-iife.html
235 | 'wrap-iife': ['error', 'outside'],
236 |
237 | // require or disallow Yoda conditions
238 | yoda: 'error'
239 | }
240 | };
241 |
--------------------------------------------------------------------------------
/rules/errors.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | rules: {
3 | // require trailing commas in multiline object literals
4 | 'comma-dangle': ['error', 'always-multiline'],
5 |
6 | // disallow assignment in conditional expressions
7 | 'no-cond-assign': ['error', 'always'],
8 |
9 | // disallow use of console
10 | 'no-console': 'warn',
11 |
12 | // disallow use of constant expressions in conditions
13 | 'no-constant-condition': 'warn',
14 |
15 | // disallow control characters in regular expressions
16 | 'no-control-regex': 'error',
17 |
18 | // disallow use of debugger
19 | 'no-debugger': 'error',
20 |
21 | // disallow duplicate arguments in functions
22 | 'no-dupe-args': 'error',
23 |
24 | // disallow duplicate keys when creating object literals
25 | 'no-dupe-keys': 'error',
26 |
27 | // disallow a duplicate case label.
28 | 'no-duplicate-case': 'error',
29 |
30 | // disallow empty statements
31 | 'no-empty': 'error',
32 |
33 | // disallow the use of empty character classes in regular expressions
34 | 'no-empty-character-class': 'error',
35 |
36 | // disallow assigning to the exception in a catch block
37 | 'no-ex-assign': 'error',
38 |
39 | // disallow double-negation boolean casts in a boolean context
40 | // http://eslint.org/docs/rules/no-extra-boolean-cast
41 | 'no-extra-boolean-cast': 'error',
42 |
43 | // disallow unnecessary parentheses
44 | // http://eslint.org/docs/rules/no-extra-parens
45 | 'no-extra-parens': ['off', 'all', {
46 | conditionalAssign: true,
47 | nestedBinaryExpressions: false,
48 | returnAssign: false,
49 | }],
50 |
51 | // disallow unnecessary semicolons
52 | 'no-extra-semi': 'error',
53 |
54 | // disallow overwriting functions written as function declarations
55 | 'no-func-assign': 'error',
56 |
57 | // disallow function or variable declarations in nested blocks
58 | 'no-inner-declarations': 'error',
59 |
60 | // disallow invalid regular expression strings in the RegExp constructor
61 | 'no-invalid-regexp': 'error',
62 |
63 | // disallow irregular whitespace outside of strings and comments
64 | 'no-irregular-whitespace': 'error',
65 |
66 | // disallow negation of the left operand of an in expression
67 | // TODO: deprecated in favor of no-unsafe-negation
68 | 'no-negated-in-lhs': 'off',
69 |
70 | // disallow the use of object properties of the global object (Math and JSON) as functions
71 | 'no-obj-calls': 'error',
72 |
73 | // disallow use of Object.prototypes builtins directly
74 | // http://eslint.org/docs/rules/no-prototype-builtins
75 | 'no-prototype-builtins': 'error',
76 |
77 | // disallow multiple spaces in a regular expression literal
78 | 'no-regex-spaces': 'error',
79 |
80 | // disallow sparse arrays
81 | 'no-sparse-arrays': 'error',
82 |
83 | // Disallow template literal placeholder syntax in regular strings
84 | // http://eslint.org/docs/rules/no-template-curly-in-string
85 | // TODO: enable, semver-major
86 | 'no-template-curly-in-string': 'off',
87 |
88 | // Avoid code that looks like two expressions but is actually one
89 | // http://eslint.org/docs/rules/no-unexpected-multiline
90 | 'no-unexpected-multiline': 'error',
91 |
92 | // disallow unreachable statements after a return, throw, continue, or break statement
93 | 'no-unreachable': 'error',
94 |
95 | // disallow return/throw/break/continue inside finally blocks
96 | // http://eslint.org/docs/rules/no-unsafe-finally
97 | 'no-unsafe-finally': 'error',
98 |
99 | // disallow negating the left operand of relational operators
100 | // http://eslint.org/docs/rules/no-unsafe-negation
101 | 'no-unsafe-negation': 'error',
102 |
103 | // disallow comparisons with the value NaN
104 | 'use-isnan': 'error',
105 |
106 | // ensure JSDoc comments are valid
107 | // http://eslint.org/docs/rules/valid-jsdoc
108 | 'valid-jsdoc': 'off',
109 |
110 | // ensure that the results of typeof are compared against a valid string
111 | 'valid-typeof': 'error'
112 | }
113 | };
114 |
--------------------------------------------------------------------------------
/rules/es6.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | es6: true
4 | },
5 | parserOptions: {
6 | ecmaVersion: 6,
7 | sourceType: 'module',
8 | ecmaFeatures: {
9 | generators: false,
10 | objectLiteralDuplicateProperties: false
11 | }
12 | },
13 |
14 | rules: {
15 | // enforces no braces where they can be omitted
16 | // http://eslint.org/docs/rules/arrow-body-style
17 | 'arrow-body-style': ['error', 'as-needed'],
18 |
19 | // require parens in arrow function arguments
20 | 'arrow-parens': 'off',
21 |
22 | // require space before/after arrow function's arrow
23 | // http://eslint.org/docs/rules/arrow-spacing
24 | 'arrow-spacing': ['error', { before: true, after: true }],
25 |
26 | // verify super() callings in constructors
27 | 'constructor-super': 'error',
28 |
29 | // enforce the spacing around the * in generator functions
30 | // http://eslint.org/docs/rules/generator-star-spacing
31 | 'generator-star-spacing': ['error', { before: false, after: true }],
32 |
33 | // disallow modifying variables of class declarations
34 | // http://eslint.org/docs/rules/no-class-assign
35 | 'no-class-assign': 'error',
36 |
37 | // disallow arrow functions where they could be confused with comparisons
38 | // http://eslint.org/docs/rules/no-confusing-arrow
39 | 'no-confusing-arrow': ['error', {
40 | allowParens: true,
41 | }],
42 |
43 | // disallow modifying variables that are declared using const
44 | 'no-const-assign': 'error',
45 |
46 | // disallow duplicate class members
47 | // http://eslint.org/docs/rules/no-dupe-class-members
48 | 'no-dupe-class-members': 'error',
49 |
50 | // disallow importing from the same path more than once
51 | // http://eslint.org/docs/rules/no-duplicate-imports
52 | 'no-duplicate-imports': 'error',
53 |
54 | // disallow symbol constructor
55 | // http://eslint.org/docs/rules/no-new-symbol
56 | 'no-new-symbol': 'error',
57 |
58 | // disallow specific imports
59 | // http://eslint.org/docs/rules/no-restricted-imports
60 | 'no-restricted-imports': 'off',
61 |
62 | // disallow to use this/super before super() calling in constructors.
63 | // http://eslint.org/docs/rules/no-this-before-super
64 | 'no-this-before-super': 'error',
65 |
66 | // disallow useless computed property keys
67 | // http://eslint.org/docs/rules/no-useless-computed-key
68 | 'no-useless-computed-key': 'error',
69 |
70 | // disallow unnecessary constructor
71 | // http://eslint.org/docs/rules/no-useless-constructor
72 | 'no-useless-constructor': 'error',
73 |
74 | // disallow renaming import, export, and destructured assignments to the same name
75 | // http://eslint.org/docs/rules/no-useless-rename
76 | 'no-useless-rename': ['error', {
77 | ignoreDestructuring: false,
78 | ignoreImport: false,
79 | ignoreExport: false,
80 | }],
81 |
82 | // require let or const instead of var
83 | 'no-var': 'error',
84 |
85 | // require method and property shorthand syntax for object literals
86 | // http://eslint.org/docs/rules/object-shorthand
87 | 'object-shorthand': ['error', 'always', {
88 | ignoreConstructors: false,
89 | avoidQuotes: true,
90 | }],
91 |
92 | // suggest using arrow functions as callbacks
93 | 'prefer-arrow-callback': ['error', {
94 | allowNamedFunctions: false,
95 | allowUnboundThis: true,
96 | }],
97 |
98 | // suggest using of const declaration for variables that are never modified after declared
99 | 'prefer-const': ['error', {
100 | destructuring: 'any',
101 | ignoreReadBeforeAssign: true,
102 | }],
103 |
104 | // suggest using Reflect methods where applicable
105 | // http://eslint.org/docs/rules/prefer-reflect
106 | // TODO: enable
107 | 'prefer-reflect': 'off',
108 |
109 | // use rest parameters instead of arguments
110 | // http://eslint.org/docs/rules/prefer-rest-params
111 | 'prefer-rest-params': 'error',
112 |
113 | // suggest using the spread operator instead of .apply()
114 | // http://eslint.org/docs/rules/prefer-spread
115 | 'prefer-spread': 'error',
116 |
117 | // suggest using template literals instead of string concatenation
118 | // http://eslint.org/docs/rules/prefer-template
119 | 'prefer-template': 'error',
120 |
121 | // disallow generator functions that do not have yield
122 | // http://eslint.org/docs/rules/require-yield
123 | 'require-yield': 'error',
124 |
125 | // enforce spacing between object rest-spread
126 | // http://eslint.org/docs/rules/rest-spread-spacing
127 | 'rest-spread-spacing': ['error', 'never'],
128 |
129 | // import sorting
130 | // http://eslint.org/docs/rules/sort-imports
131 | 'sort-imports': ['off', {
132 | ignoreCase: false,
133 | ignoreMemberSort: false,
134 | memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
135 | }],
136 |
137 | // enforce usage of spacing in template strings
138 | // http://eslint.org/docs/rules/template-curly-spacing
139 | 'template-curly-spacing': 'error',
140 |
141 | // enforce spacing around the * in yield* expressions
142 | // http://eslint.org/docs/rules/yield-star-spacing
143 | 'yield-star-spacing': ['error', 'after']
144 | }
145 | };
146 |
--------------------------------------------------------------------------------
/rules/imports.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | es6: true
4 | },
5 | parserOptions: {
6 | ecmaVersion: 6,
7 | sourceType: 'module'
8 | },
9 | plugins: [
10 | 'import'
11 | ],
12 |
13 | settings: {
14 | 'import/resolver': {
15 | node: {
16 | extensions: ['.js', '.json']
17 | }
18 | },
19 | 'import/extensions': [
20 | '.js',
21 | '.jsx',
22 | ],
23 | 'import/core-modules': [
24 | ],
25 | 'import/ignore': [
26 | 'node_modules',
27 | '\\.(coffee|scss|css|less|hbs|svg|json)$',
28 | ],
29 | },
30 |
31 | rules: {
32 | // Static analysis:
33 |
34 | // ensure imports point to files/modules that can be resolved
35 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
36 | 'import/no-unresolved': ['error', { commonjs: true }],
37 |
38 | // ensure named imports coupled with named exports
39 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
40 | 'import/named': 'off',
41 |
42 | // ensure default import coupled with default export
43 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
44 | 'import/default': 'off',
45 |
46 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
47 | 'import/namespace': 'off',
48 |
49 | // Helpful warnings:
50 |
51 | // disallow invalid exports, e.g. multiple defaults
52 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
53 | 'import/export': 'error',
54 |
55 | // do not allow a default import name to match a named export
56 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
57 | 'import/no-named-as-default': 'error',
58 |
59 | // warn on accessing default export property names that are also named exports
60 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
61 | 'import/no-named-as-default-member': 'error',
62 |
63 | // disallow use of jsdoc-marked-deprecated imports
64 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
65 | 'import/no-deprecated': 'off',
66 |
67 | // Forbid the use of extraneous packages
68 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
69 | 'import/no-extraneous-dependencies': ['error', {
70 | devDependencies: false,
71 | optionalDependencies: false,
72 | }],
73 |
74 | // Forbid mutable exports
75 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
76 | 'import/no-mutable-exports': 'error',
77 |
78 | // Module systems:
79 |
80 | // disallow require()
81 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
82 | 'import/no-commonjs': 'off',
83 |
84 | // disallow AMD require/define
85 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
86 | 'import/no-amd': 'error',
87 |
88 | // No Node.js builtin modules
89 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
90 | // TODO: enable?
91 | 'import/no-nodejs-modules': 'off',
92 |
93 | // Style guide:
94 |
95 | // disallow non-import statements appearing before import statements
96 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
97 | 'import/imports-first': ['error', 'absolute-first'],
98 |
99 | // disallow duplicate imports
100 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
101 | 'import/no-duplicates': 'error',
102 |
103 | // disallow namespace imports
104 | // TODO: enable?
105 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
106 | 'import/no-namespace': 'off',
107 |
108 | // Ensure consistent use of file extension within the import path
109 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
110 | // TODO: enable when https://github.com/benmosher/eslint-plugin-import/issues/390 is resolved
111 | 'import/extensions': ['off', 'never'],
112 |
113 | // Enforce a convention in module import order
114 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
115 | // TODO: enable?
116 | 'import/order': ['off', {
117 | groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
118 | 'newlines-between': 'never',
119 | }],
120 |
121 | // Require a newline after the last import/require in a group
122 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
123 | 'import/newline-after-import': 'error',
124 |
125 | // Require modules with a single export to use a default export
126 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
127 | 'import/prefer-default-export': 'error',
128 |
129 | // Restrict which files can be imported in a given folder
130 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
131 | 'import/no-restricted-paths': 'off',
132 | },
133 | };
134 |
--------------------------------------------------------------------------------
/rules/node.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | node: true
4 | },
5 |
6 | rules: {
7 | // enforce return after a callback
8 | 'callback-return': 'off',
9 |
10 | // require all requires be top-level
11 | // http://eslint.org/docs/rules/global-require
12 | 'global-require': 'error',
13 |
14 | // enforces error handling in callbacks (node environment)
15 | 'handle-callback-err': 'off',
16 |
17 | // disallow mixing regular variable and require declarations
18 | 'no-mixed-requires': ['off', false],
19 |
20 | // disallow use of new operator with the require function
21 | 'no-new-require': 'error',
22 |
23 | // disallow string concatenation with __dirname and __filename
24 | // http://eslint.org/docs/rules/no-path-concat
25 | 'no-path-concat': 'error',
26 |
27 | // disallow use of process.env
28 | 'no-process-env': 'off',
29 |
30 | // disallow process.exit()
31 | 'no-process-exit': 'off',
32 |
33 | // restrict usage of specified node modules
34 | 'no-restricted-modules': 'off',
35 |
36 | // disallow use of synchronous methods (off by default)
37 | 'no-sync': 'off',
38 | }
39 | };
40 |
--------------------------------------------------------------------------------
/rules/react-a11y.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | 'jsx-a11y',
4 | 'react'
5 | ],
6 | ecmaFeatures: {
7 | jsx: true
8 | },
9 | rules: {
10 | // Enforce that anchors have content
11 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
12 | // TODO: enable, semver-major
13 | 'jsx-a11y/anchor-has-content': [0, ['']],
14 |
15 | // Require ARIA roles to be valid and non-abstract
16 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
17 | 'jsx-a11y/aria-role': 2,
18 |
19 | // Enforce all aria-* props are valid.
20 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
21 | 'jsx-a11y/aria-props': 2,
22 |
23 | // Enforce ARIA state and property values are valid.
24 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
25 | 'jsx-a11y/aria-proptypes': 2,
26 |
27 | // Enforce that elements that do not support ARIA roles, states, and
28 | // properties do not have those attributes.
29 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
30 | 'jsx-a11y/aria-unsupported-elements': 2,
31 |
32 | // disallow href "#"
33 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md
34 | 'jsx-a11y/href-no-hash': [2, ['a']],
35 |
36 | // Require
to have a non-empty `alt` prop, or role="presentation"
37 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md
38 | 'jsx-a11y/img-has-alt': 2,
39 |
40 | // Prevent img alt text from containing redundant words like "image", "picture", or "photo"
41 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
42 | 'jsx-a11y/img-redundant-alt': 2,
43 |
44 | // require that JSX labels use "htmlFor"
45 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
46 | 'jsx-a11y/label-has-for': [2, ['label']],
47 |
48 | // require that mouseover/out come with focus/blur, for keyboard-only users
49 | // TODO: evaluate
50 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
51 | 'jsx-a11y/mouse-events-have-key-events': 0,
52 |
53 | // Prevent use of `accessKey`
54 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
55 | 'jsx-a11y/no-access-key': 2,
56 |
57 | // require onBlur instead of onChange
58 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
59 | 'jsx-a11y/no-onchange': 0,
60 |
61 | // Enforce that elements with onClick handlers must be focusable.
62 | // TODO: evaluate
63 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-focus.md
64 | 'jsx-a11y/onclick-has-focus': 0,
65 |
66 | // require things with onClick to have an aria role
67 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-role.md
68 | 'jsx-a11y/onclick-has-role': 0,
69 |
70 | // Enforce that elements with ARIA roles must have all required attributes
71 | // for that role.
72 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
73 | 'jsx-a11y/role-has-required-aria-props': 2,
74 |
75 | // Enforce that elements with explicit or implicit roles defined contain
76 | // only aria-* properties supported by that role.
77 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
78 | 'jsx-a11y/role-supports-aria-props': 2,
79 |
80 | // Enforce tabIndex value is not greater than zero.
81 | // TODO: evaluate
82 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
83 | 'jsx-a11y/tabindex-no-positive': 0,
84 |
85 | // ensure tags have content and are not aria-hidden
86 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
87 | 'jsx-a11y/heading-has-content': [2, ['']],
88 |
89 | // require HTML elements to have a "lang" prop
90 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
91 | 'jsx-a11y/html-has-lang': 2,
92 |
93 | // require HTML element's lang prop to be valid
94 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
95 | 'jsx-a11y/lang': 2,
96 |
97 | // prevent marquee elements
98 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-marquee.md
99 | 'jsx-a11y/no-marquee': 2,
100 |
101 | // only allow to have the "scope" attr
102 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
103 | 'jsx-a11y/scope': 2,
104 | },
105 | };
106 |
--------------------------------------------------------------------------------
/rules/react.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | 'react'
4 | ],
5 | parserOptions: {
6 | ecmaFeatures: {
7 | jsx: true,
8 | },
9 | },
10 | ecmaFeatures: {
11 | jsx: true
12 | },
13 |
14 | // View link below for react rules documentation
15 | // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
16 | rules: {
17 | // Specify whether double or single quotes should be used in JSX attributes
18 | // http://eslint.org/docs/rules/jsx-quotes
19 | 'jsx-quotes': [2, 'prefer-double'],
20 |
21 | // Prevent missing displayName in a React component definition
22 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
23 | 'react/display-name': [0, { ignoreTranspilerName: false }],
24 |
25 | // Forbid certain propTypes (any, array, object)
26 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
27 | 'react/forbid-prop-types': [0, { forbid: ['any', 'array', 'object'] }],
28 |
29 | // Enforce boolean attributes notation in JSX
30 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
31 | 'react/jsx-boolean-value': [2, 'never'],
32 |
33 | // Validate closing bracket location in JSX
34 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
35 | 'react/jsx-closing-bracket-location': [2, 'line-aligned'],
36 |
37 | // Enforce or disallow spaces inside of curly braces in JSX attributes
38 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
39 | 'react/jsx-curly-spacing': [2, 'never', { allowMultiline: true }],
40 |
41 | // Enforce event handler naming conventions in JSX
42 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
43 | 'react/jsx-handler-names': [0, {
44 | eventHandlerPrefix: 'handle',
45 | eventHandlerPropPrefix: 'on',
46 | }],
47 |
48 | // Validate props indentation in JSX
49 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
50 | 'react/jsx-indent-props': [2, 2],
51 |
52 | // Validate JSX has key prop when in array or iterator
53 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
54 | 'react/jsx-key': 0,
55 |
56 | // Limit maximum of props on a single line in JSX
57 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
58 | 'react/jsx-max-props-per-line': [0, { maximum: 1 }],
59 |
60 | // Prevent usage of .bind() in JSX props
61 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
62 | 'react/jsx-no-bind': [2, {
63 | ignoreRefs: true,
64 | allowArrowFunctions: true,
65 | allowBind: false,
66 | }],
67 |
68 | // Prevent duplicate props in JSX
69 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
70 | 'react/jsx-no-duplicate-props': [0, { ignoreCase: false }],
71 |
72 | // Prevent usage of unwrapped JSX strings
73 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
74 | 'react/jsx-no-literals': 0,
75 |
76 | // Disallow undeclared variables in JSX
77 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
78 | 'react/jsx-no-undef': 2,
79 |
80 | // Enforce PascalCase for user-defined JSX components
81 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
82 | 'react/jsx-pascal-case': [2, {
83 | allowAllCaps: true,
84 | ignore: [],
85 | }],
86 |
87 | // Enforce propTypes declarations alphabetical sorting
88 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
89 | 'react/sort-prop-types': [0, {
90 | ignoreCase: false,
91 | callbacksLast: false,
92 | requiredFirst: false,
93 | }],
94 |
95 | // Deprecated in favor of react/jsx-sort-props
96 | 'react/jsx-sort-prop-types': 0,
97 |
98 | // Enforce props alphabetical sorting
99 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
100 | 'react/jsx-sort-props': [0, {
101 | ignoreCase: false,
102 | callbacksLast: false,
103 | shorthandFirst: false,
104 | shorthandLast: false,
105 | }],
106 |
107 | // Prevent React to be incorrectly marked as unused
108 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
109 | 'react/jsx-uses-react': [2],
110 |
111 | // Prevent variables used in JSX to be incorrectly marked as unused
112 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
113 | 'react/jsx-uses-vars': 2,
114 |
115 | // Prevent usage of dangerous JSX properties
116 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md
117 | 'react/no-danger': 0,
118 |
119 | // Prevent usage of deprecated methods
120 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
121 | 'react/no-deprecated': [2],
122 |
123 | // Prevent usage of setState in componentDidMount
124 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
125 | 'react/no-did-mount-set-state': [2],
126 |
127 | // Prevent usage of setState in componentDidUpdate
128 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
129 | 'react/no-did-update-set-state': [2],
130 |
131 | // Prevent direct mutation of this.state
132 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
133 | 'react/no-direct-mutation-state': 0,
134 |
135 | // Prevent usage of isMounted
136 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
137 | 'react/no-is-mounted': 2,
138 |
139 | // Prevent multiple component definition per file
140 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
141 | 'react/no-multi-comp': [2, { ignoreStateless: true }],
142 |
143 | // Prevent usage of setState
144 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
145 | 'react/no-set-state': 0,
146 |
147 | // Prevent using string references
148 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
149 | 'react/no-string-refs': 2,
150 |
151 | // Prevent usage of unknown DOM property
152 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
153 | 'react/no-unknown-property': 2,
154 |
155 | // Require ES6 class declarations over React.createClass
156 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
157 | 'react/prefer-es6-class': [2, 'always'],
158 |
159 | // Require stateless functions when not using lifecycle methods, setState or ref
160 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
161 | 'react/prefer-stateless-function': 2,
162 |
163 | // Prevent missing props validation in a React component definition
164 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
165 | 'react/prop-types': [2, { ignore: [], customValidators: [] }],
166 |
167 | // Prevent missing React when using JSX
168 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
169 | 'react/react-in-jsx-scope': 2,
170 |
171 | // Restrict file extensions that may be required
172 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md
173 | 'react/require-extension': [2, { extensions: ['.jsx', '.js'] }],
174 |
175 | // Require render() methods to return something
176 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
177 | 'react/require-render-return': 2,
178 |
179 | // Prevent extra closing tags for components without children
180 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
181 | 'react/self-closing-comp': 2,
182 |
183 | // Enforce spaces before the closing bracket of self-closing JSX elements
184 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
185 | 'react/jsx-space-before-closing': [2, 'always'],
186 |
187 | // Enforce component methods order
188 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
189 | 'react/sort-comp': [2, {
190 | order: [
191 | 'static-methods',
192 | 'lifecycle',
193 | '/^on.+$/',
194 | '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
195 | 'everything-else',
196 | '/^render.+$/',
197 | 'render'
198 | ],
199 | }],
200 |
201 | // Prevent missing parentheses around multilines JSX
202 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
203 | 'react/jsx-wrap-multilines': [2, {
204 | declaration: true,
205 | assignment: true,
206 | return: true
207 | }],
208 | 'react/wrap-multilines': 0, // deprecated version
209 |
210 | // Require that the first prop in a JSX element be on a new line when the element is multiline
211 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
212 | 'react/jsx-first-prop-new-line': [2, 'multiline'],
213 |
214 | // Enforce spacing around jsx equals signs
215 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
216 | 'react/jsx-equals-spacing': [2, 'never'],
217 |
218 | // Enforce JSX indentation
219 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
220 | 'react/jsx-indent': [2, 2],
221 |
222 | // Disallow target="_blank" on links
223 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
224 | 'react/jsx-no-target-blank': 2,
225 |
226 | // only .jsx files may have JSX
227 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
228 | 'react/jsx-filename-extension': [2, { extensions: ['.jsx'] }],
229 |
230 | // prevent accidental JS comments from being injected into JSX as text
231 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
232 | 'react/jsx-no-comment-textnodes': 2,
233 | 'react/no-comment-textnodes': 0, // deprecated version
234 |
235 | // disallow using React.render/ReactDOM.render's return value
236 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
237 | 'react/no-render-return-value': 2,
238 |
239 | // require a shouldComponentUpdate method, or PureRenderMixin
240 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
241 | 'react/require-optimization': [0, { allowDecorators: [] }],
242 |
243 | // warn against using findDOMNode()
244 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
245 | 'react/no-find-dom-node': 2,
246 | },
247 |
248 | settings: {
249 | 'import/resolver': {
250 | node: {
251 | extensions: ['.js', '.jsx', '.json']
252 | }
253 | },
254 | react: {
255 | pragma: 'React',
256 | version: '0.14'
257 | },
258 | }
259 | };
260 |
--------------------------------------------------------------------------------
/rules/strict.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | rules: {
3 | // babel inserts `'use strict';` for us
4 | strict: ['error', 'never']
5 | }
6 | };
7 |
--------------------------------------------------------------------------------
/rules/style.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | rules: {
3 | // enforce spacing inside array brackets
4 | 'array-bracket-spacing': ['error', 'never'],
5 |
6 | // enforce spacing inside single-line blocks
7 | // http://eslint.org/docs/rules/block-spacing
8 | 'block-spacing': ['error', 'always'],
9 |
10 | // enforce one true brace style
11 | 'brace-style': ['error', '1tbs', { allowSingleLine: true }],
12 |
13 | // require camel case names
14 | camelcase: ['error', { properties: 'never' }],
15 |
16 | // enforce spacing before and after comma
17 | 'comma-spacing': ['error', { before: false, after: true }],
18 |
19 | // enforce one true comma style
20 | 'comma-style': ['error', 'last'],
21 |
22 | // disallow padding inside computed properties
23 | 'computed-property-spacing': ['error', 'never'],
24 |
25 | // enforces consistent naming when capturing the current execution context
26 | 'consistent-this': 'off',
27 |
28 | // enforce newline at the end of file, with no multiple empty lines
29 | 'eol-last': 'error',
30 |
31 | // enforce spacing between functions and their invocations
32 | // http://eslint.org/docs/rules/func-call-spacing
33 | // TODO: enable, semver-minor
34 | 'func-call-spacing': ['off', 'never'],
35 |
36 | // require function expressions to have a name
37 | 'func-names': 'warn',
38 |
39 | // enforces use of function declarations or expressions
40 | 'func-style': 'off',
41 |
42 | // Blacklist certain identifiers to prevent them being used
43 | // http://eslint.org/docs/rules/id-blacklist
44 | 'id-blacklist': 'off',
45 |
46 | // this option enforces minimum and maximum identifier lengths
47 | // (variable names, property names etc.)
48 | 'id-length': 'off',
49 |
50 | // require identifiers to match the provided regular expression
51 | 'id-match': 'off',
52 |
53 | // this option sets a specific tab width for your code
54 | // http://eslint.org/docs/rules/indent
55 | indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
56 |
57 | // specify whether double or single quotes should be used in JSX attributes
58 | // http://eslint.org/docs/rules/jsx-quotes
59 | 'jsx-quotes': ['off', 'prefer-double'],
60 |
61 | // enforces spacing between keys and values in object literal properties
62 | 'key-spacing': ['error', { beforeColon: false, afterColon: true }],
63 |
64 | // require a space before & after certain keywords
65 | 'keyword-spacing': ['error', {
66 | before: true,
67 | after: true,
68 | overrides: {
69 | return: { after: true },
70 | throw: { after: true },
71 | case: { after: true }
72 | }
73 | }],
74 |
75 | // disallow mixed 'LF' and 'CRLF' as linebreaks
76 | // http://eslint.org/docs/rules/linebreak-style
77 | 'linebreak-style': ['error', 'unix'],
78 |
79 | // enforces empty lines around comments
80 | 'lines-around-comment': 'off',
81 |
82 | // specify the maximum depth that blocks can be nested
83 | 'max-depth': ['off', 4],
84 |
85 | // specify the maximum length of a line in your program
86 | // http://eslint.org/docs/rules/max-len
87 | 'max-len': ['error', 100, 2, {
88 | ignoreUrls: true,
89 | ignoreComments: false
90 | }],
91 |
92 | // specify the max number of lines in a file
93 | // http://eslint.org/docs/rules/max-lines
94 | 'max-lines': ['off', {
95 | max: 300,
96 | skipBlankLines: true,
97 | skipComments: true
98 | }],
99 |
100 | // specify the maximum depth callbacks can be nested
101 | 'max-nested-callbacks': 'off',
102 |
103 | // limits the number of parameters that can be used in the function declaration.
104 | 'max-params': ['off', 3],
105 |
106 | // specify the maximum number of statement allowed in a function
107 | 'max-statements': ['off', 10],
108 |
109 | // restrict the number of statements per line
110 | // http://eslint.org/docs/rules/max-statements-per-line
111 | 'max-statements-per-line': ['off', { max: 1 }],
112 |
113 | // require multiline ternary
114 | // http://eslint.org/docs/rules/multiline-ternary
115 | 'multiline-ternary': 'off',
116 |
117 | // require a capital letter for constructors
118 | 'new-cap': ['error', { newIsCap: true }],
119 |
120 | // disallow the omission of parentheses when invoking a constructor with no arguments
121 | // http://eslint.org/docs/rules/new-parens
122 | 'new-parens': 'error',
123 |
124 | // allow/disallow an empty newline after var statement
125 | 'newline-after-var': 'off',
126 |
127 | // http://eslint.org/docs/rules/newline-before-return
128 | 'newline-before-return': 'off',
129 |
130 | // enforces new line after each method call in the chain to make it
131 | // more readable and easy to maintain
132 | // http://eslint.org/docs/rules/newline-per-chained-call
133 | 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
134 |
135 | // disallow use of the Array constructor
136 | 'no-array-constructor': 'error',
137 |
138 | // disallow use of bitwise operators
139 | // http://eslint.org/docs/rules/no-bitwise
140 | // TODO: enable
141 | 'no-bitwise': 'off',
142 |
143 | // disallow use of the continue statement
144 | // http://eslint.org/docs/rules/no-continue
145 | 'no-continue': 'error',
146 |
147 | // disallow comments inline after code
148 | 'no-inline-comments': 'off',
149 |
150 | // disallow if as the only statement in an else block
151 | // http://eslint.org/docs/rules/no-lonely-if
152 | 'no-lonely-if': 'error',
153 |
154 | // disallow un-paren'd mixes of different operators
155 | // http://eslint.org/docs/rules/no-mixed-operators
156 | 'no-mixed-operators': ['error', {
157 | groups: [
158 | ['+', '-', '*', '/', '%', '**'],
159 | ['&', '|', '^', '~', '<<', '>>', '>>>'],
160 | ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
161 | ['&&', '||'],
162 | ['in', 'instanceof']
163 | ],
164 | allowSamePrecedence: false
165 | }],
166 |
167 | // disallow mixed spaces and tabs for indentation
168 | 'no-mixed-spaces-and-tabs': 'error',
169 |
170 | // disallow multiple empty lines and only one newline at the end
171 | 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
172 |
173 | // disallow negated conditions
174 | // http://eslint.org/docs/rules/no-negated-condition
175 | 'no-negated-condition': 'off',
176 |
177 | // disallow nested ternary expressions
178 | 'no-nested-ternary': 'error',
179 |
180 | // disallow use of the Object constructor
181 | 'no-new-object': 'error',
182 |
183 | // disallow use of unary operators, ++ and --
184 | 'no-plusplus': 'off',
185 |
186 | // disallow certain syntax forms
187 | // http://eslint.org/docs/rules/no-restricted-syntax
188 | 'no-restricted-syntax': [
189 | 'error',
190 | 'DebuggerStatement',
191 | 'ForInStatement',
192 | 'LabeledStatement',
193 | 'WithStatement',
194 | ],
195 |
196 | // disallow space between function identifier and application
197 | 'no-spaced-func': 'error',
198 |
199 | // disallow tab characters entirely
200 | // TODO: enable
201 | 'no-tabs': 'off',
202 |
203 | // disallow the use of ternary operators
204 | 'no-ternary': 'off',
205 |
206 | // disallow trailing whitespace at the end of lines
207 | 'no-trailing-spaces': 'error',
208 |
209 | // disallow dangling underscores in identifiers
210 | 'no-underscore-dangle': ['error', { allowAfterThis: false }],
211 |
212 | // disallow the use of Boolean literals in conditional expressions
213 | // also, prefer `a || b` over `a ? a : b`
214 | // http://eslint.org/docs/rules/no-unneeded-ternary
215 | 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
216 |
217 | // disallow whitespace before properties
218 | // http://eslint.org/docs/rules/no-whitespace-before-property
219 | 'no-whitespace-before-property': 'error',
220 |
221 | // require padding inside curly braces
222 | 'object-curly-spacing': ['error', 'always'],
223 |
224 | // enforce line breaks between braces
225 | // http://eslint.org/docs/rules/object-curly-newline
226 | // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved
227 | 'object-curly-newline': ['off', {
228 | ObjectExpression: { minProperties: 0, multiline: true },
229 | ObjectPattern: { minProperties: 0, multiline: true }
230 | }],
231 |
232 | // enforce "same line" or "multiple line" on object properties.
233 | // http://eslint.org/docs/rules/object-property-newline
234 | 'object-property-newline': ['error', {
235 | allowMultiplePropertiesPerLine: true,
236 | }],
237 |
238 | // allow just one var statement per function
239 | 'one-var': ['error', 'never'],
240 |
241 | // require a newline around variable declaration
242 | // http://eslint.org/docs/rules/one-var-declaration-per-line
243 | 'one-var-declaration-per-line': ['error', 'always'],
244 |
245 | // require assignment operator shorthand where possible or prohibit it entirely
246 | // http://eslint.org/docs/rules/operator-assignment
247 | 'operator-assignment': ['error', 'always'],
248 |
249 | // enforce operators to be placed before or after line breaks
250 | 'operator-linebreak': 'off',
251 |
252 | // enforce padding within blocks
253 | 'padded-blocks': ['error', 'never'],
254 |
255 | // require quotes around object literal property names
256 | // http://eslint.org/docs/rules/quote-props.html
257 | 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
258 |
259 | // specify whether double or single quotes should be used
260 | quotes: ['error', 'single', { avoidEscape: true }],
261 |
262 | // do not require jsdoc
263 | // http://eslint.org/docs/rules/require-jsdoc
264 | 'require-jsdoc': 'off',
265 |
266 | // require or disallow use of semicolons instead of ASI
267 | semi: ['error', 'always'],
268 |
269 | // enforce spacing before and after semicolons
270 | 'semi-spacing': ['error', { before: false, after: true }],
271 |
272 | // requires object keys to be sorted
273 | 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }],
274 |
275 | // sort variables within the same declaration block
276 | 'sort-vars': 'off',
277 |
278 | // require or disallow space before blocks
279 | 'space-before-blocks': 'error',
280 |
281 | // require or disallow space before function opening parenthesis
282 | // http://eslint.org/docs/rules/space-before-function-paren
283 | 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never' }],
284 |
285 | // require or disallow spaces inside parentheses
286 | 'space-in-parens': ['error', 'never'],
287 |
288 | // require spaces around operators
289 | 'space-infix-ops': 'error',
290 |
291 | // Require or disallow spaces before/after unary operators
292 | // http://eslint.org/docs/rules/space-unary-ops
293 | 'space-unary-ops': ['error', {
294 | words: true,
295 | nonwords: false,
296 | overrides: {
297 | },
298 | }],
299 |
300 | // require or disallow a space immediately following the // or /* in a comment
301 | 'spaced-comment': ['error', 'always', {
302 | exceptions: ['-', '+'],
303 | markers: ['=', '!'] // space here to support sprockets directives
304 | }],
305 |
306 | // require or disallow the Unicode Byte Order Mark
307 | // http://eslint.org/docs/rules/unicode-bom
308 | 'unicode-bom': ['error', 'never'],
309 |
310 | // require regex literals to be wrapped in parentheses
311 | 'wrap-regex': 'off'
312 | }
313 | };
314 |
--------------------------------------------------------------------------------
/rules/variables.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | rules: {
3 | // enforce or disallow variable initializations at definition
4 | 'init-declarations': 'off',
5 |
6 | // disallow the catch clause parameter name being the same as a variable in the outer scope
7 | 'no-catch-shadow': 'off',
8 |
9 | // disallow deletion of variables
10 | 'no-delete-var': 'error',
11 |
12 | // disallow labels that share a name with a variable
13 | // http://eslint.org/docs/rules/no-label-var
14 | 'no-label-var': 'error',
15 |
16 | // disallow specific globals
17 | 'no-restricted-globals': 'off',
18 |
19 | // disallow declaration of variables already declared in the outer scope
20 | 'no-shadow': 'error',
21 |
22 | // disallow shadowing of names such as arguments
23 | 'no-shadow-restricted-names': 'error',
24 |
25 | // disallow use of undeclared variables unless mentioned in a /*global */ block
26 | 'no-undef': 'error',
27 |
28 | // disallow use of undefined when initializing variables
29 | 'no-undef-init': 'error',
30 |
31 | // disallow use of undefined variable
32 | // TODO: enable?
33 | 'no-undefined': 'off',
34 |
35 | // disallow declaration of variables that are not used in the code
36 | 'no-unused-vars': ['error', { vars: 'local', args: 'after-used' }],
37 |
38 | // disallow use of variables before they are defined
39 | 'no-use-before-define': 'error'
40 | }
41 | };
42 |
--------------------------------------------------------------------------------
|