@@ -5,23 +5,21 @@ import {
5
5
} from "@typescript-eslint/utils/json-schema" ;
6
6
import { type RuleContext } from "@typescript-eslint/utils/ts-eslint" ;
7
7
import { deepmerge } from "deepmerge-ts" ;
8
- import typeMatchesSpecifier , {
9
- type TypeDeclarationSpecifier ,
10
- } from "ts-declaration-location" ;
11
8
12
9
import {
10
+ getCoreOptions ,
13
11
ignoreIdentifierPatternOptionSchema ,
14
12
ignorePrefixSelectorOptionSchema ,
15
13
shouldIgnorePattern ,
16
14
type IgnoreIdentifierPatternOption ,
17
15
type IgnorePrefixSelectorOption ,
16
+ type OverridableOptions ,
18
17
} from "#eslint-plugin-functional/options" ;
19
18
import { typeSpecifiersSchema } from "#eslint-plugin-functional/utils/common-schemas" ;
20
19
import { ruleNameScope } from "#eslint-plugin-functional/utils/misc" ;
21
20
import { type ESFunction } from "#eslint-plugin-functional/utils/node-types" ;
22
21
import {
23
22
createRuleUsingFunction ,
24
- getTypeOfNode ,
25
23
type NamedCreateRuleCustomMeta ,
26
24
type RuleResult ,
27
25
} from "#eslint-plugin-functional/utils/rule" ;
@@ -71,21 +69,7 @@ type CoreOptions = {
71
69
type Options = [
72
70
IgnoreIdentifierPatternOption &
73
71
IgnorePrefixSelectorOption &
74
- CoreOptions & {
75
- overrides ?: Array <
76
- {
77
- specifiers : TypeDeclarationSpecifier | TypeDeclarationSpecifier [ ] ;
78
- } & (
79
- | {
80
- options : CoreOptions ;
81
- disable ?: false ;
82
- }
83
- | {
84
- disable : true ;
85
- }
86
- )
87
- > ;
88
- } ,
72
+ OverridableOptions < CoreOptions > ,
89
73
] ;
90
74
91
75
const coreOptionsPropertiesSchema : JSONSchema4ObjectSchema [ "properties" ] = {
@@ -207,39 +191,6 @@ const meta: NamedCreateRuleCustomMeta<keyof typeof errorMessages, Options> = {
207
191
schema,
208
192
} ;
209
193
210
- /**
211
- * Get the core options to use, taking into account overrides.
212
- */
213
- function getCoreOptions (
214
- node : TSESTree . Node ,
215
- context : Readonly < RuleContext < keyof typeof errorMessages , Options > > ,
216
- options : Readonly < Options > ,
217
- ) : CoreOptions | null {
218
- const [ optionsObject ] = options ;
219
-
220
- const program = context . sourceCode . parserServices ?. program ?? undefined ;
221
- if ( program === undefined ) {
222
- return optionsObject ;
223
- }
224
-
225
- const type = getTypeOfNode ( node , context ) ;
226
- const found = optionsObject . overrides ?. find ( ( override ) =>
227
- ( Array . isArray ( override . specifiers )
228
- ? override . specifiers
229
- : [ override . specifiers ]
230
- ) . some ( ( specifier ) => typeMatchesSpecifier ( program , specifier , type ) ) ,
231
- ) ;
232
-
233
- if ( found !== undefined ) {
234
- if ( found . disable === true ) {
235
- return null ;
236
- }
237
- return found . options ;
238
- }
239
-
240
- return optionsObject ;
241
- }
242
-
243
194
/**
244
195
* Get the rest parameter violations.
245
196
*/
@@ -324,7 +275,11 @@ function checkFunction(
324
275
} ;
325
276
}
326
277
327
- const optionsToUse = getCoreOptions ( node , context , options ) ;
278
+ const optionsToUse = getCoreOptions < CoreOptions , Options > (
279
+ node ,
280
+ context ,
281
+ options ,
282
+ ) ;
328
283
329
284
return {
330
285
context,
@@ -367,7 +322,7 @@ function checkIdentifier(
367
322
const optionsToUse =
368
323
functionNode === null
369
324
? optionsObject
370
- : getCoreOptions ( functionNode , context , options ) ;
325
+ : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ;
371
326
if ( optionsToUse === null ) {
372
327
return {
373
328
context,
0 commit comments