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