@kitql/eslint-config 0.4.0-next.2 → 0.4.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helper/findFileOrUp.js +22 -0
- package/package.json +3 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { statSync } from 'fs'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
|
|
4
|
+
export const findFileOrUp = (fileName, options) => {
|
|
5
|
+
// Find file recursively 4 levels max up
|
|
6
|
+
for (let i = 0; i < 4; i++) {
|
|
7
|
+
try {
|
|
8
|
+
const pathFound = '../'.repeat(i) + fileName
|
|
9
|
+
if (statSync(pathFound)) {
|
|
10
|
+
if (options?.absolute) {
|
|
11
|
+
return resolve(pathFound)
|
|
12
|
+
}
|
|
13
|
+
return pathFound
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
// nothing to do
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
console.error(`"${fileName}" not found`)
|
|
21
|
+
return null
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitql/eslint-config",
|
|
3
|
-
"version": "0.4.0-next.
|
|
3
|
+
"version": "0.4.0-next.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "opinionated linting and formatting for projects",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"cmd.js",
|
|
20
20
|
"cmd.sh",
|
|
21
21
|
"eslint.config.js",
|
|
22
|
-
"eslint.config.d.ts"
|
|
22
|
+
"eslint.config.d.ts",
|
|
23
|
+
"helper/findFileOrUp.js"
|
|
23
24
|
],
|
|
24
25
|
"keywords": [
|
|
25
26
|
"cli",
|