Skip to content

Commit

Permalink
fix: force tiniglobby to expand dot directories (#360)
Browse files Browse the repository at this point in the history
* fix: force tiniglobby to expand dot directories

* chore: changeset

* chore(deps): update tinyglobby to latest version
  • Loading branch information
carlocorradini authored Feb 20, 2025
1 parent 4f47f8a commit 8192976
Show file tree
Hide file tree
Showing 36 changed files with 175 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-parrots-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-import-resolver-typescript': patch
---

Force tiniglobby to expand dot directories
5 changes: 5 additions & 0 deletions .changeset/forty-beans-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-import-resolver-typescript': patch
---

Update tinyglobby to latest version
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"prepare": "simple-git-hooks",
"release": "changeset publish",
"test": "run-p 'test:*'",
"test:dotInclude": "eslint --ext ts,tsx tests/dotInclude --ignore-pattern \"!.dot\"",
"test:dotPaths": "eslint --ext ts,tsx tests/dotPaths --ignore-pattern \"!.dot\"",
"test:dotProject": "eslint --ext ts,tsx tests/dotProject --ignore-pattern \"!.dot\"",
"test:importXResolverV3": "eslint --config=tests/importXResolverV3/eslint.config.js tests/importXResolverV3",
"test:multipleEslintrcs": "eslint --ext ts,tsx tests/multipleEslintrcs",
"test:multipleTsconfigs": "eslint --ext ts,tsx tests/multipleTsconfigs",
Expand Down Expand Up @@ -82,7 +85,7 @@
"get-tsconfig": "^4.10.0",
"is-bun-module": "^1.0.2",
"stable-hash": "^0.0.4",
"tinyglobby": "^0.2.11"
"tinyglobby": "^0.2.12"
},
"devDependencies": {
"@1stg/eslint-config": "7.0.1",
Expand Down
13 changes: 8 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,10 @@ function initMappers(options: InternalResolverOptions) {
...globSync(
configPaths.filter(path => isDynamicPattern(path)),
{
absolute: true,
dot: true,
expandDirectories: false,
ignore: defaultIgnore,
absolute: true,
},
),
]),
Expand Down Expand Up @@ -438,12 +439,13 @@ function initMappers(options: InternalResolverOptions) {
tsconfigResult.config.include === undefined
? // Include everything if no files or include options
globSync(defaultInclude, {
absolute: true,
cwd: path.dirname(tsconfigResult.path),
dot: true,
ignore: [
...(tsconfigResult.config.exclude ?? []),
...defaultIgnore,
],
absolute: true,
cwd: path.dirname(tsconfigResult.path),
})
: [
// https://www.typescriptlang.org/tsconfig/#files
Expand All @@ -459,12 +461,13 @@ function initMappers(options: InternalResolverOptions) {
...(tsconfigResult.config.include !== undefined &&
tsconfigResult.config.include.length > 0
? globSync(tsconfigResult.config.include, {
absolute: true,
cwd: path.dirname(tsconfigResult.path),
dot: true,
ignore: [
...(tsconfigResult.config.exclude ?? []),
...defaultIgnore,
],
absolute: true,
cwd: path.dirname(tsconfigResult.path),
})
: []),
]
Expand Down
18 changes: 18 additions & 0 deletions tests/dotInclude/.dot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// import relative
import './tsImportee'
import './tsxImportee'
import './subfolder/tsImportee'
import './subfolder/tsxImportee'

// import using tsconfig.json path mapping
import 'folder/tsImportee'
import 'folder/tsxImportee'
import 'folder/subfolder/tsImportee'
import 'folder/subfolder/tsxImportee'

// import module with typings set in package.json
import 'folder/module'

// import from node_module
import 'typescript'
import 'dummy.js'
1 change: 1 addition & 0 deletions tests/dotInclude/.dot/module/module.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}
5 changes: 5 additions & 0 deletions tests/dotInclude/.dot/module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "commonjs",
"typings": "./module.d.ts",
"private": true
}
1 change: 1 addition & 0 deletions tests/dotInclude/.dot/subfolder/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
1 change: 1 addition & 0 deletions tests/dotInclude/.dot/subfolder/tsxImportee.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
1 change: 1 addition & 0 deletions tests/dotInclude/.dot/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
1 change: 1 addition & 0 deletions tests/dotInclude/.dot/tsxImportee.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
1 change: 1 addition & 0 deletions tests/dotInclude/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../baseEslintConfig.cjs')(__dirname)
11 changes: 11 additions & 0 deletions tests/dotInclude/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": "./.dot",
"jsx": "react",
"paths": {
"folder/*": ["*"],
"*": ["../../node_modules/*"]
}
},
"include": ["./**/*.ts", "./**/*.tsx"]
}
1 change: 1 addition & 0 deletions tests/dotPaths/.dot/module/module.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}
5 changes: 5 additions & 0 deletions tests/dotPaths/.dot/module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "commonjs",
"typings": "./module.d.ts",
"private": true
}
1 change: 1 addition & 0 deletions tests/dotPaths/.dot/subfolder/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
1 change: 1 addition & 0 deletions tests/dotPaths/.dot/subfolder/tsxImportee.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
1 change: 1 addition & 0 deletions tests/dotPaths/.dot/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
1 change: 1 addition & 0 deletions tests/dotPaths/.dot/tsxImportee.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
1 change: 1 addition & 0 deletions tests/dotPaths/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../baseEslintConfig.cjs')(__dirname)
18 changes: 18 additions & 0 deletions tests/dotPaths/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// import relative
import './.dot/tsImportee'
import './.dot/tsxImportee'
import './.dot/subfolder/tsImportee'
import './.dot/subfolder/tsxImportee'

