Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
feat: replace glob with tiny-glob for faster spped, close #12
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Sep 22, 2019
1 parent 5eb4874 commit 366900d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -69,7 +69,7 @@ Add the following to your `.eslintrc` config:

// use a glob pattern
"ts": {
"directory": "./packages/**/tsconfig.json"
"directory": "./packages/*/tsconfig.json"
},

// use an array
Expand All @@ -83,8 +83,8 @@ Add the following to your `.eslintrc` config:
// use an array of glob patterns
"ts": {
"directory": [
"./packages/**/tsconfig.json",
"./other-packages/**/tsconfig.json"
"./packages/*/tsconfig.json",
"./other-packages/*/tsconfig.json"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion codechecks.yml
Expand Up @@ -2,7 +2,7 @@ checks:
- name: build-size-watcher
options:
files:
- path: 'lib/**/*.*'
- path: 'lib/index.js'
- name: type-coverage-watcher
options:
atLeast: 100
Expand Down
10 changes: 5 additions & 5 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-import-resolver-ts",
"version": "0.3.0",
"version": "0.4.0",
"description": "TypeScript .ts .tsx module resolver for `eslint-plugin-import`.",
"repository": "git@github.com/rx-ts/eslint-import-resolver-ts.git",
"author": "Alex Gorbatchev <alex.gorbatchev@gmail.com>",
Expand All @@ -18,7 +18,7 @@
],
"scripts": {
"build:ts": "tsc -b src",
"build:bundle": "r",
"build:bundle": "r --externals tiny-glob/sync",
"build": "run-p build:*",
"lint": "eslint --ext md,js,ts -f friendly --ignore-pattern tests .",
"test": "eslint -f friendly tests/**/*.{ts,tsx}",
Expand All @@ -37,9 +37,9 @@
},
"dependencies": {
"debug": "^4.1.1",
"glob": "^7.1.4",
"is-glob": "^4.0.1",
"resolve": "^1.12.0",
"tiny-glob": "^0.2.6",
"tsconfig-paths": "^3.9.0"
},
"devDependencies": {
Expand All @@ -55,14 +55,14 @@
"@babel/core": "^7.6.0",
"@commitlint/cli": "^8.2.0",
"@types/debug": "^4.1.5",
"@types/glob": "^7.1.1",
"@types/is-glob": "^4.0.1",
"@types/node": "^12.7.5",
"@types/resolve": "^0.0.8",
"@types/unist": "^2.0.3",
"dummy.js": "link:dummy.js",
"eslint": "^6.4.0",
"husky": "^3.0.5",
"lint-staged": "^9.2.5",
"lint-staged": "^9.3.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"react": "^16.9.0",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Expand Up @@ -6,11 +6,11 @@ import {
loadConfig,
ConfigLoaderResult,
} from 'tsconfig-paths'
import isGlob from 'is-glob'
import globSync from 'tiny-glob/sync'

import isGlob from 'is-glob'
import { isCore, sync } from 'resolve'
import debug from 'debug'
import { sync as globSync } from 'glob'

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

Expand Down Expand Up @@ -96,7 +96,7 @@ export function resolve(
}
}

log("didn't find", source)
log("didn't find ", source)

return {
found: false,
Expand Down Expand Up @@ -151,7 +151,7 @@ function initMappers(options: TsResolverOptions) {
(paths, path) => paths.concat(isGlob(path) ? globSync(path) : path),
[],
)
.map(path => loadConfig(path))
.map(loadConfig)
.filter(isConfigLoaderSuccessResult)
.map(configLoaderResult => {
const matchPath = createMatchPath(
Expand Down
4 changes: 0 additions & 4 deletions src/is-glob.d.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/tiny-glob.d.ts
@@ -0,0 +1,13 @@
declare module 'tiny-glob/sync' {
interface Options {
cwd?: string
dot?: boolean
absolute?: boolean
filesOnly?: boolean
flush?: boolean
}

const globSync: (str: string, opts?: Options) => string[]

export = globSync
}
2 changes: 1 addition & 1 deletion tests/multipleTsconfigs/.eslintrc.js
@@ -1,6 +1,6 @@
const path = require('path');

const globPattern = './packages/**/tsconfig.json';
const globPattern = './packages/*/tsconfig.json';

// in normal cases this is not needed because the __dirname would be the root
const absoluteGlobPath = path.join(__dirname, globPattern);
Expand Down
37 changes: 30 additions & 7 deletions yarn.lock
Expand Up @@ -1427,6 +1427,11 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/is-glob@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/is-glob/-/is-glob-4.0.1.tgz#a93eec1714172c8eb3225a1cc5eb88c2477b7d00"
integrity sha512-k3RS5HyBPu4h+5hTmIEfPB2rl5P3LnGdQEZrV2b9OWTJVtsUQ2VBcedqYKGqxvZqle5UALUXdSfVA8nf3HfyWQ==

"@types/json-schema@^7.0.3":
version "7.0.3"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636"
Expand Down Expand Up @@ -2881,6 +2886,11 @@ globals@^11.1.0, globals@^11.7.0:
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==

globalyzer@^0.1.0:
version "0.1.4"
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f"
integrity sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA==

globby@^10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22"
Expand All @@ -2895,6 +2905,11 @@ globby@^10.0.1:
merge2 "^1.2.3"
slash "^3.0.0"

globrex@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==

graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02"
Expand Down Expand Up @@ -3343,10 +3358,10 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

lint-staged@^9.2.5:
version "9.2.5"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.2.5.tgz#5a3e1e0a539a403bd7f88542bc3d34ce52efdbb3"
integrity sha512-d99gTBFMJ29159+9iRvaMEQstmNcPAbQbhHSYw6D/1FncvFdIj8lWHztaq3Uq+tbZPABHXQ/fyN7Rp1QwF8HIw==
lint-staged@^9.3.0:
version "9.3.0"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.3.0.tgz#522a79f166050ab5777887348f2cbdb03f71acac"
integrity sha512-OuL3xo6XpBErl16+3W9PdnFmgeGp12lM8I1Ii/B56S8Edy1kyrf4W8VD4IBn9v17QlutRQEWUJ54YF/VVQ7J2A==
dependencies:
chalk "^2.4.2"
commander "^2.20.0"
Expand Down Expand Up @@ -4963,9 +4978,9 @@ remark-preset-lint-recommended@^3.0.3:
remark-lint-ordered-list-marker-style "^1.0.0"

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

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

tiny-glob@^0.2.6:
version "0.2.6"
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.6.tgz#9e056e169d9788fe8a734dfa1ff02e9b92ed7eda"
integrity sha512-A7ewMqPu1B5PWwC3m7KVgAu96Ch5LA0w4SnEN/LbDREj/gAD0nPWboRbn8YoP9ISZXqeNAlMvKSKoEuhcfK3Pw==
dependencies:
globalyzer "^0.1.0"
globrex "^0.1.1"

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
Expand Down

0 comments on commit 366900d

Please sign in to comment.