Skip to content

Commit aaa673f

Browse files
committed
chore: fix type errors
1 parent 1218672 commit aaa673f

27 files changed

+162
-116
lines changed

lib/rules/letter-case.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {
33
CharacterClassRange,
44
} from "@eslint-community/regexpp/ast"
55
import type { RegExpVisitor } from "@eslint-community/regexpp/visitor"
6+
import type { ObjectOption } from "../types"
67
import type { RegExpContext } from "../utils"
78
import {
89
createRule,
@@ -88,7 +89,7 @@ export default createRule("letter-case", {
8889
type: "layout", // "problem",
8990
},
9091
create(context) {
91-
const options = parseOptions(context.options[0])
92+
const options = parseOptions(context.options[0] as ObjectOption)
9293

9394
function report(
9495
{ node, getRegexpLocation, fixReplaceNode }: RegExpContext,

lib/rules/match-any.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import type { RegExpVisitor } from "@eslint-community/regexpp/visitor"
77
import type { Rule } from "eslint"
88
import { matchesAllCharacters, hasStrings } from "regexp-ast-analysis"
9+
import type { ObjectOption } from "../types"
910
import type { RegExpContext } from "../utils"
1011
import { createRule, defineRegexpVisitor } from "../utils"
1112
import { isRegexpLiteral } from "../utils/ast-utils/utils"
@@ -58,10 +59,8 @@ export default createRule("match-any", {
5859
},
5960
create(context) {
6061
const sourceCode = context.sourceCode
61-
const allowList: Allowed[] = context.options[0]?.allows ?? [
62-
OPTION_SS1,
63-
OPTION_DOTALL,
64-
]
62+
const allowList: Allowed[] = (context.options[0] as ObjectOption)
63+
?.allows ?? [OPTION_SS1, OPTION_DOTALL]
6564
const allows = new Set<string>(allowList)
6665

6766
const preference: Allowed | null = allowList[0] || null

lib/rules/no-dupe-disjunctions.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
getEffectiveMaximumRepetition,
2929
canReorder,
3030
} from "regexp-ast-analysis"
31+
import type { ObjectOption } from "../types"
3132
import type { RegExpContext } from "../utils"
3233
import {
3334
createRule,
@@ -969,12 +970,14 @@ export default createRule("no-dupe-disjunctions", {
969970
},
970971
create(context) {
971972
const reportExponentialBacktracking: ReportExponentialBacktracking =
972-
context.options[0]?.reportExponentialBacktracking ??
973+
(context.options[0] as ObjectOption)
974+
?.reportExponentialBacktracking ??
973975
ReportExponentialBacktracking.potential
974976
const reportUnreachable: ReportUnreachable =
975-
context.options[0]?.reportUnreachable ?? ReportUnreachable.certain
977+
(context.options[0] as ObjectOption)?.reportUnreachable ??
978+
ReportUnreachable.certain
976979
const report: ReportOption =
977-
context.options[0]?.report ?? ReportOption.trivial
980+
(context.options[0] as ObjectOption)?.report ?? ReportOption.trivial
978981

979982
const allowedRanges = getAllowedCharRanges(undefined, context)
980983

lib/rules/no-lazy-ends.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Alternative, Quantifier } from "@eslint-community/regexpp/ast"
22
import type { RegExpVisitor } from "@eslint-community/regexpp/visitor"
33
import type { Rule } from "eslint"
4+
import type { ObjectOption } from "../types"
45
import type { RegExpContext } from "../utils"
56
import { createRule, defineRegexpVisitor } from "../utils"
67
import { UsageOfPattern } from "../utils/get-usage-of-pattern"
@@ -79,7 +80,8 @@ export default createRule("no-lazy-ends", {
7980
type: "problem",
8081
},
8182
create(context) {
82-
const ignorePartial = context.options[0]?.ignorePartial ?? true
83+
const ignorePartial =
84+
(context.options[0] as ObjectOption)?.ignorePartial ?? true
8385

8486
function createVisitor({
8587
node,

lib/rules/no-legacy-features.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { MemberExpression } from "estree"
2+
import type { ObjectOption } from "../types"
23
import { createRule } from "../utils"
34
import { createTypeTracker } from "../utils/type-tracker"
45
import type { TYPES } from "@eslint-community/eslint-utils"
@@ -83,9 +84,11 @@ export default createRule("no-legacy-features", {
8384
},
8485
create(context) {
8586
const staticProperties: StaticProperty[] =
86-
context.options[0]?.staticProperties ?? STATIC_PROPERTIES
87+
(context.options[0] as ObjectOption)?.staticProperties ??
88+
STATIC_PROPERTIES
8789
const prototypeMethods: PrototypeMethod[] =
88-
context.options[0]?.prototypeMethods ?? PROTOTYPE_METHODS
90+
(context.options[0] as ObjectOption)?.prototypeMethods ??
91+
PROTOTYPE_METHODS
8992
const typeTracer = createTypeTracker(context)
9093

9194
return {

lib/rules/no-misleading-capturing-group.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
followPaths,
2020
toUnicodeSet,
2121
} from "regexp-ast-analysis"
22+
import type { ObjectOption } from "../types"
2223
import type { RegExpContext } from "../utils"
2324
import { createRule, defineRegexpVisitor } from "../utils"
2425
import { fixSimplifyQuantifier } from "../utils/fix-simplify-quantifier"
@@ -291,7 +292,7 @@ export default createRule("no-misleading-capturing-group", {
291292
},
292293
create(context) {
293294
const reportBacktrackingEnds =
294-
context.options[0]?.reportBacktrackingEnds ?? true
295+
(context.options[0] as ObjectOption)?.reportBacktrackingEnds ?? true
295296

296297
function createVisitor(
297298
regexpContext: RegExpContext,

lib/rules/no-misleading-unicode-character.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import type { RegExpVisitor } from "@eslint-community/regexpp/visitor"
77
import type { Rule } from "eslint"
88
import type { ReadonlyFlags } from "regexp-ast-analysis"
9+
import type { ObjectOption } from "../types"
910
import type { RegExpContext } from "../utils"
1011
import { createRule, defineRegexpVisitor } from "../utils"
1112
import type { PatternRange } from "../utils/ast-utils/pattern-source"
@@ -225,7 +226,7 @@ export default createRule("no-misleading-unicode-character", {
225226
type: "problem",
226227
},
227228
create(context) {
228-
const fixable = context.options[0]?.fixable ?? false
229+
const fixable = (context.options[0] as ObjectOption)?.fixable ?? false
229230

230231
function makeFix(
231232
fix: Rule.ReportFixer,

lib/rules/no-missing-g-flag.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ObjectOption } from "../types"
12
import type { RegExpContext, UnparsableRegExpContext } from "../utils"
23
import { createRule, defineRegexpVisitor } from "../utils"
34
import type { ExpressionReference } from "../utils/ast-utils"
@@ -51,7 +52,7 @@ export default createRule("no-missing-g-flag", {
5152
type: "problem",
5253
},
5354
create(context) {
54-
const { strictTypes } = parseOption(context.options[0])
55+
const { strictTypes } = parseOption(context.options[0] as ObjectOption)
5556
const typeTracer = createTypeTracker(context)
5657

5758
/** The logic of this rule */

lib/rules/no-obscure-range.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { RegExpVisitor } from "@eslint-community/regexpp/visitor"
2+
import type { ObjectOption } from "../types"
23
import type { RegExpContext } from "../utils"
34
import { createRule, defineRegexpVisitor } from "../utils"
45
import {
@@ -38,7 +39,7 @@ export default createRule("no-obscure-range", {
3839
},
3940
create(context) {
4041
const allowedRanges = getAllowedCharRanges(
41-
context.options[0]?.allowed,
42+
(context.options[0] as ObjectOption)?.allowed,
4243
context,
4344
)
4445

lib/rules/no-super-linear-backtracking.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { RegExpVisitor } from "@eslint-community/regexpp/visitor"
22
import type { Position, SourceLocation } from "estree"
33
import { analyse } from "scslre"
4+
import type { ObjectOption } from "../types"
45
import type { RegExpContext } from "../utils"
56
import { createRule, defineRegexpVisitor } from "../utils"
67
import { UsageOfPattern } from "../utils/get-usage-of-pattern"
@@ -60,7 +61,8 @@ export default createRule("no-super-linear-backtracking", {
6061
},
6162
create(context) {
6263
const reportUncertain =
63-
(context.options[0]?.report ?? "certain") === "potential"
64+
((context.options[0] as ObjectOption)?.report ?? "certain") ===
65+
"potential"
6466

6567
function createVisitor(
6668
regexpContext: RegExpContext,

0 commit comments

Comments
 (0)