diff --git a/internal/lint-configs/eslint-config/package.json b/internal/lint-configs/eslint-config/package.json index 12556ec5c..82206c55d 100644 --- a/internal/lint-configs/eslint-config/package.json +++ b/internal/lint-configs/eslint-config/package.json @@ -49,8 +49,10 @@ "eslint-plugin-unused-imports": "catalog:", "eslint-plugin-vitest": "catalog:", "eslint-plugin-vue": "catalog:", + "eslint-plugin-yml": "catalog:", "globals": "catalog:", "jsonc-eslint-parser": "catalog:", - "vue-eslint-parser": "catalog:" + "vue-eslint-parser": "catalog:", + "yaml-eslint-parser": "catalog:" } } diff --git a/internal/lint-configs/eslint-config/src/configs/ignores.ts b/internal/lint-configs/eslint-config/src/configs/ignores.ts index 136c956de..0a05e9e9e 100644 --- a/internal/lint-configs/eslint-config/src/configs/ignores.ts +++ b/internal/lint-configs/eslint-config/src/configs/ignores.ts @@ -46,6 +46,8 @@ export async function ignores(): Promise { '**/*.sh', '**/*.ttf', '**/*.woff', + '**/.github', + '**/lefthook.yml', ], }, ]; diff --git a/internal/lint-configs/eslint-config/src/configs/index.ts b/internal/lint-configs/eslint-config/src/configs/index.ts index c0284efb2..3e08921f7 100644 --- a/internal/lint-configs/eslint-config/src/configs/index.ts +++ b/internal/lint-configs/eslint-config/src/configs/index.ts @@ -15,3 +15,4 @@ export * from './turbo'; export * from './typescript'; export * from './unicorn'; export * from './vue'; +export * from './yaml'; diff --git a/internal/lint-configs/eslint-config/src/configs/yaml.ts b/internal/lint-configs/eslint-config/src/configs/yaml.ts new file mode 100644 index 000000000..55aa94d53 --- /dev/null +++ b/internal/lint-configs/eslint-config/src/configs/yaml.ts @@ -0,0 +1,87 @@ +import type { Linter } from 'eslint'; + +import { interopDefault } from '../util'; + +export async function yaml(): Promise { + const [pluginYaml, parserYaml] = await Promise.all([ + interopDefault(import('eslint-plugin-yml')), + interopDefault(import('yaml-eslint-parser')), + ] as const); + + return [ + { + files: ['**/*.y?(a)ml'], + plugins: { + yaml: pluginYaml as any, + }, + languageOptions: { + parser: parserYaml, + }, + rules: { + 'style/spaced-comment': 'off', + + 'yaml/block-mapping': 'error', + 'yaml/block-sequence': 'error', + 'yaml/no-empty-key': 'error', + 'yaml/no-empty-sequence-entry': 'error', + 'yaml/no-irregular-whitespace': 'error', + 'yaml/plain-scalar': 'error', + + 'yaml/vue-custom-block/no-parsing-error': 'error', + + 'yaml/block-mapping-question-indicator-newline': 'error', + 'yaml/block-sequence-hyphen-indicator-newline': 'error', + 'yaml/flow-mapping-curly-newline': 'error', + 'yaml/flow-mapping-curly-spacing': 'error', + 'yaml/flow-sequence-bracket-newline': 'error', + 'yaml/flow-sequence-bracket-spacing': 'error', + 'yaml/indent': ['error', 2], + 'yaml/key-spacing': 'error', + 'yaml/no-tab-indent': 'error', + 'yaml/quotes': [ + 'error', + { + avoidEscape: true, + prefer: 'single', + }, + ], + 'yaml/spaced-comment': 'error', + }, + }, + { + files: ['pnpm-workspace.yaml'], + rules: { + 'yaml/sort-keys': [ + 'error', + { + order: [ + 'packages', + 'overrides', + 'patchedDependencies', + 'hoistPattern', + 'catalog', + 'catalogs', + + 'allowedDeprecatedVersions', + 'allowNonAppliedPatches', + 'configDependencies', + 'ignoredBuiltDependencies', + 'ignoredOptionalDependencies', + 'neverBuiltDependencies', + 'onlyBuiltDependencies', + 'onlyBuiltDependenciesFile', + 'packageExtensions', + 'peerDependencyRules', + 'supportedArchitectures', + ], + pathPattern: '^$', + }, + { + order: { type: 'asc' }, + pathPattern: '.*', + }, + ], + }, + }, + ]; +} diff --git a/internal/lint-configs/eslint-config/src/index.ts b/internal/lint-configs/eslint-config/src/index.ts index c9f08bd54..ae710544b 100644 --- a/internal/lint-configs/eslint-config/src/index.ts +++ b/internal/lint-configs/eslint-config/src/index.ts @@ -18,6 +18,7 @@ import { typescript, unicorn, vue, + yaml, } from './configs'; import { customConfig } from './custom-config'; @@ -48,6 +49,7 @@ async function defineConfig(config: FlatConfig[] = []) { regexp(), command(), turbo(), + yaml(), ...customConfig, ...config, ]; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5fb9005c4..f99739f92 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -273,6 +273,9 @@ catalogs: eslint-plugin-vue: specifier: ^10.6.2 version: 10.6.2 + eslint-plugin-yml: + specifier: ^1.19.0 + version: 1.19.0 execa: specifier: ^9.6.0 version: 9.6.1 @@ -513,6 +516,9 @@ catalogs: watermark-js-plus: specifier: ^1.6.2 version: 1.6.3 + yaml-eslint-parser: + specifier: ^1.3.1 + version: 1.3.1 zod: specifier: ^3.25.67 version: 3.25.76 @@ -1038,6 +1044,9 @@ importers: eslint-plugin-vue: specifier: 'catalog:' version: 10.6.2(@typescript-eslint/parser@8.48.1(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@2.6.1))) + eslint-plugin-yml: + specifier: 'catalog:' + version: 1.19.0(eslint@9.39.1(jiti@2.6.1)) globals: specifier: 'catalog:' version: 16.5.0 @@ -1047,6 +1056,9 @@ importers: vue-eslint-parser: specifier: 'catalog:' version: 10.2.0(eslint@9.39.1(jiti@2.6.1)) + yaml-eslint-parser: + specifier: 'catalog:' + version: 1.3.1 internal/lint-configs/prettier-config: dependencies: @@ -6479,6 +6491,12 @@ packages: '@typescript-eslint/parser': optional: true + eslint-plugin-yml@1.19.0: + resolution: {integrity: sha512-S+4GbcCWksFKAvFJtf0vpdiCkZZvDJCV4Zsi9ahmYkYOYcf+LRqqzvzkb/ST7vTYV6sFwXOvawzYyL/jFT2nQA==} + engines: {node: ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: '>=6.0.0' + eslint-scope@8.4.0: resolution: {integrity: sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -15879,6 +15897,18 @@ snapshots: optionalDependencies: '@typescript-eslint/parser': 8.48.1(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + eslint-plugin-yml@1.19.0(eslint@9.39.1(jiti@2.6.1)): + dependencies: + debug: 4.4.3 + diff-sequences: 27.5.1 + escape-string-regexp: 4.0.0 + eslint: 9.39.1(jiti@2.6.1) + eslint-compat-utils: 0.6.5(eslint@9.39.1(jiti@2.6.1)) + natural-compare: 1.4.0 + yaml-eslint-parser: 1.3.1 + transitivePeerDependencies: + - supports-color + eslint-scope@8.4.0: dependencies: esrecurse: 4.3.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 5fcc051f6..b01e1f7b1 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -90,6 +90,7 @@ catalog: dotenv: ^16.6.1 echarts: ^6.0.0 element-plus: ^2.10.2 + es-toolkit: ^1.41.0 eslint: ^9.39.1 eslint-config-turbo: ^2.6.1 eslint-plugin-command: ^3.3.1 @@ -106,6 +107,7 @@ catalog: eslint-plugin-unused-imports: ^4.3.0 eslint-plugin-vitest: ^0.5.4 eslint-plugin-vue: ^10.6.2 + eslint-plugin-yml: ^1.19.0 execa: ^9.6.0 find-up: ^7.0.0 get-port: ^7.1.0 @@ -192,6 +194,6 @@ catalog: vxe-pc-ui: ^4.10.22 vxe-table: ^4.17.14 watermark-js-plus: ^1.6.2 + yaml-eslint-parser: ^1.3.1 zod: ^3.25.67 zod-defaults: 0.1.3 - es-toolkit: ^1.41.0