@html-validate/prettier-config 3.1.7 → 3.1.8

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.
@@ -24,28 +24,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  mod
25
25
  ));
26
26
 
27
- // node_modules/sort-object-keys/index.js
28
- var require_sort_object_keys = __commonJS({
29
- "node_modules/sort-object-keys/index.js"(exports, module) {
30
- module.exports = function sortObjectByKeyNameList(object, sortWith) {
31
- var keys;
32
- var sortFn;
33
- if (typeof sortWith === "function") {
34
- sortFn = sortWith;
35
- } else {
36
- keys = sortWith;
37
- }
38
- var objectKeys = Object.keys(object);
39
- return (keys || []).concat(objectKeys.sort(sortFn)).reduce(function(total, key) {
40
- if (objectKeys.indexOf(key) !== -1) {
41
- total[key] = object[key];
42
- }
43
- return total;
44
- }, /* @__PURE__ */ Object.create(null));
45
- };
46
- }
47
- });
48
-
49
27
  // node_modules/sort-package-json/node_modules/semver/internal/constants.js
50
28
  var require_constants = __commonJS({
51
29
  "node_modules/sort-package-json/node_modules/semver/internal/constants.js"(exports, module) {
@@ -1979,8 +1957,24 @@ var require_semver2 = __commonJS({
1979
1957
  // src/sort-package-json.ts
1980
1958
  import { parsers } from "prettier/esm/parser-babel.mjs";
1981
1959
 
1982
- // node_modules/sort-package-json/index.js
1983
- var import_sort_object_keys = __toESM(require_sort_object_keys(), 1);
1960
+ // node_modules/sort-object-keys/index.js
1961
+ var has = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
1962
+ function sortObjectByKeyNameList(object, sortWith) {
1963
+ let keys, sortFn, key;
1964
+ if (typeof sortWith === "function") {
1965
+ sortFn = sortWith;
1966
+ } else {
1967
+ keys = sortWith;
1968
+ }
1969
+ const total = {};
1970
+ const objectKeys = [...keys ?? [], ...Object.keys(object).sort(sortFn)];
1971
+ for (key of objectKeys) {
1972
+ if (has(object, key)) {
1973
+ total[key] = object[key];
1974
+ }
1975
+ }
1976
+ return total;
1977
+ }
1984
1978
 
1985
1979
  // node_modules/detect-indent/index.js
1986
1980
  var INDENT_REGEX = /^(?:( )+|\t+)/;
@@ -2156,10 +2150,26 @@ var sortObjectBy = (comparator, deep) => {
2156
2150
  Object.entries(object).map(([key, value]) => [key, over(value)])
2157
2151
  );
2158
2152
  }
2159
- return (0, import_sort_object_keys.default)(object, comparator);
2153
+ return sortObjectByKeyNameList(object, comparator);
2160
2154
  });
2161
2155
  return over;
2162
2156
  };
2157
+ var objectGroupBy = (
2158
+ // eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax -- Safe
2159
+ Object.groupBy || // Remove this when we drop support for Node.js 20
2160
+ ((array, callback) => {
2161
+ const result = /* @__PURE__ */ Object.create(null);
2162
+ for (const value of array) {
2163
+ const key = callback(value);
2164
+ if (result[key]) {
2165
+ result[key].push(value);
2166
+ } else {
2167
+ result[key] = [value];
2168
+ }
2169
+ }
2170
+ return result;
2171
+ })
2172
+ );
2163
2173
  var sortObject = sortObjectBy();
2164
2174
  var sortURLObject = sortObjectBy(["type", "url"]);
2165
2175
  var sortPeopleObject = sortObjectBy(["name", "email", "url"]);
@@ -2272,7 +2282,7 @@ var sortVSCodeBadgeObject = sortObjectBy(["description", "url", "href"]);
2272
2282
  var sortPrettierConfig = onObject(
2273
2283
  pipe([
2274
2284
  // sort keys alphabetically, but put `overrides` at bottom
2275
- (config) => (0, import_sort_object_keys.default)(config, [
2285
+ (config) => sortObjectByKeyNameList(config, [
2276
2286
  ...Object.keys(config).filter((key) => key !== "overrides").sort(),
2277
2287
  "overrides"
2278
2288
  ]),
@@ -2359,7 +2369,35 @@ var sortScripts = onObject((scripts, packageJson) => {
2359
2369
  const order = keys.flatMap(
2360
2370
  (key) => prefixable.has(key) ? [`pre${key}`, key, `post${key}`] : [key]
2361
2371
  );
2362
- return (0, import_sort_object_keys.default)(scripts, order);
2372
+ return sortObjectByKeyNameList(scripts, order);
2373
+ });
2374
+ var sortConditions = (conditions) => {
2375
+ const {
2376
+ typesConditions = [],
2377
+ defaultConditions = [],
2378
+ restConditions = []
2379
+ } = objectGroupBy(conditions, (condition) => {
2380
+ if (condition === "types" || condition.startsWith("types@")) {
2381
+ return "typesConditions";
2382
+ }
2383
+ if (condition === "default") {
2384
+ return "defaultConditions";
2385
+ }
2386
+ return "restConditions";
2387
+ });
2388
+ return [...typesConditions, ...restConditions, ...defaultConditions];
2389
+ };
2390
+ var sortExports = onObject((exports) => {
2391
+ const { paths = [], conditions = [] } = objectGroupBy(
2392
+ Object.keys(exports),
2393
+ (key) => key.startsWith(".") ? "paths" : "conditions"
2394
+ );
2395
+ return Object.fromEntries(
2396
+ [...paths, ...sortConditions(conditions)].map((key) => [
2397
+ key,
2398
+ sortExports(exports[key])
2399
+ ])
2400
+ );
2363
2401
  });
2364
2402
  var fields = [
2365
2403
  { key: "$schema" },
@@ -2395,7 +2433,7 @@ var fields = [
2395
2433
  { key: "sideEffects" },
2396
2434
  { key: "type" },
2397
2435
  { key: "imports" },
2398
- { key: "exports" },
2436
+ { key: "exports", over: sortExports },
2399
2437
  { key: "main" },
2400
2438
  { key: "svelte" },
2401
2439
  { key: "umd:main" },
@@ -2548,7 +2586,7 @@ function sortPackageJson(jsonIsh, options = {}) {
2548
2586
  ...privateKeys.sort()
2549
2587
  ];
2550
2588
  }
2551
- return overFields((0, import_sort_object_keys.default)(json, sortOrder), json);
2589
+ return overFields(sortObjectByKeyNameList(json, sortOrder), json);
2552
2590
  })
2553
2591
  );
2554
2592
  }
@@ -2562,9 +2600,9 @@ var plugin = {
2562
2600
  parsers: {
2563
2601
  "json-stringify": {
2564
2602
  ...parser,
2565
- preprocess(text, options) {
2603
+ async preprocess(text, options) {
2566
2604
  if (parser.preprocess) {
2567
- text = parser.preprocess(text, options);
2605
+ text = await parser.preprocess(text, options);
2568
2606
  }
2569
2607
  return testPath(options.filepath) ? sortPackageJson(text) : text;
2570
2608
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/prettier-config",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "Prettier sharable config used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "prettier"
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "lint-staged": "16.2.7",
30
- "prettier": "3.6.2"
30
+ "prettier": "3.7.2"
31
31
  },
32
32
  "engines": {
33
33
  "node": ">= 20.18"