@@ -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" ;
@@ -69,23 +67,7 @@ type CoreOptions = IgnoreIdentifierPatternOption &
69
67
/**
70
68
* The options this rule can take.
71
69
*/
72
- type Options = [
73
- CoreOptions & {
74
- overrides ?: Array <
75
- {
76
- specifiers : TypeDeclarationSpecifier | TypeDeclarationSpecifier [ ] ;
77
- } & (
78
- | {
79
- options : CoreOptions ;
80
- disable ?: false ;
81
- }
82
- | {
83
- disable : true ;
84
- }
85
- )
86
- > ;
87
- } ,
88
- ] ;
70
+ type Options = [ OverridableOptions < CoreOptions > ] ;
89
71
90
72
const coreOptionsPropertiesSchema : JSONSchema4ObjectSchema [ "properties" ] = {
91
73
allowRestParameter : {
@@ -206,39 +188,6 @@ const meta: NamedCreateRuleCustomMeta<keyof typeof errorMessages, Options> = {
206
188
schema,
207
189
} ;
208
190
209
- /**
210
- * Get the core options to use, taking into account overrides.
211
- */
212
- function getCoreOptions (
213
- node : TSESTree . Node ,
214
- context : Readonly < RuleContext < keyof typeof errorMessages , Options > > ,
215
- options : Readonly < Options > ,
216
- ) : CoreOptions | null {
217
- const [ optionsObject ] = options ;
218
-
219
- const program = context . sourceCode . parserServices ?. program ?? undefined ;
220
- if ( program === undefined ) {
221
- return optionsObject ;
222
- }
223
-
224
- const type = getTypeOfNode ( node , context ) ;
225
- const found = optionsObject . overrides ?. find ( ( override ) =>
226
- ( Array . isArray ( override . specifiers )
227
- ? override . specifiers
228
- : [ override . specifiers ]
229
- ) . some ( ( specifier ) => typeMatchesSpecifier ( program , specifier , type ) ) ,
230
- ) ;
231
-
232
- if ( found !== undefined ) {
233
- if ( found . disable === true ) {
234
- return null ;
235
- }
236
- return found . options ;
237
- }
238
-
239
- return optionsObject ;
240
- }
241
-
242
191
/**
243
192
* Get the rest parameter violations.
244
193
*/
@@ -313,7 +262,11 @@ function checkFunction(
313
262
context : Readonly < RuleContext < keyof typeof errorMessages , Options > > ,
314
263
options : Readonly < Options > ,
315
264
) : RuleResult < keyof typeof errorMessages , Options > {
316
- const optionsToUse = getCoreOptions ( node , context , options ) ;
265
+ const optionsToUse = getCoreOptions < CoreOptions , Options > (
266
+ node ,
267
+ context ,
268
+ options ,
269
+ ) ;
317
270
318
271
if ( optionsToUse === null ) {
319
272
return {
@@ -359,7 +312,7 @@ function checkIdentifier(
359
312
const optionsToUse =
360
313
functionNode === null
361
314
? options [ 0 ]
362
- : getCoreOptions ( functionNode , context , options ) ;
315
+ : getCoreOptions < CoreOptions , Options > ( functionNode , context , options ) ;
363
316
364
317
if ( optionsToUse === null ) {
365
318
return {
0 commit comments