// import using tsconfig.json path mapping
import 'folder/tsImportee'
import 'folder/tsxImportee'
import 'folder/subfolder/tsImportee'
import 'folder/subfolder/tsxImportee'

// import module with typings set in package.json
import 'folder/module'

// import from node_module
import 'typescript'
import 'dummy.js'
11 changes: 11 additions & 0 deletions tests/dotPaths/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": ".",
"jsx": "react",
"paths": {
"folder/*": [".dot/*"],
"*": ["../../node_modules/*"]
}
},
"files": ["index.ts", ".dot/tsImportee.ts", ".dot/tsxImportee.tsx"]
}
8 changes: 8 additions & 0 deletions tests/dotProject/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path')

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)

module.exports = require('../baseEslintConfig.cjs')(absoluteGlobPath)
11 changes: 11 additions & 0 deletions tests/dotProject/packages/module-a/.dot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": "../",
"jsx": "react",
"paths": {
"folder/*": ["*"],
"*": ["../../../../node_modules/*"]
}
},
"files": ["../index.ts", "../tsImportee.ts", "../tsxImportee.tsx"]
}
15 changes: 15 additions & 0 deletions tests/dotProject/packages/module-a/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// import relative
import './tsImportee'
import './tsxImportee'
import './subfolder/tsImportee'
import './subfolder/tsxImportee'

// import using tsconfig.json path mapping
import 'folder/tsImportee'
import 'folder/tsxImportee'
import 'folder/subfolder/tsImportee'
import 'folder/subfolder/tsxImportee'

// import from node_module
import 'typescript'
import 'dummy.js'
1 change: 1 addition & 0 deletions tests/dotProject/packages/module-a/subfolder/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
1 change: 1 addition & 0 deletions tests/dotProject/packages/module-a/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
1 change: 1 addition & 0 deletions tests/dotProject/packages/module-a/tsxImportee.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
11 changes: 11 additions & 0 deletions tests/dotProject/packages/module-b/.dot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": "../",
"jsx": "react",
"paths": {
"folder/*": ["*"],
"*": ["../../../../node_modules/*"]
}
},
"files": ["../index.ts", "../tsImportee.ts", "../tsxImportee.tsx"]
}
15 changes: 15 additions & 0 deletions tests/dotProject/packages/module-b/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// import relative
import './tsImportee'
import './tsxImportee'
import './subfolder/tsImportee'
import './subfolder/tsxImportee'

// import using tsconfig.json path mapping
import 'folder/tsImportee'
import 'folder/tsxImportee'
import 'folder/subfolder/tsImportee'
import 'folder/subfolder/tsxImportee'

// import from node_module
import 'typescript'
import 'dummy.js'
1 change: 1 addition & 0 deletions tests/dotProject/packages/module-b/subfolder/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
1 change: 1 addition & 0 deletions tests/dotProject/packages/module-b/tsImportee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'yes'
1 change: 1 addition & 0 deletions tests/dotProject/packages/module-b/tsxImportee.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'React Component'
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6170,7 +6170,7 @@ __metadata:
size-limit: "npm:^11.0.0"
size-limit-preset-node-lib: "npm:^0.3.0"
stable-hash: "npm:^0.0.4"
tinyglobby: "npm:^0.2.11"
tinyglobby: "npm:^0.2.12"
type-coverage: "npm:^2.27.0"
typescript: "npm:^5.3.2"
peerDependencies:
Expand Down Expand Up @@ -13513,13 +13513,13 @@ __metadata:
languageName: node
linkType: hard

"tinyglobby@npm:^0.2.11":
version: 0.2.11
resolution: "tinyglobby@npm:0.2.11"
"tinyglobby@npm:^0.2.12":
version: 0.2.12
resolution: "tinyglobby@npm:0.2.12"
dependencies:
fdir: "npm:^6.4.3"
picomatch: "npm:^4.0.2"
checksum: 8f10a0cd527041155c0dadd9febb5afc97a95649521f550554868c09beb4cb62ceca1d97536108efe53957967eb54f83a7bed59867f666b325fc3f00ca72fd24
checksum: 4ad28701fa9118b32ef0e27f409e0a6c5741e8b02286d50425c1f6f71e6d6c6ded9dd5bbbbb714784b08623c4ec4d150151f1d3d996cfabe0495f908ab4f7002
languageName: node
linkType: hard

Expand Down

0 comments on commit 8192976

Please sign in to comment.