Skip to content

Commit 8ec6cde

Browse files
committed
tests
1 parent 6871129 commit 8ec6cde

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"@commitlint/config-conventional": "^19.8.0",
7575
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
7676
"@eslint/js": "^9.23.0",
77+
"@eslint/json": "^0.12.0",
7778
"@graphql-eslint/eslint-plugin": "^4.3.0",
7879
"@html-eslint/parser": "^0.41.0",
7980
"@prettier/plugin-pug": "^3.2.1",

pnpm-lock.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/invalid/json.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CODE:
2+
{
3+
"a": [
4+
"b",
5+
{"c":
6+
"d"}
7+
] }
8+
9+
OUTPUT:
10+
{
11+
"a": ["b", { "c": "d" }]
12+
}
13+
14+
OPTIONS:
15+
[]
16+
17+
ERRORS:
18+
[
19+
{
20+
message: 'Replace `"a":·[⏎"b",⏎{"c":⏎"d"}⏎]·` with `··"a":·["b",·{·"c":·"d"·}]⏎`',
21+
},
22+
]

test/prettier.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import eslintPluginPug from 'eslint-plugin-pug';
2525
import vueEslintParser from 'vue-eslint-parser';
2626
import * as eslintPluginGraphql from '@graphql-eslint/eslint-plugin';
2727
import eslintMdx from 'eslint-mdx';
28+
import eslintPluginJson from '@eslint/json';
2829

2930
const rule = eslintPluginPrettier.rules.prettier;
3031
const RuleTester =
@@ -380,6 +381,31 @@ runFixture('invalid-prettierrc/*', [
380381
],
381382
]);
382383

384+
const jsonRuleTester = new RuleTester({
385+
plugins: {
386+
json: eslintPluginJson,
387+
},
388+
language: 'json/json',
389+
});
390+
391+
jsonRuleTester.run('@eslint/json', rule, {
392+
valid: [
393+
{
394+
code: '{}\n',
395+
filename: 'empty.json',
396+
},
397+
{
398+
code: '{ "foo": 1 }\n',
399+
filename: 'simple.json',
400+
},
401+
],
402+
invalid: [
403+
Object.assign(loadInvalidFixture('json'), {
404+
filename: 'invalid.json',
405+
}),
406+
],
407+
});
408+
383409
// ------------------------------------------------------------------------------
384410
// Helpers
385411
// ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)