Skip to content

Commit 914702d

Browse files
authored
chore: fix CI error (#777)
* chore: fix ci error * fix * fix
1 parent 3567f9f commit 914702d

File tree

9 files changed

+273
-134
lines changed

9 files changed

+273
-134
lines changed

.github/workflows/NodeCI.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ jobs:
3434
run: npm ci
3535
- name: Install ESLint ${{ matrix.eslint }}
3636
run: npm i -D eslint@${{ matrix.eslint }}
37-
- name: Build
38-
run: npm run build
3937
- name: Test
4038
run: npm test
4139
test-and-coverage:

lib/utils/ast-utils/pattern-source.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import type { Rule, AST, SourceCode } from "eslint"
2-
import type { Expression, Literal, RegExpLiteral } from "estree"
2+
import type {
3+
Expression,
4+
Literal,
5+
RegExpLiteral,
6+
PrivateIdentifier,
7+
} from "estree"
38
import {
49
dereferenceOwnedVariable,
510
astRangeToLocation,
@@ -266,6 +271,7 @@ export class PatternSource {
266271
let value = ""
267272

268273
for (const e of flat) {
274+
if (e.type === "PrivateIdentifier") return null
269275
const staticValue = getStaticValue(context, e)
270276
if (!staticValue) {
271277
return null
@@ -433,10 +439,15 @@ export class PatternSource {
433439
*
434440
* This will automatically dereference owned constants.
435441
*/
436-
function flattenPlus(context: Rule.RuleContext, e: Expression): Expression[] {
442+
function flattenPlus(
443+
context: Rule.RuleContext,
444+
e: Expression,
445+
): (Expression | PrivateIdentifier)[] {
437446
if (e.type === "BinaryExpression" && e.operator === "+") {
438447
return [
439-
...flattenPlus(context, e.left),
448+
...(e.left.type !== "PrivateIdentifier"
449+
? flattenPlus(context, e.left)
450+
: [e.left]),
440451
...flattenPlus(context, e.right),
441452
]
442453
}

lib/utils/regexp-ast/is-covered.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ function normalizeNodeWithoutCache(
481481

482482
case "Backreference":
483483
case "Flags":
484+
case "ModifierFlags":
485+
case "Modifiers":
484486
return NormalizedOther.fromNode(node)
485487

486488
default:

lib/utils/regexp-ast/is-equals.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ const EQUALS_CHECKER: {
141141
Group(a, b, flags, shortCircuit) {
142142
return isEqualSet(a.alternatives, b.alternatives, flags, shortCircuit)
143143
},
144+
ModifierFlags(a, b) {
145+
return (
146+
a.dotAll === b.dotAll &&
147+
a.ignoreCase === b.ignoreCase &&
148+
a.multiline === b.multiline
149+
)
150+
},
151+
Modifiers(a, b, flags, shortCircuit) {
152+
return (
153+
isEqualNodes(a.add, b.add, flags, shortCircuit) &&
154+
((a.remove == null && b.remove == null) ||
155+
(a.remove != null &&
156+
b.remove != null &&
157+
isEqualNodes(a.remove, b.remove, flags, shortCircuit)))
158+
)
159+
},
144160
Pattern(a, b, flags, shortCircuit) {
145161
return isEqualSet(a.alternatives, b.alternatives, flags, shortCircuit)
146162
},

lib/utils/type-tracker/jsdoc.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ export class JSDoc {
109109
* Get the JSDoc comment for a given expression node.
110110
*/
111111
export function getJSDoc(
112-
node: ES.Expression | ES.VariableDeclarator | ES.FunctionDeclaration,
112+
node:
113+
| ES.Expression
114+
| ES.VariableDeclarator
115+
| ES.FunctionDeclaration
116+
| ES.PrivateIdentifier,
113117
context: Rule.RuleContext,
114118
): JSDoc | null {
115119
const sourceCode = context.sourceCode

lib/utils/type-tracker/tracker.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ export function createTypeTracker(context: Rule.RuleContext): TypeTracker {
7474

7575
const { tsNodeMap, checker, usedTS } = getTypeScriptTools(context)
7676

77-
const cacheTypeInfo = new WeakMap<ES.Expression, TypeInfo | null>()
77+
const cacheTypeInfo = new WeakMap<
78+
ES.Expression | ES.PrivateIdentifier,
79+
TypeInfo | null
80+
>()
7881

7982
const tracker: TypeTracker = {
8083
isString,
@@ -129,7 +132,9 @@ export function createTypeTracker(context: Rule.RuleContext): TypeTracker {
129132
/**
130133
* Get the type name from given node.
131134
*/
132-
function getType(node: ES.Expression): TypeInfo | null {
135+
function getType(
136+
node: ES.Expression | ES.PrivateIdentifier,
137+
): TypeInfo | null {
133138
if (cacheTypeInfo.has(node)) {
134139
return cacheTypeInfo.get(node) ?? null
135140
}
@@ -147,7 +152,9 @@ export function createTypeTracker(context: Rule.RuleContext): TypeTracker {
147152
/**
148153
* Get the type name from given node.
149154
*/
150-
function getTypeWithoutCache(node: ES.Expression): TypeInfo | null {
155+
function getTypeWithoutCache(
156+
node: ES.Expression | ES.PrivateIdentifier,
157+
): TypeInfo | null {
151158
if (node.type === "Literal") {
152159
if (typeof node.value === "string") {
153160
return STRING
@@ -511,7 +518,9 @@ export function createTypeTracker(context: Rule.RuleContext): TypeTracker {
511518
/**
512519
* Get type from given node by ts types.
513520
*/
514-
function getTypeByTs(node: ES.Expression): TypeInfo | null {
521+
function getTypeByTs(
522+
node: ES.Expression | ES.PrivateIdentifier,
523+
): TypeInfo | null {
515524
const tsNode = tsNodeMap.get(node)
516525
const tsType = (tsNode && checker?.getTypeAtLocation(tsNode)) || null
517526
return tsType && getTypeFromTsType(tsType)

lib/utils/type-tracker/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { Rule } from "eslint"
2-
import type { Variable } from "eslint-scope"
1+
import type { Rule, Scope } from "eslint"
32
import type * as ES from "estree"
43
import * as astUtils from "../ast-utils"
54
import * as eslintUtils from "@eslint-community/eslint-utils"
@@ -10,7 +9,7 @@ import * as eslintUtils from "@eslint-community/eslint-utils"
109
export function findVariable(
1110
context: Rule.RuleContext,
1211
node: ES.Identifier,
13-
): Variable | null {
12+
): Scope.Variable | null {
1413
return astUtils.findVariable(context, node)
1514
}
1615
/**

0 commit comments

Comments
 (0)