es6.js
6.06 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
module.exports = {
env: {
es6: true
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
generators: false,
objectLiteralDuplicateProperties: false
}
},
rules: {
// enforces no braces where they can be omitted
// https://eslint.org/docs/rules/arrow-body-style
// TODO: enable requireReturnForObjectLiteral?
'arrow-body-style': ['error', 'as-needed', {
requireReturnForObjectLiteral: false,
}],
// require parens in arrow function arguments
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': ['error', 'always'],
// require space before/after arrow function's arrow
// https://eslint.org/docs/rules/arrow-spacing
'arrow-spacing': ['error', { before: true, after: true }],
// verify super() callings in constructors
'constructor-super': 'error',
// enforce the spacing around the * in generator functions
// https://eslint.org/docs/rules/generator-star-spacing
'generator-star-spacing': ['error', { before: false, after: true }],
// disallow modifying variables of class declarations
// https://eslint.org/docs/rules/no-class-assign
'no-class-assign': 'error',
// disallow arrow functions where they could be confused with comparisons
// https://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': ['error', {
allowParens: true,
}],
// disallow modifying variables that are declared using const
'no-const-assign': 'error',
// disallow duplicate class members
// https://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 'error',
// disallow importing from the same path more than once
// https://eslint.org/docs/rules/no-duplicate-imports
// replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'no-duplicate-imports': 'off',
// disallow symbol constructor
// https://eslint.org/docs/rules/no-new-symbol
'no-new-symbol': 'error',
// Disallow specified names in exports
// https://eslint.org/docs/rules/no-restricted-exports
// TODO enable, semver-minor, once eslint v7 is required (which is major)
'no-restricted-exports': ['off', {
restrictedNamedExports: [
'default', // use `export default` to provide a default export
'then', // this will cause tons of confusion when your module is dynamically `import()`ed
],
}],
// disallow specific imports
// https://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': ['off', {
paths: [],
patterns: []
}],
// disallow to use this/super before super() calling in constructors.
// https://eslint.org/docs/rules/no-this-before-super
'no-this-before-super': 'error',
// disallow useless computed property keys
// https://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 'error',
// disallow unnecessary constructor
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',
// disallow renaming import, export, and destructured assignments to the same name
// https://eslint.org/docs/rules/no-useless-rename
'no-useless-rename': ['error', {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
}],
// require let or const instead of var
'no-var': 'error',
// require method and property shorthand syntax for object literals
// https://eslint.org/docs/rules/object-shorthand
'object-shorthand': ['error', 'always', {
ignoreConstructors: false,
avoidQuotes: true,
}],
// suggest using arrow functions as callbacks
'prefer-arrow-callback': ['error', {
allowNamedFunctions: false,
allowUnboundThis: true,
}],
// suggest using of const declaration for variables that are never modified after declared
'prefer-const': ['error', {
destructuring: 'any',
ignoreReadBeforeAssign: true,
}],
// Prefer destructuring from arrays and objects
// https://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': ['error', {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
}, {
enforceForRenamedProperties: false,
}],
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
// https://eslint.org/docs/rules/prefer-numeric-literals
'prefer-numeric-literals': 'error',
// suggest using Reflect methods where applicable
// https://eslint.org/docs/rules/prefer-reflect
'prefer-reflect': 'off',
// use rest parameters instead of arguments
// https://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 'error',
// suggest using the spread operator instead of .apply()
// https://eslint.org/docs/rules/prefer-spread
'prefer-spread': 'error',
// suggest using template literals instead of string concatenation
// https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',
// disallow generator functions that do not have yield
// https://eslint.org/docs/rules/require-yield
'require-yield': 'error',
// enforce spacing between object rest-spread
// https://eslint.org/docs/rules/rest-spread-spacing
'rest-spread-spacing': ['error', 'never'],
// import sorting
// https://eslint.org/docs/rules/sort-imports
'sort-imports': ['off', {
ignoreCase: false,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
}],
// require a Symbol description
// https://eslint.org/docs/rules/symbol-description
'symbol-description': 'error',
// enforce usage of spacing in template strings
// https://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': 'error',
// enforce spacing around the * in yield* expressions
// https://eslint.org/docs/rules/yield-star-spacing
'yield-star-spacing': ['error', 'after']
}
};