diff --git a/package.json b/package.json index 015a3ca9..e0a434dc 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@xylabs/ts-scripts-yarn3": "workspace:^" }, "devDependencies": { + "@eslint/json": "^0.5.0", "@types/json-schema": "^7.0.15", "@types/node": "^22.7.5", "@xylabs/eslint-config-flat": "workspace:^", @@ -54,7 +55,7 @@ "eslint-import-resolver-typescript": "^3.6.3", "rimraf": "^6.0.1", "typescript": "^5.6.3", - "vitest": "^2.1.2" + "vitest": "^2.1.3" }, "peerDependencies": { "typescript": "^5" diff --git a/packages/eslint-config-flat/package.json b/packages/eslint-config-flat/package.json index 5bb16841..25f6322d 100644 --- a/packages/eslint-config-flat/package.json +++ b/packages/eslint-config-flat/package.json @@ -36,20 +36,19 @@ "package-compile2": "yarn tsc -p tsconfig.json --module es2022 --outDir dist --rootDir src" }, "dependencies": { + "@eslint/json": "^0.5.0", "@stylistic/eslint-plugin": "^2.9.0", "@typescript-eslint/eslint-plugin": "^8.8.1", "@typescript-eslint/parser": "^8.8.1", "eslint": "^9.12.0", "eslint-plugin-depend": "^0.11.0", "eslint-plugin-import-x": "^4.3.1", - "eslint-plugin-jsonc": "^2.16.0", "eslint-plugin-md": "^1.0.19", "eslint-plugin-package-json": "^0.15.3", "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-sonarjs": "^2.0.3", "eslint-plugin-unicorn": "^56.0.0", - "eslint-plugin-workspaces": "^0.10.1", - "jsonc-eslint-parser": "^2.4.0" + "eslint-plugin-workspaces": "^0.10.1" }, "devDependencies": { "@xylabs/ts-scripts-yarn3": "workspace:^", diff --git a/packages/eslint-config-flat/src/import/index.ts b/packages/eslint-config-flat/src/import/index.ts index f54da6c4..4f7ef0d5 100644 --- a/packages/eslint-config-flat/src/import/index.ts +++ b/packages/eslint-config-flat/src/import/index.ts @@ -37,6 +37,7 @@ export const importConfig: Linter.Config = { 'warn', { allow: [ + 'vitest/*', // Allow imports from vitest '@*/**', // Allow imports from any @scoped package // Allow imports to any index.js file '**/index.js', diff --git a/packages/eslint-config-flat/src/index.ts b/packages/eslint-config-flat/src/index.ts index 8ebf1af0..56eaed4c 100644 --- a/packages/eslint-config-flat/src/index.ts +++ b/packages/eslint-config-flat/src/index.ts @@ -1,7 +1,6 @@ import type { Linter } from 'eslint' import { importConfig } from './import/index.ts' -// import { jsonConfig } from './json/index.ts' // import { markdownConfig } from './markdown/index.ts' // import { prettierConfig } from './prettier/index.ts' import { rulesConfig } from './rules/index.ts' @@ -13,16 +12,18 @@ import { workspacesConfig } from './workspaces/index.ts' export const config: Linter.Config[] = [ // markdownConfig, typescriptConfig, - // jsonConfig, unicornConfig, workspacesConfig, rulesConfig, // prettierConfig, importConfig, - // sonarConfig, + // sonarConfig ] export { importConfig } from './import/index.ts' +export { + json5Config, jsoncConfig, jsonConfig, +} from './json/index.ts' export { rulesConfig } from './rules/index.ts' export { sonarConfig } from './sonar/index.ts' export { ignores, typescriptConfig } from './typescript/index.ts' diff --git a/packages/eslint-config-flat/src/json/index.ts b/packages/eslint-config-flat/src/json/index.ts index 8df4fcbd..5e00349e 100644 --- a/packages/eslint-config-flat/src/json/index.ts +++ b/packages/eslint-config-flat/src/json/index.ts @@ -1,34 +1,23 @@ +import json from '@eslint/json' import type { ESLint, Linter } from 'eslint' -import jsonc from 'eslint-plugin-jsonc' -import jsoncParser from 'jsonc-eslint-parser' -export const jsonConfig: Linter.FlatConfig = { - ignores: ['.yarn/**', 'jest.config.cjs', '**/dist/**', 'dist', 'build/**', 'node_modules/**'], - files: ['**/*.json', '**/*.jsonc', '**/*.json5'], - plugins: { jsonc: jsonc as unknown as ESLint.Plugin }, - languageOptions: { parser: jsoncParser }, - rules: { - ...jsonc.configs['all'].rules, - - /// Support arrays with and without new lines but they can't mix - 'jsonc/array-element-newline': ['error', 'consistent'], - - 'jsonc/auto': 'off', - - /// see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/comma-dangle.html - 'jsonc/comma-dangle': ['error', 'only-multiline'], - - /// Indent with 2 spaces - 'jsonc/indent': ['error', 2, {}], - - /// Not all keys are camelCase - 'jsonc/key-name-casing': 'off', +export const jsonConfig: Linter.Config = { + files: ['**/*.json'], + plugins: { json: json as unknown as ESLint.Plugin }, + language: 'json/json', + rules: { 'json/no-duplicate-keys': ['error'] }, +} - /// jsonc and json5 can have comments - 'jsonc/no-comments': 'off', +export const jsoncConfig: Linter.Config = { + files: ['**/*.jsonc'], + plugins: { json: json as unknown as ESLint.Plugin }, + language: 'json/jsonc', + rules: { 'json/no-duplicate-keys': ['error'] }, +} - /// Don't sort keys. We want to keep the order of keys as they are: - /// especially in arrays. - 'jsonc/sort-keys': 'off', - }, +export const json5Config: Linter.Config = { + files: ['**/*.json5'], + plugins: { json: json as unknown as ESLint.Plugin }, + language: 'json/json5', + rules: { 'json/no-duplicate-keys': ['error'] }, } diff --git a/packages/ts-scripts-yarn3/package.json b/packages/ts-scripts-yarn3/package.json index c6e77577..d6bf8d73 100644 --- a/packages/ts-scripts-yarn3/package.json +++ b/packages/ts-scripts-yarn3/package.json @@ -127,7 +127,7 @@ "tsup": "^8.3.0", "typedoc": "^0.26.9", "types-package-json": "^2.0.39", - "vitest": "^2.1.2", + "vitest": "^2.1.3", "yargs": "^17.7.2" }, "devDependencies": { diff --git a/vitest.config.ts b/vitest.config.ts index f2308d95..ba589bfa 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,5 +1,4 @@ import dotenv from 'dotenv' -// eslint-disable-next-line import-x/no-internal-modules import { defineConfig } from 'vitest/config' dotenv.config() diff --git a/vitest.workspace.ts b/vitest.workspace.ts index 1cafbfce..561c034c 100644 --- a/vitest.workspace.ts +++ b/vitest.workspace.ts @@ -1,5 +1,5 @@ import { defineWorkspace } from 'vitest/config' export default defineWorkspace([ - "./vitest.config.ts" + './vitest.config.ts', ]) diff --git a/yarn.lock b/yarn.lock index 6332c89b..9c791eb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2162,6 +2162,16 @@ __metadata: languageName: node linkType: hard +"@eslint/json@npm:^0.5.0": + version: 0.5.0 + resolution: "@eslint/json@npm:0.5.0" + dependencies: + "@eslint/plugin-kit": "npm:^0.2.0" + "@humanwhocodes/momoa": "npm:^3.2.1" + checksum: 10/9722bc98b23b3c7fdfc835cc017fe2dd0fda169677651430bc9ae0b198b1638580f1ef60a3a6813dda571d3a20d731d835c345d1c74940d7b6d5a822d0eb8127 + languageName: node + linkType: hard + "@eslint/object-schema@npm:^2.1.4": version: 2.1.4 resolution: "@eslint/object-schema@npm:2.1.4" @@ -2202,6 +2212,13 @@ __metadata: languageName: node linkType: hard +"@humanwhocodes/momoa@npm:^3.2.1": + version: 3.2.2 + resolution: "@humanwhocodes/momoa@npm:3.2.2" + checksum: 10/d2afc205ae3dbb1bacdf40cb7914cd37b86751ae771a8e93fa9b4a7d54c40bc1620bcafbf5058fbd8d29fdf633e5c1d10ec36eaaa0f97b4bea69d1957064db66 + languageName: node + linkType: hard + "@humanwhocodes/retry@npm:^0.3.0, @humanwhocodes/retry@npm:^0.3.1": version: 0.3.1 resolution: "@humanwhocodes/retry@npm:0.3.1" @@ -3211,27 +3228,27 @@ __metadata: languageName: node linkType: hard -"@vitest/expect@npm:2.1.2": - version: 2.1.2 - resolution: "@vitest/expect@npm:2.1.2" +"@vitest/expect@npm:2.1.3": + version: 2.1.3 + resolution: "@vitest/expect@npm:2.1.3" dependencies: - "@vitest/spy": "npm:2.1.2" - "@vitest/utils": "npm:2.1.2" + "@vitest/spy": "npm:2.1.3" + "@vitest/utils": "npm:2.1.3" chai: "npm:^5.1.1" tinyrainbow: "npm:^1.2.0" - checksum: 10/0e2991295a6b9c51e2d074d1185317dcb2d85d1e9b5045299431fd7b84e51a847942911b08efad2379f56bb4dfe2f02442abd267df348751c61c86bc7b3154a3 + checksum: 10/94e61e01f14cfcd9ced0e7ac1bbdeee55ff4bf68f09d8f244fd7d73f97b106f35d10cba3fe7a0132464c312206f2eee9e83b16a8d761101b61da053890062858 languageName: node linkType: hard -"@vitest/mocker@npm:2.1.2": - version: 2.1.2 - resolution: "@vitest/mocker@npm:2.1.2" +"@vitest/mocker@npm:2.1.3": + version: 2.1.3 + resolution: "@vitest/mocker@npm:2.1.3" dependencies: - "@vitest/spy": "npm:^2.1.0-beta.1" + "@vitest/spy": "npm:2.1.3" estree-walker: "npm:^3.0.3" magic-string: "npm:^0.30.11" peerDependencies: - "@vitest/spy": 2.1.2 + "@vitest/spy": 2.1.3 msw: ^2.3.5 vite: ^5.0.0 peerDependenciesMeta: @@ -3239,57 +3256,57 @@ __metadata: optional: true vite: optional: true - checksum: 10/f6ec9aa061c21877322bf3f0b12bf4e78eba3f092174a506b2d2d479b78e36b4d46a6458cd23d3bf3cbdcf212276cf5d1a87234ae2014e8362ea2afc23e46bec + checksum: 10/84be8830d6e965109730257d7a84b3d7594db0998ae55decdbfc304857c1c7d29b49f1f5b23f2addcbce1bd7e8bb33832407737a9bb3f95cb3bf7bb312db4d9d languageName: node linkType: hard -"@vitest/pretty-format@npm:2.1.2, @vitest/pretty-format@npm:^2.1.2": - version: 2.1.2 - resolution: "@vitest/pretty-format@npm:2.1.2" +"@vitest/pretty-format@npm:2.1.3, @vitest/pretty-format@npm:^2.1.3": + version: 2.1.3 + resolution: "@vitest/pretty-format@npm:2.1.3" dependencies: tinyrainbow: "npm:^1.2.0" - checksum: 10/5866fb3c45e794b695a9f62f76b886a8a8d07d711f7187e9e769fd614bc62df1f87d076880c032d5cd8c0272c385fe824c12191b04a3ca44a8bb9fed1a0c3693 + checksum: 10/d9382ee93f0f32e2ef8fe03bda818e5277f052a50ddb05b6a6cf0864b2ccb228484f12f130c05faf62dc2140292ffafc213f2941b0fa24058b3ee2943daa286c languageName: node linkType: hard -"@vitest/runner@npm:2.1.2": - version: 2.1.2 - resolution: "@vitest/runner@npm:2.1.2" +"@vitest/runner@npm:2.1.3": + version: 2.1.3 + resolution: "@vitest/runner@npm:2.1.3" dependencies: - "@vitest/utils": "npm:2.1.2" + "@vitest/utils": "npm:2.1.3" pathe: "npm:^1.1.2" - checksum: 10/60b086e39a31dd664875746b0da3a2402d4088801306e87fe25f20dc660abda50afd3e5ec6ea34ef0849f5652ac05ce2a93a13ea4d5dd16a549d9882941de328 + checksum: 10/cdf9b82d388c1cc148753f4a8632dfcadf9c4a1c0e065fdcd485d5af824af62507fd7eab9efb21244009775c05773ccb59547043af522a5ab6d216433321066e languageName: node linkType: hard -"@vitest/snapshot@npm:2.1.2": - version: 2.1.2 - resolution: "@vitest/snapshot@npm:2.1.2" +"@vitest/snapshot@npm:2.1.3": + version: 2.1.3 + resolution: "@vitest/snapshot@npm:2.1.3" dependencies: - "@vitest/pretty-format": "npm:2.1.2" + "@vitest/pretty-format": "npm:2.1.3" magic-string: "npm:^0.30.11" pathe: "npm:^1.1.2" - checksum: 10/acd29f59883899c660eeba5950366e4f9f799cb29e7edd65575a7b6ad319a1df4d7a46a95048f8f9475f4c6f46cea198a7ecfab06e88e435dfd4989b365b917f + checksum: 10/2c0c4ad8abb758f2f76d1d6094f8928360437e09d0a59e0c6a85a544c892cc41a5324ebbc5657a66c8a3793e51cbf58e357c7f71e899f4e5c5eb76e8c9745abf languageName: node linkType: hard -"@vitest/spy@npm:2.1.2, @vitest/spy@npm:^2.1.0-beta.1": - version: 2.1.2 - resolution: "@vitest/spy@npm:2.1.2" +"@vitest/spy@npm:2.1.3": + version: 2.1.3 + resolution: "@vitest/spy@npm:2.1.3" dependencies: tinyspy: "npm:^3.0.0" - checksum: 10/0183ab53b431bd6a08531752113780e15202ebd7579eed25b9bf87c849f75d74d0e4f346d886034cd9dd1381aa8814b3e468f141f41f7539b75f30268df35a79 + checksum: 10/94d6f1bc34da5d0c973d9382c133b938e555fcf2d238edf0aaad3de1a98dd57ebf7c104ba229c6beec48122d2e6f55386d8d2cf96a5804dc95ac683a54754cc7 languageName: node linkType: hard -"@vitest/utils@npm:2.1.2": - version: 2.1.2 - resolution: "@vitest/utils@npm:2.1.2" +"@vitest/utils@npm:2.1.3": + version: 2.1.3 + resolution: "@vitest/utils@npm:2.1.3" dependencies: - "@vitest/pretty-format": "npm:2.1.2" + "@vitest/pretty-format": "npm:2.1.3" loupe: "npm:^3.1.1" tinyrainbow: "npm:^1.2.0" - checksum: 10/fa898ea6312cb62e4027f55b06859d84ba50ac20e583bab2889eeadea41d73baf6022ed87547deec6251cd8021f1df13d2ea4515ab253582c3ca93226acd6313 + checksum: 10/f064e6634cb84c925a17d8937df7441d150c3e24fa5bbd6304151d11dab6cdeb0cb3d5a95a9aacb8b416c87fb0d9aa8c6b9cc5e174191784231e8345948d6d18 languageName: node linkType: hard @@ -3354,6 +3371,7 @@ __metadata: version: 0.0.0-use.local resolution: "@xylabs/config@workspace:." dependencies: + "@eslint/json": "npm:^0.5.0" "@types/json-schema": "npm:^7.0.15" "@types/node": "npm:^22.7.5" "@xylabs/eslint-config-flat": "workspace:^" @@ -3364,7 +3382,7 @@ __metadata: eslint-import-resolver-typescript: "npm:^3.6.3" rimraf: "npm:^6.0.1" typescript: "npm:^5.6.3" - vitest: "npm:^2.1.2" + vitest: "npm:^2.1.3" peerDependencies: typescript: ^5 languageName: unknown @@ -3374,6 +3392,7 @@ __metadata: version: 0.0.0-use.local resolution: "@xylabs/eslint-config-flat@workspace:packages/eslint-config-flat" dependencies: + "@eslint/json": "npm:^0.5.0" "@stylistic/eslint-plugin": "npm:^2.9.0" "@typescript-eslint/eslint-plugin": "npm:^8.8.1" "@typescript-eslint/parser": "npm:^8.8.1" @@ -3382,14 +3401,12 @@ __metadata: eslint: "npm:^9.12.0" eslint-plugin-depend: "npm:^0.11.0" eslint-plugin-import-x: "npm:^4.3.1" - eslint-plugin-jsonc: "npm:^2.16.0" eslint-plugin-md: "npm:^1.0.19" eslint-plugin-package-json: "npm:^0.15.3" eslint-plugin-simple-import-sort: "npm:^12.1.1" eslint-plugin-sonarjs: "npm:^2.0.3" eslint-plugin-unicorn: "npm:^56.0.0" eslint-plugin-workspaces: "npm:^0.10.1" - jsonc-eslint-parser: "npm:^2.4.0" typescript: "npm:^5.6.3" languageName: unknown linkType: soft @@ -3513,7 +3530,7 @@ __metadata: typedoc: "npm:^0.26.9" types-package-json: "npm:^2.0.39" typescript: "npm:^5.6.3" - vitest: "npm:^2.1.2" + vitest: "npm:^2.1.3" yargs: "npm:^17.7.2" peerDependencies: typescript: ^5 @@ -5469,17 +5486,6 @@ __metadata: languageName: node linkType: hard -"eslint-compat-utils@npm:^0.5.0": - version: 0.5.1 - resolution: "eslint-compat-utils@npm:0.5.1" - dependencies: - semver: "npm:^7.5.4" - peerDependencies: - eslint: ">=6.0.0" - checksum: 10/ac65ac1c6107cf19f63f5fc17cea361c9cb1336be7356f23dbb0fac10979974b4622e13e950be43cbf431801f2c07f7dab448573181ccf6edc0b86d5b5304511 - languageName: node - linkType: hard - "eslint-import-resolver-node@npm:^0.3.9": version: 0.3.9 resolution: "eslint-import-resolver-node@npm:0.3.9" @@ -5588,23 +5594,6 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-jsonc@npm:^2.16.0": - version: 2.16.0 - resolution: "eslint-plugin-jsonc@npm:2.16.0" - dependencies: - "@eslint-community/eslint-utils": "npm:^4.2.0" - eslint-compat-utils: "npm:^0.5.0" - espree: "npm:^9.6.1" - graphemer: "npm:^1.4.0" - jsonc-eslint-parser: "npm:^2.0.4" - natural-compare: "npm:^1.4.0" - synckit: "npm:^0.6.0" - peerDependencies: - eslint: ">=6.0.0" - checksum: 10/bec880a4d6f0cd8ba37ae3a6528477d3161b41ca7b885ed43c34bed95d09b30fd1d277bfa9e487164f5a8aad265f3b075a4b479c20811fe0dd18c25b6835cf56 - languageName: node - linkType: hard - "eslint-plugin-jsx-a11y@npm:^6.10.0": version: 6.10.0 resolution: "eslint-plugin-jsx-a11y@npm:6.10.0" @@ -6152,7 +6141,7 @@ __metadata: languageName: node linkType: hard -"espree@npm:^9.0.0, espree@npm:^9.3.1, espree@npm:^9.6.1": +"espree@npm:^9.0.0, espree@npm:^9.3.1": version: 9.6.1 resolution: "espree@npm:9.6.1" dependencies: @@ -7813,7 +7802,7 @@ __metadata: languageName: node linkType: hard -"jsonc-eslint-parser@npm:^2.0.4, jsonc-eslint-parser@npm:^2.4.0": +"jsonc-eslint-parser@npm:^2.4.0": version: 2.4.0 resolution: "jsonc-eslint-parser@npm:2.4.0" dependencies: @@ -11339,15 +11328,6 @@ __metadata: languageName: node linkType: hard -"synckit@npm:^0.6.0": - version: 0.6.2 - resolution: "synckit@npm:0.6.2" - dependencies: - tslib: "npm:^2.3.1" - checksum: 10/9641f4a4f113b7d6a810c34870947c1f19b7a736b510211c0ea69b05aed530d9aa52cb4942f0988a72514ce9fda61011e913c52fa86c58ebf56901d54c2fe241 - languageName: node - linkType: hard - "table@npm:^5.2.3": version: 5.4.6 resolution: "table@npm:5.4.6" @@ -11676,7 +11656,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.6.3, tslib@npm:^2.7.0": +"tslib@npm:^2.4.0, tslib@npm:^2.6.3, tslib@npm:^2.7.0": version: 2.7.0 resolution: "tslib@npm:2.7.0" checksum: 10/9a5b47ddac65874fa011c20ff76db69f97cf90c78cff5934799ab8894a5342db2d17b4e7613a087046bc1d133d21547ddff87ac558abeec31ffa929c88b7fce6 @@ -12220,9 +12200,9 @@ __metadata: languageName: node linkType: hard -"vite-node@npm:2.1.2": - version: 2.1.2 - resolution: "vite-node@npm:2.1.2" +"vite-node@npm:2.1.3": + version: 2.1.3 + resolution: "vite-node@npm:2.1.3" dependencies: cac: "npm:^6.7.14" debug: "npm:^4.3.6" @@ -12230,7 +12210,7 @@ __metadata: vite: "npm:^5.0.0" bin: vite-node: vite-node.mjs - checksum: 10/582843800ee968e7edf2cf6e6f1573634122cba74e47ef531a373337f6084c4a394c3c1c2abb210c178c8671200530412c09f5cc2f02a4519f0045a03c3eed02 + checksum: 10/8ba6b145cbb02a492c7bb1f0490d02383000462f234ed61d24f650547163825c16f14e6908ee1eb661403bd0a7a3fb3cdbedf116cc015b1e5cdf7bb992872a01 languageName: node linkType: hard @@ -12277,17 +12257,17 @@ __metadata: languageName: node linkType: hard -"vitest@npm:^2.1.2": - version: 2.1.2 - resolution: "vitest@npm:2.1.2" - dependencies: - "@vitest/expect": "npm:2.1.2" - "@vitest/mocker": "npm:2.1.2" - "@vitest/pretty-format": "npm:^2.1.2" - "@vitest/runner": "npm:2.1.2" - "@vitest/snapshot": "npm:2.1.2" - "@vitest/spy": "npm:2.1.2" - "@vitest/utils": "npm:2.1.2" +"vitest@npm:^2.1.3": + version: 2.1.3 + resolution: "vitest@npm:2.1.3" + dependencies: + "@vitest/expect": "npm:2.1.3" + "@vitest/mocker": "npm:2.1.3" + "@vitest/pretty-format": "npm:^2.1.3" + "@vitest/runner": "npm:2.1.3" + "@vitest/snapshot": "npm:2.1.3" + "@vitest/spy": "npm:2.1.3" + "@vitest/utils": "npm:2.1.3" chai: "npm:^5.1.1" debug: "npm:^4.3.6" magic-string: "npm:^0.30.11" @@ -12298,13 +12278,13 @@ __metadata: tinypool: "npm:^1.0.0" tinyrainbow: "npm:^1.2.0" vite: "npm:^5.0.0" - vite-node: "npm:2.1.2" + vite-node: "npm:2.1.3" why-is-node-running: "npm:^2.3.0" peerDependencies: "@edge-runtime/vm": "*" "@types/node": ^18.0.0 || >=20.0.0 - "@vitest/browser": 2.1.2 - "@vitest/ui": 2.1.2 + "@vitest/browser": 2.1.3 + "@vitest/ui": 2.1.3 happy-dom: "*" jsdom: "*" peerDependenciesMeta: @@ -12322,7 +12302,7 @@ __metadata: optional: true bin: vitest: vitest.mjs - checksum: 10/3a331a10499f5ed678530594903869e37a0de548598bcf540db9a6e015bb7a38f36c3585376b3aeeb53fee6b20d75b93081f32b1ea09fd8c2098aa541af28491 + checksum: 10/f6079a88583045b551e6526c08774aeac4a9cf85b132793a03f9470c013326abd7fce3985e3c2217dc0dac2fadeee3506e3dc51e215f10862b2fe9da9289af0f languageName: node linkType: hard