@wondermarin/eslint-config 2.4.0 → 2.4.1
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/dist/main.js +25 -13
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import path, { join, dirname } from 'node:path';
|
|
2
|
+
import fs, { existsSync } from 'node:fs';
|
|
3
3
|
import globals from 'globals';
|
|
4
4
|
|
|
5
5
|
// node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
@@ -57,6 +57,15 @@ function createDefu(merger) {
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
var defu = createDefu();
|
|
60
|
+
function findProjectRoot() {
|
|
61
|
+
const startDir = process.cwd();
|
|
62
|
+
let currentDir = startDir;
|
|
63
|
+
while (!currentDir.endsWith("\\")) {
|
|
64
|
+
if (existsSync(join(currentDir, "package.json"))) return currentDir;
|
|
65
|
+
currentDir = dirname(currentDir);
|
|
66
|
+
}
|
|
67
|
+
return startDir;
|
|
68
|
+
}
|
|
60
69
|
|
|
61
70
|
// src/configs/javascript.ts
|
|
62
71
|
function javascriptConfig() {
|
|
@@ -408,7 +417,7 @@ async function interopDefault(module) {
|
|
|
408
417
|
}
|
|
409
418
|
|
|
410
419
|
// src/configs/typescript.ts
|
|
411
|
-
async function typescriptConfig() {
|
|
420
|
+
async function typescriptConfig(projectRoot) {
|
|
412
421
|
const [typescriptParser, typescriptPlugin] = await Promise.all([
|
|
413
422
|
interopDefault(import('@typescript-eslint/parser')),
|
|
414
423
|
interopDefault(import('@typescript-eslint/eslint-plugin'))
|
|
@@ -421,7 +430,7 @@ async function typescriptConfig() {
|
|
|
421
430
|
parser: typescriptParser,
|
|
422
431
|
parserOptions: {
|
|
423
432
|
project: true,
|
|
424
|
-
tsconfigRootDir:
|
|
433
|
+
tsconfigRootDir: projectRoot
|
|
425
434
|
}
|
|
426
435
|
},
|
|
427
436
|
plugins: {
|
|
@@ -1520,7 +1529,7 @@ async function reactConfig() {
|
|
|
1520
1529
|
}
|
|
1521
1530
|
];
|
|
1522
1531
|
}
|
|
1523
|
-
function baseConfig() {
|
|
1532
|
+
function baseConfig(projectRoot) {
|
|
1524
1533
|
return [
|
|
1525
1534
|
{
|
|
1526
1535
|
name: "wondermarin/eslint-config",
|
|
@@ -1540,7 +1549,7 @@ function baseConfig() {
|
|
|
1540
1549
|
},
|
|
1541
1550
|
{
|
|
1542
1551
|
name: "wondermarin/eslint-config/ignores",
|
|
1543
|
-
ignores: includeIgnoreFile(join(
|
|
1552
|
+
ignores: includeIgnoreFile(join(projectRoot, ".gitignore")).ignores
|
|
1544
1553
|
}
|
|
1545
1554
|
];
|
|
1546
1555
|
}
|
|
@@ -1586,13 +1595,16 @@ async function wondermarin(options) {
|
|
|
1586
1595
|
stylistic: true,
|
|
1587
1596
|
json: true
|
|
1588
1597
|
});
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1598
|
+
const projectRoot = findProjectRoot();
|
|
1599
|
+
const configs = await Promise.all([
|
|
1600
|
+
baseConfig(projectRoot),
|
|
1601
|
+
options.javascript ? javascriptConfig() : [],
|
|
1602
|
+
options.typescript ? typescriptConfig(projectRoot) : [],
|
|
1603
|
+
options.stylistic ? stylisticConfig() : [],
|
|
1604
|
+
options.json ? jsonConfig() : [],
|
|
1605
|
+
options.react ? reactConfig() : []
|
|
1606
|
+
]);
|
|
1607
|
+
return configs.flat();
|
|
1596
1608
|
}
|
|
1597
1609
|
var main_default = wondermarin;
|
|
1598
1610
|
|