Skip to content

Commit f88a8c9

Browse files
authored
refactor: use non-capturing groups for perf (#123)
1 parent ee1222c commit f88a8c9

File tree

5 files changed

+932
-1255
lines changed

5 files changed

+932
-1255
lines changed

Diff for: .changeset/sharp-buttons-smash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-import-resolver-typescript": patch
3+
---
4+
5+
refactor: use non-capturing groups for perf

Diff for: package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"license": "ISC",
1212
"packageManager": "[email protected]",
1313
"engines": {
14-
"node": "^12.20 || ^14.18.0 || >=16.0.0"
14+
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
1515
},
1616
"main": "lib/index.cjs",
1717
"module": "lib/index.js",
@@ -71,7 +71,7 @@
7171
"synckit": "^0.7.1"
7272
},
7373
"devDependencies": {
74-
"@1stg/lib-config": "^7.1.0",
74+
"@1stg/lib-config": "^7.2.0",
7575
"@changesets/changelog-github": "^0.4.5",
7676
"@changesets/cli": "^2.23.0",
7777
"@mozilla/glean": "^1.0.0",
@@ -83,7 +83,6 @@
8383
"@types/unist": "^2.0.6",
8484
"dummy.js": "link:dummy.js",
8585
"react": "^18.2.0",
86-
"standard-version": "^9.5.0",
8786
"type-coverage": "^2.21.2",
8887
"typescript": "^4.7.4"
8988
},

Diff for: src/.eslintrc

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"extends": "@1stg",
3-
"rules": {
4-
"regexp/no-unused-capturing-group": "off"
5-
}
2+
"extends": "@1stg"
63
}

Diff for: src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@ function removeQuerystring(id: string) {
231231
return id
232232
}
233233

234+
const JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/
235+
const RELATIVE_PATH_PATTERN = /^\.{1,2}(?:\/.*)?$/
236+
234237
/** Remove .js or .jsx extension from module id. */
235238
function removeJsExtension(id: string) {
236-
return id.replace(/\.([cm]js|jsx?)$/, '')
239+
return id.replace(JS_EXT_PATTERN, '')
237240
}
238241

239-
const JS_EXT_PATTERN = /\.([cm]js|jsx?)$/
240-
const RELATIVE_PATH_PATTERN = /^\.{1,2}(\/.*)?$/
241-
242242
const isFile = (path?: string | undefined): path is string => {
243243
try {
244244
return !!path && fs.statSync(path).isFile()

0 commit comments

Comments
 (0)