Skip to content

Commit

Permalink
Merge branch 'master' into update-eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Aug 26, 2023
2 parents f025ac4 + 1dea921 commit effd266
Show file tree
Hide file tree
Showing 11 changed files with 542 additions and 115 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
"no-warning-comments": "warn",
"no-lonely-if": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-duplicate-imports": "error",

"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/require-unicode-regexp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function isSyntacticallyCompatible(pattern: Pattern): false | Pattern {
pattern.raw,
undefined,
undefined,
true,
{ unicode: true },
)
} catch (_error) {
return false
Expand Down
10 changes: 4 additions & 6 deletions lib/rules/strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
defineRegexpVisitor,
isEscapeSequence,
} from "../utils"
import type { ReadonlyFlags } from "regexp-ast-analysis"

const validator = new RegExpValidator({ strict: true, ecmaVersion: 2020 })

Expand All @@ -21,10 +22,10 @@ const validator = new RegExpValidator({ strict: true, ecmaVersion: 2020 })
*/
function validateRegExpPattern(
pattern: string,
uFlag?: boolean,
flags: ReadonlyFlags,
): string | null {
try {
validator.validatePattern(pattern, undefined, undefined, uFlag)
validator.validatePattern(pattern, undefined, undefined, flags)
return null
} catch (err) {
return err instanceof Error ? err.message : null
Expand Down Expand Up @@ -272,10 +273,7 @@ export default createRule("strict", {
// our own logic couldn't find any problems,
// so let's use a real parser to do the job.

const message = validateRegExpPattern(
pattern,
flags.unicode,
)
const message = validateRegExpPattern(pattern, flags)

if (message) {
context.report({
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ function buildRegexpVisitor(
patternSource.value,
0,
patternSource.value.length,
flags.unicode,
flags,
)
} catch (error: unknown) {
if (error instanceof SyntaxError) {
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/regexp-ast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export function getRegExpNodeFromExpression(
node.regex.pattern,
0,
node.regex.pattern.length,
node.regex.flags.includes("u"),
{
unicode: node.regex.flags.includes("u"),
unicodeSets: node.regex.flags.includes("v"),
},
)
} catch {
return null
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/type-tracker/jsdoc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Rule, SourceCode, AST } from "eslint"
import type * as ES from "estree"
import { isCommentToken } from "@eslint-community/eslint-utils"
import * as commentParser from "comment-parser"
import type { Spec } from "comment-parser/lib/primitives"
import type { Spec } from "comment-parser"
// @ts-expect-error -- no type
import * as jsdocTypeParser from "jsdoctypeparser"
import type { JSDocTypeNode } from "./jsdoctypeparser-ast"
Expand Down
1 change: 0 additions & 1 deletion lib/utils/type-tracker/type-data/union-or-intersection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class TypeUnionOrIntersection implements ITypeClass {
}

public typeNames(): string[] {
// eslint-disable-next-line @typescript-eslint/require-array-sort-compare -- ignore
return [...this.collection.strings()].sort()
}

Expand Down
Loading

0 comments on commit effd266

Please sign in to comment.