@yasainet/eslint 0.0.47 → 0.0.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yasainet/eslint",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "description": "ESLint",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,7 +1,28 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join, sep } from "node:path";
3
+
1
4
  import tseslint from "typescript-eslint";
2
5
 
3
6
  import { simpleImportSortPlugin, stylistic } from "./plugins.mjs";
4
7
 
8
+ // When evaluated under LSP servers like vscode-eslint, `process.cwd()` returns
9
+ // the linted file's directory rather than the consumer's project root, so it
10
+ // cannot be used to derive `tsconfigRootDir`. Walk up from this module until a
11
+ // `tsconfig.json` outside of `node_modules` is found. Falls back to
12
+ // `process.cwd()` for CLI parity if no such directory is reachable.
13
+ const findProjectRoot = (start) => {
14
+ let dir = start;
15
+ while (dir !== dirname(dir)) {
16
+ if (!dir.split(sep).includes("node_modules") && existsSync(join(dir, "tsconfig.json"))) {
17
+ return dir;
18
+ }
19
+ dir = dirname(dir);
20
+ }
21
+ return process.cwd();
22
+ };
23
+
24
+ const projectRoot = findProjectRoot(import.meta.dirname);
25
+
5
26
  /** Base rule configs for code style and TypeScript checks. */
6
27
  export const rulesConfigs = [
7
28
  {
@@ -46,7 +67,7 @@ export const rulesConfigs = [
46
67
  // can consult the TypeScript type checker.
47
68
  parserOptions: {
48
69
  projectService: true,
49
- tsconfigRootDir: process.cwd(),
70
+ tsconfigRootDir: projectRoot,
50
71
  },
51
72
  },
52
73
  plugins: {