Skip to content

Commit 5f87698

Browse files
authored
feat: replace glob with tiny-glob for faster speed, close #12 (#13)
2 parents 5eb4874 + f436627 commit 5f87698

File tree

8 files changed

+57
-25
lines changed

8 files changed

+57
-25
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Add the following to your `.eslintrc` config:
6969

7070
// use a glob pattern
7171
"ts": {
72-
"directory": "./packages/**/tsconfig.json"
72+
"directory": "./packages/*/tsconfig.json"
7373
},
7474

7575
// use an array
@@ -83,8 +83,8 @@ Add the following to your `.eslintrc` config:
8383
// use an array of glob patterns
8484
"ts": {
8585
"directory": [
86-
"./packages/**/tsconfig.json",
87-
"./other-packages/**/tsconfig.json"
86+
"./packages/*/tsconfig.json",
87+
"./other-packages/*/tsconfig.json"
8888
]
8989
}
9090
}

codechecks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ checks:
22
- name: build-size-watcher
33
options:
44
files:
5-
- path: 'lib/**/*.*'
5+
- path: 'lib/index.js'
66
- name: type-coverage-watcher
77
options:
88
atLeast: 100

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-import-resolver-ts",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "TypeScript .ts .tsx module resolver for `eslint-plugin-import`.",
55
"repository": "git@github.com/rx-ts/eslint-import-resolver-ts.git",
66
"author": "Alex Gorbatchev <alex.gorbatchev@gmail.com>",
@@ -18,7 +18,7 @@
1818
],
1919
"scripts": {
2020
"build:ts": "tsc -b src",
21-
"build:bundle": "r",
21+
"build:bundle": "r --externals tiny-glob/sync",
2222
"build": "run-p build:*",
2323
"lint": "eslint --ext md,js,ts -f friendly --ignore-pattern tests .",
2424
"test": "eslint -f friendly tests/**/*.{ts,tsx}",
@@ -37,9 +37,9 @@
3737
},
3838
"dependencies": {
3939
"debug": "^4.1.1",
40-
"glob": "^7.1.4",
4140
"is-glob": "^4.0.1",
4241
"resolve": "^1.12.0",
42+
"tiny-glob": "^0.2.6",
4343
"tsconfig-paths": "^3.9.0"
4444
},
4545
"devDependencies": {
@@ -55,14 +55,14 @@
5555
"@babel/core": "^7.6.0",
5656
"@commitlint/cli": "^8.2.0",
5757
"@types/debug": "^4.1.5",
58-
"@types/glob": "^7.1.1",
58+
"@types/is-glob": "^4.0.1",
5959
"@types/node": "^12.7.5",
6060
"@types/resolve": "^0.0.8",
6161
"@types/unist": "^2.0.3",
6262
"dummy.js": "link:dummy.js",
6363
"eslint": "^6.4.0",
6464
"husky": "^3.0.5",
65-
"lint-staged": "^9.2.5",
65+
"lint-staged": "^9.3.0",
6666
"npm-run-all": "^4.1.5",
6767
"prettier": "^1.18.2",
6868
"react": "^16.9.0",

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import {
66
loadConfig,
77
ConfigLoaderResult,
88
} from 'tsconfig-paths'
9-
import isGlob from 'is-glob'
9+
import globSync from 'tiny-glob/sync'
1010

11+
import isGlob from 'is-glob'
1112
import { isCore, sync } from 'resolve'
1213
import debug from 'debug'
13-
import { sync as globSync } from 'glob'
1414

1515
const log = debug('eslint-import-resolver-ts')
1616

@@ -96,7 +96,7 @@ export function resolve(
9696
}
9797
}
9898

99-
log("didn't find", source)
99+
log("didn't find ", source)
100100

