@valbuild/eslint-plugin 0.43.1 → 0.43.2

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.
@@ -75,7 +75,7 @@ var noIllegalModuleIds = {
75
75
  // in a monorepo, the root dir will be the root of the monorepo, not the root of the package
76
76
  // so we need to account for that
77
77
  // Assume the import of the val.config is correct and that it is in the root folder
78
- var numberOfDirsToRoot = valConfigImportSource.split("..").reduce(function (acc, curr) {
78
+ var numberOfDirsToRoot = valConfigImportSource.split(".." + path__default["default"].sep).reduce(function (acc, curr) {
79
79
  return curr === "" ? acc + 1 : acc;
80
80
  }, 0);
81
81
  var pathSegments = expectedValue.split(path__default["default"].sep);
@@ -75,7 +75,7 @@ var noIllegalModuleIds = {
75
75
  // in a monorepo, the root dir will be the root of the monorepo, not the root of the package
76
76
  // so we need to account for that
77
77
  // Assume the import of the val.config is correct and that it is in the root folder
78
- var numberOfDirsToRoot = valConfigImportSource.split("..").reduce(function (acc, curr) {
78
+ var numberOfDirsToRoot = valConfigImportSource.split(".." + path__default["default"].sep).reduce(function (acc, curr) {
79
79
  return curr === "" ? acc + 1 : acc;
80
80
  }, 0);
81
81
  var pathSegments = expectedValue.split(path__default["default"].sep);
@@ -67,7 +67,7 @@ var noIllegalModuleIds = {
67
67
  // in a monorepo, the root dir will be the root of the monorepo, not the root of the package
68
68
  // so we need to account for that
69
69
  // Assume the import of the val.config is correct and that it is in the root folder
70
- var numberOfDirsToRoot = valConfigImportSource.split("..").reduce(function (acc, curr) {
70
+ var numberOfDirsToRoot = valConfigImportSource.split(".." + path.sep).reduce(function (acc, curr) {
71
71
  return curr === "" ? acc + 1 : acc;
72
72
  }, 0);
73
73
  var pathSegments = expectedValue.split(path.sep);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/eslint-plugin",
3
- "version": "0.43.1",
3
+ "version": "0.43.2",
4
4
  "description": "ESLint rules for val",
5
5
  "keywords": [
6
6
  "eslint",
@@ -52,7 +52,7 @@ export default {
52
52
  // so we need to account for that
53
53
  // Assume the import of the val.config is correct and that it is in the root folder
54
54
  const numberOfDirsToRoot = valConfigImportSource
55
- .split("..")
55
+ .split(".." + path.sep)
56
56
  .reduce((acc, curr) => (curr === "" ? acc + 1 : acc), 0);
57
57
  const pathSegments = expectedValue.split(path.sep);
58
58
  expectedValue = `/${path.join(
@@ -46,4 +46,45 @@ export default val.content(
46
46
  expect(results[0].messages).toHaveLength(1);
47
47
  expect(results[0].messages[0].fix?.text).toEqual('"/app/test"');
48
48
  });
49
+
50
+ test("no illegal modules for monorepos (projects that are not at root) - nested", async () => {
51
+ const code = `import { s, val } from "../../../../val.config";
52
+
53
+ export const schema = s.string();
54
+
55
+ export default val.content(
56
+ "/something",
57
+ schema,
58
+ "React Server components also works"
59
+ );`;
60
+ const results = await eslint.lintText(code, {
61
+ filePath: "./content/stuff/with/all/test.val.ts",
62
+ });
63
+
64
+ expect(results).toHaveLength(1);
65
+ expect(results[0].messages).toHaveLength(1);
66
+ expect(results[0].messages[0].fix?.text).toEqual(
67
+ '"/content/stuff/with/all/test"'
68
+ );
69
+ });
70
+ test("no illegal modules for monorepos (projects that are not at root) - src", async () => {
71
+ const code = `import { s, val } from "../../../../val.config";
72
+
73
+ export const schema = s.string();
74
+
75
+ export default val.content(
76
+ "/something",
77
+ schema,
78
+ "React Server components also works"
79
+ );`;
80
+ const results = await eslint.lintText(code, {
81
+ filePath: "./src/content/stuff/with/all/test.val.ts",
82
+ });
83
+
84
+ expect(results).toHaveLength(1);
85
+ expect(results[0].messages).toHaveLength(1);
86
+ expect(results[0].messages[0].fix?.text).toEqual(
87
+ '"/content/stuff/with/all/test"'
88
+ );
89
+ });
49
90
  });