@eslint/json 1.0.1 → 1.1.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
@@ -294,7 +294,7 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
294
294
 
295
295
  <h3>Platinum Sponsors</h3>
296
296
  <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
297
- <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
297
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
298
298
  <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
299
299
  <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" height="32"></a> <a href="https://www.n-ix.com/"><img src="https://images.opencollective.com/n-ix-ltd/575a7a5/logo.png" alt="N-iX Ltd" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
300
300
  <h3>Technology Sponsors</h3>
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import rules from "./build/rules.js";
15
15
  const plugin = {
16
16
  meta: {
17
17
  name: "@eslint/json",
18
- version: "1.0.1", // x-release-please-version
18
+ version: "1.1.0", // x-release-please-version
19
19
  },
20
20
  languages: {
21
21
  json: new JSONLanguage({ mode: "json" }),
@@ -5,7 +5,7 @@
5
5
  //-----------------------------------------------------------------------------
6
6
  // Imports
7
7
  //-----------------------------------------------------------------------------
8
- import { getKey } from "../util.js";
8
+ import { getKey, getRawKey } from "../util.js";
9
9
  //-----------------------------------------------------------------------------
10
10
  // Type Definitions
11
11
  //-----------------------------------------------------------------------------
@@ -22,6 +22,7 @@ import { getKey } from "../util.js";
22
22
  const rule = {
23
23
  meta: {
24
24
  type: "problem",
25
+ fixable: "code",
25
26
  docs: {
26
27
  recommended: true,
27
28
  description: "Disallow JSON keys that are not normalized",
@@ -52,12 +53,24 @@ const rule = {
52
53
  return {
53
54
  Member(node) {
54
55
  const key = getKey(node);
55
- if (key.normalize(form) !== key) {
56
+ const rawKey = getRawKey(node, context.sourceCode);
57
+ const normalizedKey = key.normalize(form);
58
+ if (normalizedKey !== key) {
59
+ const { name } = node;
56
60
  context.report({
57
- loc: node.name.loc,
61
+ loc: name.loc,
58
62
  messageId: "unnormalizedKey",
59
63
  data: {
60
- key,
64
+ key: rawKey,
65
+ },
66
+ fix(fixer) {
67
+ if (key !== rawKey) {
68
+ // Do not perform auto-fix when the raw key contains escape sequences.
69
+ return null;
70
+ }
71
+ return fixer.replaceTextRange(name.type === "String"
72
+ ? [name.range[0] + 1, name.range[1] - 1]
73
+ : name.range, normalizedKey);
61
74
  },
62
75
  });
63
76
  }
package/dist/types.d.ts CHANGED
@@ -34,6 +34,6 @@ export type JSONRuleDefinition<Options extends Partial<JSONRuleDefinitionTypeOpt
34
34
  LangOptions: JSONLanguageOptions;
35
35
  Code: JSONSourceCode;
36
36
  Visitor: JSONRuleVisitor;
37
- Node: AnyNode;
37
+ Node: JSONSyntaxElement;
38
38
  }, Options>;
39
39
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint/json",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "JSON linting plugin for ESLint",
5
5
  "author": "Nicholas C. Zakas",
6
6
  "type": "module",
@@ -66,18 +66,18 @@
66
66
  ],
67
67
  "license": "Apache-2.0",
68
68
  "dependencies": {
69
- "@eslint/core": "^1.1.0",
70
- "@eslint/plugin-kit": "^0.6.0",
69
+ "@eslint/core": "^1.1.1",
70
+ "@eslint/plugin-kit": "^0.6.1",
71
71
  "@humanwhocodes/momoa": "^3.3.10",
72
72
  "natural-compare": "^1.4.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@arethetypeswrong/cli": "^0.18.2",
76
- "c8": "^10.1.3",
76
+ "c8": "^11.0.0",
77
77
  "dedent": "^1.5.3",
78
- "eslint": "^9.39.2",
79
- "eslint-config-eslint": "^13.0.0",
80
- "eslint-plugin-eslint-plugin": "^6.3.2",
78
+ "eslint": "^10.0.0",
79
+ "eslint-config-eslint": "^14.0.0",
80
+ "eslint-plugin-eslint-plugin": "^7.3.2",
81
81
  "globals": "^17.0.0",
82
82
  "lint-staged": "^16.0.0",
83
83
  "mdast-util-from-markdown": "^2.0.2",