exadev-eslint-config 2.13.0 → 2.14.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
@@ -160,6 +160,14 @@ export default tseslint.config(
160
160
 
161
161
  Trailing arguments are arbitrary flat-config objects, appended in order after everything else -- `exadevConfig({}, { rules: { 'no-console': 'warn' } })` is equivalent to spreading the default export plus one more config object.
162
162
 
163
+ ## RFC 8785 canonical JSON formatting
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.
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.
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` is excluded because its key order is a distinct, separately-optional concern (syncpack-style field-priority pinning, not RFC 8785's plain alphabetical order); a project wanting that instead reaches for `eslint-plugin-json-canonical` directly on its own terms, not through this package.
170
+
163
171
  ## Rules
164
172
 
165
173
  | Rule | Fixable | Description |
package/dist/index.cjs CHANGED
@@ -28,6 +28,8 @@ let eslint_plugin_jsdoc = require("eslint-plugin-jsdoc");
28
28
  eslint_plugin_jsdoc = __toESM(eslint_plugin_jsdoc, 1);
29
29
  let eslint_plugin_tsdoc = require("eslint-plugin-tsdoc");
30
30
  eslint_plugin_tsdoc = __toESM(eslint_plugin_tsdoc, 1);
31
+ let eslint_plugin_json_canonical = require("eslint-plugin-json-canonical");
32
+ eslint_plugin_json_canonical = __toESM(eslint_plugin_json_canonical, 1);
31
33
  let node_module = require("node:module");
32
34
  let _eslint_js = require("@eslint/js");
33
35
  _eslint_js = __toESM(_eslint_js, 1);
@@ -74,6 +76,22 @@ const jsdocAndTsdoc = [{
74
76
  rules: { "tsdoc/syntax": "error" }
75
77
  }];
76
78
  //#endregion
79
+ //#region src/json-canonical.ts
80
+ function isSingleFlatConfig(value) {
81
+ return typeof value === "object" && value !== null && !Array.isArray(value) && "language" in value;
82
+ }
83
+ const recommended = eslint_plugin_json_canonical.default.configs?.["recommended"];
84
+ 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");
85
+ const jsonCanonicalConfig = [{
86
+ files: ["**/*.json"],
87
+ ignores: [
88
+ "**/tsconfig*.json",
89
+ "**/turbo.json",
90
+ "**/package.json"
91
+ ],
92
+ ...recommended
93
+ }];
94
+ //#endregion
77
95
  //#region src/optional-plugin.ts
78
96
  const nodeRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
79
97
  function tryRequire(specifier, requireFn = nodeRequire) {
@@ -159,7 +177,7 @@ function buildReactConfig(options = {}) {
159
177
  }
160
178
  //#endregion
161
179
  //#region package.json
162
- var version = "2.13.0";
180
+ var version = "2.14.0";
163
181
  //#endregion
164
182
  //#region src/rules/barrel-helpers.ts
165
183
  const INDEX_BASENAME$1 = /^index\.[cm]?[tj]sx?$/;
@@ -1562,6 +1580,7 @@ function exadevConfig(options = {}, ...userConfigs) {
1562
1580
  return toPublicConfigArray([
1563
1581
  ...recommendedTypeChecked,
1564
1582
  ...jsdocAndTsdoc,
1583
+ ...jsonCanonicalConfig,
1565
1584
  ...buildReactConfig({ enabled: options.react }),
1566
1585
  ...buildNextjsConfig({ enabled: options.nextjs }),
1567
1586
  ...userConfigs
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import jsdoc from "eslint-plugin-jsdoc";
2
2
  import tsdoc from "eslint-plugin-tsdoc";
3
+ import jsonCanonical from "eslint-plugin-json-canonical";
3
4
  import { createRequire } from "node:module";
4
5
  import js from "@eslint/js";
5
6
  import tseslint from "typescript-eslint";
@@ -43,6 +44,22 @@ const jsdocAndTsdoc = [{
43
44
  rules: { "tsdoc/syntax": "error" }
44
45
  }];
45
46
  //#endregion
47
+ //#region src/json-canonical.ts
48
+ function isSingleFlatConfig(value) {
49
+ return typeof value === "object" && value !== null && !Array.isArray(value) && "language" in value;
50
+ }
51
+ const recommended = jsonCanonical.configs?.["recommended"];
52
+ 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");
53
+ const jsonCanonicalConfig = [{
54
+ files: ["**/*.json"],
55
+ ignores: [
56
+ "**/tsconfig*.json",
57
+ "**/turbo.json",
58
+ "**/package.json"
59
+ ],
60
+ ...recommended
61
+ }];
62
+ //#endregion
46
63
  //#region src/optional-plugin.ts
47
64
  const nodeRequire = createRequire(import.meta.url);
48
65
  function tryRequire(specifier, requireFn = nodeRequire) {
@@ -128,7 +145,7 @@ function buildReactConfig(options = {}) {
128
145
  }
129
146
  //#endregion
130
147
  //#region package.json
131
- var version = "2.13.0";
148
+ var version = "2.14.0";
132
149
  //#endregion
133
150
  //#region src/rules/barrel-helpers.ts
134
151
  const INDEX_BASENAME$1 = /^index\.[cm]?[tj]sx?$/;
@@ -1531,6 +1548,7 @@ function exadevConfig(options = {}, ...userConfigs) {
1531
1548
  return toPublicConfigArray([
1532
1549
  ...recommendedTypeChecked,
1533
1550
  ...jsdocAndTsdoc,
1551
+ ...jsonCanonicalConfig,
1534
1552
  ...buildReactConfig({ enabled: options.react }),
1535
1553
  ...buildNextjsConfig({ enabled: options.nextjs }),
1536
1554
  ...userConfigs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exadev-eslint-config",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Shared custom ESLint rules and plugin for ExaDev projects",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -88,6 +88,7 @@
88
88
  "@eslint/js": "^10.0.1",
89
89
  "@typescript-eslint/utils": "8.67.0",
90
90
  "eslint-plugin-jsdoc": "64.3.6",
91
+ "eslint-plugin-json-canonical": "1.0.0",
91
92
  "eslint-plugin-tsdoc": "^0.5.2",
92
93
  "ts-api-utils": "^2.5.0"
93
94
  },