Skip to content

Commit 7215b1d

Browse files
authored
Replace eslint-plugin-jsonc with jsonc-eslint-parser. (#118)
1 parent 58a1509 commit 7215b1d

File tree

11 files changed

+104
-41
lines changed

11 files changed

+104
-41
lines changed

lib/configs/base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export = {
88
// see https://github.com/vuejs/eslint-plugin-vue/pull/1262
99
parser: require.resolve('vue-eslint-parser'),
1010
parserOptions: {
11-
parser: require.resolve('eslint-plugin-jsonc')
11+
parser: require.resolve('jsonc-eslint-parser')
1212
}
1313
},
1414
{

lib/rules/no-duplicate-keys-in-locale.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @author Yosuke Ota
33
*/
44
import type { AST as VAST } from 'vue-eslint-parser'
5-
import type { AST as JSONAST } from 'eslint-plugin-jsonc'
5+
import type { AST as JSONAST } from 'jsonc-eslint-parser'
66
import type { AST as YAMLAST } from 'yaml-eslint-parser'
77
import { extname } from 'path'
88
import { getLocaleMessages } from '../utils/index'

lib/rules/no-html-messages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import parse5 from 'parse5'
66
import { getLocaleMessages } from '../utils/index'
77
import debugBuilder from 'debug'
88
import type { AST as VAST } from 'vue-eslint-parser'
9-
import type { AST as JSONAST } from 'eslint-plugin-jsonc'
9+
import type { AST as JSONAST } from 'jsonc-eslint-parser'
1010
import type { AST as YAMLAST } from 'yaml-eslint-parser'
1111
import type { RuleContext, RuleListener } from '../types'
1212

lib/rules/no-unused-keys.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @author kazuya kawaguchi (a.k.a. kazupon)
33
*/
44
import type { AST as VAST } from 'vue-eslint-parser'
5-
import type { AST as JSONAST } from 'eslint-plugin-jsonc'
5+
import type { AST as JSONAST } from 'jsonc-eslint-parser'
66
import type { AST as YAMLAST } from 'yaml-eslint-parser'
77
import { extname } from 'path'
88
import { collectKeysFromAST, usedKeysCache } from '../utils/collect-keys'

lib/types/eslint.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AST as JSONAST } from 'eslint-plugin-jsonc'
1+
import type { AST as JSONAST } from 'jsonc-eslint-parser'
22
import type { AST as YAMLAST } from 'yaml-eslint-parser'
33
import type { AST as VAST } from 'vue-eslint-parser'
44
import type { VueParserServices } from './vue-parser-services'

lib/utils/locale-messages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @fileoverview Classes that acquires and manages localization messages
33
* @author Yosuke Ota
44
*/
5-
import type { AST as JSONAST } from 'eslint-plugin-jsonc'
5+
import type { AST as JSONAST } from 'jsonc-eslint-parser'
66
import type { AST as YAMLAST } from 'yaml-eslint-parser'
77
import type { AST as VAST } from 'vue-eslint-parser'
88
import type {

lib/utils/parsers/index.ts

+4-11
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* @fileoverview parser for <i18n> block
33
* @author Yosuke Ota
44
*/
5-
import type { AST as JSONAST } from 'eslint-plugin-jsonc'
5+
import type { AST as JSONAST } from 'jsonc-eslint-parser'
66
import type { AST as YAMLAST } from 'yaml-eslint-parser'
77
import {
88
parseForESLint as parseJsonForESLint,
99
getStaticJSONValue
10-
} from 'eslint-plugin-jsonc'
10+
} from 'jsonc-eslint-parser'
1111
import {
1212
parseForESLint as parseYamlForESLint,
1313
getStaticYAMLValue
@@ -203,21 +203,14 @@ export function parseJsonInI18nBlock(
203203
context: RuleContext,
204204
i18nBlock: VAST.VElement
205205
): JSONParsed | null {
206-
const result = parseInI18nBlock(
207-
context,
208-
i18nBlock,
209-
(parseJsonForESLint as never) as (
210-
code: string,
211-
option: unknown
212-
) => { ast: JSONAST.JSONProgram; visitorKeys: VisitorKeys }
213-
)
206+
const result = parseInI18nBlock(context, i18nBlock, parseJsonForESLint)
214207
if (result == null) {
215208
return result
216209
}
217210
return {
218211
lang: 'json',
219212
getStaticValue(node: JSONAST.JSONNode): I18nLocaleMessageDictionary {
220-
return getStaticJSONValue(node as never) as never
213+
return getStaticJSONValue(node) as never
221214
},
222215
...result
223216
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
}
2525
},
2626
"dependencies": {
27-
"eslint-plugin-jsonc": "^0.4.0",
2827
"fast-diff": "^1.2.0",
2928
"glob": "^7.1.3",
3029
"ignore": "^5.0.5",
3130
"js-yaml": "^3.14.0",
3231
"json5": "^2.1.3",
32+
"jsonc-eslint-parser": "^0.5.2",
3333
"lodash": "^4.17.11",
3434
"parse5": "^6.0.0",
3535
"vue-eslint-parser": "^7.0.0",

tests-integrations/config-recommended/.eslintrc.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
module.exports = {
44
root: true,
5-
extends: [
6-
'plugin:vue/recommended',
7-
'plugin:jsonc/recommended-with-jsonc',
8-
'plugin:@intlify/vue-i18n/recommended'
9-
],
5+
extends: ['plugin:vue/recommended', 'plugin:@intlify/vue-i18n/recommended'],
106
settings: {
117
'vue-i18n': {
128
localeDir: `./src/resources/*.json`

tests-integrations/config-recommended/yarn.lock

+69-9
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424
js-tokens "^4.0.0"
2525

2626
"@intlify/eslint-plugin-vue-i18n@file:../..":
27-
version "0.6.0"
27+
version "0.8.1"
2828
dependencies:
29-
eslint-plugin-jsonc "^0.3.1"
3029
fast-diff "^1.2.0"
3130
glob "^7.1.3"
3231
ignore "^5.0.5"
32+
js-yaml "^3.14.0"
33+
json5 "^2.1.3"
34+
jsonc-eslint-parser "^0.5.2"
3335
lodash "^4.17.11"
3436
parse5 "^6.0.0"
3537
vue-eslint-parser "^7.0.0"
38+
yaml-eslint-parser "^0.0.8"
3639

3740
"@types/color-name@^1.1.1":
3841
version "1.1.1"
@@ -49,6 +52,11 @@ acorn@^7.1.1, acorn@^7.2.0:
4952
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.3.1.tgz#85010754db53c3fbaf3b9ea3e083aa5c5d147ffd"
5053
integrity sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==
5154

55+
acorn@^7.3.1:
56+
version "7.4.0"
57+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c"
58+
integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==
59+
5260
ajv@^6.10.0, ajv@^6.10.2:
5361
version "6.12.3"
5462
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706"
@@ -210,11 +218,6 @@ escape-string-regexp@^1.0.5:
210218
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
211219
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
212220

213-
eslint-plugin-jsonc@^0.3.1:
214-
version "0.3.1"
215-
resolved "https://registry.yarnpkg.com/eslint-plugin-jsonc/-/eslint-plugin-jsonc-0.3.1.tgz#363b3516ce57a4ef49b8149f108837a3151c06a0"
216-
integrity sha512-MkvmvKv4WYrxYMds0LjzC+rn+g4EpGIs1xLYeZeULSK/m90CxKPHrsKKnEMyp+bXVTU2WgBV/d8xIpEHTJWbUw==
217-
218221
eslint-scope@^5.0.0, eslint-scope@^5.1.0:
219222
version "5.1.0"
220223
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.0.tgz#d0f971dfe59c69e0cada684b23d49dbf82600ce5"
@@ -230,7 +233,7 @@ eslint-utils@^2.0.0:
230233
dependencies:
231234
eslint-visitor-keys "^1.1.0"
232235

233-
eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.2.0:
236+
eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.2.0, eslint-visitor-keys@^1.3.0:
234237
version "1.3.0"
235238
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
236239
integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
@@ -277,6 +280,15 @@ eslint@^7.4.0:
277280
text-table "^0.2.0"
278281
v8-compile-cache "^2.0.3"
279282

283+
"espree@^6.0.0 || ^7.2.0":
284+
version "7.2.0"
285+
resolved "https://registry.yarnpkg.com/espree/-/espree-7.2.0.tgz#1c263d5b513dbad0ac30c4991b93ac354e948d69"
286+
integrity sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==
287+
dependencies:
288+
acorn "^7.3.1"
289+
acorn-jsx "^5.2.0"
290+
eslint-visitor-keys "^1.3.0"
291+
280292
espree@^6.2.1:
281293
version "6.2.1"
282294
resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a"
@@ -479,7 +491,7 @@ js-tokens@^4.0.0:
479491
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
480492
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
481493

482-
js-yaml@^3.13.1:
494+
js-yaml@^3.13.1, js-yaml@^3.14.0:
483495
version "3.14.0"
484496
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482"
485497
integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==
@@ -497,6 +509,21 @@ json-stable-stringify-without-jsonify@^1.0.1:
497509
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
498510
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
499511

512+
json5@^2.1.3:
513+
version "2.1.3"
514+
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43"
515+
integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==
516+
dependencies:
517+
minimist "^1.2.5"
518+
519+
jsonc-eslint-parser@^0.5.2:
520+
version "0.5.2"
521+
resolved "https://registry.yarnpkg.com/jsonc-eslint-parser/-/jsonc-eslint-parser-0.5.2.tgz#b195bb21cc81c466724da5c1d4368d25807fb3ac"
522+
integrity sha512-TNtw6VVL1dS95FbMQTvv6I6OjaEORW9mH4OdN07VSDt8TAO7G7ZQEfSMf1p0+hC0tKZLtMmU6wZZmpPcupmGrg==
523+
dependencies:
524+
eslint-visitor-keys "^1.3.0"
525+
espree "^6.0.0 || ^7.2.0"
526+
500527
levn@^0.4.1:
501528
version "0.4.1"
502529
resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
@@ -505,6 +532,11 @@ levn@^0.4.1:
505532
prelude-ls "^1.2.1"
506533
type-check "~0.4.0"
507534

535+
lines-and-columns@^1.1.6:
536+
version "1.1.6"
537+
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
538+
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
539+
508540
lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15:
509541
version "4.17.19"
510542
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
@@ -700,6 +732,11 @@ text-table@^0.2.0:
700732
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
701733
integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
702734

735+
tslib@^1.10.0:
736+
version "1.13.0"
737+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
738+
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
739+
703740
type-check@^0.4.0, type-check@~0.4.0:
704741
version "0.4.0"
705742
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
@@ -759,3 +796,26 @@ [email protected]:
759796
integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==
760797
dependencies:
761798
mkdirp "^0.5.1"
799+
800+
yaml-eslint-parser@^0.0.8:
801+
version "0.0.8"
802+
resolved "https://registry.yarnpkg.com/yaml-eslint-parser/-/yaml-eslint-parser-0.0.8.tgz#9bf30c1433e27fe47524509f087df1501f6d55ea"
803+
integrity sha512-VefMCl1P4St+PUBaGPRtZEwZowOGaALufuOuQs+3hUaut5X6ReTfUqIXQY3TJ/L3WkuugpnvzNdpCVu0WbgeeQ==
804+
dependencies:
805+
eslint-visitor-keys "^1.3.0"
806+
yaml "^1.10.0"
807+
yaml-unist-parser "^1.2.1"
808+
809+
yaml-unist-parser@^1.2.1:
810+
version "1.3.0"
811+
resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.3.0.tgz#f64f1af96171fe4d7eb462e94225d42a6009b60e"
812+
integrity sha512-kF1OS6fi9BzqX+vVC5hp+R5mmrHLH4f19Nx8fAwb08VqUwgFDBPOOu24VZO06nSOur13CGUTgHuaw5RIzpRnCw==
813+
dependencies:
814+
lines-and-columns "^1.1.6"
815+
tslib "^1.10.0"
816+
yaml "^1.10.0"
817+
818+
yaml@^1.10.0:
819+
version "1.10.0"
820+
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
821+
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==

yarn.lock

+23-9
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,11 @@ acorn@^7.2.0:
17301730
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.3.1.tgz#85010754db53c3fbaf3b9ea3e083aa5c5d147ffd"
17311731
integrity sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==
17321732

1733+
acorn@^7.3.1:
1734+
version "7.4.0"
1735+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c"
1736+
integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==
1737+
17331738
add-stream@^1.0.0:
17341739
version "1.0.0"
17351740
resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa"
@@ -4211,14 +4216,6 @@ eslint-config-prettier@^6.11.0:
42114216
dependencies:
42124217
get-stdin "^6.0.0"
42134218

4214-
eslint-plugin-jsonc@^0.4.0:
4215-
version "0.4.0"
4216-
resolved "https://registry.yarnpkg.com/eslint-plugin-jsonc/-/eslint-plugin-jsonc-0.4.0.tgz#c471f7dc1c8d4c3798ef7eeee67066c14384bb52"
4217-
integrity sha512-pWSpv2aXBeXAal4hYgn+jfWTwEmypMdPV9AQMs19QLXNPvOoJ23mWMAxCV+aU5xyuH28ME12qeiM1BpeGZxDrg==
4218-
dependencies:
4219-
eslint-utils "^2.1.0"
4220-
natural-compare "^1.4.0"
4221-
42224219
eslint-plugin-markdown@^1.0.0:
42234220
version "1.0.1"
42244221
resolved "https://registry.yarnpkg.com/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.1.tgz#9705786310f84dad9cf800bea1eb5c4acafcc13a"
@@ -4274,7 +4271,7 @@ eslint-scope@^5.1.0:
42744271
esrecurse "^4.1.0"
42754272
estraverse "^4.1.1"
42764273

4277-
eslint-utils@^2.0.0, eslint-utils@^2.1.0:
4274+
eslint-utils@^2.0.0:
42784275
version "2.1.0"
42794276
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27"
42804277
integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==
@@ -4347,6 +4344,15 @@ espree@^4.1.0:
43474344
acorn-jsx "^5.0.0"
43484345
eslint-visitor-keys "^1.0.0"
43494346

4347+
"espree@^6.0.0 || ^7.2.0":
4348+
version "7.2.0"
4349+
resolved "https://registry.yarnpkg.com/espree/-/espree-7.2.0.tgz#1c263d5b513dbad0ac30c4991b93ac354e948d69"
4350+
integrity sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==
4351+
dependencies:
4352+
acorn "^7.3.1"
4353+
acorn-jsx "^5.2.0"
4354+
eslint-visitor-keys "^1.3.0"
4355+
43504356
espree@^6.1.2:
43514357
version "6.1.2"
43524358
resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d"
@@ -6310,6 +6316,14 @@ json5@^2.1.2, json5@^2.1.3:
63106316
dependencies:
63116317
minimist "^1.2.5"
63126318

6319+
jsonc-eslint-parser@^0.5.2:
6320+
version "0.5.2"
6321+
resolved "https://registry.yarnpkg.com/jsonc-eslint-parser/-/jsonc-eslint-parser-0.5.2.tgz#b195bb21cc81c466724da5c1d4368d25807fb3ac"
6322+
integrity sha512-TNtw6VVL1dS95FbMQTvv6I6OjaEORW9mH4OdN07VSDt8TAO7G7ZQEfSMf1p0+hC0tKZLtMmU6wZZmpPcupmGrg==
6323+
dependencies:
6324+
eslint-visitor-keys "^1.3.0"
6325+
espree "^6.0.0 || ^7.2.0"
6326+
63136327
jsonfile@^4.0.0:
63146328
version "4.0.0"
63156329
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"

0 commit comments

Comments
 (0)