@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,301 @@
1
+ module.exports = {
2
+ env: {
3
+ es6: true,
4
+ },
5
+ parserOptions: {
6
+ ecmaVersion: 6,
7
+ sourceType: "module",
8
+ },
9
+ plugins: ["import"],
10
+
11
+ settings: {
12
+ "import/resolver": {
13
+ node: {
14
+ extensions: [".mjs", ".js", ".json"],
15
+ },
16
+ },
17
+ "import/extensions": [".js", ".mjs", ".jsx"],
18
+ "import/core-modules": [],
19
+ "import/ignore": [
20
+ "node_modules",
21
+ "\\.(coffee|scss|css|less|hbs|svg|json)$",
22
+ ],
23
+ },
24
+
25
+ rules: {
26
+ // Static analysis:
27
+
28
+ // ensure imports point to files/modules that can be resolved
29
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
30
+ "import/no-unresolved": ["error", { commonjs: true, caseSensitive: true }],
31
+
32
+ // ensure named imports coupled with named exports
33
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
34
+ "import/named": "error",
35
+
36
+ // ensure default import coupled with default export
37
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
38
+ "import/default": "off",
39
+
40
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/namespace.md
41
+ "import/namespace": "off",
42
+
43
+ // Helpful warnings:
44
+
45
+ // disallow invalid exports, e.g. multiple defaults
46
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/export.md
47
+ "import/export": "error",
48
+
49
+ // do not allow a default import name to match a named export
50
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
51
+ "import/no-named-as-default": "error",
52
+
53
+ // warn on accessing default export property names that are also named exports
54
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
55
+ "import/no-named-as-default-member": "error",
56
+
57
+ // disallow use of jsdoc-marked-deprecated imports
58
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
59
+ "import/no-deprecated": "off",
60
+
61
+ // Forbid the use of extraneous packages
62
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
63
+ // paths are treated both as absolute paths, and relative to process.cwd()
64
+ "import/no-extraneous-dependencies": [
65
+ "error",
66
+ {
67
+ devDependencies: [
68
+ "test/**", // tape, common npm pattern
69
+ "tests/**", // also common npm pattern
70
+ "spec/**", // mocha, rspec-like pattern
71
+ "**/__tests__/**", // jest pattern
72
+ "**/__mocks__/**", // jest pattern
73
+ "test.{js,jsx}", // repos with a single test file
74
+ "test-*.{js,jsx}", // repos with multiple top-level test files
75
+ "**/*{.,_}{test,spec}.{js,jsx}", // tests where the extension or filename suffix denotes that it is a test
76
+ "**/jest.config.js", // jest config
77
+ "**/jest.setup.js", // jest setup
78
+ "**/vue.config.js", // vue-cli config
79
+ "**/webpack.config.js", // webpack config
80
+ "**/webpack.config.*.js", // webpack config
81
+ "**/rollup.config.js", // rollup config
82
+ "**/rollup.config.*.js", // rollup config
83
+ "**/gulpfile.js", // gulp config
84
+ "**/gulpfile.*.js", // gulp config
85
+ "**/Gruntfile{,.js}", // grunt config
86
+ "**/protractor.conf.js", // protractor config
87
+ "**/protractor.conf.*.js", // protractor config
88
+ "**/karma.conf.js", // karma config
89
+ "**/.eslintrc.js", // eslint config
90
+ ],
91
+ optionalDependencies: false,
92
+ },
93
+ ],
94
+
95
+ // Forbid mutable exports
96
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
97
+ "import/no-mutable-exports": "error",
98
+
99
+ // Module systems:
100
+
101
+ // disallow require()
102
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
103
+ "import/no-commonjs": "off",
104
+
105
+ // disallow AMD require/define
106
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-amd.md
107
+ "import/no-amd": "error",
108
+
109
+ // No Node.js builtin modules
110
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
111
+ // TODO: enable?
112
+ "import/no-nodejs-modules": "off",
113
+
114
+ // Style guide:
115
+
116
+ // disallow non-import statements appearing before import statements
117
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/first.md
118
+ "import/first": "error",
119
+
120
+ // disallow non-import statements appearing before import statements
121
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/imports-first.md
122
+ // deprecated: use `import/first`
123
+ "import/imports-first": "off",
124
+
125
+ // disallow duplicate imports
126
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
127
+ "import/no-duplicates": "error",
128
+
129
+ // disallow namespace imports
130
+ // TODO: enable?
131
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
132
+ "import/no-namespace": "off",
133
+
134
+ // Ensure consistent use of file extension within the import path
135
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md
136
+ "import/extensions": [
137
+ "error",
138
+ "ignorePackages",
139
+ {
140
+ js: "never",
141
+ mjs: "never",
142
+ jsx: "never",
143
+ },
144
+ ],
145
+
146
+ // ensure absolute imports are above relative imports and that unassigned imports are ignored
147
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md
148
+ // TODO: enforce a stricter convention in module import order?
149
+ "import/order": [
150
+ "error",
151
+ { groups: [["builtin", "external", "internal"]] },
152
+ ],
153
+
154
+ // Require a newline after the last import/require in a group
155
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
156
+ "import/newline-after-import": "error",
157
+
158
+ // Require modules with a single export to use a default export
159
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
160
+ "import/prefer-default-export": "error",
161
+
162
+ // Restrict which files can be imported in a given folder
163
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
164
+ "import/no-restricted-paths": "off",
165
+
166
+ // Forbid modules to have too many dependencies
167
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
168
+ "import/max-dependencies": ["off", { max: 10 }],
169
+
170
+ // Forbid import of modules using absolute paths
171
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
172
+ "import/no-absolute-path": "error",
173
+
174
+ // Forbid require() calls with expressions
175
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
176
+ "import/no-dynamic-require": "error",
177
+
178
+ // prevent importing the submodules of other modules
179
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
180
+ "import/no-internal-modules": [
181
+ "off",
182
+ {
183
+ allow: [],
184
+ },
185
+ ],
186
+
187
+ // Warn if a module could be mistakenly parsed as a script by a consumer
188
+ // leveraging Unambiguous JavaScript Grammar
189
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
190
+ // this should not be enabled until this proposal has at least been *presented* to TC39.
191
+ // At the moment, it's not a thing.
192
+ "import/unambiguous": "off",
193
+
194
+ // Forbid Webpack loader syntax in imports
195
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
196
+ "import/no-webpack-loader-syntax": "error",
197
+
198
+ // Prevent unassigned imports
199
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
200
+ // importing for side effects is perfectly acceptable, if you need side effects.
201
+ "import/no-unassigned-import": "off",
202
+
203
+ // Prevent importing the default as if it were named
204
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
205
+ "import/no-named-default": "error",
206
+
207
+ // Reports if a module's default export is unnamed
208
+ // https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
209
+ "import/no-anonymous-default-export": [
210
+ "off",
211
+ {
212
+ allowArray: false,
213
+ allowArrowFunction: false,
214
+ allowAnonymousClass: false,
215
+ allowAnonymousFunction: false,
216
+ allowLiteral: false,
217
+ allowObject: false,
218
+ },
219
+ ],
220
+
221
+ // This rule enforces that all exports are declared at the bottom of the file.
222
+ // https://github.com/import-js/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
223
+ // TODO: enable?
224
+ "import/exports-last": "off",
225
+
226
+ // Reports when named exports are not grouped together in a single export declaration
227
+ // or when multiple assignments to CommonJS module.exports or exports object are present
228
+ // in a single file.
229
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
230
+ "import/group-exports": "off",
231
+
232
+ // forbid default exports. this is a terrible rule, do not use it.
233
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md
234
+ "import/no-default-export": "off",
235
+
236
+ // Prohibit named exports. this is a terrible rule, do not use it.
237
+ // https://github.com/import-js/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md
238
+ "import/no-named-export": "off",
239
+
240
+ // Forbid a module from importing itself
241
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
242
+ "import/no-self-import": "error",
243
+
244
+ // Forbid cyclical dependencies between modules
245
+ // https://github.com/import-js/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md
246
+ "import/no-cycle": ["error", { maxDepth: "∞" }],
247
+
248
+ // Ensures that there are no useless path segments
249
+ // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md
250
+ "import/no-useless-path-segments": ["error", { commonjs: true }],
251
+
252
+ // dynamic imports require a leading comment with a webpackChunkName
253
+ // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md
254
+ "import/dynamic-import-chunkname": [
255
+ "off",
256
+ {
257
+ importFunctions: [],
258
+ webpackChunknameFormat: "[0-9a-zA-Z-_/.]+",
259
+ },
260
+ ],
261
+
262
+ // Use this rule to prevent imports to folders in relative parent paths.
263
+ // https://github.com/import-js/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md
264
+ "import/no-relative-parent-imports": "off",
265
+
266
+ // Reports modules without any exports, or with unused exports
267
+ // https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
268
+ // TODO: enable once it supports CJS
269
+ "import/no-unused-modules": [
270
+ "off",
271
+ {
272
+ ignoreExports: [],
273
+ missingExports: true,
274
+ unusedExports: true,
275
+ },
276
+ ],
277
+
278
+ // Reports the use of import declarations with CommonJS exports in any module except for the main module.
279
+ // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
280
+ "import/no-import-module-exports": [
281
+ "error",
282
+ {
283
+ exceptions: [],
284
+ },
285
+ ],
286
+
287
+ // Use this rule to prevent importing packages through relative paths.
288
+ // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
289
+ "import/no-relative-packages": "error",
290
+
291
+ // enforce a consistent style for type specifiers (inline or top-level)
292
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/consistent-type-specifier-style.md
293
+ // TODO, semver-major: enable (just in case)
294
+ "import/consistent-type-specifier-style": ["off", "prefer-inline"],
295
+
296
+ // Reports the use of empty named import blocks.
297
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md
298
+ // TODO, semver-minor: enable
299
+ "import/no-empty-named-blocks": "off",
300
+ },
301
+ };
package/rules/node.js ADDED
@@ -0,0 +1,43 @@
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
+ // https://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 use of the Buffer() constructor
18
+ // https://eslint.org/docs/rules/no-buffer-constructor
19
+ "no-buffer-constructor": "error",
20
+
21
+ // disallow mixing regular variable and require declarations
22
+ "no-mixed-requires": ["off", false],
23
+
24
+ // disallow use of new operator with the require function
25
+ "no-new-require": "error",
26
+
27
+ // disallow string concatenation with __dirname and __filename
28
+ // https://eslint.org/docs/rules/no-path-concat
29
+ "no-path-concat": "error",
30
+
31
+ // disallow use of process.env
32
+ "no-process-env": "off",
33
+
34
+ // disallow process.exit()
35
+ "no-process-exit": "off",
36
+
37
+ // restrict usage of specified node modules
38
+ "no-restricted-modules": "off",
39
+
40
+ // disallow use of synchronous methods (off by default)
41
+ "no-sync": "off",
42
+ },
43
+ };