exadev-eslint-config 2.15.0 → 2.16.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.
package/README.md CHANGED
@@ -162,11 +162,13 @@ Trailing arguments are arbitrary flat-config objects, appended in order after ev
162
162
 
163
163
  ## RFC 8785 canonical JSON formatting
164
164
 
165
- Every JSON file (`**/*.json`, excluding `**/tsconfig*.json`, `**/turbo.json`, and `**/package.json`) is linted against [`eslint-plugin-json-canonical`](https://github.com/ExaDev/eslint-plugin-json-canonical)'s `configs.recommended` -- plain UTF-16 code-unit key ordering, canonical number formatting, and canonical string escaping, per [RFC 8785](https://www.rfc-editor.org/rfc/rfc8785). This is bundled unconditionally, the same way jsdoc/tsdoc support is: `eslint-plugin-json-canonical` is a plain dependency of this package, so every consumer already has it. There is no option to turn it off.
165
+ Every JSON file is linted against [`eslint-plugin-json-canonical`](https://github.com/ExaDev/eslint-plugin-json-canonical) v2 -- plain UTF-16 code-unit key ordering, canonical number formatting, canonical string escaping, and (as of that plugin's own v2) pretty-printed layout (2-space indentation, one member/element per line, a trailing newline), per [RFC 8785](https://www.rfc-editor.org/rfc/rfc8785). This is bundled unconditionally, the same way jsdoc/tsdoc support is: `eslint-plugin-json-canonical` is a plain dependency of this package, so every consumer already has it. There is no option to turn it off.
166
166
 
167
- The plugin's own whitespace-collapsing rule (`no-insignificant-whitespace`, which reformats a document to a single compacted line) is deliberately not part of `configs.recommended` and is not enabled here either -- it stays available for a consumer to opt into directly for their own genuine canonicalization pass.
167
+ The plugin's own full-canonicalization rule (`no-insignificant-whitespace`, which collapses a document to a single compacted line with no whitespace at all) is deliberately not part of the config this package extends -- it stays available for a consumer to opt into directly for their own genuine canonicalization pass (hashing, signing, byte-for-byte comparison).
168
168
 
169
- `**/tsconfig*.json` and `**/turbo.json` are excluded because they genuinely carry comments (TypeScript and turbo both accept them), which `@eslint/json`'s `json/json` language -- what this plugin's recommended config hard-codes -- has no concept of and fails to parse. `**/package.json`'s own key order is excluded from this bundle specifically (its number-format/string-escaping rules still apply) since ordering is the separate, syncpack-aware concern the next section covers.
169
+ `**/*.jsonc`, `**/tsconfig*.json`, and `**/turbo.json` get the plugin's `configs.contentOnlyJsonc` instead of the plain-JSON config: they genuinely carry comments (TypeScript and turbo both accept them), which `@eslint/json`'s `json/json` language has no concept of and fails to parse, and neither pretty-printing nor whitespace-collapsing has a well-defined answer for a comment's own attachment to a member once its surrounding whitespace is rewritten. Content canonicalization (key order, number/string formatting) still applies to these files under `json/jsonc`.
170
+
171
+ `**/package.json` gets everything the plain-JSON config gives every other file -- including pretty-printed layout -- except `json/sort-keys`, turned back off in its own override block, since its key order is the separate, syncpack-aware concern the next section covers.
170
172
 
171
173
  ## Optional package.json key ordering
172
174
 
package/dist/index.cjs CHANGED
@@ -81,17 +81,36 @@ const jsdocAndTsdoc = [{
81
81
  function isSingleFlatConfig(value) {
82
82
  return typeof value === "object" && value !== null && !Array.isArray(value) && "language" in value;
83
83
  }
84
- const recommended = eslint_plugin_json_canonical.default.configs?.["recommended"];
85
- if (!isSingleFlatConfig(recommended)) throw new Error("eslint-plugin-json-canonical: expected configs.recommended to be a single flat config object, got an array or undefined");
86
- const jsonCanonicalConfig = [{
87
- files: ["**/*.json"],
88
- ignores: [
89
- "**/tsconfig*.json",
90
- "**/turbo.json",
91
- "**/package.json"
92
- ],
93
- ...recommended
94
- }];
84
+ function requireConfig(name) {
85
+ const config = eslint_plugin_json_canonical.default.configs?.[name];
86
+ if (!isSingleFlatConfig(config)) throw new Error(`eslint-plugin-json-canonical: expected configs.${name} to be a single flat config object, got an array or undefined`);
87
+ return config;
88
+ }
89
+ const recommended = requireConfig("recommended");
90
+ const contentOnlyJsonc = requireConfig("contentOnlyJsonc");
91
+ const jsonCanonicalConfig = [
92
+ {
93
+ files: ["**/*.json"],
94
+ ignores: [
95
+ "**/*.jsonc",
96
+ "**/tsconfig*.json",
97
+ "**/turbo.json"
98
+ ],
99
+ ...recommended
100
+ },
101
+ {
102
+ files: [
103
+ "**/*.jsonc",
104
+ "**/tsconfig*.json",
105
+ "**/turbo.json"
106
+ ],
107
+ ...contentOnlyJsonc
108
+ },
109
+ {
110
+ files: ["**/package.json"],
111
+ rules: { "json/sort-keys": "off" }
112
+ }
113
+ ];
95
114
  //#endregion
96
115
  //#region src/optional-plugin.ts
97
116
  const nodeRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
@@ -141,7 +160,7 @@ function buildNextjsConfig(options = {}) {
141
160
  }
142
161
  //#endregion
143
162
  //#region package.json
144
- var version = "2.15.0";
163
+ var version = "2.16.0";
145
164
  //#endregion
146
165
  //#region src/react.ts
147
166
  const JSX_FILE_PATTERNS = ["**/*.jsx", "**/*.tsx"];
package/dist/index.js CHANGED
@@ -49,17 +49,36 @@ const jsdocAndTsdoc = [{
49
49
  function isSingleFlatConfig(value) {
50
50
  return typeof value === "object" && value !== null && !Array.isArray(value) && "language" in value;
51
51
  }
52
- const recommended = jsonCanonical.configs?.["recommended"];
53
- if (!isSingleFlatConfig(recommended)) throw new Error("eslint-plugin-json-canonical: expected configs.recommended to be a single flat config object, got an array or undefined");
54
- const jsonCanonicalConfig = [{
55
- files: ["**/*.json"],
56
- ignores: [
57
- "**/tsconfig*.json",
58
- "**/turbo.json",
59
- "**/package.json"
60
- ],
61
- ...recommended
62
- }];
52
+ function requireConfig(name) {
53
+ const config = jsonCanonical.configs?.[name];
54
+ if (!isSingleFlatConfig(config)) throw new Error(`eslint-plugin-json-canonical: expected configs.${name} to be a single flat config object, got an array or undefined`);
55
+ return config;
56
+ }
57
+ const recommended = requireConfig("recommended");
58
+ const contentOnlyJsonc = requireConfig("contentOnlyJsonc");
59
+ const jsonCanonicalConfig = [
60
+ {
61
+ files: ["**/*.json"],
62
+ ignores: [
63
+ "**/*.jsonc",
64
+ "**/tsconfig*.json",
65
+ "**/turbo.json"
66
+ ],
67
+ ...recommended
68
+ },
69
+ {
70
+ files: [
71
+ "**/*.jsonc",
72
+ "**/tsconfig*.json",
73
+ "**/turbo.json"
74
+ ],
75
+ ...contentOnlyJsonc
76
+ },
77
+ {
78
+ files: ["**/package.json"],
79
+ rules: { "json/sort-keys": "off" }
80
+ }
81
+ ];
63
82
  //#endregion
64
83
  //#region src/optional-plugin.ts
65
84
  const nodeRequire = createRequire(import.meta.url);
@@ -109,7 +128,7 @@ function buildNextjsConfig(options = {}) {
109
128
  }
110
129
  //#endregion
111
130
  //#region package.json
112
- var version = "2.15.0";
131
+ var version = "2.16.0";
113
132
  //#endregion
114
133
  //#region src/react.ts
115
134
  const JSX_FILE_PATTERNS = ["**/*.jsx", "**/*.tsx"];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "exadev-eslint-config",
3
3
  "description": "Shared custom ESLint rules and plugin for ExaDev projects",
4
- "version": "2.15.0",
4
+ "version": "2.16.0",
5
5
  "dependencies": {
6
6
  "@eslint/js": "^10.0.1",
7
7
  "@typescript-eslint/utils": "8.67.0",
8
8
  "eslint-plugin-jsdoc": "64.3.6",
9
- "eslint-plugin-json-canonical": "1.0.0",
9
+ "eslint-plugin-json-canonical": "2.0.0",
10
10
  "eslint-plugin-tsdoc": "^0.5.2",
11
11
  "ts-api-utils": "^2.5.0"
12
12
  },