11import type { TSESTree } from "@typescript-eslint/utils" ;
2- import type { JSONSchema4 } from "@typescript-eslint/utils/json-schema" ;
2+ import type { JSONSchema4 , JSONSchema4ObjectSchema } from "@typescript-eslint/utils/json-schema" ;
33import type { RuleContext } from "@typescript-eslint/utils/ts-eslint" ;
4+ import { deepmerge } from "deepmerge-ts" ;
45import type { Type } from "typescript" ;
56
67import tsApiUtils from "#/conditional-imports/ts-api-utils" ;
8+ import { type IgnoreCodePatternOption , ignoreCodePatternOptionSchema , shouldIgnorePattern } from "#/options" ;
79import { ruleNameScope } from "#/utils/misc" ;
810import { type NamedCreateRuleCustomMeta , type Rule , type RuleResult , createRule , getTypeOfNode } from "#/utils/rule" ;
911import {
@@ -32,7 +34,7 @@ export const fullName: `${typeof ruleNameScope}/${typeof name}` = `${ruleNameSco
3234 * The options this rule can take.
3335 */
3436type Options = [
35- {
37+ IgnoreCodePatternOption & {
3638 allowReturningBranches : boolean | "ifExhaustive" ;
3739 } ,
3840] ;
@@ -43,7 +45,7 @@ type Options = [
4345const schema : JSONSchema4 [ ] = [
4446 {
4547 type : "object" ,
46- properties : {
48+ properties : deepmerge ( ignoreCodePatternOptionSchema , {
4749 allowReturningBranches : {
4850 oneOf : [
4951 {
@@ -55,7 +57,7 @@ const schema: JSONSchema4[] = [
5557 } ,
5658 ] ,
5759 } ,
58- } ,
60+ } satisfies JSONSchema4ObjectSchema [ "properties" ] ) ,
5961 additionalProperties : false ,
6062 } ,
6163] ;
@@ -273,7 +275,14 @@ function checkIfStatement(
273275 context : Readonly < RuleContext < keyof typeof errorMessages , Options > > ,
274276 options : Readonly < Options > ,
275277) : RuleResult < keyof typeof errorMessages , Options > {
276- const [ { allowReturningBranches } ] = options ;
278+ const [ { allowReturningBranches, ignoreCodePattern } ] = options ;
279+
280+ if ( shouldIgnorePattern ( node . test , context , undefined , undefined , ignoreCodePattern ) ) {
281+ return {
282+ context,
283+ descriptors : [ ] ,
284+ } ;
285+ }
277286
278287 return {
279288 context,
0 commit comments