Skip to content

Commit a049bf5

Browse files
authored
Change to use jsonc-eslint-parser (#20)
* Change to use jsonc-eslint-parser * update * update doc * update * fix lint error
1 parent 3364f1e commit a049bf5

File tree

107 files changed

+74
-9524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+74
-9524
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Also, [JSONC] and [JSON5], which are variants of [JSON], are more similar to Jav
3232
This plugin parses `.json` with its own parser, but this parser just converts AST parsed by `espree` (ESLint standard parser) into AST with another name. However, ASTs that do not exist in [JSON] and the superset of JSON syntaxes are reported as parsing errors. By converting the AST to another name, we prevent false positives from ESLint core rules.
3333
Moreover, You can do the same linting using the extended rules of the ESLint core rules provided by this plugin.
3434

35+
The parser package used by this plugin is [jsonc-eslint-parser].
36+
3537
<!--DOCS_IGNORE_START-->
3638

3739
## :book: Documentation
@@ -193,3 +195,4 @@ See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
193195
[JSON]: https://json.org/
194196
[JSONC]: https://github.com/microsoft/node-jsonc-parser
195197
[JSON5]: https://json5.org/
198+
[jsonc-eslint-parser]: https://github.com/ota-meshi/jsonc-eslint-parser

docs/.vuepress/components/components/EslintPluginEditor.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default {
8484
SharedArrayBuffer: false,
8585
},
8686
rules: this.rules,
87-
parser: "json-eslint-parser",
87+
parser: "jsonc-eslint-parser",
8888
parserOptions: {
8989
sourceType: "script",
9090
ecmaVersion: 2020,
@@ -104,7 +104,7 @@ export default {
104104
const Linter = this.eslint4b
105105
106106
const linter = new Linter()
107-
linter.defineParser("json-eslint-parser", {
107+
linter.defineParser("jsonc-eslint-parser", {
108108
parseForESLint: this.parseForESLint,
109109
})
110110
@@ -121,9 +121,8 @@ export default {
121121
// Load linter asynchronously.
122122
const [{ default: eslint4b }, { parseForESLint }] = await Promise.all([
123123
import("eslint4b"),
124-
import("espree").then(() =>
125-
import("../../../../dist/parser/json-eslint-parser")
126-
),
124+
// eslint-disable-next-line @mysticatea/node/no-extraneous-import
125+
import("espree").then(() => import("jsonc-eslint-parser")),
127126
])
128127
this.eslint4b = eslint4b
129128
this.parseForESLint = parseForESLint

docs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Also, [JSONC] and [JSON5], which are variants of [JSON], are more similar to Jav
3232
This plugin parses `.json` with its own parser, but this parser just converts AST parsed by `espree` (ESLint standard parser) into AST with another name. However, ASTs that do not exist in [JSON] and the superset of JSON syntaxes are reported as parsing errors. By converting the AST to another name, we prevent false positives from ESLint core rules.
3333
Moreover, You can do the same linting using the extended rules of the ESLint core rules provided by this plugin.
3434

35+
The parser package used by this plugin is [jsonc-eslint-parser].
36+
3537
## :book: Usage
3638

3739
See [User Guide](./user-guide/README.md).
@@ -47,3 +49,4 @@ See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
4749
[JSON]: https://json.org/
4850
[JSONC]: https://github.com/microsoft/node-jsonc-parser
4951
[JSON5]: https://json5.org/
52+
[jsonc-eslint-parser]: https://github.com/ota-meshi/jsonc-eslint-parser

docs/user-guide/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = {
9696
overrides: [
9797
{
9898
files: ["*.json6"], // If you want to parse `.json6`
99-
parser: "eslint-plugin-jsonc", // Set this plugin as a parser.
99+
parser: "jsonc-eslint-parser", // Set jsonc-eslint-parser.
100100
},
101101
],
102102
}
@@ -110,7 +110,7 @@ module.exports = {
110110
overrides: [
111111
{
112112
files: ["*.json6"],
113-
parser: "eslint-plugin-jsonc",
113+
parser: "jsonc-eslint-parser",
114114
+ processor: "jsonc/auto-config",
115115
},
116116
],

lib/configs/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export = {
33
overrides: [
44
{
55
files: ["*.json", "*.json5"],
6-
parser: require.resolve("../parser/json-eslint-parser"),
6+
parser: require.resolve("jsonc-eslint-parser"),
77
},
88
],
99
}

lib/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import autoConfig from "./configs/auto-config"
66
import recommendedWithJson from "./configs/recommended-with-json"
77
import recommendedWithJsonc from "./configs/recommended-with-jsonc"
88
import recommendedWithJson5 from "./configs/recommended-with-json5"
9-
import { parseForESLint } from "./parser/json-eslint-parser"
10-
import { traverseNodes } from "./parser/traverse"
11-
import { getStaticJSONValue } from "./utils/ast"
12-
13-
import type * as AST from "./parser/ast"
9+
// backward compatibility
10+
import {
11+
parseForESLint,
12+
traverseNodes,
13+
AST,
14+
getStaticJSONValue,
15+
} from "jsonc-eslint-parser"
1416

1517
const configs = {
1618
base,

lib/parser/ast.ts

Lines changed: 0 additions & 165 deletions
This file was deleted.

0 commit comments

Comments
 (0)