-
Notifications
You must be signed in to change notification settings - Fork 80
/
.eslintrc.js
170 lines (150 loc) · 5.57 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// ======================================================
// NOTE: Depends on airbnb's basic eslint settings, which need to be installed
// via npm install. To install specific versions and update the package.json
// se
// some pretty specific commands per your environment.
// See: https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
// ======================================================
module.exports = {
// Only import some air bnb rules
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base/rules
'extends': [
'airbnb-base',
'plugin:jasmine/recommended',
'plugin:jasmine-jquery/recommended'
],
'parserOptions': {
'ecmaVersion': 8,
'sourceType': 'module'
},
'plugins': [
'jasmine',
'jasmine-jquery'
],
'env': {
'browser': true,
'jquery': true,
'node': true,
'jasmine': true,
'protractor': true
},
'rules': {
// require function expressions to have a name
// https://eslint.org/docs/rules/func-names
'func-names': 'off',
// require trailing commas in multiline object literals
'comma-dangle': ['off', {
'arrays': 'never',
'objects': 'never',
'imports': 'never',
'exports': 'never',
'functions': 'never'
}],
// enforce line breaks between braces
// https://eslint.org/docs/rules/object-curly-newline
'object-curly-newline': ['error', {
ObjectExpression: { minProperties: 8, multiline: true, consistent: true },
ObjectPattern: { minProperties: 8, multiline: true, consistent: true }
}],
// disallow use of unary operators, ++ and --
// https://eslint.org/docs/rules/no-plusplus
'no-plusplus': 'off',
// disallow multiple empty lines and only one newline at the end
'no-multiple-empty-lines': ['warn', { max: 1, maxEOF: 1 }],
// set "no-trailing-spaces" to only a warning (this shouldn't fail builds)
'no-trailing-spaces': ['warn'],
// ensure JSDoc comments are valid
// https://eslint.org/docs/rules/valid-jsdoc
'valid-jsdoc': ['warn', {
'prefer': {
'arg': 'param',
'argument': 'param',
'class': 'class',
'return': 'returns'
},
'requireReturn': false
}],
// disallow use of chained assignment expressions
// https://eslint.org/docs/rules/no-multi-assign
'no-multi-assign': ['warn'],
// disallow reassignment of function parameters
// disallow parameter object manipulation except for specific exclusions
// rule: https://eslint.org/docs/rules/no-param-reassign.html
'no-param-reassign': ['off', {
props: true,
ignorePropertyModificationsFor: [
'acc', // for reduce accumulators
'e', // for e.returnvalue
'ctx', // for Koa routing
'req', // for Express requests
'request', // for Express requests
'res', // for Express responses
'response', // for Express responses
'$scope', // for Angular 1 scopes
]
}],
// Prefer destructuring from arrays and objects
// https://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': ['off', {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: true,
},
}, {
enforceForRenamedProperties: false,
}],
// don't enforce arrow functions
// https://eslint.org/docs/rules/prefer-arrow-callback
'prefer-arrow-callback': ['warn', {}],
// don't enforce disallowing of mixed operators.
// We use lots of algebra for positioning/etc that gets flagged by this.
// https://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': ['off'],
// Require modules with a single export to use a default export
// Will ignore because of https://medium.com/@timoxley/named-exports-as-the-default-export-api-670b1b554f65
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
'import/prefer-default-export': 'off',
// Ignore certain globals:
// - IsNaN - due to our previous assumptions in code about how it sometimes will return 'false', and because `Number.isNaN` has no native IE11 support.
// for things that are not numbers (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN#Examples).
// https://eslint.org/docs/rules/no-restricted-globals
'no-restricted-globals': ['off', 'isNaN'],
// Ignore usage of certain properties:
// - Math.pow (not really sure why AirBNB doesn't allow this)
//
'no-restricted-properties': ['off', {
'object': 'Math',
'property': 'pow'
}],
// Ignore errors for continue statements, currently used in:
// - Mask
// - Validation
// https://eslint.org/docs/rules/no-continue
'no-continue': ['off'],
// Forbid the use of extraneous packages
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
// paths are treated both as absolute paths, and relative to process.cwd()
'import/no-extraneous-dependencies': ['off'],
// specify the maximum length of a line in your program
// https://eslint.org/docs/rules/max-len
'max-len': ['error', {
code: 100,
comments: 350,
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
// Disallow use of disabled tests (Jasmine)
'jasmine/no-disabled-tests': ['off']
},
'globals': {
'd3': false,
'spyOnEvent': true
}
};