@aryaemami59/eslint-config 0.0.5 → 0.0.7

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.
@@ -1,10 +1,9 @@
1
- import type { TSESLint } from '@typescript-eslint/utils'
2
- import type { Linter } from 'eslint'
1
+ import packageJson from '../package.json' with { type: 'json' }
3
2
  import { disabledRules } from './disabledRules.js'
4
- import { config, configs, js, prettierConfig } from './external.js'
3
+ import type { Config, FlatConfig, Linter } from './external.js'
4
+ import { js, prettierConfig } from './external.js'
5
5
  import { globalIgnores } from './globalIgnores.js'
6
6
  import { globals } from './globals.js'
7
- import { packageName } from './packageName.js'
8
7
 
9
8
  /**
10
9
  * Flat ESLint configuration tailored for projects using TypeScript.
@@ -48,199 +47,204 @@ import { packageName } from './packageName.js'
48
47
  * @since 0.0.3
49
48
  * @public
50
49
  */
51
- export const flatESLintConfig: TSESLint.FlatConfig.Config[] =
52
- /* @__PURE__ */ config(
53
- // `ignores` must be first.
54
- // config with just `ignores` is the replacement for `.eslintignore`
55
- globalIgnores,
50
+ export const flatESLintConfig = [
51
+ // `ignores` must be first.
52
+ // config with just `ignores` is the replacement for `.eslintignore`
53
+ globalIgnores,
56
54
 
57
- {
58
- name: `${js.meta.name}/recommended`,
59
- ...js.configs.recommended,
60
- } as const satisfies TSESLint.FlatConfig.Config satisfies Linter.Config,
55
+ {
56
+ name: `${js.meta.name}/recommended`,
57
+ ...js.configs.recommended,
58
+ } as const satisfies FlatConfig.Config satisfies Config,
61
59
 
62
- configs.recommended,
63
- configs.stylistic,
60
+ // TODO: You can remove the type assertion in the next major version of `typescript-eslint`.
61
+ // TODO: Uncomment this once https://github.com/typescript-eslint/typescript-eslint/issues/11952 is resolved.
62
+ // ...(configs.recommended satisfies Config[] as Config<any>[]),
63
+ // TODO: You can remove the type assertion in the next major version of `typescript-eslint`.
64
+ // TODO: Uncomment this once https://github.com/typescript-eslint/typescript-eslint/issues/11952 is resolved.
65
+ // ...(configs.stylistic satisfies Config[] as Config<any>[]),
64
66
 
65
- {
66
- name: `${packageName}/defaults/overrides`,
67
- languageOptions: {
68
- globals,
69
- parserOptions: {
70
- ecmaVersion: 'latest',
71
- projectService: true,
72
- },
73
- },
74
- rules: {
75
- '@typescript-eslint/consistent-type-imports': [
76
- 2,
77
- {
78
- disallowTypeAnnotations: true,
79
- fixStyle: 'separate-type-imports',
80
- prefer: 'type-imports',
81
- },
82
- ],
83
- '@typescript-eslint/consistent-type-exports': [
84
- 2,
85
- { fixMixedExportsWithInlineTypeSpecifier: false },
86
- ],
87
- '@typescript-eslint/no-explicit-any': [
88
- 2,
89
- {
90
- fixToUnknown: false,
91
- ignoreRestArgs: false,
92
- },
93
- ],
94
- '@typescript-eslint/no-empty-object-type': [
95
- 2,
96
- {
97
- allowInterfaces: 'never',
98
- allowObjectTypes: 'never',
99
- },
100
- ],
101
- '@typescript-eslint/no-restricted-types': [
102
- 2,
103
- {
104
- types: {
105
- '{}': {
106
- message: `
107
- - If you want to represent an empty object, use \`type EmptyObject = Record<string, never>\`.
108
- - If you want to represent an object literal, use either \`type AnyObject = Record<string, any>\` or \`object\`.
109
- - If you want to represent any non-nullish value, use \`type AnyNonNullishValue = NonNullable<unknown>\`.`,
110
- suggest: [
111
- 'AnyNonNullishValue',
112
- 'EmptyObject',
113
- 'AnyObject',
114
- 'object',
115
- 'Record<string, never>',
116
- 'Record<string, any>',
117
- 'NonNullable<unknown>',
118
- ],
119
- },
120
- },
121
- },
122
- ],
123
- '@typescript-eslint/no-namespace': [
124
- 2,
125
- {
126
- allowDeclarations: false,
127
- allowDefinitionFiles: true,
128
- },
129
- ],
130
- '@typescript-eslint/consistent-type-definitions': [2, 'type'],
131
- 'sort-imports': [
132
- 2,
133
- {
134
- allowSeparatedGroups: true,
135
- ignoreCase: false,
136
- ignoreDeclarationSort: true,
137
- ignoreMemberSort: false,
138
- memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
139
- },
140
- ],
141
- '@typescript-eslint/unified-signatures': [
142
- 2,
143
- {
144
- ignoreDifferentlyNamedParameters: false,
145
- ignoreOverloadsWithDifferentJSDoc: false,
146
- },
147
- ],
148
- '@typescript-eslint/no-unnecessary-type-parameters': [2],
149
- '@typescript-eslint/no-invalid-void-type': [
150
- 2,
151
- {
152
- allowAsThisParameter: false,
153
- allowInGenericTypeArguments: true,
154
- },
155
- ],
156
- '@typescript-eslint/no-confusing-void-expression': [
157
- 2,
158
- {
159
- ignoreArrowShorthand: false,
160
- ignoreVoidOperator: false,
161
- ignoreVoidReturningFunctions: false,
162
- },
163
- ],
164
- '@typescript-eslint/no-duplicate-type-constituents': [
165
- 2,
166
- {
167
- ignoreIntersections: false,
168
- ignoreUnions: false,
169
- },
170
- ],
171
- '@typescript-eslint/require-await': [2],
172
- '@typescript-eslint/no-redundant-type-constituents': [2],
173
- '@typescript-eslint/no-unnecessary-type-arguments': [2],
174
- '@typescript-eslint/no-unnecessary-type-assertion': [
175
- 2,
176
- { typesToIgnore: [] },
177
- ],
178
- '@typescript-eslint/prefer-nullish-coalescing': [
179
- 2,
180
- {
181
- allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
182
- ignoreBooleanCoercion: false,
183
- ignoreConditionalTests: true,
184
- ignoreIfStatements: false,
185
- ignoreMixedLogicalExpressions: false,
186
- ignorePrimitives: {
187
- bigint: false,
188
- boolean: false,
189
- number: false,
190
- string: false,
191
- },
192
- ignoreTernaryTests: false,
193
- },
194
- ],
195
- '@typescript-eslint/no-inferrable-types': [
196
- 2,
197
- {
198
- ignoreParameters: false,
199
- ignoreProperties: false,
200
- },
201
- ],
202
- '@typescript-eslint/no-require-imports': [
203
- 2,
204
- {
205
- allow: [],
206
- allowAsImport: true,
207
- },
208
- ],
209
- 'object-shorthand': [
210
- 2,
211
- 'always',
212
- {
213
- avoidExplicitReturnArrows: true,
214
- avoidQuotes: true,
215
- ignoreConstructors: true,
216
- methodsIgnorePattern: '',
217
- },
218
- ],
67
+ {
68
+ languageOptions: {
69
+ globals,
70
+ parserOptions: {
71
+ ecmaVersion: 'latest',
72
+ projectService: true,
73
+ } as const satisfies FlatConfig.ParserOptions satisfies Linter.ParserOptions,
74
+ },
75
+ linterOptions: {
76
+ reportUnusedDisableDirectives: 2,
77
+ reportUnusedInlineConfigs: 2,
78
+ },
79
+ name: `${packageJson.name}/defaults/overrides`,
219
80
 
220
- ...disabledRules,
221
- },
81
+ rules: {
82
+ // TODO: Uncomment this once https://github.com/typescript-eslint/typescript-eslint/issues/11952 is resolved.
83
+ // '@typescript-eslint/consistent-type-definitions': [2, 'type'],
84
+ // '@typescript-eslint/consistent-type-exports': [
85
+ // 2,
86
+ // { fixMixedExportsWithInlineTypeSpecifier: false },
87
+ // ],
88
+ // '@typescript-eslint/consistent-type-imports': [
89
+ // 2,
90
+ // {
91
+ // disallowTypeAnnotations: true,
92
+ // fixStyle: 'separate-type-imports',
93
+ // prefer: 'type-imports',
94
+ // },
95
+ // ],
96
+ // '@typescript-eslint/no-confusing-void-expression': [
97
+ // 2,
98
+ // {
99
+ // ignoreArrowShorthand: false,
100
+ // ignoreVoidOperator: false,
101
+ // ignoreVoidReturningFunctions: false,
102
+ // },
103
+ // ],
104
+ // '@typescript-eslint/no-duplicate-type-constituents': [
105
+ // 2,
106
+ // {
107
+ // ignoreIntersections: false,
108
+ // ignoreUnions: false,
109
+ // },
110
+ // ],
111
+ // '@typescript-eslint/no-empty-object-type': [
112
+ // 2,
113
+ // {
114
+ // allowInterfaces: 'never',
115
+ // allowObjectTypes: 'never',
116
+ // },
117
+ // ],
118
+ // '@typescript-eslint/no-explicit-any': [
119
+ // 2,
120
+ // {
121
+ // fixToUnknown: false,
122
+ // ignoreRestArgs: false,
123
+ // },
124
+ // ],
125
+ // '@typescript-eslint/no-inferrable-types': [
126
+ // 2,
127
+ // {
128
+ // ignoreParameters: false,
129
+ // ignoreProperties: false,
130
+ // },
131
+ // ],
132
+ // '@typescript-eslint/no-invalid-void-type': [
133
+ // 2,
134
+ // {
135
+ // allowAsThisParameter: false,
136
+ // allowInGenericTypeArguments: true,
137
+ // },
138
+ // ],
139
+ // '@typescript-eslint/no-namespace': [
140
+ // 2,
141
+ // {
142
+ // allowDeclarations: false,
143
+ // allowDefinitionFiles: true,
144
+ // },
145
+ // ],
146
+ // '@typescript-eslint/no-redundant-type-constituents': [2],
147
+ // '@typescript-eslint/no-require-imports': [
148
+ // 2,
149
+ // {
150
+ // allow: [],
151
+ // allowAsImport: true,
152
+ // },
153
+ // ],
154
+ // '@typescript-eslint/no-restricted-types': [
155
+ // 2,
156
+ // {
157
+ // types: {
158
+ // '{}': {
159
+ // message: `
160
+ // - If you want to represent an empty object, use \`type EmptyObject = Record<string, never>\`.
161
+ // - If you want to represent an object literal, use either \`type AnyObject = Record<string, any>\` or \`object\`.
162
+ // - If you want to represent any non-nullish value, use \`type AnyNonNullishValue = NonNullable<unknown>\`.`,
163
+ // suggest: [
164
+ // 'AnyNonNullishValue',
165
+ // 'EmptyObject',
166
+ // 'AnyObject',
167
+ // 'object',
168
+ // 'Record<string, never>',
169
+ // 'Record<string, any>',
170
+ // 'NonNullable<unknown>',
171
+ // ],
172
+ // },
173
+ // },
174
+ // },
175
+ // ],
176
+ // '@typescript-eslint/no-unnecessary-type-arguments': [2],
177
+ // '@typescript-eslint/no-unnecessary-type-assertion': [
178
+ // 2,
179
+ // { typesToIgnore: [] },
180
+ // ],
181
+ // '@typescript-eslint/no-unnecessary-type-parameters': [2],
182
+ // '@typescript-eslint/prefer-nullish-coalescing': [
183
+ // 2,
184
+ // {
185
+ // allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
186
+ // ignoreBooleanCoercion: false,
187
+ // ignoreConditionalTests: true,
188
+ // ignoreIfStatements: false,
189
+ // ignoreMixedLogicalExpressions: false,
190
+ // ignorePrimitives: {
191
+ // bigint: false,
192
+ // boolean: false,
193
+ // number: false,
194
+ // string: false,
195
+ // },
196
+ // ignoreTernaryTests: false,
197
+ // },
198
+ // ],
199
+ // '@typescript-eslint/require-await': [2],
200
+ // '@typescript-eslint/unified-signatures': [
201
+ // 2,
202
+ // {
203
+ // ignoreDifferentlyNamedParameters: false,
204
+ // ignoreOverloadsWithDifferentJSDoc: false,
205
+ // },
206
+ // ],
207
+ 'object-shorthand': [
208
+ 2,
209
+ 'always',
210
+ {
211
+ avoidExplicitReturnArrows: true,
212
+ avoidQuotes: true,
213
+ ignoreConstructors: true,
214
+ methodsIgnorePattern: '',
215
+ },
216
+ ],
217
+ 'sort-imports': [
218
+ 2,
219
+ {
220
+ allowSeparatedGroups: true,
221
+ ignoreCase: false,
222
+ ignoreDeclarationSort: true,
223
+ ignoreMemberSort: false,
224
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
225
+ },
226
+ ],
222
227
 
223
- linterOptions: {
224
- reportUnusedDisableDirectives: 2,
225
- },
226
- } as const satisfies TSESLint.FlatConfig.Config satisfies Linter.Config,
228
+ ...disabledRules,
229
+ },
230
+ } as const satisfies Config,
227
231
 
228
- {
229
- name: `${packageName}/commonjs-files`,
230
- files: ['**/*.cjs'],
231
- languageOptions: {
232
- sourceType: 'commonjs',
233
- },
234
- rules: {
235
- '@typescript-eslint/no-require-imports': [
236
- 0,
237
- {
238
- allow: [],
239
- allowAsImport: false,
240
- },
241
- ],
242
- },
243
- } as const satisfies TSESLint.FlatConfig.Config satisfies Linter.Config,
232
+ {
233
+ files: ['**/*.cjs'],
234
+ languageOptions: {
235
+ sourceType: 'commonjs',
236
+ } as const satisfies FlatConfig.LanguageOptions satisfies Linter.LanguageOptions,
237
+ name: `${packageJson.name}/commonjs-files`,
238
+ rules: {
239
+ '@typescript-eslint/no-require-imports': [
240
+ 0,
241
+ {
242
+ allow: [],
243
+ allowAsImport: false,
244
+ },
245
+ ],
246
+ },
247
+ } as const satisfies Config,
244
248
 
245
- prettierConfig,
246
- )
249
+ prettierConfig,
250
+ ] as const satisfies Config[]
package/src/utils.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type { TSESLint } from '@typescript-eslint/utils'
2
- import type { ConfigWithExtends } from './external.js'
3
- import { config } from './external.js'
1
+ import type { Config } from './external.js'
2
+ import { defineConfig } from './external.js'
4
3
  import { flatESLintConfig } from './shareableConfigs.js'
5
4
 
6
5
  /**
@@ -9,7 +8,7 @@ import { flatESLintConfig } from './shareableConfigs.js'
9
8
  * It's made mainly to provide intellisense and eliminate
10
9
  * the need for manual type annotations using JSDoc comments.
11
10
  *
12
- * @param [additionalOverrides] - **Optional** additional overrides to apply to the configuration.
11
+ * @param [additionalOverrides=[]] - **Optional** additional overrides to apply to the configuration.
13
12
  * @returns An augmented version of the default {@linkcode flatESLintConfig}, incorporating any provided overrides.
14
13
  *
15
14
  * @example
@@ -88,6 +87,6 @@ import { flatESLintConfig } from './shareableConfigs.js'
88
87
  * @public
89
88
  */
90
89
  export const createESLintConfig = (
91
- additionalOverrides: ConfigWithExtends[] = [],
92
- ): TSESLint.FlatConfig.Config[] =>
93
- /* @__PURE__ */ config(...flatESLintConfig, ...additionalOverrides)
90
+ additionalOverrides: Parameters<typeof defineConfig> = [],
91
+ ): Config[] =>
92
+ /* @__PURE__ */ defineConfig(...flatESLintConfig, ...additionalOverrides)