101101
return {
102102
found: false,
@@ -151,7 +151,7 @@ function initMappers(options: TsResolverOptions) {
151151
(paths, path) => paths.concat(isGlob(path) ? globSync(path) : path),
152152
[],
153153
)
154-
.map(path => loadConfig(path))
154+
.map(loadConfig)
155155
.filter(isConfigLoaderSuccessResult)
156156
.map(configLoaderResult => {
157157
const matchPath = createMatchPath(

src/is-glob.d.ts

-4
This file was deleted.

src/tiny-glob.d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
declare module 'tiny-glob/sync' {
2+
interface Options {
3+
cwd?: string
4+
dot?: boolean
5+
absolute?: boolean
6+
filesOnly?: boolean
7+
flush?: boolean
8+
}
9+
10+
const globSync: (str: string, opts?: Options) => string[]
11+
12+
export = globSync
13+
}

tests/multipleTsconfigs/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22

3-
const globPattern = './packages/**/tsconfig.json';
3+
const globPattern = './packages/*/tsconfig.json';
44

55
// in normal cases this is not needed because the __dirname would be the root
66
const absoluteGlobPath = path.join(__dirname, globPattern);

yarn.lock

+30-7
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,11 @@
14271427
"@types/minimatch" "*"
14281428
"@types/node" "*"
14291429

1430+
"@types/is-glob@^4.0.1":
1431+
version "4.0.1"
1432+
resolved "https://registry.yarnpkg.com/@types/is-glob/-/is-glob-4.0.1.tgz#a93eec1714172c8eb3225a1cc5eb88c2477b7d00"
1433+
integrity sha512-k3RS5HyBPu4h+5hTmIEfPB2rl5P3LnGdQEZrV2b9OWTJVtsUQ2VBcedqYKGqxvZqle5UALUXdSfVA8nf3HfyWQ==
1434+
14301435
"@types/json-schema@^7.0.3":
14311436
version "7.0.3"
14321437
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636"
@@ -2881,6 +2886,11 @@ globals@^11.1.0, globals@^11.7.0:
28812886
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
28822887
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
28832888

2889+
globalyzer@^0.1.0:
2890+
version "0.1.4"
2891+
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f"
2892+
integrity sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA==
2893+
28842894
globby@^10.0.1:
28852895
version "10.0.1"
28862896
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22"
@@ -2895,6 +2905,11 @@ globby@^10.0.1:
28952905
merge2 "^1.2.3"
28962906
slash "^3.0.0"
28972907

2908+
globrex@^0.1.1:
2909+
version "0.1.2"
2910+
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
2911+
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==
2912+
28982913
graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.2.2:
28992914
version "4.2.2"
29002915
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02"
@@ -3343,10 +3358,10 @@ lines-and-columns@^1.1.6:
33433358
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
33443359
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
33453360

3346-
lint-staged@^9.2.5:
3347-
version "9.2.5"
3348-
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.2.5.tgz#5a3e1e0a539a403bd7f88542bc3d34ce52efdbb3"
3349-
integrity sha512-d99gTBFMJ29159+9iRvaMEQstmNcPAbQbhHSYw6D/1FncvFdIj8lWHztaq3Uq+tbZPABHXQ/fyN7Rp1QwF8HIw==
3361+
lint-staged@^9.3.0:
3362+
version "9.3.0"
3363+
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.3.0.tgz#522a79f166050ab5777887348f2cbdb03f71acac"
3364+
integrity sha512-OuL3xo6XpBErl16+3W9PdnFmgeGp12lM8I1Ii/B56S8Edy1kyrf4W8VD4IBn9v17QlutRQEWUJ54YF/VVQ7J2A==
33503365
dependencies:
33513366
chalk "^2.4.2"
33523367
commander "^2.20.0"
@@ -4963,9 +4978,9 @@ remark-preset-lint-recommended@^3.0.3:
49634978
remark-lint-ordered-list-marker-style "^1.0.0"
49644979

49654980
remark-preset-prettier@^0.2.0:
4966-
version "0.2.0"
4967-
resolved "https://registry.yarnpkg.com/remark-preset-prettier/-/remark-preset-prettier-0.2.0.tgz#cb369b86ce7d7980e90879fe468bae501fc06969"
4968-
integrity sha512-JC79MERKMoOrokjCsnMe1RXxH5KrZ2veg5eGRDzUbfKliXSTVMMvvw3PoZ5Gng8MhPrpOd+DkE+jpu937aS/wQ==
4981+
version "0.2.1"
4982+
resolved "https://registry.yarnpkg.com/remark-preset-prettier/-/remark-preset-prettier-0.2.1.tgz#00de65b8f3817428ba79aa535ee230530d0afd70"
4983+
integrity sha512-CH3CQi9sU1vrJGGmW4/+JlazpRsXJMaZYjmNmKyk58e7TUfKjE2VNVLJI8AIhA3G5sKZhEgD7FgmdIdp9Bxrsw==
49694984

49704985
remark-stringify@^7.0.3:
49714986
version "7.0.3"
@@ -5542,6 +5557,14 @@ through2@^2.0.0, through2@^2.0.2:
55425557
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
55435558
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
55445559

5560+
tiny-glob@^0.2.6:
5561+
version "0.2.6"
5562+
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.6.tgz#9e056e169d9788fe8a734dfa1ff02e9b92ed7eda"
5563+
integrity sha512-A7ewMqPu1B5PWwC3m7KVgAu96Ch5LA0w4SnEN/LbDREj/gAD0nPWboRbn8YoP9ISZXqeNAlMvKSKoEuhcfK3Pw==
5564+
dependencies:
5565+
globalyzer "^0.1.0"
5566+
globrex "^0.1.1"
5567+
55455568
tmp@^0.0.33:
55465569
version "0.0.33"
55475570
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"

0 commit comments

Comments
 (0)