eslint-plugin-package-json 0.35.0 → 0.36.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/lib/createRule.js +4 -28
  3. package/lib/index.js +7 -32
  4. package/lib/plugin.js +34 -69
  5. package/lib/rules/no-empty-fields.js +10 -31
  6. package/lib/rules/no-redundant-files.js +13 -37
  7. package/lib/rules/order-properties.js +12 -46
  8. package/lib/rules/repository-shorthand.js +12 -36
  9. package/lib/rules/require-properties.js +4 -28
  10. package/lib/rules/restrict-dependency-ranges.js +12 -46
  11. package/lib/rules/sort-collections.js +4 -28
  12. package/lib/rules/unique-dependencies.js +12 -33
  13. package/lib/rules/valid-local-dependency.js +6 -40
  14. package/lib/rules/valid-name.js +6 -40
  15. package/lib/rules/valid-package-definition.js +6 -30
  16. package/lib/rules/valid-repository-directory.js +9 -43
  17. package/lib/rules/valid-version.js +6 -40
  18. package/lib/tests/rules/ruleTester.js +10 -44
  19. package/lib/utils/createRequirePropertyRule.js +6 -30
  20. package/lib/utils/findPropertyWithKeyValue.js +2 -26
  21. package/lib/utils/isPackageJson.js +2 -26
  22. package/lib/utils/predicates.js +2 -27
  23. package/package.json +11 -15
  24. package/lib/createRule.d.mts +0 -33
  25. package/lib/createRule.mjs +0 -15
  26. package/lib/index.d.mts +0 -41
  27. package/lib/index.mjs +0 -9
  28. package/lib/plugin.d.mts +0 -39
  29. package/lib/plugin.mjs +0 -95
  30. package/lib/rules/no-empty-fields.d.mts +0 -11
  31. package/lib/rules/no-empty-fields.mjs +0 -88
  32. package/lib/rules/no-redundant-files.d.mts +0 -11
  33. package/lib/rules/no-redundant-files.mjs +0 -146
  34. package/lib/rules/order-properties.d.mts +0 -15
  35. package/lib/rules/order-properties.mjs +0 -123
  36. package/lib/rules/repository-shorthand.d.mts +0 -15
  37. package/lib/rules/repository-shorthand.mjs +0 -118
  38. package/lib/rules/require-properties.d.mts +0 -9
  39. package/lib/rules/require-properties.mjs +0 -26
  40. package/lib/rules/restrict-dependency-ranges.d.mts +0 -20
  41. package/lib/rules/restrict-dependency-ranges.mjs +0 -205
  42. package/lib/rules/sort-collections.d.mts +0 -12
  43. package/lib/rules/sort-collections.mjs +0 -109
  44. package/lib/rules/unique-dependencies.d.mts +0 -11
  45. package/lib/rules/unique-dependencies.mjs +0 -87
  46. package/lib/rules/valid-local-dependency.d.mts +0 -11
  47. package/lib/rules/valid-local-dependency.mjs +0 -61
  48. package/lib/rules/valid-name.d.mts +0 -11
  49. package/lib/rules/valid-name.mjs +0 -51
  50. package/lib/rules/valid-package-definition.d.mts +0 -15
  51. package/lib/rules/valid-package-definition.mjs +0 -56
  52. package/lib/rules/valid-repository-directory.d.mts +0 -11
  53. package/lib/rules/valid-repository-directory.mjs +0 -88
  54. package/lib/rules/valid-version.d.mts +0 -11
  55. package/lib/rules/valid-version.mjs +0 -39
  56. package/lib/tests/rules/ruleTester.d.mts +0 -15
  57. package/lib/tests/rules/ruleTester.mjs +0 -25
  58. package/lib/utils/createRequirePropertyRule.d.mts +0 -15
  59. package/lib/utils/createRequirePropertyRule.mjs +0 -35
  60. package/lib/utils/findPropertyWithKeyValue.d.mts +0 -9
  61. package/lib/utils/findPropertyWithKeyValue.mjs +0 -8
  62. package/lib/utils/isPackageJson.d.mts +0 -3
  63. package/lib/utils/isPackageJson.mjs +0 -4
  64. package/lib/utils/predicates.d.mts +0 -6
  65. package/lib/utils/predicates.mjs +0 -10
package/CHANGELOG.md CHANGED
@@ -1,11 +1,23 @@
1
1
  # Changelog
2
2
 
