feat: lint add yaml config
This commit is contained in:
@@ -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:"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ export async function ignores(): Promise<Linter.Config[]> {
|
||||
'**/*.sh',
|
||||
'**/*.ttf',
|
||||
'**/*.woff',
|
||||
'**/.github',
|
||||
'**/lefthook.yml',
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -15,3 +15,4 @@ export * from './turbo';
|
||||
export * from './typescript';
|
||||
export * from './unicorn';
|
||||
export * from './vue';
|
||||
export * from './yaml';
|
||||
|
||||
87
internal/lint-configs/eslint-config/src/configs/yaml.ts
Normal file
87
internal/lint-configs/eslint-config/src/configs/yaml.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function yaml(): Promise<Linter.Config[]> {
|
||||
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: '.*',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -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,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user