@eslint/json 1.0.0 → 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,9 +294,9 @@ 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>
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://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" 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
- <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://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" 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://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" 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="LambdaTest" height="32"></a></p>
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
+ <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
+ <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>
301
301
  Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
302
302
  <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
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.0", // 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
@@ -2,7 +2,8 @@
2
2
  * @fileoverview Additional types for this package.
3
3
  * @author Nicholas C. Zakas
4
4
  */
5
- import type { CustomRuleDefinitionType, CustomRuleTypeDefinitions, RuleVisitor } from "@eslint/core";
5
+ import type { RuleVisitor } from "@eslint/core";
6
+ import type { CustomRuleDefinitionType, CustomRuleTypeDefinitions, CustomRuleVisitorWithExit } from "@eslint/plugin-kit";
6
7
  import type { DocumentNode, MemberNode, ElementNode, ObjectNode, ArrayNode, StringNode, NullNode, NumberNode, BooleanNode, NaNNode, InfinityNode, IdentifierNode, AnyNode, Token } from "@humanwhocodes/momoa";
7
8
  import type { JSONLanguageOptions, JSONSourceCode } from "./index.js";
8
9
  type ValueNodeParent = DocumentNode | MemberNode | ElementNode;
@@ -13,7 +14,7 @@ export type JSONSyntaxElement = Token | AnyNode;
13
14
  /**
14
15
  * The visitor format returned from rules in this package.
15
16
  */
16
- export interface JSONRuleVisitor extends RuleVisitor {
17
+ export interface JSONRuleVisitor extends RuleVisitor, CustomRuleVisitorWithExit<{
17
18
  Document?(node: DocumentNode): void;
18
19
  Member?(node: MemberNode, parent?: ObjectNode): void;
19
20
  Element?(node: ElementNode, parent?: ArrayNode): void;
@@ -26,24 +27,13 @@ export interface JSONRuleVisitor extends RuleVisitor {
26
27
  NaN?(node: NaNNode, parent?: ValueNodeParent): void;
27
28
  Infinity?(node: InfinityNode, parent?: ValueNodeParent): void;
28
29
  Identifier?(node: IdentifierNode, parent?: ValueNodeParent): void;
29
- "Document:exit"?(node: DocumentNode): void;
30
- "Member:exit"?(node: MemberNode, parent?: ObjectNode): void;
31
- "Element:exit"?(node: ElementNode, parent?: ArrayNode): void;
32
- "Object:exit"?(node: ObjectNode, parent?: ValueNodeParent): void;
33
- "Array:exit"?(node: ArrayNode, parent?: ValueNodeParent): void;
34
- "String:exit"?(node: StringNode, parent?: ValueNodeParent): void;
35
- "Null:exit"?(node: NullNode, parent?: ValueNodeParent): void;
36
- "Number:exit"?(node: NumberNode, parent?: ValueNodeParent): void;
37
- "Boolean:exit"?(node: BooleanNode, parent?: ValueNodeParent): void;
38
- "NaN:exit"?(node: NaNNode, parent?: ValueNodeParent): void;
39
- "Infinity:exit"?(node: InfinityNode, parent?: ValueNodeParent): void;
40
- "Identifier:exit"?(node: IdentifierNode, parent?: ValueNodeParent): void;
30
+ }> {
41
31
  }
42
32
  export type JSONRuleDefinitionTypeOptions = CustomRuleTypeDefinitions;
43
33
  export type JSONRuleDefinition<Options extends Partial<JSONRuleDefinitionTypeOptions> = {}> = CustomRuleDefinitionType<{
44
34
  LangOptions: JSONLanguageOptions;
45
35
  Code: JSONSourceCode;
46
36
  Visitor: JSONRuleVisitor;
47
- Node: AnyNode;
37
+ Node: JSONSyntaxElement;
48
38
  }, Options>;
49
39
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint/json",
3
- "version": "1.0.0",
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.0.1",
70
- "@eslint/plugin-kit": "^0.5.1",
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",