Skip to content

Commit 26420ce

Browse files
committed
fix
1 parent d1a967d commit 26420ce

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

lib/utils/parser-config-resolver/should-use-flat-config.ts

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,29 @@ export function findFlatConfigFile(cwd: string) {
3838

3939
/** We used https://github.com/sindresorhus/find-up/blob/b733bb70d3aa21b22fa011be8089110d467c317f/index.js#L94 as a reference */
4040
function findUp(names: string[], options: { cwd: string }) {
41-
try {
42-
let directory = path.resolve(options.cwd)
43-
const { root } = path.parse(directory)
44-
const stopAt = path.resolve(directory, root)
45-
// eslint-disable-next-line no-constant-condition -- ignore
46-
while (true) {
47-
for (const name of names) {
48-
const target = path.resolve(directory, name)
49-
const stat = fs.existsSync(target)
50-
? fs.statSync(target, {
51-
throwIfNoEntry: false
52-
})
53-
: null
54-
if (stat?.isFile()) {
55-
return target
56-
}
57-
}
58-
59-
if (directory === stopAt) {
60-
break
41+
let directory = path.resolve(options.cwd)
42+
const { root } = path.parse(directory)
43+
const stopAt = path.resolve(directory, root)
44+
// eslint-disable-next-line no-constant-condition -- ignore
45+
while (true) {
46+
for (const name of names) {
47+
const target = path.resolve(directory, name)
48+
const stat = fs.existsSync(target)
49+
? fs.statSync(target, {
50+
throwIfNoEntry: false
51+
})
52+
: null
53+
if (stat?.isFile()) {
54+
return target
6155
}
56+
}
6257

63-
directory = path.dirname(directory)
58+
if (directory === stopAt) {
59+
break
6460
}
6561

66-
return null
67-
} catch (e) {
68-
console.log('Error in should-use-flat-config')
69-
console.error(e)
70-
throw e
62+
directory = path.dirname(directory)
7163
}
64+
65+
return null
7266
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"files": [
3535
"dist"
3636
],
37-
"main": "dist/lib/index.js",
37+
"main": "dist/index.js",
3838
"scripts": {
3939
"build": "tsc --project ./tsconfig.build.json",
4040
"clean": "git clean -fx .nyc_output coverage dist docs/.vitepress/dist",

0 commit comments

Comments
 (0)