Skip to content

Commit 82131c2

Browse files
chore: add eslint-plugin-jsonc with sort-keys rule (#53)
* chore: add eslint-plugin-jsonc with sort-keys rule * Put back ESLint config, and do build failure * yarn lint --fix * More to uncomment lol
1 parent 7be4c2e commit 82131c2

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

.eslintrc.cjs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
module.exports = {
22
extends: [
33
"eslint:recommended",
4-
"plugin:@typescript-eslint/recommended",
5-
"plugin:@typescript-eslint/recommended-requiring-type-checking",
6-
"plugin:@typescript-eslint/strict",
74
"plugin:typescript-sort-keys/recommended",
85
"prettier",
96
],
107
overrides: [
8+
{
9+
extends: [
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
12+
"plugin:@typescript-eslint/strict",
13+
],
14+
files: ["**/*.{ts,tsx}"],
15+
},
16+
{
17+
files: "*.json",
18+
parser: "jsonc-eslint-parser",
19+
rules: {
20+
"jsonc/sort-keys": "error",
21+
},
22+
extends: ["plugin:jsonc/recommended-with-json"],
23+
},
1124
{
1225
files: "**/*.test.ts",
1326
rules: {

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
"cspell": "^6.12.0",
1414
"eslint": "^8.24.0",
1515
"eslint-config-prettier": "^8.5.0",
16+
"eslint-plugin-jsonc": "^2.4.0",
1617
"eslint-plugin-simple-import-sort": "^8.0.0",
1718
"eslint-plugin-typescript-sort-keys": "^2.1.0",
1819
"husky": ">=6",
20+
"jsonc-eslint-parser": "^2.1.0",
1921
"lint-staged": ">=10",
2022
"markdownlint-cli": "^0.32.2",
2123
"npm-package-json-lint": "^6.3.0",
@@ -33,13 +35,13 @@
3335
"name": "template-typescript-node-package",
3436
"scripts": {
3537
"build": "tsc",
36-
"format:write": "yarn format --write",
3738
"format": "prettier \"**/*\" --ignore-unknown",
38-
"lint:package": "npmPkgJsonLint .",
39+
"format:write": "yarn format --write",
40+
"lint": "npx eslint . --max-warnings 0 --report-unused-disable-directives",
3941
"lint:md": "npx markdownlint \"**/*.md\" \".github/**/*.md\"",
42+
"lint:package": "npmPkgJsonLint .",
4043
"lint:prune": "ts-prune",
4144
"lint:spelling": "cspell \"**\" \".github/**/*\"",
42-
"lint": "npx eslint . --max-warnings 0 --report-unused-disable-directives",
4345
"prepare": "husky install",
4446
"test": "vitest"
4547
},

yarn.lock

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ acorn-jsx@^5.3.2:
960960
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
961961
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
962962

963-
acorn@^8.8.0:
963+
acorn@^8.5.0, acorn@^8.8.0:
964964
version "8.8.0"
965965
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8"
966966
integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==
@@ -1969,6 +1969,15 @@ eslint-config-prettier@^8.5.0:
19691969
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1"
19701970
integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==
19711971

1972+
eslint-plugin-jsonc@^2.4.0:
1973+
version "2.4.0"
1974+
resolved "https://registry.yarnpkg.com/eslint-plugin-jsonc/-/eslint-plugin-jsonc-2.4.0.tgz#83a0f9a22689492d58514ab0464fa0612dceabc7"
1975+
integrity sha512-YXy5PjyUL9gFYal6pYijd8P6EmpeWskv7PVhB9Py/AwKPn+hwnQHcIzQILiLfxztfhtWiRIUSzoLe/JThZgSUw==
1976+
dependencies:
1977+
eslint-utils "^3.0.0"
1978+
jsonc-eslint-parser "^2.0.4"
1979+
natural-compare "^1.4.0"
1980+
19721981
eslint-plugin-simple-import-sort@^8.0.0:
19731982
version "8.0.0"
19741983
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-8.0.0.tgz#9d9a2372b0606e999ea841b10458a370a6ccc160"
@@ -2011,7 +2020,7 @@ eslint-visitor-keys@^2.0.0:
20112020
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
20122021
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
20132022

2014-
eslint-visitor-keys@^3.3.0:
2023+
eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.3.0:
20152024
version "3.3.0"
20162025
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826"
20172026
integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==
@@ -2061,7 +2070,7 @@ eslint@^8.24.0:
20612070
strip-json-comments "^3.1.0"
20622071
text-table "^0.2.0"
20632072

2064-
espree@^9.4.0:
2073+
espree@^9.0.0, espree@^9.4.0:
20652074
version "9.4.0"
20662075
resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.0.tgz#cd4bc3d6e9336c433265fc0aa016fc1aaf182f8a"
20672076
integrity sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==
@@ -2840,6 +2849,16 @@ json5@^2.1.3:
28402849
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
28412850
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
28422851

2852+
jsonc-eslint-parser@^2.0.4, jsonc-eslint-parser@^2.1.0:
2853+
version "2.1.0"
2854+
resolved "https://registry.yarnpkg.com/jsonc-eslint-parser/-/jsonc-eslint-parser-2.1.0.tgz#4c126b530aa583d85308d0b3041ff81ce402bbb2"
2855+
integrity sha512-qCRJWlbP2v6HbmKW7R3lFbeiVWHo+oMJ0j+MizwvauqnCV/EvtAeEeuCgoc/ErtsuoKgYB8U4Ih8AxJbXoE6/g==
2856+
dependencies:
2857+
acorn "^8.5.0"
2858+
eslint-visitor-keys "^3.0.0"
2859+
espree "^9.0.0"
2860+
semver "^7.3.5"
2861+
28432862
jsonc-parser@^3.0.0:
28442863
version "3.2.0"
28452864
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76"

0 commit comments

Comments
 (0)