@valbuild/eslint-plugin 0.60.23 → 0.60.25

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.
@@ -8,36 +8,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
8
8
 
9
9
  var path__default = /*#__PURE__*/_interopDefault(path);
10
10
 
11
- function _arrayLikeToArray(arr, len) {
12
- if (len == null || len > arr.length) len = arr.length;
13
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
14
- return arr2;
15
- }
16
-
17
- function _arrayWithoutHoles(arr) {
18
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
19
- }
20
-
21
- function _iterableToArray(iter) {
22
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
23
- }
24
-
25
- function _unsupportedIterableToArray(o, minLen) {
26
- if (!o) return;
27
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
28
- var n = Object.prototype.toString.call(o).slice(8, -1);
29
- if (n === "Object" && o.constructor) n = o.constructor.name;
30
- if (n === "Map" || n === "Set") return Array.from(o);
31
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
32
- }
33
-
34
- function _nonIterableSpread() {
35
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
- }
37
-
38
- function _toConsumableArray(arr) {
39
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
40
- }
11
+ // @ts-check
41
12
 
42
13
  /**
43
14
  * @type {import('eslint').Rule.RuleModule}
@@ -64,21 +35,11 @@ var noIllegalModuleIds = {
64
35
  return n.type === "ImportDeclaration" && typeof n.source.value === "string" && (n.source.value.endsWith("val.config") || n.source.value.endsWith("val.config.ts") || n.source.value.endsWith("val.config.js")) ? n.source.value : false;
65
36
  });
66
37
  if ((maybeValConfigImportDeclaration === null || maybeValConfigImportDeclaration === void 0 ? void 0 : maybeValConfigImportDeclaration.type) === "ImportDeclaration" && typeof maybeValConfigImportDeclaration.source.value === "string") {
67
- var valConfigImportSource = maybeValConfigImportDeclaration.source.value;
68
38
  var filename = context.filename || context.getFilename();
69
39
  if (filename !== null && filename !== void 0 && filename.endsWith(".val.ts") || filename !== null && filename !== void 0 && filename.endsWith(".val.js")) {
70
40
  var root = context.cwd || process.cwd();
71
41
  var relativePath = path__default["default"].relative(root, filename);
72
- expectedValue = relativePath.replace(/\.val\.(ts|js)$/, "");
73
- // TODO: this feels like a weird way to figure out the correct relative path,
74
- // in a monorepo, the root dir will be the root of the monorepo, not the root of the package
75
- // so we need to account for that
76
- // Assume the import of the val.config is correct and that it is in the root folder
77
- var numberOfDirsToRoot = valConfigImportSource.split(".." + path__default["default"].sep).reduce(function (acc, curr) {
78
- return curr === "" ? acc + 1 : acc;
79
- }, 0);
80
- var pathSegments = expectedValue.split(path__default["default"].sep);
81
- expectedValue = "/".concat(path__default["default"].join.apply(path__default["default"], _toConsumableArray(pathSegments.slice(pathSegments.length - (numberOfDirsToRoot + 1), pathSegments.length))));
42
+ expectedValue = "/".concat(relativePath.replace(/\.val\.(ts|js)$/, ""));
82
43
  }
83
44
  }
84
45
  } else {
@@ -8,36 +8,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
8
8
 
9
9
  var path__default = /*#__PURE__*/_interopDefault(path);
10
10
 
11
- function _arrayLikeToArray(arr, len) {
12
- if (len == null || len > arr.length) len = arr.length;
13
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
14
- return arr2;
15
- }
16
-
17
- function _arrayWithoutHoles(arr) {
18
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
19
- }
20
-
21
- function _iterableToArray(iter) {
22
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
23
- }
24
-
25
- function _unsupportedIterableToArray(o, minLen) {
26
- if (!o) return;
27
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
28
- var n = Object.prototype.toString.call(o).slice(8, -1);
29
- if (n === "Object" && o.constructor) n = o.constructor.name;
30
- if (n === "Map" || n === "Set") return Array.from(o);
31
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
32
- }
33
-
34
- function _nonIterableSpread() {
35
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
- }
37
-
38
- function _toConsumableArray(arr) {
39
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
40
- }
11
+ // @ts-check
41
12
 
