Skip to content

Commit 4b20166

Browse files
Upgrade to RAA v0.5.1 and improve sort-alternatives (#419)
* Upgrade to RAA v0.5.0 * Update to RAA v0.5.1 * Fix issue #416
1 parent 4686774 commit 4b20166

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

lib/rules/no-useless-assertions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export default createRule("no-useless-assertions", {
252252
const range = getLengthRange(assertion.alternatives)
253253
// we only check the first character, so it's only correct if the assertion requires only one
254254
// character
255-
if (range && range.max === 1) {
255+
if (range.max === 1) {
256256
// require exactness
257257
if (
258258
firstOf.exact &&

lib/rules/prefer-lookaround.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function getSideEffectsWhenReplacingCapturingGroup(
168168
/** Checks whether the given element is constant length. */
169169
function isConstantLength(target: Element): boolean {
170170
const range = getLengthRange(target)
171-
return Boolean(range && range.min === range.max)
171+
return range.min === range.max
172172
}
173173
}
174174

lib/rules/sort-alternatives.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function compareCharSetStrings(
152152

153153
const LONGEST_PREFIX_OPTIONS: GetLongestPrefixOptions = {
154154
includeAfter: true,
155+
onlyInside: true,
155156
looseGroups: true,
156157
}
157158

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"grapheme-splitter": "^1.0.4",
9595
"jsdoctypeparser": "^9.0.0",
9696
"refa": "^0.9.0",
97-
"regexp-ast-analysis": "^0.4.1",
97+
"regexp-ast-analysis": "^0.5.1",
9898
"regexpp": "^3.2.0",
9999
"scslre": "^0.1.6"
100100
}

tests/lib/rules/sort-alternatives.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ const tester = new RuleTester({
99
})
1010

1111
tester.run("sort-alternatives", rule as any, {
12-
valid: [String.raw`/\b(?:a|\d+|c|b)\b/`, String.raw`/\b(?:\^|c|b)\b/`],
12+
valid: [
13+
String.raw`/\b(?:a|\d+|c|b)\b/`,
14+
String.raw`/\b(?:\^|c|b)\b/`,
15+
String.raw`/^(?:a|ab)a/u`,
16+
String.raw`/^(?:a|ab)c/u`,
17+
String.raw`/^(?:deg|g?rad|turn)\b/`,
18+
],
1319
invalid: [
1420
{
1521
code: String.raw`/c|b|a/`,

0 commit comments

Comments
 (0)