@inlang/sdk 0.13.0 → 0.15.0

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.
@@ -1,5 +1,4 @@
1
1
  import type { NodeishFilesystemSubset } from "@inlang/plugin";
2
- export declare const isAbsolutePath: (path: string) => boolean;
3
2
  /**
4
3
  * Wraps the nodeish filesystem subset with a function that intercepts paths
5
4
  * and prepends the base path.
@@ -1 +1 @@
1
- {"version":3,"file":"createNodeishFsWithAbsolutePaths.d.ts","sourceRoot":"","sources":["../src/createNodeishFsWithAbsolutePaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAG7D,eAAO,MAAM,cAAc,SAAU,MAAM,YAAwB,CAAA;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,SAAU;IACtD,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,uBAAuB,CAAA;CAClC,KAAG,uBAyBH,CAAA"}
1
+ {"version":3,"file":"createNodeishFsWithAbsolutePaths.d.ts","sourceRoot":"","sources":["../src/createNodeishFsWithAbsolutePaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAI7D;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,SAAU;IACtD,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,uBAAuB,CAAA;CAClC,KAAG,uBAyBH,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { normalizePath } from "@lix-js/fs";
2
- export const isAbsolutePath = (path) => /^[/\\]/.test(path);
2
+ import { isAbsolutePath } from "./isAbsolutePath.js";
3
3
  /**
4
4
  * Wraps the nodeish filesystem subset with a function that intercepts paths
5
5
  * and prepends the base path.
@@ -8,11 +8,11 @@ export const isAbsolutePath = (path) => /^[/\\]/.test(path);
8
8
  */
