@generatech/eslint-config-base 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,199 @@
1
+ module.exports = {
2
+ rules: {
3
+ // Enforce “for” loop update clause moving the counter in the right direction
4
+ // https://eslint.org/docs/rules/for-direction
5
+ "for-direction": "error",
6
+
7
+ // Enforces that a return statement is present in property getters
8
+ // https://eslint.org/docs/rules/getter-return
9
+ "getter-return": ["error", { allowImplicit: true }],
10
+
11
+ // disallow using an async function as a Promise executor
12
+ // https://eslint.org/docs/rules/no-async-promise-executor
13
+ "no-async-promise-executor": "error",
14
+
15
+ // Disallow await inside of loops
16
+ // https://eslint.org/docs/rules/no-await-in-loop
17
+ "no-await-in-loop": "error",
18
+
19
+ // Disallow comparisons to negative zero
20
+ // https://eslint.org/docs/rules/no-compare-neg-zero
21
+ "no-compare-neg-zero": "error",
22
+
23
+ // disallow assignment in conditional expressions
24
+ "no-cond-assign": ["error", "always"],
25
+
26
+ // disallow use of console
27
+ "no-console": "warn",
28
+
29
+ // Disallows expressions where the operation doesn't affect the value
30
+ // https://eslint.org/docs/rules/no-constant-binary-expression
31
+ // TODO: semver-major, enable
32
+ "no-constant-binary-expression": "off",
33
+
34
+ // disallow use of constant expressions in conditions
35
+ "no-constant-condition": "warn",
36
+
37
+ // disallow control characters in regular expressions
38
+ "no-control-regex": "error",
39
+
40
+ // disallow use of debugger
41
+ "no-debugger": "error",
42
+
43
+ // disallow duplicate arguments in functions
44
+ "no-dupe-args": "error",
45
+
46
+ // Disallow duplicate conditions in if-else-if chains
47
+ // https://eslint.org/docs/rules/no-dupe-else-if
48
+ "no-dupe-else-if": "error",
49
+
50
+ // disallow duplicate keys when creating object literals
51
+ "no-dupe-keys": "error",
52
+
53
+ // disallow a duplicate case label.
54
+ "no-duplicate-case": "error",
55
+
56
+ // disallow empty statements
57
+ "no-empty": "error",
58
+
59
+ // disallow the use of empty character classes in regular expressions
60
+ "no-empty-character-class": "error",
61
+
62
+ // disallow assigning to the exception in a catch block
63
+ "no-ex-assign": "error",
64
+
65
+ // disallow double-negation boolean casts in a boolean context
66
+ // https://eslint.org/docs/rules/no-extra-boolean-cast
67
+ "no-extra-boolean-cast": "error",
68
+
69
+ // disallow unnecessary parentheses
70
+ // https://eslint.org/docs/rules/no-extra-parens
71
+ "no-extra-parens": [
72
+ "off",
73
+ "all",
74
+ {
75
+ conditionalAssign: true,
76
+ nestedBinaryExpressions: false,
77
+ returnAssign: false,
78
+ ignoreJSX: "all", // delegate to eslint-plugin-react
79
+ enforceForArrowConditionals: false,
80
+ },
81
+ ],
82
+
83
+ // disallow unnecessary semicolons
84
+ "no-extra-semi": "error",
85
+
86
+ // disallow overwriting functions written as function declarations
87
+ "no-func-assign": "error",
88
+
89
+ // https://eslint.org/docs/rules/no-import-assign
90
+ "no-import-assign": "error",
91
+
92
+ // disallow function or variable declarations in nested blocks
93
+ "no-inner-declarations": "error",
94
+
95
+ // disallow invalid regular expression strings in the RegExp constructor
96
+ "no-invalid-regexp": "error",
97
+
98
+ // disallow irregular whitespace outside of strings and comments
99
+ "no-irregular-whitespace": "error",
100
+
101
+ // Disallow Number Literals That Lose Precision
102
+ // https://eslint.org/docs/rules/no-loss-of-precision
103
+ "no-loss-of-precision": "error",
104
+
105
+ // Disallow characters which are made with multiple code points in character class syntax
106
+ // https://eslint.org/docs/rules/no-misleading-character-class
107
+ "no-misleading-character-class": "error",
108
+
109
+ // disallow the use of object properties of the global object (Math and JSON) as functions
110
+ "no-obj-calls": "error",
111
+
112
+ // Disallow new operators with global non-constructor functions
113
+ // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
114
+ // TODO: semver-major, enable
115
+ "no-new-native-nonconstructor": "off",
116
+
117
+ // Disallow returning values from Promise executor functions
118
+ // https://eslint.org/docs/rules/no-promise-executor-return
119
+ "no-promise-executor-return": "error",
120
+
121
+ // disallow use of Object.prototypes builtins directly
122
+ // https://eslint.org/docs/rules/no-prototype-builtins
123
+ "no-prototype-builtins": "error",
124
+
125
+ // disallow multiple spaces in a regular expression literal
126
+ "no-regex-spaces": "error",
127
+
128
+ // Disallow returning values from setters
129
+ // https://eslint.org/docs/rules/no-setter-return
130
+ "no-setter-return": "error",
131
+
132
+ // disallow sparse arrays
133
+ "no-sparse-arrays": "error",
134
+
135
+ // Disallow template literal placeholder syntax in regular strings
136
+ // https://eslint.org/docs/rules/no-template-curly-in-string
137
+ "no-template-curly-in-string": "error",
138
+
139
+ // Avoid code that looks like two expressions but is actually one
140
+ // https://eslint.org/docs/rules/no-unexpected-multiline
141
+ "no-unexpected-multiline": "error",
142
+
143
+ // disallow unreachable statements after a return, throw, continue, or break statement
144
+ "no-unreachable": "error",
145
+
146
+ // Disallow loops with a body that allows only one iteration
147
+ // https://eslint.org/docs/rules/no-unreachable-loop
148
+ "no-unreachable-loop": [
149
+ "error",
150
+ {
151
+ ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
152
+ },
153
+ ],
154
+
155
+ // disallow return/throw/break/continue inside finally blocks
156
+ // https://eslint.org/docs/rules/no-unsafe-finally
157
+ "no-unsafe-finally": "error",
158
+
159
+ // disallow negating the left operand of relational operators
160
+ // https://eslint.org/docs/rules/no-unsafe-negation
161
+ "no-unsafe-negation": "error",
162
+
163
+ // disallow use of optional chaining in contexts where the undefined value is not allowed
164
+ // https://eslint.org/docs/rules/no-unsafe-optional-chaining
165
+ "no-unsafe-optional-chaining": [
166
+ "error",
167
+ { disallowArithmeticOperators: true },
168
+ ],
169
+
170
+ // Disallow Unused Private Class Members
171
+ // https://eslint.org/docs/rules/no-unused-private-class-members
172
+ // TODO: enable once eslint 7 is dropped (which is semver-major)
173
+ "no-unused-private-class-members": "off",
174
+
175
+ // Disallow useless backreferences in regular expressions
176
+ // https://eslint.org/docs/rules/no-useless-backreference
177
+ "no-useless-backreference": "error",
178
+
179
+ // disallow negation of the left operand of an in expression
180
+ // deprecated in favor of no-unsafe-negation
181
+ "no-negated-in-lhs": "off",
182
+
183
+ // Disallow assignments that can lead to race conditions due to usage of await or yield
184
+ // https://eslint.org/docs/rules/require-atomic-updates
185
+ // note: not enabled because it is very buggy
186
+ "require-atomic-updates": "off",
187
+
188
+ // disallow comparisons with the value NaN
189
+ "use-isnan": "error",
190
+
191
+ // ensure JSDoc comments are valid
192
+ // https://eslint.org/docs/rules/valid-jsdoc
193
+ "valid-jsdoc": "off",
194
+
195
+ // ensure that the results of typeof are compared against a valid string
196
+ // https://eslint.org/docs/rules/valid-typeof
197
+ "valid-typeof": ["error", { requireStringLiterals: true }],
198
+ },
199
+ };
package/rules/es.js ADDED
@@ -0,0 +1,218 @@
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
+ // https://eslint.org/docs/rules/arrow-body-style
17
+ // TODO: enable requireReturnForObjectLiteral?
18
+ "arrow-body-style": [
19
+ "error",
20
+ "as-needed",
21
+ {
22
+ requireReturnForObjectLiteral: false,
23
+ },
24
+ ],
25
+
26
+ // require parens in arrow function arguments
27
+ // https://eslint.org/docs/rules/arrow-parens
28
+ "arrow-parens": ["error", "always"],
29
+
30
+ // require space before/after arrow function's arrow
31
+ // https://eslint.org/docs/rules/arrow-spacing
32
+ "arrow-spacing": ["error", { before: true, after: true }],
33
+
34
+ // verify super() callings in constructors
35
+ "constructor-super": "error",
36
+
37
+ // enforce the spacing around the * in generator functions
38
+ // https://eslint.org/docs/rules/generator-star-spacing
39
+ "generator-star-spacing": ["error", { before: false, after: true }],
40
+
41
+ // disallow modifying variables of class declarations
42
+ // https://eslint.org/docs/rules/no-class-assign
43
+ "no-class-assign": "error",
44
+
45
+ // disallow arrow functions where they could be confused with comparisons
46
+ // https://eslint.org/docs/rules/no-confusing-arrow
47
+ "no-confusing-arrow": [
48
+ "error",
49
+ {
50
+ allowParens: true,
51
+ },
52
+ ],
53
+
54
+ // disallow modifying variables that are declared using const
55
+ "no-const-assign": "error",
56
+
57
+ // disallow duplicate class members
58
+ // https://eslint.org/docs/rules/no-dupe-class-members
59
+ "no-dupe-class-members": "error",
60
+
61
+ // disallow importing from the same path more than once
62
+ // https://eslint.org/docs/rules/no-duplicate-imports
63
+ // replaced by https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
64
+ "no-duplicate-imports": "off",
65
+
66
+ // disallow symbol constructor
67
+ // https://eslint.org/docs/rules/no-new-symbol
68
+ "no-new-symbol": "error",
69
+
70
+ // Disallow specified names in exports
71
+ // https://eslint.org/docs/rules/no-restricted-exports
72
+ "no-restricted-exports": [
73
+ "error",
74
+ {
75
+ restrictedNamedExports: [
76
+ "default", // use `export default` to provide a default export
77
+ "then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
78
+ ],
79
+ },
80
+ ],
81
+
82
+ // disallow specific imports
83
+ // https://eslint.org/docs/rules/no-restricted-imports
84
+ "no-restricted-imports": [
85
+ "off",
86
+ {
87
+ paths: [],
88
+ patterns: [],
89
+ },
90
+ ],
91
+
92
+ // disallow to use this/super before super() calling in constructors.
93
+ // https://eslint.org/docs/rules/no-this-before-super
94
+ "no-this-before-super": "error",
95
+
96
+ // disallow useless computed property keys
97
+ // https://eslint.org/docs/rules/no-useless-computed-key
98
+ "no-useless-computed-key": "error",
99
+
100
+ // disallow unnecessary constructor
101
+ // https://eslint.org/docs/rules/no-useless-constructor
102
+ "no-useless-constructor": "error",
103
+
104
+ // disallow renaming import, export, and destructured assignments to the same name
105
+ // https://eslint.org/docs/rules/no-useless-rename
106
+ "no-useless-rename": [
107
+ "error",
108
+ {
109
+ ignoreDestructuring: false,
110
+ ignoreImport: false,
111
+ ignoreExport: false,
112
+ },
113
+ ],
114
+
115
+ // require let or const instead of var
116
+ "no-var": "error",
117
+
118
+ // require method and property shorthand syntax for object literals
119
+ // https://eslint.org/docs/rules/object-shorthand
120
+ "object-shorthand": [
121
+ "error",
122
+ "always",
123
+ {
124
+ ignoreConstructors: false,
125
+ avoidQuotes: true,
126
+ },
127
+ ],
128
+
129
+ // suggest using arrow functions as callbacks
130
+ "prefer-arrow-callback": [
131
+ "error",
132
+ {
133
+ allowNamedFunctions: false,
134
+ allowUnboundThis: true,
135
+ },
136
+ ],
137
+
138
+ // suggest using of const declaration for variables that are never modified after declared
139
+ "prefer-const": [
140
+ "error",
141
+ {
142
+ destructuring: "any",
143
+ ignoreReadBeforeAssign: true,
144
+ },
145
+ ],
146
+
147
+ // Prefer destructuring from arrays and objects
148
+ // https://eslint.org/docs/rules/prefer-destructuring
149
+ "prefer-destructuring": [
150
+ "error",
151
+ {
152
+ VariableDeclarator: {
153
+ array: false,
154
+ object: true,
155
+ },
156
+ AssignmentExpression: {
157
+ array: true,
158
+ object: false,
159
+ },
160
+ },
161
+ {
162
+ enforceForRenamedProperties: false,
163
+ },
164
+ ],
165
+
166
+ // disallow parseInt() in favor of binary, octal, and hexadecimal literals
167
+ // https://eslint.org/docs/rules/prefer-numeric-literals
168
+ "prefer-numeric-literals": "error",
169
+
170
+ // suggest using Reflect methods where applicable
171
+ // https://eslint.org/docs/rules/prefer-reflect
172
+ "prefer-reflect": "off",
173
+
174
+ // use rest parameters instead of arguments
175
+ // https://eslint.org/docs/rules/prefer-rest-params
176
+ "prefer-rest-params": "error",
177
+
178
+ // suggest using the spread syntax instead of .apply()
179
+ // https://eslint.org/docs/rules/prefer-spread
180
+ "prefer-spread": "error",
181
+
182
+ // suggest using template literals instead of string concatenation
183
+ // https://eslint.org/docs/rules/prefer-template
184
+ "prefer-template": "error",
185
+
186
+ // disallow generator functions that do not have yield
187
+ // https://eslint.org/docs/rules/require-yield
188
+ "require-yield": "error",
189
+
190
+ // enforce spacing between object rest-spread
191
+ // https://eslint.org/docs/rules/rest-spread-spacing
192
+ "rest-spread-spacing": ["error", "never"],
193
+
194
+ // import sorting
195
+ // https://eslint.org/docs/rules/sort-imports
196
+ "sort-imports": [
197
+ "off",
198
+ {
199
+ ignoreCase: false,
200
+ ignoreDeclarationSort: false,
201
+ ignoreMemberSort: false,
202
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
203
+ },
204
+ ],
205
+
206
+ // require a Symbol description
207
+ // https://eslint.org/docs/rules/symbol-description
208
+ "symbol-description": "error",
209
+
210
+ // enforce usage of spacing in template strings
211
+ // https://eslint.org/docs/rules/template-curly-spacing
212
+ "template-curly-spacing": "error",
213
+
214
+ // enforce spacing around the * in yield* expressions
215
+ // https://eslint.org/docs/rules/yield-star-spacing
216
+ "yield-star-spacing": ["error", "after"],
217
+ },
218
+ };