@aryaemami59/eslint-config 0.0.4 → 0.0.5

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.
package/src/utils.ts ADDED
@@ -0,0 +1,93 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+ import type { ConfigWithExtends } from './external.js'
3
+ import { config } from './external.js'
4
+ import { flatESLintConfig } from './shareableConfigs.js'
5
+
6
+ /**
7
+ * A function that returns {@linkcode flatESLintConfig}
8
+ * along with optional additional overrides.
9
+ * It's made mainly to provide intellisense and eliminate
10
+ * the need for manual type annotations using JSDoc comments.
11
+ *
12
+ * @param [additionalOverrides] - **Optional** additional overrides to apply to the configuration.
13
+ * @returns An augmented version of the default {@linkcode flatESLintConfig}, incorporating any provided overrides.
14
+ *
15
+ * @example
16
+ * <caption>#### __ECMAScript Modules (ESM) usage inside a file like `eslint.config.mts` or `eslint.config.mjs`__</caption>
17
+ *
18
+ * ```ts
19
+ * import { createESLintConfig } from '@aryaemami59/eslint-config'
20
+ *
21
+ * export default createESLintConfig([
22
+ * {
23
+ * rules: {
24
+ * 'no-console': [0],
25
+ * },
26
+ * },
27
+ * {
28
+ * // ...Other additional overrides
29
+ * },
30
+ * ])
31
+ * ```
32
+ *
33
+ * @example
34
+ * <caption>#### __CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using `require`)__</caption>
35
+ *
36
+ * ```ts
37
+ * const { createESLintConfig } = require('@aryaemami59/eslint-config')
38
+ *
39
+ * module.exports = createESLintConfig([
40
+ * {
41
+ * rules: {
42
+ * 'no-console': [0],
43
+ * },
44
+ * },
45
+ * {
46
+ * // ...Other additional overrides
47
+ * },
48
+ * ])
49
+ * ```
50
+ *
51
+ * @example
52
+ * <caption>#### __CommonJS (CJS) usage inside a file like `eslint.config.cts` or `eslint.config.cjs` (using dynamic import)__</caption>
53
+ *
54
+ * ```ts
55
+ * module.exports = (async () =>
56
+ * (await import('@aryaemami59/eslint-config')).createESLintConfig([
57
+ * {
58
+ * rules: {
59
+ * 'no-console': [0],
60
+ * },
61
+ * },
62
+ * {
63
+ * // ...Other additional overrides
64
+ * },
65
+ * ]))()
66
+ * ```
67
+ *
68
+ * @example
69
+ * <caption>#### __CommonJS (CJS) usage inside a file like `eslint.config.cts` (using import and export assignment)__</caption>
70
+ *
71
+ * ```ts
72
+ * import eslintConfigModule = require('@aryaemami59/eslint-config')
73
+ * import createESLintConfig = eslintConfigModule.createESLintConfig
74
+ *
75
+ * export = createESLintConfig([
76
+ * {
77
+ * rules: {
78
+ * 'no-console': [0],
79
+ * },
80
+ * },
81
+ * {
82
+ * // ...Other additional overrides
83
+ * },
84
+ * ])
85
+ * ```
86
+ *
87
+ * @since 0.0.3
88
+ * @public
89
+ */
90
+ export const createESLintConfig = (
91
+ additionalOverrides: ConfigWithExtends[] = [],
92
+ ): TSESLint.FlatConfig.Config[] =>
93
+ /* @__PURE__ */ config(...flatESLintConfig, ...additionalOverrides)