Skip to content

Commit d49c846

Browse files
Upgrade to RAA v0.4.1 (#415)
* Upgrade to RAA v0.4.0 * Use old package-lock format * Update to RAA v0.4.1 * Adjusted no-dupe-disjunctions tests
1 parent 6946393 commit d49c846

File tree

9 files changed

+100
-1488
lines changed

9 files changed

+100
-1488
lines changed

lib/rules/no-dupe-disjunctions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import {
3333
hasSomeDescendant,
3434
getMatchingDirection,
3535
getEffectiveMaximumRepetition,
36+
canReorder,
3637
} from "regexp-ast-analysis"
3738
import { RegExpParser } from "regexpp"
3839
import { UsageOfPattern } from "../utils/get-usage-of-pattern"
39-
import { canReorder } from "../utils/reorder-alternatives"
4040
import { mention, mentionChar } from "../utils/mention"
4141
import type { NestedAlternative } from "../utils/partial-parser"
4242
import { PartialParser } from "../utils/partial-parser"

lib/rules/sort-alternatives.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ import {
1212
createRule,
1313
defineRegexpVisitor,
1414
} from "../utils"
15-
import type { ReadonlyFlags } from "regexp-ast-analysis"
15+
import type {
16+
GetLongestPrefixOptions,
17+
ReadonlyFlags,
18+
} from "regexp-ast-analysis"
1619
import {
1720
Chars,
1821
getFirstConsumedChar,
1922
hasSomeDescendant,
23+
canReorder,
24+
getLongestPrefix,
2025
} from "regexp-ast-analysis"
2126
import type { CharSet } from "refa"
2227
import { JS } from "refa"
23-
import { canReorder } from "../utils/reorder-alternatives"
2428
import { getPossiblyConsumedChar } from "../utils/regexp-ast"
25-
import { getLongestPrefix } from "../utils/regexp-ast/alternative-prefix"
2629

2730
interface AllowedChars {
2831
allowed: CharSet
@@ -147,6 +150,11 @@ function compareCharSetStrings(
147150
return a.length - b.length
148151
}
149152

153+
const LONGEST_PREFIX_OPTIONS: GetLongestPrefixOptions = {
154+
includeAfter: true,
155+
looseGroups: true,
156+
}
157+
150158
/**
151159
* Sorts the given alternatives.
152160
*/
@@ -166,8 +174,8 @@ function sortAlternatives(
166174

167175
alternatives.sort((a, b) => {
168176
const prefixDiff = compareCharSetStrings(
169-
getLongestPrefix(a, "ltr", flags),
170-
getLongestPrefix(b, "ltr", flags),
177+
getLongestPrefix(a, "ltr", flags, LONGEST_PREFIX_OPTIONS),
178+
getLongestPrefix(b, "ltr", flags, LONGEST_PREFIX_OPTIONS),
171179
)
172180
if (prefixDiff !== 0) {
173181
return prefixDiff

lib/utils/regexp-ast/alternative-prefix.ts

Lines changed: 0 additions & 237 deletions
This file was deleted.

0 commit comments

Comments
 (0)