From 5c2bd9b3767406009c1732e996967a96f9ac9e5c Mon Sep 17 00:00:00 2001 From: CRIMX Date: Fri, 10 Jan 2025 16:43:41 +0800 Subject: [PATCH] chore: sort json (#29) --- .prettierrc.json | 14 ++-- eslint.config.mjs | 66 ++++++++++--------- package-lock.json | 159 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + tsconfig.json | 19 +++--- typedoc.json | 12 ++-- 6 files changed, 220 insertions(+), 51 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index b22ccb6..d4b079f 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,11 +1,6 @@ { - "printWidth": 120, - "trailingComma": "all", - "tabWidth": 2, - "semi": true, - "singleQuote": false, - "endOfLine": "auto", "arrowParens": "avoid", + "endOfLine": "auto", "overrides": [ { "files": "*.json", @@ -13,5 +8,10 @@ "printWidth": 80 } } - ] + ], + "printWidth": 120, + "semi": true, + "singleQuote": false, + "tabWidth": 2, + "trailingComma": "all" } diff --git a/eslint.config.mjs b/eslint.config.mjs index c61e863..ff89820 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -2,32 +2,46 @@ import jsEslint from "@eslint/js"; import gitignore from "eslint-config-flat-gitignore"; import eslintConfigPrettier from "eslint-config-prettier"; import importX from "eslint-plugin-import-x"; +import jsonc from "eslint-plugin-jsonc"; import perfectionist from "eslint-plugin-perfectionist"; import tsEslint from "typescript-eslint"; export default tsEslint.config( - jsEslint.configs.recommended, - ...tsEslint.configs.recommended, - eslintConfigPrettier, - importX.flatConfigs.recommended, - perfectionist.configs["recommended-natural"], gitignore(), + eslintConfigPrettier, { + extends: [ + jsEslint.configs.recommended, + ...tsEslint.configs.recommended, + importX.flatConfigs.recommended, + perfectionist.configs["recommended-natural"], + ], + files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], languageOptions: { ecmaVersion: "latest", globals: { console: true, process: true, }, + parser: tsEslint.parser, sourceType: "module", }, - rules: { - "prefer-const": "off", - "sort-imports": "off", + plugins: { + "@typescript-eslint": tsEslint.plugin, }, - }, - { rules: { + "@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }], + "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + argsIgnorePattern: "^_", + destructuredArrayIgnorePattern: "^_", + ignoreRestSiblings: true, + varsIgnorePattern: "^_", + }, + ], "import-x/consistent-type-specifier-style": ["error", "prefer-inline"], "import-x/no-duplicates": ["error", { considerQueryString: true, "prefer-inline": true }], "import-x/no-unresolved": "off", @@ -46,29 +60,23 @@ export default tsEslint.config( ], }, ], + "prefer-const": "off", + "sort-imports": "off", }, }, { - files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], - languageOptions: { - parser: tsEslint.parser, - }, - plugins: { - "@typescript-eslint": tsEslint.plugin, - }, + extends: [...jsonc.configs["flat/recommended-with-json"]], + files: [ + "src/**/*.json", + "scripts/**/*.json", + "tsconfig.json", + ".prettierrc.json", + ".prettierrc", + "typedoc.json", + "mangle-cache.json", + ], rules: { - "@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }], - "@typescript-eslint/no-empty-interface": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unused-vars": [ - "error", - { - argsIgnorePattern: "^_", - destructuredArrayIgnorePattern: "^_", - ignoreRestSiblings: true, - varsIgnorePattern: "^_", - }, - ], + "jsonc/sort-keys": ["error", "asc", { caseSensitive: true, minKeys: 2, natural: true }], }, }, ); diff --git a/package-lock.json b/package-lock.json index 699e784..fc266c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "eslint-config-flat-gitignore": "^0.3.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import-x": "^4.6.1", + "eslint-plugin-jsonc": "^2.18.2", "eslint-plugin-perfectionist": "^4.6.0", "gzip-size": "^7.0.0", "prettier": "^3.4.2", @@ -2821,6 +2822,22 @@ } } }, + "node_modules/eslint-compat-utils": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.6.4.tgz", + "integrity": "sha512-/u+GQt8NMfXO8w17QendT4gvO5acfxQsAKirAt0LVxDnr2N8YLCVbregaNc/Yhp7NM128DwCaRvr8PLDfeNkQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, "node_modules/eslint-config-flat-gitignore": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/eslint-config-flat-gitignore/-/eslint-config-flat-gitignore-0.3.0.tgz", @@ -2870,6 +2887,28 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-json-compat-utils": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/eslint-json-compat-utils/-/eslint-json-compat-utils-0.2.1.tgz", + "integrity": "sha512-YzEodbDyW8DX8bImKhAcCeu/L31Dd/70Bidx2Qex9OFUtgzXLqtfWL4Hr5fM/aCCB8QUZLuJur0S9k6UfgFkfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "esquery": "^1.6.0" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "eslint": "*", + "jsonc-eslint-parser": "^2.4.0" + }, + "peerDependenciesMeta": { + "@eslint/json": { + "optional": true + } + } + }, "node_modules/eslint-plugin-import-x": { "version": "4.6.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.6.1.tgz", @@ -2936,6 +2975,63 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/eslint-plugin-jsonc": { + "version": "2.18.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsonc/-/eslint-plugin-jsonc-2.18.2.tgz", + "integrity": "sha512-SDhJiSsWt3nItl/UuIv+ti4g3m4gpGkmnUJS9UWR3TrpyNsIcnJoBRD7Kof6cM4Rk3L0wrmY5Tm3z7ZPjR2uGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "eslint-compat-utils": "^0.6.0", + "eslint-json-compat-utils": "^0.2.1", + "espree": "^9.6.1", + "graphemer": "^1.4.0", + "jsonc-eslint-parser": "^2.0.4", + "natural-compare": "^1.4.0", + "synckit": "^0.6.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/eslint-plugin-jsonc/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-jsonc/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/eslint-plugin-perfectionist": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-4.6.0.tgz", @@ -4082,6 +4178,56 @@ "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, + "node_modules/jsonc-eslint-parser": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jsonc-eslint-parser/-/jsonc-eslint-parser-2.4.0.tgz", + "integrity": "sha512-WYDyuc/uFcGp6YtM2H0uKmUwieOuzeE/5YocFJLnLfclZ4inf3mRn8ZVy1s7Hxji7Jxm6Ss8gqpexD/GlKoGgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.5.0", + "eslint-visitor-keys": "^3.0.0", + "espree": "^9.0.0", + "semver": "^7.3.5" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + } + }, + "node_modules/jsonc-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/jsonc-eslint-parser/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -5760,6 +5906,19 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, + "node_modules/synckit": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.6.2.tgz", + "integrity": "sha512-Vhf+bUa//YSTYKseDiiEuQmhGCoIF3CVBhunm3r/DQnYiGT4JssmnKQc44BIyOZRK2pKjXXAgbhfmbeoC9CJpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.3.1" + }, + "engines": { + "node": ">=12.20" + } + }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", diff --git a/package.json b/package.json index f92cc42..5c38832 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "eslint-config-flat-gitignore": "^0.3.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import-x": "^4.6.1", + "eslint-plugin-jsonc": "^2.18.2", "eslint-plugin-perfectionist": "^4.6.0", "gzip-size": "^7.0.0", "prettier": "^3.4.2", diff --git a/tsconfig.json b/tsconfig.json index 5d81e84..3124a72 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,21 @@ { "compilerOptions": { "declaration": true, - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Node", "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, "isolatedModules": true, + "lib": ["DOM", "ESNext"], + "module": "ESNext", + "moduleResolution": "Node", "noFallthroughCasesInSwitch": true, - "noUnusedParameters": true, "noImplicitOverride": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, + "noUnusedParameters": true, + "outDir": "dist", "resolveJsonModule": true, - "lib": ["DOM", "ESNext"], - "outDir": "dist" + "skipLibCheck": true, + "strict": true, + "stripInternal": true, + "target": "ESNext" }, "include": ["src/**/*"] } diff --git a/typedoc.json b/typedoc.json index ab4a3bd..4a3e100 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,13 +1,13 @@ { "$schema": "https://typedoc.org/schema.json", - "entryPoints": ["./src/index.ts"], - "out": "docs", + "cleanOutputDir": true, "customCss": "./assets/docs.css", - "visibilityFilters": {}, + "entryPoints": ["./src/index.ts"], + "excludeInternal": true, "excludePrivate": true, "excludeProtected": true, - "excludeInternal": true, - "cleanOutputDir": true, + "hideGenerator": true, "includeVersion": true, - "hideGenerator": true + "out": "docs", + "visibilityFilters": {} }