Skip to content

Commit ff04eeb

Browse files
authored
Upgrade parser and add jsonc/no-numeric-separators rule. (#22)
* Upgrade parser and add `jsonc/no-numeric-separators` rule. * Fix test
1 parent b964f68 commit ff04eeb

Some content is hidden

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

42 files changed

+304
-130
lines changed

.eslintrc.js

Lines changed: 70 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,102 @@
1-
"use strict"
2-
31
// const version = require("./package.json").version
42

53
module.exports = {
64
parserOptions: {
7-
sourceType: "script",
5+
// sourceType: "script",
86
ecmaVersion: 2020,
7+
project: require.resolve("./tsconfig.json"),
98
},
109
extends: [
11-
"plugin:@mysticatea/es2015",
12-
"plugin:@mysticatea/+node",
13-
"plugin:@mysticatea/+eslint-plugin",
10+
"plugin:@ota-meshi/recommended",
11+
"plugin:@ota-meshi/+node",
12+
"plugin:@ota-meshi/+typescript",
13+
"plugin:@ota-meshi/+eslint-plugin",
14+
"plugin:@ota-meshi/+vue2",
15+
"plugin:@ota-meshi/+prettier",
16+
// "plugin:@ota-meshi/+json",
1417
],
1518
rules: {
1619
"require-jsdoc": "error",
1720
"no-warning-comments": "warn",
1821
"no-lonely-if": "off",
19-
"@mysticatea/ts/ban-ts-ignore": "off",
22+
"@typescript-eslint/no-non-null-assertion": "off",
23+
"@typescript-eslint/no-explicit-any": "off",
24+
"no-shadow": "off",
2025
},
2126
overrides: [
2227
{
2328
files: ["*.ts"],
2429
rules: {
25-
// "@mysticatea/ts/no-require-imports": "off",
26-
// "@mysticatea/ts/no-var-requires": "off",
27-
"@mysticatea/node/no-missing-import": "off",
28-
"no-implicit-globals": "off",
29-
"@mysticatea/node/no-extraneous-import": "off",
30+
"@typescript-eslint/naming-convention": [
31+
"error",
32+
{
33+
selector: "default",
34+
format: ["camelCase"],
35+
leadingUnderscore: "allow",
36+
trailingUnderscore: "allow",
37+
},
38+
{
39+
selector: "variable",
40+
format: ["camelCase", "UPPER_CASE"],
41+
leadingUnderscore: "allow",
42+
trailingUnderscore: "allow",
43+
},
44+
{
45+
selector: "typeLike",
46+
format: ["PascalCase"],
47+
},
48+
{
49+
selector: "method",
50+
format: ["camelCase", "UPPER_CASE", "PascalCase"],
51+
},
52+
],
3053
},
54+
parser: "@typescript-eslint/parser",
3155
parserOptions: {
3256
sourceType: "module",
3357
project: "./tsconfig.json",
3458
},
3559
},
36-
{
37-
files: ["lib/rules/**"],
38-
rules: {
39-
"@mysticatea/eslint-plugin/report-message-format": [
40-
"error",
41-
"[^a-z].*\\.$",
42-
],
43-
"@mysticatea/eslint-plugin/require-meta-docs-url": "off",
44-
},
45-
},
60+
// {
61+
// files: ["lib/rules/**"],
62+
// rules: {
63+
// "eslint-plugin/report-message-format": [
64+
// "error",
65+
// "[^a-z].*\\.$",
66+
// ],
67+
// "eslint-plugin/require-meta-docs-url": "off",
68+
// },
69+
// },
4670
{
4771
files: ["scripts/**/*.ts", "tests/**/*.ts"],
4872
rules: {
4973
"require-jsdoc": "off",
5074
"no-console": "off",
75+
"@typescript-eslint/ban-ts-comment": "off",
5176
},
5277
},
53-
{
54-
files: ["*.vue"],
55-
parserOptions: {
56-
sourceType: "module",
57-
},
58-
globals: {
59-
require: true,
60-
},
61-
},
62-
{
63-
files: ["docs/.vuepress/**"],
64-
parserOptions: {
65-
sourceType: "module",
66-
ecmaVersion: 2020,
67-
parser: "babel-eslint",
68-
},
69-
globals: {
70-
window: true,
71-
},
72-
rules: {
73-
"require-jsdoc": "off",
74-
"@mysticatea/vue/html-closing-bracket-newline": "off",
75-
"@mysticatea/vue/max-attributes-per-line": "off",
76-
"@mysticatea/vue/comma-dangle": "off",
77-
"@mysticatea/vue/html-indent": "off",
78-
"@mysticatea/vue/html-self-closing": "off",
79-
"@mysticatea/node/no-unsupported-features/es-syntax": "off",
80-
"@mysticatea/node/no-missing-import": "off",
81-
"@mysticatea/node/no-missing-require": "off",
82-
},
83-
},
78+
// {
79+
// files: ["*.vue"],
80+
// parserOptions: {
81+
// sourceType: "module",
82+
// },
83+
// globals: {
84+
// require: true,
85+
// },
86+
// },
87+
// {
88+
// files: ["docs/.vuepress/**"],
89+
// parserOptions: {
90+
// sourceType: "module",
91+
// ecmaVersion: 2020,
92+
// parser: "babel-eslint",
93+
// },
94+
// globals: {
95+
// window: true,
96+
// },
97+
// rules: {
98+
// "require-jsdoc": "off",
99+
// },
100+
// },
84101
],
85102
}

.github/workflows/NodeCI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
node-version: 14
1717
- name: Install Packages
1818
run: npm install
19-
- name: Lint
20-
run: npm run lint
2119
- name: Build
2220
run: npm run build
21+
- name: Lint
22+
run: npm run lint
2323
test:
2424
runs-on: ubuntu-latest
2525
strategy:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ The rules with the following star :star: are included in the config.
140140
| [jsonc/no-bigint-literals](https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-bigint-literals.html) | disallow BigInt literals | | :star: | :star: | :star: |
141141
| [jsonc/no-comments](https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-comments.html) | disallow comments | | :star: | | |
142142
| [jsonc/no-number-props](https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-number-props.html) | disallow number property keys | :wrench: | :star: | :star: | :star: |
143+
| [jsonc/no-numeric-separators](https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-numeric-separators.html) | disallow numeric separators | :wrench: | :star: | :star: | :star: |
143144
| [jsonc/no-regexp-literals](https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-regexp-literals.html) | disallow RegExp literals | | :star: | :star: | :star: |
144145
| [jsonc/no-template-literals](https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-template-literals.html) | disallow template literals | :wrench: | :star: | :star: | :star: |
145146
| [jsonc/no-undefined-value](https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-undefined-value.html) | disallow `undefined` | | :star: | :star: | :star: |

docs/.vuepress/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// 'use strict'
2+
3+
module.exports = {
4+
rules: {
5+
"prettier/prettier": "off",
6+
"require-jsdoc": "off"
7+
},
8+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default {
8787
parser: "jsonc-eslint-parser",
8888
parserOptions: {
8989
sourceType: "script",
90-
ecmaVersion: 2020,
90+
ecmaVersion: 2021,
9191
},
9292
}
9393
},
@@ -121,7 +121,7 @@ export default {
121121
// Load linter asynchronously.
122122
const [{ default: eslint4b }, { parseForESLint }] = await Promise.all([
123123
import("eslint4b"),
124-
// eslint-disable-next-line @mysticatea/node/no-extraneous-import
124+
// eslint-disable-next-line node/no-extraneous-import -- DEMO
125125
import("espree").then(() => import("jsonc-eslint-parser")),
126126
])
127127
this.eslint4b = eslint4b

docs/.vuepress/components/demo/.eslintrc.js

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

docs/.vuepress/components/rules/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
12
import * as coreRules from "../../../../node_modules/eslint4b/dist/core-rules"
3+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
24
import plugin from "../../../../"
35

46
const CATEGORY_TITLES = {
@@ -51,9 +53,10 @@ for (const k of Object.keys(coreRules)) {
5153
}
5254

5355
allRules.sort((a, b) =>
54-
a.ruleId > b.ruleId ? 1 : a.ruleId < b.ruleId ? -1 : 0
56+
a.ruleId > b.ruleId ? 1 : a.ruleId < b.ruleId ? -1 : 0,
5557
)
5658

59+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
5760
export const categories = []
5861

5962
for (const rule of allRules) {
@@ -80,9 +83,10 @@ categories.sort((a, b) =>
8083
? 1
8184
: a.title < b.title
8285
? -1
83-
: 0
86+
: 0,
8487
)
8588

89+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
8690
export const DEFAULT_RULES_CONFIG = allRules.reduce((c, r) => {
8791
if (r.ruleId === "vue/no-parsing-error") {
8892
c[r.ruleId] = "error"
@@ -92,4 +96,5 @@ export const DEFAULT_RULES_CONFIG = allRules.reduce((c, r) => {
9296
return c
9397
}, {})
9498

99+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
95100
export const rules = allRules

docs/.vuepress/components/state/deserialize.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
12
import pako from "../../../../node_modules/pako"
23

34
/**
45
* Deserialize a given serialized string then update this object.
56
* @param {string} serializedString A serialized string.
67
* @returns {object} The deserialized state.
78
*/
9+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
810
export function deserializeState(serializedString) {
911
const state = {
1012
code: undefined,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
12
export * from "./deserialize"
3+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
24
export * from "./serialize"

docs/.vuepress/components/state/serialize.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
12
import pako from "../../../../node_modules/pako"
23

34
/**
@@ -19,6 +20,7 @@ function getEnabledRules(allRules) {
1920
* @param {State} state The state to serialize.
2021
* @returns {string} The serialized string.
2122
*/
23+
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- DEMO
2224
export function serializeState(state) {
2325
const saveData = {
2426
code: state.code,
@@ -30,12 +32,11 @@ export function serializeState(state) {
3032
(typeof window !== "undefined" && window.btoa(compressedString)) ||
3133
compressedString
3234

33-
//eslint-disable-next-line no-console
3435
console.log(
3536
`The compress rate of serialized string: ${(
3637
(100 * base64.length) /
3738
jsonString.length
38-
).toFixed(1)}% (${jsonString.length}B → ${base64.length}B)`
39+
).toFixed(1)}% (${jsonString.length}B → ${base64.length}B)`,
3940
)
4041

4142
return base64

0 commit comments

Comments
 (0)