@eslint/json 0.6.0 → 0.7.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 +2 -1
- package/dist/cjs/index.cjs +64 -1
- package/dist/cjs/index.d.cts +16 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +64 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -154,6 +154,7 @@ export default [
|
|
|
154
154
|
|
|
155
155
|
- `no-duplicate-keys` - warns when there are two keys in an object with the same text.
|
|
156
156
|
- `no-empty-keys` - warns when there is a key in an object that is an empty string or contains only whitespace (note: `package-lock.json` uses empty keys intentionally)
|
|
157
|
+
- `no-unsafe-values` - warns on values that are unsafe for interchange, such as numbers outside safe range or lone surrogates.
|
|
157
158
|
|
|
158
159
|
## Configuration Comments
|
|
159
160
|
|
|
@@ -249,7 +250,7 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
|
|
249
250
|
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
|
250
251
|
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
|
|
251
252
|
<p><a href="https://www.serptriumph.com/"><img src="https://images.opencollective.com/serp-triumph5/fea3074/logo.png" alt="SERP Triumph" height="64"></a> <a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
|
|
252
|
-
<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://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p>
|
|
253
|
+
<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://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p>
|
|
253
254
|
<h3>Technology Sponsors</h3>
|
|
254
255
|
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.
|
|
255
256
|
<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/cjs/index.cjs
CHANGED
|
@@ -538,6 +538,67 @@ var noEmptyKeys = {
|
|
|
538
538
|
},
|
|
539
539
|
};
|
|
540
540
|
|
|
541
|
+
/**
|
|
542
|
+
* @fileoverview Rule to detect unsafe values in JSON.
|
|
543
|
+
* @author Bradley Meck Farias
|
|
544
|
+
*/
|
|
545
|
+
|
|
546
|
+
var noUnsafeValues = {
|
|
547
|
+
meta: {
|
|
548
|
+
type: "problem",
|
|
549
|
+
|
|
550
|
+
docs: {
|
|
551
|
+
description: "Disallow JSON values that are unsafe for interchange",
|
|
552
|
+
},
|
|
553
|
+
|
|
554
|
+
messages: {
|
|
555
|
+
unsafeNumber: "Number outside safe range found.",
|
|
556
|
+
loneSurrogate: "Lone surrogate '{{ surrogate }}' found.",
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
|
|
560
|
+
create(context) {
|
|
561
|
+
return {
|
|
562
|
+
Number(node) {
|
|
563
|
+
if (Number.isFinite(node.value) !== true) {
|
|
564
|
+
context.report({
|
|
565
|
+
loc: node.loc,
|
|
566
|
+
messageId: "unsafeNumber",
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
String(node) {
|
|
571
|
+
if (node.value.isWellFormed) {
|
|
572
|
+
if (node.value.isWellFormed()) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
// match any high surrogate and, if it exists, a paired low surrogate
|
|
577
|
+
// match any low surrogate not already matched
|
|
578
|
+
const surrogatePattern =
|
|
579
|
+
/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[\uDC00-\uDFFF]/gu;
|
|
580
|
+
let match = surrogatePattern.exec(node.value);
|
|
581
|
+
while (match) {
|
|
582
|
+
// only need to report non-paired surrogates
|
|
583
|
+
if (match[0].length < 2) {
|
|
584
|
+
context.report({
|
|
585
|
+
loc: node.loc,
|
|
586
|
+
messageId: "loneSurrogate",
|
|
587
|
+
data: {
|
|
588
|
+
surrogate: JSON.stringify(match[0]).slice(
|
|
589
|
+
1,
|
|
590
|
+
-1,
|
|
591
|
+
),
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
match = surrogatePattern.exec(node.value);
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
};
|
|
599
|
+
},
|
|
600
|
+
};
|
|
601
|
+
|
|
541
602
|
/**
|
|
542
603
|
* @fileoverview JSON plugin.
|
|
543
604
|
* @author Nicholas C. Zakas
|
|
@@ -551,7 +612,7 @@ var noEmptyKeys = {
|
|
|
551
612
|
const plugin = {
|
|
552
613
|
meta: {
|
|
553
614
|
name: "@eslint/json",
|
|
554
|
-
version: "0.
|
|
615
|
+
version: "0.7.0", // x-release-please-version
|
|
555
616
|
},
|
|
556
617
|
languages: {
|
|
557
618
|
json: new JSONLanguage({ mode: "json" }),
|
|
@@ -561,6 +622,7 @@ const plugin = {
|
|
|
561
622
|
rules: {
|
|
562
623
|
"no-duplicate-keys": noDuplicateKeys,
|
|
563
624
|
"no-empty-keys": noEmptyKeys,
|
|
625
|
+
"no-unsafe-values": noUnsafeValues,
|
|
564
626
|
},
|
|
565
627
|
configs: {},
|
|
566
628
|
};
|
|
@@ -571,6 +633,7 @@ Object.assign(plugin.configs, {
|
|
|
571
633
|
rules: {
|
|
572
634
|
"json/no-duplicate-keys": "error",
|
|
573
635
|
"json/no-empty-keys": "error",
|
|
636
|
+
"json/no-unsafe-values": "error",
|
|
574
637
|
},
|
|
575
638
|
},
|
|
576
639
|
});
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -202,6 +202,22 @@ declare namespace plugin {
|
|
|
202
202
|
Member(node: any): void;
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
|
+
"no-unsafe-values": {
|
|
206
|
+
meta: {
|
|
207
|
+
type: string;
|
|
208
|
+
docs: {
|
|
209
|
+
description: string;
|
|
210
|
+
};
|
|
211
|
+
messages: {
|
|
212
|
+
unsafeNumber: string;
|
|
213
|
+
loneSurrogate: string;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
create(context: any): {
|
|
217
|
+
Number(node: any): void;
|
|
218
|
+
String(node: any): void;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
205
221
|
};
|
|
206
222
|
let configs: {};
|
|
207
223
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -202,6 +202,22 @@ declare namespace plugin {
|
|
|
202
202
|
Member(node: any): void;
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
|
+
"no-unsafe-values": {
|
|
206
|
+
meta: {
|
|
207
|
+
type: string;
|
|
208
|
+
docs: {
|
|
209
|
+
description: string;
|
|
210
|
+
};
|
|
211
|
+
messages: {
|
|
212
|
+
unsafeNumber: string;
|
|
213
|
+
loneSurrogate: string;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
create(context: any): {
|
|
217
|
+
Number(node: any): void;
|
|
218
|
+
String(node: any): void;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
205
221
|
};
|
|
206
222
|
let configs: {};
|
|
207
223
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -535,6 +535,67 @@ var noEmptyKeys = {
|
|
|
535
535
|
},
|
|
536
536
|
};
|
|
537
537
|
|
|
538
|
+
/**
|
|
539
|
+
* @fileoverview Rule to detect unsafe values in JSON.
|
|
540
|
+
* @author Bradley Meck Farias
|
|
541
|
+
*/
|
|
542
|
+
|
|
543
|
+
var noUnsafeValues = {
|
|
544
|
+
meta: {
|
|
545
|
+
type: "problem",
|
|
546
|
+
|
|
547
|
+
docs: {
|
|
548
|
+
description: "Disallow JSON values that are unsafe for interchange",
|
|
549
|
+
},
|
|
550
|
+
|
|
551
|
+
messages: {
|
|
552
|
+
unsafeNumber: "Number outside safe range found.",
|
|
553
|
+
loneSurrogate: "Lone surrogate '{{ surrogate }}' found.",
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
|
|
557
|
+
create(context) {
|
|
558
|
+
return {
|
|
559
|
+
Number(node) {
|
|
560
|
+
if (Number.isFinite(node.value) !== true) {
|
|
561
|
+
context.report({
|
|
562
|
+
loc: node.loc,
|
|
563
|
+
messageId: "unsafeNumber",
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
String(node) {
|
|
568
|
+
if (node.value.isWellFormed) {
|
|
569
|
+
if (node.value.isWellFormed()) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
// match any high surrogate and, if it exists, a paired low surrogate
|
|
574
|
+
// match any low surrogate not already matched
|
|
575
|
+
const surrogatePattern =
|
|
576
|
+
/[\uD800-\uDBFF][\uDC00-\uDFFF]?|[\uDC00-\uDFFF]/gu;
|
|
577
|
+
let match = surrogatePattern.exec(node.value);
|
|
578
|
+
while (match) {
|
|
579
|
+
// only need to report non-paired surrogates
|
|
580
|
+
if (match[0].length < 2) {
|
|
581
|
+
context.report({
|
|
582
|
+
loc: node.loc,
|
|
583
|
+
messageId: "loneSurrogate",
|
|
584
|
+
data: {
|
|
585
|
+
surrogate: JSON.stringify(match[0]).slice(
|
|
586
|
+
1,
|
|
587
|
+
-1,
|
|
588
|
+
),
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
match = surrogatePattern.exec(node.value);
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
};
|
|
596
|
+
},
|
|
597
|
+
};
|
|
598
|
+
|
|
538
599
|
/**
|
|
539
600
|
* @fileoverview JSON plugin.
|
|
540
601
|
* @author Nicholas C. Zakas
|
|
@@ -548,7 +609,7 @@ var noEmptyKeys = {
|
|
|
548
609
|
const plugin = {
|
|
549
610
|
meta: {
|
|
550
611
|
name: "@eslint/json",
|
|
551
|
-
version: "0.
|
|
612
|
+
version: "0.7.0", // x-release-please-version
|
|
552
613
|
},
|
|
553
614
|
languages: {
|
|
554
615
|
json: new JSONLanguage({ mode: "json" }),
|
|
@@ -558,6 +619,7 @@ const plugin = {
|
|
|
558
619
|
rules: {
|
|
559
620
|
"no-duplicate-keys": noDuplicateKeys,
|
|
560
621
|
"no-empty-keys": noEmptyKeys,
|
|
622
|
+
"no-unsafe-values": noUnsafeValues,
|
|
561
623
|
},
|
|
562
624
|
configs: {},
|
|
563
625
|
};
|
|
@@ -568,6 +630,7 @@ Object.assign(plugin.configs, {
|
|
|
568
630
|
rules: {
|
|
569
631
|
"json/no-duplicate-keys": "error",
|
|
570
632
|
"json/no-empty-keys": "error",
|
|
633
|
+
"json/no-unsafe-values": "error",
|
|
571
634
|
},
|
|
572
635
|
},
|
|
573
636
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint/json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "JSON linting plugin for ESLint",
|
|
5
5
|
"author": "Nicholas C. Zakas",
|
|
6
6
|
"type": "module",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
],
|
|
63
63
|
"license": "Apache-2.0",
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@eslint/plugin-kit": "^0.2.
|
|
66
|
-
"@humanwhocodes/momoa": "^3.3.
|
|
65
|
+
"@eslint/plugin-kit": "^0.2.3",
|
|
66
|
+
"@humanwhocodes/momoa": "^3.3.3"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@eslint/core": "^0.6.0",
|