@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.
Files changed (2) hide show
  1. package/dist/main.js +25 -13
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
- import fs from 'node:fs';
2
- import path, { join } from 'node:path';
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: process.cwd()
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(process.cwd(), ".gitignore")).ignores
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 config = [...baseConfig()];
1590
- if (options.javascript) config.push(...javascriptConfig());
1591
- if (options.typescript) config.push(...await typescriptConfig());
1592
- if (options.stylistic) config.push(...await stylisticConfig());
1593
- if (options.json) config.push(...await jsonConfig());
1594
- if (options.react) config.push(...await reactConfig());
1595
- return config;
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wondermarin/eslint-config",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Personal ESLint config.",
5
5
  "homepage": "https://github.com/Wondermarin/eslint-config#readme",
6
6
  "repository": {