9
9
  export const createNodeishFsWithAbsolutePaths = (args) => {
10
10
  if (!isAbsolutePath(args.settingsFilePath)) {
11
- throw new Error("The argument `settingsFilePath` must be an absolute path.");
11
+ throw new Error(`Expected an absolute path but received "${args.settingsFilePath}".`);
12
12
  }
13
13
  // get the base path of the settings file by
14
14
  // removing the file name from the path
15
- const basePath = args.settingsFilePath.split("/").slice(0, -1).join("/");
15
+ const basePath = normalizePath(args.settingsFilePath).split("/").slice(0, -1).join("/");
16
16
  const makeAbsolute = (path) => {
17
17
  if (isAbsolutePath(path)) {
18
18
  return normalizePath(path);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,qBAAa,0BAA2B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE;CAI1D;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACzC,OAAO,EAAE;QAAE,MAAM,EAAE,UAAU,EAAE,CAAA;KAAE;CAQ7C;AAED,qBAAa,kCAAmC,SAAQ,KAAK;gBAChD,OAAO,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAOnE;AAED,qBAAa,gCAAiC,SAAQ,KAAK;gBAC9C,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAIpE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACrC,OAAO,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;KAAE;CAIrD;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACrC,OAAO,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;KAAE;CAIrD"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,qBAAa,0BAA2B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE;CAI1D;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACzC,OAAO,EAAE;QAAE,MAAM,EAAE,UAAU,EAAE,CAAA;KAAE;CAU7C;AAED,qBAAa,kCAAmC,SAAQ,KAAK;gBAChD,OAAO,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAOnE;AAED,qBAAa,gCAAiC,SAAQ,KAAK;gBAC9C,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAIpE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACrC,OAAO,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;KAAE;CAIrD;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACrC,OAAO,EAAE;QAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;KAAE;CAIrD"}
package/dist/errors.js CHANGED
@@ -6,8 +6,10 @@ export class LoadProjectInvalidArgument extends Error {
6
6
  }
7
7
  export class ProjectSettingsInvalidError extends Error {
8
8
  constructor(options) {
9
+ // TODO: beatufiy ValueErrors
9
10
  super(`The project settings are invalid:\n\n${options.errors
10
- .map((error) => `The value of "${error.path}" is invalid:\n\n${error.message}`)
11
+ .filter((error) => error.path)
12
+ .map((error) => `"${error.path}":\n\n${error.message}`)
11
13
  .join("\n")}`);
12
14
  this.name = "ProjectSettingsInvalidError";
13
15
  }
@@ -0,0 +1,2 @@
1
+ export declare const isAbsolutePath: (path: string) => boolean;
2
+ //# sourceMappingURL=isAbsolutePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isAbsolutePath.d.ts","sourceRoot":"","sources":["../src/isAbsolutePath.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,SAAU,MAAM,YAI1C,CAAA"}
@@ -0,0 +1,4 @@
1
+ export const isAbsolutePath = (path) => {
2
+ const matchPosixAndWindowsAbsolutePaths = /^(?:[A-Za-z]:\\(?:[^\\]+\\)*[^\\]+|[A-Za-z]:\/(?:[^/]+\/)*[^/]+|\/(?:[^/]+\/)*[^/]+)$/;
3
+ return matchPosixAndWindowsAbsolutePaths.test(path);
4
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=isAbsolutePath.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isAbsolutePath.test.d.ts","sourceRoot":"","sources":["../src/isAbsolutePath.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { assert, describe, it } from "vitest";
2
+ import { isAbsolutePath } from "./isAbsolutePath.js";
3
+ describe("isAbsolutePath", () => {
4
+ it("should correctly identify Unix absolute paths", () => {
5
+ assert.isTrue(isAbsolutePath("/home/user/documents/file.txt"));
6
+ assert.isTrue(isAbsolutePath("/usr/local/bin/script.sh"));
7
+ assert.isFalse(isAbsolutePath("relative/path/to/file.txt"));
8
+ });
9
+ it("should correctly identify Windows absolute paths", () => {
10
+ assert.isTrue(isAbsolutePath("C:\\Users\\User\\Documents\\File.txt"));
11
+ assert.isTrue(isAbsolutePath("C:/Users/user/project/project.inlang.json"));
12
+ assert.isFalse(isAbsolutePath("Projects\\Project1\\source\\file.txt"));
13
+ });
14
+ it("should handle edge cases", () => {
15
+ assert.isFalse(isAbsolutePath("")); // Empty path should return false
16
+ assert.isFalse(isAbsolutePath("relative/path/../file.txt")); // Relative path with ".." should return false
17
+ assert.isFalse(isAbsolutePath("../relative/path/to/file.txt"));
18
+ assert.isFalse(isAbsolutePath("./relative/path/to/file.txt"));
19
+ });
20
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"loadProject.d.ts","sourceRoot":"","sources":["../src/loadProject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,aAAa,EAGb,YAAY,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,4BAA4B,CAAA;AAchF,OAAO,EAA4B,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAWjG;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW;sBACL,MAAM;eACb,uBAAuB;;qBAElB,MAAM,SAAS,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI;MAC5D,QAAQ,aAAa,CAuMxB,CAAA;AAuHD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAQtE"}
1
+ {"version":3,"file":"loadProject.d.ts","sourceRoot":"","sources":["../src/loadProject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,aAAa,EAGb,YAAY,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,4BAA4B,CAAA;AAchF,OAAO,EAA4B,KAAK,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AASjG;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW;sBACL,MAAM;eACb,uBAAuB;;qBAElB,MAAM,SAAS,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI;MAC5D,QAAQ,aAAa,CAuMxB,CAAA;AAuHD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAQtE"}
@@ -8,8 +8,9 @@ import { createMessageLintReportsQuery } from "./createMessageLintReportsQuery.j
8
8
  import { ProjectSettings, Message } from "./versionedInterfaces.js";
9
9
  import { tryCatch } from "@inlang/result";
10
10
  import { migrateIfOutdated } from "@inlang/project-settings/migration";
11
- import { createNodeishFsWithAbsolutePaths, isAbsolutePath, } from "./createNodeishFsWithAbsolutePaths.js";
11
+ import { createNodeishFsWithAbsolutePaths } from "./createNodeishFsWithAbsolutePaths.js";
12
12
  import { normalizePath } from "@lix-js/fs";
13
+ import { isAbsolutePath } from "./isAbsolutePath.js";
13
14
  const settingsCompiler = TypeCompiler.Compile(ProjectSettings);
14
15
  /**
15
16
  * Creates an inlang instance.
@@ -91,6 +91,18 @@ describe("initialization", () => {
91
91
  expect(result.error).toBeInstanceOf(LoadProjectInvalidArgument);
92
92
  expect(result.data).toBeUndefined();
93
93
  });
94
+ it("should resolve from a windows path", async () => {
95
+ const fs = createNodeishMemoryFs();
96
+ fs.mkdir("C:\\Users\\user\\project", { recursive: true });
97
+ fs.writeFile("C:\\Users\\user\\project\\project.inlang.json", JSON.stringify(settings));
98
+ const result = await tryCatch(() => loadProject({
99
+ settingsFilePath: "C:\\Users\\user\\project\\project.inlang.json",
100
+ nodeishFs: fs,
101
+ _import,
102
+ }));
103
+ expect(result.error).toBeUndefined();
104
+ expect(result.data).toBeDefined();
105
+ });
94
106
  describe("settings", () => {
95
107
  it("should return an error if settings file is not found", async () => {
96
108
  const fs = createNodeishMemoryFs();
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/resolve-modules/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAE9C,qBAAa,WAAY,SAAQ,KAAK;IACrC,SAAgB,MAAM,EAAE,MAAM,CAAA;gBAClB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAMvE;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,WAAW;gBAC3C,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAItD;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;gBACrC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE;CAIrD;AAED,qBAAa,0BAA2B,SAAQ,WAAW;gBAC9C,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,EAAE,CAAA;KAAE;CAS7D"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/resolve-modules/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAE9C,qBAAa,WAAY,SAAQ,KAAK;IACrC,SAAgB,MAAM,EAAE,MAAM,CAAA;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAMvE;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,WAAW;gBAC3C,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAOtD;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;gBACrC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE;CAIrD;AAED,qBAAa,0BAA2B,SAAQ,WAAW;gBAC9C,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,EAAE,CAAA;KAAE;CAS7D"}
@@ -14,7 +14,7 @@ export class ModuleError extends Error {
14
14
  */
15
15
  export class ModuleHasNoExportsError extends ModuleError {
16
16
  constructor(options) {
17
- super(`Module "${module}" has no exports. Every module must have an "export default".`, options);
17
+ super(`Module "${options.module}" has no exports. Every module must have an "export default".`, options);
18
18
  this.name = "ModuleHasNoExportsError";
19
19
  }
20
20
  }
@@ -23,14 +23,14 @@ export class ModuleHasNoExportsError extends ModuleError {
23
23
  */
24
24
  export class ModuleImportError extends ModuleError {
25
25
  constructor(options) {
26
- super(`Couldn't import the plugin "${module}":\n\n${options.cause}`, options);
26
+ super(`Couldn't import the plugin "${options.module}":\n\n${options.cause}`, options);
27
27
  this.name = "ModuleImportError";
28
28
  }
29
29
  }
30
30
  export class ModuleExportIsInvalidError extends ModuleError {
31
31
  constructor(options) {
32
- super(`The export(s) of "${module}" are invalid:\n\n${options.errors
33
- .map((error) => `Path "${error.path}" with value "${error.value}": "${error.message}"`)
32
+ super(`The export(s) of "${options.module}" are invalid:\n\n${options.errors
33
+ .map((error) => `"${error.path}" "${error.value}": "${error.message}"`)
34
34
  .join("\n")}`, options);
35
35
  this.name = "ModuleExportIsInvalidError";
36
36
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
3
  "type": "module",
4
- "version": "0.13.0",
4
+ "version": "0.15.0",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -1,7 +1,6 @@
1
1
  import type { NodeishFilesystemSubset } from "@inlang/plugin"
2
2
  import { normalizePath } from "@lix-js/fs"
3
-
4
- export const isAbsolutePath = (path: string) => /^[/\\]/.test(path)
3
+ import { isAbsolutePath } from "./isAbsolutePath.js"
5
4
 
6
5
  /**
7
6
  * Wraps the nodeish filesystem subset with a function that intercepts paths
@@ -14,12 +13,12 @@ export const createNodeishFsWithAbsolutePaths = (args: {
14
13
  nodeishFs: NodeishFilesystemSubset
15
14
  }): NodeishFilesystemSubset => {
16
15
  if (!isAbsolutePath(args.settingsFilePath)) {
17
- throw new Error("The argument `settingsFilePath` must be an absolute path.")
16
+ throw new Error(`Expected an absolute path but received "${args.settingsFilePath}".`)
18
17
  }
19
18
 
20
19
  // get the base path of the settings file by
21
20
  // removing the file name from the path
22
- const basePath = args.settingsFilePath.split("/").slice(0, -1).join("/")
21
+ const basePath = normalizePath(args.settingsFilePath).split("/").slice(0, -1).join("/")
23
22
 
24
23
  const makeAbsolute = (path: string) => {
25
24
  if (isAbsolutePath(path)) {
package/src/errors.ts CHANGED
@@ -9,9 +9,11 @@ export class LoadProjectInvalidArgument extends Error {
9
9
 
10
10
  export class ProjectSettingsInvalidError extends Error {
11
11
  constructor(options: { errors: ValueError[] }) {
12
+ // TODO: beatufiy ValueErrors
12
13
  super(
13
14
  `The project settings are invalid:\n\n${options.errors
14
- .map((error) => `The value of "${error.path}" is invalid:\n\n${error.message}`)
15
+ .filter((error) => error.path)
16
+ .map((error) => `"${error.path}":\n\n${error.message}`)
15
17
  .join("\n")}`
16
18
  )
17
19
  this.name = "ProjectSettingsInvalidError"
@@ -0,0 +1,23 @@
1
+ import { assert, describe, it } from "vitest"
2
+ import { isAbsolutePath } from "./isAbsolutePath.js"
3
+
4
+ describe("isAbsolutePath", () => {
5
+ it("should correctly identify Unix absolute paths", () => {
6
+ assert.isTrue(isAbsolutePath("/home/user/documents/file.txt"))
7
+ assert.isTrue(isAbsolutePath("/usr/local/bin/script.sh"))
8
+ assert.isFalse(isAbsolutePath("relative/path/to/file.txt"))
9
+ })
10
+
11
+ it("should correctly identify Windows absolute paths", () => {
12
+ assert.isTrue(isAbsolutePath("C:\\Users\\User\\Documents\\File.txt"))
13
+ assert.isTrue(isAbsolutePath("C:/Users/user/project/project.inlang.json"))
14
+ assert.isFalse(isAbsolutePath("Projects\\Project1\\source\\file.txt"))
15
+ })
16
+
17
+ it("should handle edge cases", () => {
18
+ assert.isFalse(isAbsolutePath("")) // Empty path should return false
19
+ assert.isFalse(isAbsolutePath("relative/path/../file.txt")) // Relative path with ".." should return false
20
+ assert.isFalse(isAbsolutePath("../relative/path/to/file.txt"))
21
+ assert.isFalse(isAbsolutePath("./relative/path/to/file.txt"))
22
+ })
23
+ })
@@ -0,0 +1,5 @@
1
+ export const isAbsolutePath = (path: string) => {
2
+ const matchPosixAndWindowsAbsolutePaths =
3
+ /^(?:[A-Za-z]:\\(?:[^\\]+\\)*[^\\]+|[A-Za-z]:\/(?:[^/]+\/)*[^/]+|\/(?:[^/]+\/)*[^/]+)$/
4
+ return matchPosixAndWindowsAbsolutePaths.test(path)
5
+ }
@@ -113,6 +113,23 @@ describe("initialization", () => {
113
113
  expect(result.data).toBeUndefined()
114
114
  })
115
115
 
116
+ it("should resolve from a windows path", async () => {
117
+ const fs = createNodeishMemoryFs()
118
+ fs.mkdir("C:\\Users\\user\\project", { recursive: true })
119
+ fs.writeFile("C:\\Users\\user\\project\\project.inlang.json", JSON.stringify(settings))
120
+
121
+ const result = await tryCatch(() =>
122
+ loadProject({
123
+ settingsFilePath: "C:\\Users\\user\\project\\project.inlang.json",
124
+ nodeishFs: fs,
125
+ _import,
126
+ })
127
+ )
128
+
129
+ expect(result.error).toBeUndefined()
130
+ expect(result.data).toBeDefined()
131
+ })
132
+
116
133
  describe("settings", () => {
117
134
  it("should return an error if settings file is not found", async () => {
118
135
  const fs = createNodeishMemoryFs()
@@ -22,11 +22,9 @@ import { createMessageLintReportsQuery } from "./createMessageLintReportsQuery.j
22
22
  import { ProjectSettings, Message, type NodeishFilesystemSubset } from "./versionedInterfaces.js"
23
23
  import { tryCatch, type Result } from "@inlang/result"
24
24
  import { migrateIfOutdated } from "@inlang/project-settings/migration"
25
- import {
26
- createNodeishFsWithAbsolutePaths,
27
- isAbsolutePath,
28
- } from "./createNodeishFsWithAbsolutePaths.js"
25
+ import { createNodeishFsWithAbsolutePaths } from "./createNodeishFsWithAbsolutePaths.js"
29
26
  import { normalizePath } from "@lix-js/fs"
27
+ import { isAbsolutePath } from "./isAbsolutePath.js"
30
28
 
31
29
  const settingsCompiler = TypeCompiler.Compile(ProjectSettings)
32
30
 
@@ -4,6 +4,7 @@ export * from "./message-lint-rules/errors.js"
4
4
 
5
5
  export class ModuleError extends Error {
6
6
  public readonly module: string
7
+
7
8
  constructor(message: string, options: { module: string; cause?: Error }) {
8
9
  super(message)
9
10
  this.name = "ModuleError"
@@ -17,7 +18,10 @@ export class ModuleError extends Error {
17
18
  */
18
19
  export class ModuleHasNoExportsError extends ModuleError {
19
20
  constructor(options: { module: string; cause?: Error }) {
20
- super(`Module "${module}" has no exports. Every module must have an "export default".`, options)
21
+ super(
22
+ `Module "${options.module}" has no exports. Every module must have an "export default".`,
23
+ options
24
+ )
21
25
  this.name = "ModuleHasNoExportsError"
22
26
  }
23
27
  }
@@ -27,7 +31,7 @@ export class ModuleHasNoExportsError extends ModuleError {
27
31
  */
28
32
  export class ModuleImportError extends ModuleError {
29
33
  constructor(options: { module: string; cause: Error }) {
30
- super(`Couldn't import the plugin "${module}":\n\n${options.cause}`, options)
34
+ super(`Couldn't import the plugin "${options.module}":\n\n${options.cause}`, options)
31
35
  this.name = "ModuleImportError"
32
36
  }
33
37
  }
@@ -35,8 +39,8 @@ export class ModuleImportError extends ModuleError {
35
39
  export class ModuleExportIsInvalidError extends ModuleError {
36
40
  constructor(options: { module: string; errors: ValueError[] }) {
37
41
  super(
38
- `The export(s) of "${module}" are invalid:\n\n${options.errors
39
- .map((error) => `Path "${error.path}" with value "${error.value}": "${error.message}"`)
42
+ `The export(s) of "${options.module}" are invalid:\n\n${options.errors
43
+ .map((error) => `"${error.path}" "${error.value}": "${error.message}"`)
40
44
  .join("\n")}`,
41
45
  options
42
46
  )