File tree 8 files changed +54
-6
lines changed
8 files changed +54
-6
lines changed Original file line number Diff line number Diff line change 45
45
run : npm install
46
46
- name : Run tests
47
47
run : npm run test
48
+ test_types :
49
+ name : Test Types
50
+ runs-on : ubuntu-latest
51
+ steps :
52
+ - uses : actions/checkout@v4
53
+ - name : Setup Node.js
54
+ uses : actions/setup-node@v4
55
+ with :
56
+ node-version : " lts/*"
57
+ - name : Install dependencies
58
+ run : npm install
59
+ - name : Build
60
+ run : npm run build
61
+ - name : Check Types
62
+ run : npm run test:types
48
63
jsr_test :
49
64
name : Verify JSR Publish
50
65
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change 51
51
"fmt" : " prettier --write ." ,
52
52
"fmt:check" : " prettier --check ." ,
53
53
"test" : " mocha tests/**/*.js" ,
54
- "test:coverage" : " c8 npm test"
54
+ "test:coverage" : " c8 npm test" ,
55
+ "test:types" : " tsc -p tests/types/tsconfig.json"
55
56
},
56
57
"keywords" : [
57
58
" eslint" ,
Original file line number Diff line number Diff line change @@ -35,11 +35,11 @@ const plugin = {
35
35
configs : {
36
36
recommended : {
37
37
plugins : { } ,
38
- rules : {
38
+ rules : /** @type { const } */ ( {
39
39
"json/no-duplicate-keys" : "error" ,
40
40
"json/no-empty-keys" : "error" ,
41
41
"json/no-unsafe-values" : "error" ,
42
- } ,
42
+ } ) ,
43
43
} ,
44
44
} ,
45
45
} ;
Original file line number Diff line number Diff line change 9
9
10
10
export default {
11
11
meta : {
12
- type : "problem" ,
12
+ type : /** @type { const } */ ( "problem" ) ,
13
13
14
14
docs : {
15
15
description : "Disallow duplicate keys in JSON objects" ,
Original file line number Diff line number Diff line change 5
5
6
6
export default {
7
7
meta : {
8
- type : "problem" ,
8
+ type : /** @type { const } */ ( "problem" ) ,
9
9
10
10
docs : {
11
11
description : "Disallow empty keys in JSON objects" ,
Original file line number Diff line number Diff line change 5
5
6
6
export default {
7
7
meta : {
8
- type : "problem" ,
8
+ type : /** @type { const } */ ( "problem" ) ,
9
9
10
10
docs : {
11
11
description : "Disallow JSON values that are unsafe for interchange" ,
Original file line number Diff line number Diff line change
1
+ {
2
+ "extends" : " ../../tsconfig.json" ,
3
+ "compilerOptions" : {
4
+ "noEmit" : true ,
5
+ "rootDir" : " ../.." ,
6
+ "strict" : true
7
+ },
8
+ "files" : [" ../../dist/esm/index.d.ts" , " types.test.ts" ]
9
+ }
Original file line number Diff line number Diff line change
1
+ import json from "@eslint/json" ;
2
+ import { ESLint } from "eslint" ;
3
+
4
+ json satisfies ESLint . Plugin ;
5
+ json . meta . name satisfies string ;
6
+ json . meta . version satisfies string ;
7
+
8
+ // Check that these languages are defined:
9
+ json . languages . json satisfies object ;
10
+ json . languages . json5 satisfies object ;
11
+ json . languages . jsonc satisfies object ;
12
+
13
+ // Check that `plugins` in the recommended config is defined:
14
+ json . configs . recommended . plugins satisfies object ;
15
+
16
+ {
17
+ type RecommendedRuleName = keyof typeof json . configs . recommended . rules ;
18
+ type RuleName = `json/${keyof typeof json . rules } `;
19
+ type AssertAllNamesIn < T1 extends T2 , T2 > = never ;
20
+
21
+ // Check that all recommended rule names match the names of existing rules in this plugin.
22
+ null as AssertAllNamesIn < RecommendedRuleName , RuleName > ;
23
+ }
You can’t perform that action at this time.
0 commit comments