Skip to content

Commit

Permalink
refactor: use non-capturing groups for perf (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Jul 1, 2022
1 parent ee1222c commit f88a8c9
Show file tree
Hide file tree
Showing 5 changed files with 932 additions and 1,255 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-buttons-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-import-resolver-typescript": patch
---

refactor: use non-capturing groups for perf
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "ISC",
"packageManager": "yarn@1.22.19",
"engines": {
"node": "^12.20 || ^14.18.0 || >=16.0.0"
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
},
"main": "lib/index.cjs",
"module": "lib/index.js",
Expand Down Expand Up @@ -71,7 +71,7 @@
"synckit": "^0.7.1"
},
"devDependencies": {
"@1stg/lib-config": "^7.1.0",
"@1stg/lib-config": "^7.2.0",
"@changesets/changelog-github": "^0.4.5",
"@changesets/cli": "^2.23.0",
"@mozilla/glean": "^1.0.0",
Expand All @@ -83,7 +83,6 @@
"@types/unist": "^2.0.6",
"dummy.js": "link:dummy.js",
"react": "^18.2.0",
"standard-version": "^9.5.0",
"type-coverage": "^2.21.2",
"typescript": "^4.7.4"
},
Expand Down
5 changes: 1 addition & 4 deletions src/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": "@1stg",
"rules": {
"regexp/no-unused-capturing-group": "off"
}
"extends": "@1stg"
}
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ function removeQuerystring(id: string) {
return id
}

const JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/
const RELATIVE_PATH_PATTERN = /^\.{1,2}(?:\/.*)?$/

/** Remove .js or .jsx extension from module id. */
function removeJsExtension(id: string) {
return id.replace(/\.([cm]js|jsx?)$/, '')
return id.replace(JS_EXT_PATTERN, '')
}

const JS_EXT_PATTERN = /\.([cm]js|jsx?)$/
const RELATIVE_PATH_PATTERN = /^\.{1,2}(\/.*)?$/

const isFile = (path?: string | undefined): path is string => {
try {
return !!path && fs.statSync(path).isFile()
Expand Down
Loading

0 comments on commit f88a8c9

Please sign in to comment.