42
13
  /**
43
14
  * @type {import('eslint').Rule.RuleModule}
@@ -64,21 +35,11 @@ var noIllegalModuleIds = {
64
35
  return n.type === "ImportDeclaration" && typeof n.source.value === "string" && (n.source.value.endsWith("val.config") || n.source.value.endsWith("val.config.ts") || n.source.value.endsWith("val.config.js")) ? n.source.value : false;
65
36
  });
66
37
  if ((maybeValConfigImportDeclaration === null || maybeValConfigImportDeclaration === void 0 ? void 0 : maybeValConfigImportDeclaration.type) === "ImportDeclaration" && typeof maybeValConfigImportDeclaration.source.value === "string") {
67
- var valConfigImportSource = maybeValConfigImportDeclaration.source.value;
68
38
  var filename = context.filename || context.getFilename();
69
39
  if (filename !== null && filename !== void 0 && filename.endsWith(".val.ts") || filename !== null && filename !== void 0 && filename.endsWith(".val.js")) {
70
40
  var root = context.cwd || process.cwd();
71
41
  var relativePath = path__default["default"].relative(root, filename);
72
- expectedValue = relativePath.replace(/\.val\.(ts|js)$/, "");
73
- // TODO: this feels like a weird way to figure out the correct relative path,
74
- // in a monorepo, the root dir will be the root of the monorepo, not the root of the package
75
- // so we need to account for that
76
- // Assume the import of the val.config is correct and that it is in the root folder
77
- var numberOfDirsToRoot = valConfigImportSource.split(".." + path__default["default"].sep).reduce(function (acc, curr) {
78
- return curr === "" ? acc + 1 : acc;
79
- }, 0);
80
- var pathSegments = expectedValue.split(path__default["default"].sep);
81
- expectedValue = "/".concat(path__default["default"].join.apply(path__default["default"], _toConsumableArray(pathSegments.slice(pathSegments.length - (numberOfDirsToRoot + 1), pathSegments.length))));
42
+ expectedValue = "/".concat(relativePath.replace(/\.val\.(ts|js)$/, ""));
82
43
  }
83
44
  }
84
45
  } else {
@@ -1,35 +1,6 @@
1
1
  import path from 'path';
2
2
 
3
- function _arrayLikeToArray(arr, len) {
4
- if (len == null || len > arr.length) len = arr.length;
5
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
6
- return arr2;
7
- }
8
-
9
- function _arrayWithoutHoles(arr) {
10
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
11
- }
12
-
13
- function _iterableToArray(iter) {
14
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
15
- }
16
-
17
- function _unsupportedIterableToArray(o, minLen) {
18
- if (!o) return;
19
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
20
- var n = Object.prototype.toString.call(o).slice(8, -1);
21
- if (n === "Object" && o.constructor) n = o.constructor.name;
22
- if (n === "Map" || n === "Set") return Array.from(o);
23
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
24
- }
25
-
26
- function _nonIterableSpread() {
27
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
28
- }
29
-
30
- function _toConsumableArray(arr) {
31
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
32
- }
3
+ // @ts-check
33
4
 
34
5
  /**
35
6
  * @type {import('eslint').Rule.RuleModule}
@@ -56,21 +27,11 @@ var noIllegalModuleIds = {
56
27
  return n.type === "ImportDeclaration" && typeof n.source.value === "string" && (n.source.value.endsWith("val.config") || n.source.value.endsWith("val.config.ts") || n.source.value.endsWith("val.config.js")) ? n.source.value : false;
57
28
  });
58
29
  if ((maybeValConfigImportDeclaration === null || maybeValConfigImportDeclaration === void 0 ? void 0 : maybeValConfigImportDeclaration.type) === "ImportDeclaration" && typeof maybeValConfigImportDeclaration.source.value === "string") {
59
- var valConfigImportSource = maybeValConfigImportDeclaration.source.value;
60
30
  var filename = context.filename || context.getFilename();
61
31
  if (filename !== null && filename !== void 0 && filename.endsWith(".val.ts") || filename !== null && filename !== void 0 && filename.endsWith(".val.js")) {
62
32
  var root = context.cwd || process.cwd();
63
33
  var relativePath = path.relative(root, filename);
64
- expectedValue = relativePath.replace(/\.val\.(ts|js)$/, "");
65
- // TODO: this feels like a weird way to figure out the correct relative path,
66
- // in a monorepo, the root dir will be the root of the monorepo, not the root of the package
67
- // so we need to account for that
68
- // Assume the import of the val.config is correct and that it is in the root folder
69
- var numberOfDirsToRoot = valConfigImportSource.split(".." + path.sep).reduce(function (acc, curr) {
70
- return curr === "" ? acc + 1 : acc;
71
- }, 0);
72
- var pathSegments = expectedValue.split(path.sep);
73
- expectedValue = "/".concat(path.join.apply(path, _toConsumableArray(pathSegments.slice(pathSegments.length - (numberOfDirsToRoot + 1), pathSegments.length))));
34
+ expectedValue = "/".concat(relativePath.replace(/\.val\.(ts|js)$/, ""));
74
35
  }
75
36
  }
76
37
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/eslint-plugin",
3
- "version": "0.60.23",
3
+ "version": "0.60.25",
4
4
  "description": "ESLint rules for val",
5
5
  "keywords": [
6
6
  "eslint",
@@ -36,8 +36,6 @@ export default {
36
36
  maybeValConfigImportDeclaration?.type === "ImportDeclaration" &&
37
37
  typeof maybeValConfigImportDeclaration.source.value === "string"
38
38
  ) {
39
- const valConfigImportSource =
40
- maybeValConfigImportDeclaration.source.value;
41
39
  const filename = context.filename || context.getFilename();
42
40
  if (
43
41
  filename?.endsWith(".val.ts") ||
@@ -45,21 +43,7 @@ export default {
45
43
  ) {
46
44
  const root = context.cwd || process.cwd();
47
45
  const relativePath = path.relative(root, filename);
48
- expectedValue = relativePath.replace(/\.val\.(ts|js)$/, "");
49
- // TODO: this feels like a weird way to figure out the correct relative path,
50
- // in a monorepo, the root dir will be the root of the monorepo, not the root of the package
51
- // so we need to account for that
52
- // Assume the import of the val.config is correct and that it is in the root folder
53
- const numberOfDirsToRoot = valConfigImportSource
54
- .split(".." + path.sep)
55
- .reduce((acc, curr) => (curr === "" ? acc + 1 : acc), 0);
56
- const pathSegments = expectedValue.split(path.sep);
57
- expectedValue = `/${path.join(
58
- ...pathSegments.slice(
59
- pathSegments.length - (numberOfDirsToRoot + 1),
60
- pathSegments.length
61
- )
62
- )}`;
46
+ expectedValue = `/${relativePath.replace(/\.val\.(ts|js)$/, "")}`;
63
47
  }
64
48
  }
65
49
  } else {