3
- # [0.35.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.34.0...v0.35.0) (2025-06-10)
3
+ # [0.36.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.35.1...v0.36.0) (2025-06-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * migrate to ESM-only ([#1100](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1100)) ([623f162](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/623f162daa726a717c3ad48c1a777c3be7c404b0)), closes [#1080](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1080)
4
9
 
10
+ ## [0.35.1](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.35.0...v0.35.1) (2025-06-10)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **deps:** update dependency detect-indent to v7 ([#874](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/874)) ([65300dc](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/65300dc30dfdc79ab789a144f251f0b8ba96ea22))
15
+
16
+ # [0.35.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.34.0...v0.35.0) (2025-06-10)
5
17
 
6
18
  ### Features
7
19
 
8
- * remove support for node 18 ([#1097](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1097)) ([257659a](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/257659af4fda63e2143d1ab250546dd3cb0932e7)), closes [#1074](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1074)
20
+ - remove support for node 18 ([#1097](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1097)) ([257659a](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/commit/257659af4fda63e2143d1ab250546dd3cb0932e7)), closes [#1074](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1074)
9
21
 
10
22
  # [0.34.0](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/compare/v0.33.2...v0.34.0) (2025-06-10)
11
23
 
package/lib/createRule.js CHANGED
@@ -1,39 +1,15 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var createRule_exports = {};
20
- __export(createRule_exports, {
21
- createRule: () => createRule
22
- });
23
- module.exports = __toCommonJS(createRule_exports);
24
- var import_isPackageJson = require("./utils/isPackageJson.js");
1
+ import { isPackageJson } from "./utils/isPackageJson.js";
25
2
  function createRule(rule) {
26
3
  return {
27
4
  ...rule,
28
5
  create(context) {
29
- if (!(0, import_isPackageJson.isPackageJson)(context.filename)) {
6
+ if (!isPackageJson(context.filename)) {
30
7
  return {};
31
8
  }
32
9
  return rule.create(context);
33
10
  }
34
11
  };
35
12
  }
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
13
+ export {
38
14
  createRule
39
- });
15
+ };
package/lib/index.js CHANGED
@@ -1,34 +1,9 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var index_exports = {};
20
- __export(index_exports, {
21
- configs: () => configs,
22
- default: () => index_default,
23
- rules: () => rules
24
- });
25
- module.exports = __toCommonJS(index_exports);
26
- var import_plugin = require("./plugin.js");
27
- const rules = import_plugin.plugin.rules;
28
- const configs = import_plugin.plugin.configs;
29
- var index_default = import_plugin.plugin;
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
1
+ import { plugin } from "./plugin.js";
2
+ const rules = plugin.rules;
3
+ const configs = plugin.configs;
4
+ var index_default = plugin;
5
+ export {
32
6
  configs,
7
+ index_default as default,
33
8
  rules
34
- });
9
+ };
package/lib/plugin.js CHANGED
@@ -1,76 +1,42 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name2 in all)
10
- __defProp(target, name2, { get: all[name2], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var plugin_exports = {};
30
- __export(plugin_exports, {
31
- plugin: () => plugin
32
- });
33
- module.exports = __toCommonJS(plugin_exports);
34
- var parserJsonc = __toESM(require("jsonc-eslint-parser"));
35
- var import_node_module = require("node:module");
36
- var import_no_empty_fields = require("./rules/no-empty-fields.js");
37
- var import_no_redundant_files = require("./rules/no-redundant-files.js");
38
- var import_order_properties = require("./rules/order-properties.js");
39
- var import_repository_shorthand = require("./rules/repository-shorthand.js");
40
- var import_require_properties = require("./rules/require-properties.js");
41
- var import_restrict_dependency_ranges = require("./rules/restrict-dependency-ranges.js");
42
- var import_sort_collections = require("./rules/sort-collections.js");
43
- var import_unique_dependencies = require("./rules/unique-dependencies.js");
44
- var import_valid_local_dependency = require("./rules/valid-local-dependency.js");
45
- var import_valid_name = require("./rules/valid-name.js");
46
- var import_valid_package_definition = require("./rules/valid-package-definition.js");
47
- var import_valid_repository_directory = require("./rules/valid-repository-directory.js");
48
- var import_valid_version = require("./rules/valid-version.js");
49
- const import_meta = {};
50
- const require2 = (0, import_node_module.createRequire)(import_meta.url || __filename);
1
+ import * as parserJsonc from "jsonc-eslint-parser";
2
+ import { createRequire } from "node:module";
3
+ import { rule as noEmptyFields } from "./rules/no-empty-fields.js";
4
+ import { rule as noRedundantFiles } from "./rules/no-redundant-files.js";
5
+ import { rule as orderProperties } from "./rules/order-properties.js";
6
+ import { rule as preferRepositoryShorthand } from "./rules/repository-shorthand.js";
7
+ import { rules as requireRules } from "./rules/require-properties.js";
8
+ import { rule as restrictDependencyRanges } from "./rules/restrict-dependency-ranges.js";
9
+ import { rule as sortCollections } from "./rules/sort-collections.js";
10
+ import { rule as uniqueDependencies } from "./rules/unique-dependencies.js";
11
+ import { rule as validLocalDependency } from "./rules/valid-local-dependency.js";
12
+ import { rule as validName } from "./rules/valid-name.js";
13
+ import { rule as validPackageDefinition } from "./rules/valid-package-definition.js";
14
+ import { rule as validRepositoryDirectory } from "./rules/valid-repository-directory.js";
15
+ import { rule as validVersion } from "./rules/valid-version.js";
16
+ const require2 = createRequire(import.meta.url);
51
17
  const { name, version } = require2("../package.json");
52
18
  const rules = {
53
- "no-empty-fields": import_no_empty_fields.rule,
54
- "no-redundant-files": import_no_redundant_files.rule,
55
- "order-properties": import_order_properties.rule,
56
- ...import_require_properties.rules,
57
- "repository-shorthand": import_repository_shorthand.rule,
58
- "restrict-dependency-ranges": import_restrict_dependency_ranges.rule,
59
- "sort-collections": import_sort_collections.rule,
60
- "unique-dependencies": import_unique_dependencies.rule,
61
- "valid-local-dependency": import_valid_local_dependency.rule,
62
- "valid-name": import_valid_name.rule,
63
- "valid-package-definition": import_valid_package_definition.rule,
64
- "valid-repository-directory": import_valid_repository_directory.rule,
65
- "valid-version": import_valid_version.rule,
19
+ "no-empty-fields": noEmptyFields,
20
+ "no-redundant-files": noRedundantFiles,
21
+ "order-properties": orderProperties,
22
+ ...requireRules,
23
+ "repository-shorthand": preferRepositoryShorthand,
24
+ "restrict-dependency-ranges": restrictDependencyRanges,
25
+ "sort-collections": sortCollections,
26
+ "unique-dependencies": uniqueDependencies,
27
+ "valid-local-dependency": validLocalDependency,
28
+ "valid-name": validName,
29
+ "valid-package-definition": validPackageDefinition,
30
+ "valid-repository-directory": validRepositoryDirectory,
31
+ "valid-version": validVersion,
66
32
  /** @deprecated use 'valid-package-definition' instead */
67
33
  "valid-package-def": {
68
- ...import_valid_package_definition.rule,
34
+ ...validPackageDefinition,
69
35
  meta: {
70
- ...import_valid_package_definition.rule.meta,
36
+ ...validPackageDefinition.meta,
71
37
  deprecated: true,
72
38
  docs: {
73
- ...import_valid_package_definition.rule.meta.docs,
39
+ ...validPackageDefinition.meta.docs,
74
40
  recommended: false
75
41
  },
76
42
  replacedBy: ["valid-package-definition"]
@@ -124,7 +90,6 @@ const plugin = {
124
90
  },
125
91
  rules
126
92
  };
127
- // Annotate the CommonJS export names for ESM import in node:
128
- 0 && (module.exports = {
93
+ export {
129
94
  plugin
130
- });
95
+ };
@@ -1,28 +1,8 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var no_empty_fields_exports = {};
20
- __export(no_empty_fields_exports, {
21
- rule: () => rule
22
- });
23
- module.exports = __toCommonJS(no_empty_fields_exports);
24
- var import_eslint_fix_utils = require("eslint-fix-utils");
25
- var import_createRule = require("../createRule");
1
+ import {
2
+ fixRemoveArrayElement,
3
+ fixRemoveObjectProperty
4
+ } from "eslint-fix-utils";
5
+ import { createRule } from "../createRule.js";
26
6
  const getDataAndMessageId = (node) => {
27
7
  switch (node.type) {
28
8
  case "JSONArrayExpression":
@@ -56,10 +36,10 @@ const report = (context, node) => {
56
36
  node,
57
37
  suggest: [
58
38
  {
59
- fix: node.type === "JSONProperty" ? (0, import_eslint_fix_utils.fixRemoveObjectProperty)(
39
+ fix: node.type === "JSONProperty" ? fixRemoveObjectProperty(
60
40
  context,
61
41
  node
62
- ) : (0, import_eslint_fix_utils.fixRemoveArrayElement)(
42
+ ) : fixRemoveArrayElement(
63
43
  context,
64
44
  node,
65
45
  node.parent
@@ -72,7 +52,7 @@ const report = (context, node) => {
72
52
  const getNode = (node) => {
73
53
  return node.parent.type === "JSONProperty" ? node.parent : node;
74
54
  };
75
- const rule = (0, import_createRule.createRule)({
55
+ const rule = createRule({
76
56
  create(context) {
77
57
  return {
78
58
  JSONArrayExpression(node) {
@@ -103,7 +83,6 @@ const rule = (0, import_createRule.createRule)({
103
83
  type: "suggestion"
104
84
  }
105
85
  });
106
- // Annotate the CommonJS export names for ESM import in node:
107
- 0 && (module.exports = {
86
+ export {
108
87
  rule
109
- });
88
+ };
@@ -1,29 +1,6 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var no_redundant_files_exports = {};
20
- __export(no_redundant_files_exports, {
21
- rule: () => rule
22
- });
23
- module.exports = __toCommonJS(no_redundant_files_exports);
24
- var import_eslint_fix_utils = require("eslint-fix-utils");
25
- var import_createRule = require("../createRule.js");
26
- var import_predicates = require("../utils/predicates.js");
1
+ import { fixRemoveArrayElement } from "eslint-fix-utils";
2
+ import { createRule } from "../createRule.js";
3
+ import { isJSONStringLiteral, isNotNullish } from "../utils/predicates.js";
27
4
  const defaultFiles = [
28
5
  /* cspell:disable-next-line */
29
6
  /^(\.\/)?LICEN(C|S)E(\.|$)/i,
@@ -46,19 +23,19 @@ const getCachedLocalFileRegex = (filename) => {
46
23
  return regex;
47
24
  }
48
25
  };
49
- const rule = (0, import_createRule.createRule)({
26
+ const rule = createRule({
50
27
  create(context) {
51
28
  const entryCache = { bin: [], files: [] };
52
29
  const report = (elements, index, messageId) => {
53
30
  const element = elements[index];
54
- if ((0, import_predicates.isNotNullish)(element) && (0, import_predicates.isJSONStringLiteral)(element)) {
31
+ if (isNotNullish(element) && isJSONStringLiteral(element)) {
55
32
  context.report({
56
33
  data: { file: element.value },
57
34
  messageId,
58
35
  node: element,
59
36
  suggest: [
60
37
  {
61
- fix: (0, import_eslint_fix_utils.fixRemoveArrayElement)(
38
+ fix: fixRemoveArrayElement(
62
39
  context,
63
40
  index,
64
41
  elements
@@ -72,11 +49,11 @@ const rule = (0, import_createRule.createRule)({
72
49
  return {
73
50
  "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=bin]"(node) {
74
51
  const binValue = node.value;
75
- if ((0, import_predicates.isJSONStringLiteral)(binValue)) {
52
+ if (isJSONStringLiteral(binValue)) {
76
53
  entryCache.bin.push(binValue.value);
77
54
  } else if (binValue.type === "JSONObjectExpression") {
78
55
  for (const prop of binValue.properties) {
79
- if ((0, import_predicates.isJSONStringLiteral)(prop.value)) {
56
+ if (isJSONStringLiteral(prop.value)) {
80
57
  entryCache.bin.push(prop.value.value);
81
58
  }
82
59
  }
@@ -88,7 +65,7 @@ const rule = (0, import_createRule.createRule)({
88
65
  const elements = node.value.elements;
89
66
  entryCache.files = elements;
90
67
  for (const [index, element] of elements.entries()) {
91
- if ((0, import_predicates.isNotNullish)(element) && (0, import_predicates.isJSONStringLiteral)(element)) {
68
+ if (isNotNullish(element) && isJSONStringLiteral(element)) {
92
69
  if (seen.has(element.value)) {
93
70
  report(elements, index, "duplicate");
94
71
  } else {
@@ -108,7 +85,7 @@ const rule = (0, import_createRule.createRule)({
108
85
  }
109
86
  },
110
87
  "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=main]"(node) {
111
- if ((0, import_predicates.isJSONStringLiteral)(node.value)) {
88
+ if (isJSONStringLiteral(node.value)) {
112
89
  entryCache.main = node.value.value;
113
90
  }
114
91
  },
@@ -132,7 +109,7 @@ const rule = (0, import_createRule.createRule)({
132
109
  for (const validation of validations) {
133
110
  for (const fileToCheck of validation.files) {
134
111
  for (const [index, fileEntry] of files.entries()) {
135
- if ((0, import_predicates.isNotNullish)(fileEntry) && (0, import_predicates.isJSONStringLiteral)(fileEntry)) {
112
+ if (isNotNullish(fileEntry) && isJSONStringLiteral(fileEntry)) {
136
113
  const regex = getCachedLocalFileRegex(
137
114
  fileEntry.value
138
115
  );
@@ -164,7 +141,6 @@ const rule = (0, import_createRule.createRule)({
164
141
  type: "suggestion"
165
142
  }
166
143
  });
167
- // Annotate the CommonJS export names for ESM import in node:
168
- 0 && (module.exports = {
144
+ export {
169
145
  rule
170
- });
146
+ };
@@ -1,41 +1,8 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var order_properties_exports = {};
30
- __export(order_properties_exports, {
31
- rule: () => rule
32
- });
33
- module.exports = __toCommonJS(order_properties_exports);
34
- var import_detect_indent = __toESM(require("detect-indent"));
35
- var import_detect_newline = __toESM(require("detect-newline"));
36
- var import_sort_object_keys = __toESM(require("sort-object-keys"));
37
- var import_sort_package_json = require("sort-package-json");
38
- var import_createRule = require("../createRule.js");
1
+ import detectIndent from "detect-indent";
2
+ import detectNewline from "detect-newline";
3
+ import sortObjectKeys from "sort-object-keys";
4
+ import { sortOrder } from "sort-package-json";
5
+ import { createRule } from "../createRule.js";
39
6
  const standardOrderLegacy = [
40
7
  "name",
41
8
  "version",
@@ -66,7 +33,7 @@ const standardOrderLegacy = [
66
33
  "os",
67
34
  "cpu"
68
35
  ];
69
- const rule = (0, import_createRule.createRule)({
36
+ const rule = createRule({
70
37
  create(context) {
71
38
  return {
72
39
  "Program:exit"() {
@@ -75,9 +42,9 @@ const rule = (0, import_createRule.createRule)({
75
42
  order: "sort-package-json",
76
43
  ...context.options[0]
77
44
  };
78
- const requiredOrder = options.order === "legacy" ? standardOrderLegacy : options.order === "sort-package-json" ? import_sort_package_json.sortOrder : options.order;
45
+ const requiredOrder = options.order === "legacy" ? standardOrderLegacy : options.order === "sort-package-json" ? sortOrder : options.order;
79
46
  const json = JSON.parse(text);
80
- const orderedSource = (0, import_sort_object_keys.default)(json, [
47
+ const orderedSource = sortObjectKeys(json, [
81
48
  ...requiredOrder,
82
49
  ...Object.keys(json)
83
50
  ]);
@@ -94,9 +61,9 @@ const rule = (0, import_createRule.createRule)({
94
61
  property: value
95
62
  },
96
63
  fix(fixer) {
97
- const { indent, type } = (0, import_detect_indent.default)(text);
64
+ const { indent, type } = detectIndent(text);
98
65
  const endCharacters = text.endsWith("\n") ? "\n" : "";
99
- const newline = import_detect_newline.default.graceful(text);
66
+ const newline = detectNewline.graceful(text);
100
67
  let result = JSON.stringify(
101
68
  orderedSource,
102
69
  null,
@@ -151,7 +118,6 @@ const rule = (0, import_createRule.createRule)({
151
118
  type: "layout"
152
119
  }
153
120
  });
154
- // Annotate the CommonJS export names for ESM import in node:
155
- 0 && (module.exports = {
121
+ export {
156
122
  rule
157
- });
123
+ };
@@ -1,40 +1,17 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var repository_shorthand_exports = {};
20
- __export(repository_shorthand_exports, {
21
- rule: () => rule
22
- });
23
- module.exports = __toCommonJS(repository_shorthand_exports);
24
- var import_createRule = require("../createRule.js");
25
- var import_findPropertyWithKeyValue = require("../utils/findPropertyWithKeyValue.js");
26
- var import_predicates = require("../utils/predicates.js");
1
+ import { createRule } from "../createRule.js";
2
+ import { findPropertyWithKeyValue } from "../utils/findPropertyWithKeyValue.js";
3
+ import { isJSONStringLiteral } from "../utils/predicates.js";
27
4
  const githubUrlRegex = /^(?:git\+)?(?:ssh:\/\/git@|http?s:\/\/)?(?:www\.)?github\.com\//;
28
5
  const isGitHubUrl = (url) => githubUrlRegex.test(url);
29
6
  const cleanGitHubUrl = (url) => url.replace(githubUrlRegex, "").replace(/\.git$/, "");
30
- const rule = (0, import_createRule.createRule)({
7
+ const rule = createRule({
31
8
  create(context) {
32
9
  const [{ form = "object" } = {}] = context.options;
33
10
  function validateRepositoryForObject(node) {
34
- if ((0, import_predicates.isJSONStringLiteral)(node.value)) {
11
+ if (isJSONStringLiteral(node.value)) {
35
12
  context.report({
36
13
  fix(fixer) {
37
- if (!(0, import_predicates.isJSONStringLiteral)(node.value) || node.value.value.split("/").filter(Boolean).length !== 2) {
14
+ if (!isJSONStringLiteral(node.value) || node.value.value.split("/").filter(Boolean).length !== 2) {
38
15
  return null;
39
16
  }
40
17
  return fixer.replaceText(
@@ -55,7 +32,7 @@ const rule = (0, import_createRule.createRule)({
55
32
  }
56
33
  }
57
34
  function validateRepositoryForShorthand(node) {
58
- if ((0, import_predicates.isJSONStringLiteral)(node.value)) {
35
+ if (isJSONStringLiteral(node.value)) {
59
36
  const { value } = node.value;
60
37
  if (typeof value === "string" && isGitHubUrl(value)) {
61
38
  context.report({
@@ -75,14 +52,14 @@ const rule = (0, import_createRule.createRule)({
75
52
  return;
76
53
  }
77
54
  const { properties } = node.value;
78
- if ((0, import_findPropertyWithKeyValue.findPropertyWithKeyValue)(properties, "directory")) {
55
+ if (findPropertyWithKeyValue(properties, "directory")) {
79
56
  return;
80
57
  }
81
- const typeProperty = (0, import_findPropertyWithKeyValue.findPropertyWithKeyValue)(properties, "type");
58
+ const typeProperty = findPropertyWithKeyValue(properties, "type");
82
59
  if (typeProperty?.value.type !== "JSONLiteral" || typeProperty.value.value !== "git") {
83
60
  return;
84
61
  }
85
- const urlProperty = (0, import_findPropertyWithKeyValue.findPropertyWithKeyValue)(properties, "url");
62
+ const urlProperty = findPropertyWithKeyValue(properties, "url");
86
63
  if (urlProperty?.value.type !== "JSONLiteral" || typeof urlProperty.value.value !== "string" || !isGitHubUrl(urlProperty.value.value)) {
87
64
  return;
88
65
  }
@@ -136,7 +113,6 @@ const rule = (0, import_createRule.createRule)({
136
113
  type: "suggestion"
137
114
  }
138
115
  });
139
- // Annotate the CommonJS export names for ESM import in node:
140
- 0 && (module.exports = {
116
+ export {
141
117
  rule
142
- });
118
+ };
@@ -1,27 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var require_properties_exports = {};
20
- __export(require_properties_exports, {
21
- rules: () => rules
22
- });
23
- module.exports = __toCommonJS(require_properties_exports);
24
- var import_createRequirePropertyRule = require("../utils/createRequirePropertyRule.js");
1
+ import { createRequirePropertyRule } from "../utils/createRequirePropertyRule.js";
25
2
  const properties = [
26
3
  ["author", false],
27
4
  ["description", true],
@@ -36,7 +13,7 @@ const properties = [
36
13
  ];
37
14
  const rules = properties.reduce(
38
15
  (acc, [propertyName, isRecommended]) => {
39
- acc[`require-${propertyName}`] = (0, import_createRequirePropertyRule.createRequirePropertyRule)(
16
+ acc[`require-${propertyName}`] = createRequirePropertyRule(
40
17
  propertyName,
41
18
  isRecommended
42
19
  );
@@ -44,7 +21,6 @@ const rules = properties.reduce(
44
21
  },
45
22
  {}
46
23
  );
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
24
+ export {
49
25
  rules
50
- });
26
+ };