diff --git a/package.json b/package.json index 466ecfba..69df5951 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "eslint-plugin-vitest": "~0.2.6", "eslint-plugin-vue": "~9.15.1", "eslint-plugin-vue-pug": "~0.6.0", + "eslint-plugin-yml": "~1.8.0", "expect-type": "~0.16.0", "graphql": "~16.7.1", "json-schema": "~0.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 80db5b9e..4afc8168 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,6 +104,9 @@ devDependencies: eslint-plugin-vue-pug: specifier: ~0.6.0 version: 0.6.0(eslint-plugin-vue@9.15.1)(vue-eslint-parser@9.3.1) + eslint-plugin-yml: + specifier: ~1.8.0 + version: 1.8.0(eslint@8.45.0) expect-type: specifier: ~0.16.0 version: 0.16.0 @@ -3096,6 +3099,21 @@ packages: - supports-color dev: true + /eslint-plugin-yml@1.8.0(eslint@8.45.0): + resolution: {integrity: sha512-fgBiJvXD0P2IN7SARDJ2J7mx8t0bLdG6Zcig4ufOqW5hOvSiFxeUyc2g5I1uIm8AExbo26NNYCcTGZT0MXTsyg==} + engines: {node: ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: '>=6.0.0' + dependencies: + debug: 4.3.4 + eslint: 8.45.0 + lodash: 4.17.21 + natural-compare: 1.4.0 + yaml-eslint-parser: 1.2.2 + transitivePeerDependencies: + - supports-color + dev: true + /eslint-scope@5.1.1: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} engines: {node: '>=8.0.0'} diff --git a/scripts/generate-rule-files/src/plugins-map.ts b/scripts/generate-rule-files/src/plugins-map.ts index 4b9b84c0..ccbe6f9d 100644 --- a/scripts/generate-rule-files/src/plugins-map.ts +++ b/scripts/generate-rule-files/src/plugins-map.ts @@ -101,6 +101,10 @@ export const PLUGIN_REGISTRY: Readonly> = { name: 'VuePug', module: 'eslint-plugin-vue-pug', }, + yml: { + name: 'Yml', + module: 'eslint-plugin-yml', + }, } as const; export async function loadPlugin(plugin: Plugin): Promise { diff --git a/src/rules/index.d.ts b/src/rules/index.d.ts index 70323bac..d1e8e3fc 100644 --- a/src/rules/index.d.ts +++ b/src/rules/index.d.ts @@ -21,6 +21,7 @@ import type { VitestRules } from './vitest'; import type { VueRules } from './vue'; import type { VueI18nRules } from './vue-i18n'; import type { VuePugRules } from './vue-pug'; +import type { YmlRules } from './yml'; /** * Rules. @@ -50,5 +51,6 @@ export type Rules = Partial< VueRules & VueI18nRules & VuePugRules & + YmlRules & Record >; diff --git a/src/rules/yml/block-mapping-colon-indicator-newline.d.ts b/src/rules/yml/block-mapping-colon-indicator-newline.d.ts new file mode 100644 index 00000000..10dce809 --- /dev/null +++ b/src/rules/yml/block-mapping-colon-indicator-newline.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type BlockMappingColonIndicatorNewlineOption = 'always' | 'never'; + +/** + * Options. + */ +export type BlockMappingColonIndicatorNewlineOptions = [ + BlockMappingColonIndicatorNewlineOption?, +]; + +/** + * Enforce consistent line breaks after `:` indicator. + * + * @see [block-mapping-colon-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-colon-indicator-newline.html) + */ +export type BlockMappingColonIndicatorNewlineRuleConfig = + RuleConfig; + +/** + * Enforce consistent line breaks after `:` indicator. + * + * @see [block-mapping-colon-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-colon-indicator-newline.html) + */ +export interface BlockMappingColonIndicatorNewlineRule { + /** + * Enforce consistent line breaks after `:` indicator. + * + * @see [block-mapping-colon-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-colon-indicator-newline.html) + */ + 'yml/block-mapping-colon-indicator-newline': BlockMappingColonIndicatorNewlineRuleConfig; +} diff --git a/src/rules/yml/block-mapping-question-indicator-newline.d.ts b/src/rules/yml/block-mapping-question-indicator-newline.d.ts new file mode 100644 index 00000000..791a2d1b --- /dev/null +++ b/src/rules/yml/block-mapping-question-indicator-newline.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type BlockMappingQuestionIndicatorNewlineOption = 'always' | 'never'; + +/** + * Options. + */ +export type BlockMappingQuestionIndicatorNewlineOptions = [ + BlockMappingQuestionIndicatorNewlineOption?, +]; + +/** + * Enforce consistent line breaks after `?` indicator. + * + * @see [block-mapping-question-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-question-indicator-newline.html) + */ +export type BlockMappingQuestionIndicatorNewlineRuleConfig = + RuleConfig; + +/** + * Enforce consistent line breaks after `?` indicator. + * + * @see [block-mapping-question-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-question-indicator-newline.html) + */ +export interface BlockMappingQuestionIndicatorNewlineRule { + /** + * Enforce consistent line breaks after `?` indicator. + * + * @see [block-mapping-question-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-question-indicator-newline.html) + */ + 'yml/block-mapping-question-indicator-newline': BlockMappingQuestionIndicatorNewlineRuleConfig; +} diff --git a/src/rules/yml/block-mapping.d.ts b/src/rules/yml/block-mapping.d.ts new file mode 100644 index 00000000..f6779c5e --- /dev/null +++ b/src/rules/yml/block-mapping.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type BlockMappingOption = + | ('always' | 'never') + | { + singleline?: 'always' | 'never' | 'ignore'; + multiline?: 'always' | 'never' | 'ignore'; + }; + +/** + * Options. + */ +export type BlockMappingOptions = [BlockMappingOption?]; + +/** + * Require or disallow block style mappings. + * + * @see [block-mapping](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping.html) + */ +export type BlockMappingRuleConfig = RuleConfig; + +/** + * Require or disallow block style mappings. + * + * @see [block-mapping](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping.html) + */ +export interface BlockMappingRule { + /** + * Require or disallow block style mappings. + * + * @see [block-mapping](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping.html) + */ + 'yml/block-mapping': BlockMappingRuleConfig; +} diff --git a/src/rules/yml/block-sequence-hyphen-indicator-newline.d.ts b/src/rules/yml/block-sequence-hyphen-indicator-newline.d.ts new file mode 100644 index 00000000..54982f50 --- /dev/null +++ b/src/rules/yml/block-sequence-hyphen-indicator-newline.d.ts @@ -0,0 +1,43 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface BlockSequenceHyphenIndicatorNewlineConfig { + nestedHyphen?: 'always' | 'never'; +} + +/** + * Option. + */ +export type BlockSequenceHyphenIndicatorNewlineOption = 'always' | 'never'; + +/** + * Options. + */ +export type BlockSequenceHyphenIndicatorNewlineOptions = [ + BlockSequenceHyphenIndicatorNewlineOption?, + BlockSequenceHyphenIndicatorNewlineConfig?, +]; + +/** + * Enforce consistent line breaks after `-` indicator. + * + * @see [block-sequence-hyphen-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence-hyphen-indicator-newline.html) + */ +export type BlockSequenceHyphenIndicatorNewlineRuleConfig = + RuleConfig; + +/** + * Enforce consistent line breaks after `-` indicator. + * + * @see [block-sequence-hyphen-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence-hyphen-indicator-newline.html) + */ +export interface BlockSequenceHyphenIndicatorNewlineRule { + /** + * Enforce consistent line breaks after `-` indicator. + * + * @see [block-sequence-hyphen-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence-hyphen-indicator-newline.html) + */ + 'yml/block-sequence-hyphen-indicator-newline': BlockSequenceHyphenIndicatorNewlineRuleConfig; +} diff --git a/src/rules/yml/block-sequence.d.ts b/src/rules/yml/block-sequence.d.ts new file mode 100644 index 00000000..94f09a84 --- /dev/null +++ b/src/rules/yml/block-sequence.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type BlockSequenceOption = + | ('always' | 'never') + | { + singleline?: 'always' | 'never' | 'ignore'; + multiline?: 'always' | 'never' | 'ignore'; + }; + +/** + * Options. + */ +export type BlockSequenceOptions = [BlockSequenceOption?]; + +/** + * Require or disallow block style sequences. + * + * @see [block-sequence](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence.html) + */ +export type BlockSequenceRuleConfig = RuleConfig; + +/** + * Require or disallow block style sequences. + * + * @see [block-sequence](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence.html) + */ +export interface BlockSequenceRule { + /** + * Require or disallow block style sequences. + * + * @see [block-sequence](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence.html) + */ + 'yml/block-sequence': BlockSequenceRuleConfig; +} diff --git a/src/rules/yml/file-extension.d.ts b/src/rules/yml/file-extension.d.ts new file mode 100644 index 00000000..56a937af --- /dev/null +++ b/src/rules/yml/file-extension.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface FileExtensionOption { + extension?: 'yaml' | 'yml'; + caseSensitive?: boolean; +} + +/** + * Options. + */ +export type FileExtensionOptions = [FileExtensionOption?]; + +/** + * Enforce YAML file extension. + * + * @see [file-extension](https://ota-meshi.github.io/eslint-plugin-yml/rules/file-extension.html) + */ +export type FileExtensionRuleConfig = RuleConfig; + +/** + * Enforce YAML file extension. + * + * @see [file-extension](https://ota-meshi.github.io/eslint-plugin-yml/rules/file-extension.html) + */ +export interface FileExtensionRule { + /** + * Enforce YAML file extension. + * + * @see [file-extension](https://ota-meshi.github.io/eslint-plugin-yml/rules/file-extension.html) + */ + 'yml/file-extension': FileExtensionRuleConfig; +} diff --git a/src/rules/yml/flow-mapping-curly-newline.d.ts b/src/rules/yml/flow-mapping-curly-newline.d.ts new file mode 100644 index 00000000..92b43e00 --- /dev/null +++ b/src/rules/yml/flow-mapping-curly-newline.d.ts @@ -0,0 +1,39 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type FlowMappingCurlyNewlineOption = + | ('always' | 'never') + | { + multiline?: boolean; + minProperties?: number; + consistent?: boolean; + }; + +/** + * Options. + */ +export type FlowMappingCurlyNewlineOptions = [FlowMappingCurlyNewlineOption?]; + +/** + * Enforce consistent line breaks inside braces. + * + * @see [flow-mapping-curly-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-mapping-curly-newline.html) + */ +export type FlowMappingCurlyNewlineRuleConfig = + RuleConfig; + +/** + * Enforce consistent line breaks inside braces. + * + * @see [flow-mapping-curly-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-mapping-curly-newline.html) + */ +export interface FlowMappingCurlyNewlineRule { + /** + * Enforce consistent line breaks inside braces. + * + * @see [flow-mapping-curly-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-mapping-curly-newline.html) + */ + 'yml/flow-mapping-curly-newline': FlowMappingCurlyNewlineRuleConfig; +} diff --git a/src/rules/yml/flow-mapping-curly-spacing.d.ts b/src/rules/yml/flow-mapping-curly-spacing.d.ts new file mode 100644 index 00000000..9c7021af --- /dev/null +++ b/src/rules/yml/flow-mapping-curly-spacing.d.ts @@ -0,0 +1,44 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface FlowMappingCurlySpacingConfig { + arraysInObjects?: boolean; + objectsInObjects?: boolean; +} + +/** + * Option. + */ +export type FlowMappingCurlySpacingOption = 'always' | 'never'; + +/** + * Options. + */ +export type FlowMappingCurlySpacingOptions = [ + FlowMappingCurlySpacingOption?, + FlowMappingCurlySpacingConfig?, +]; + +/** + * Enforce consistent spacing inside braces. + * + * @see [flow-mapping-curly-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-mapping-curly-spacing.html) + */ +export type FlowMappingCurlySpacingRuleConfig = + RuleConfig; + +/** + * Enforce consistent spacing inside braces. + * + * @see [flow-mapping-curly-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-mapping-curly-spacing.html) + */ +export interface FlowMappingCurlySpacingRule { + /** + * Enforce consistent spacing inside braces. + * + * @see [flow-mapping-curly-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-mapping-curly-spacing.html) + */ + 'yml/flow-mapping-curly-spacing': FlowMappingCurlySpacingRuleConfig; +} diff --git a/src/rules/yml/flow-sequence-bracket-newline.d.ts b/src/rules/yml/flow-sequence-bracket-newline.d.ts new file mode 100644 index 00000000..8c16f2d1 --- /dev/null +++ b/src/rules/yml/flow-sequence-bracket-newline.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type FlowSequenceBracketNewlineOption = + | ('always' | 'never' | 'consistent') + | { + multiline?: boolean; + minItems?: number | null; + }; + +/** + * Options. + */ +export type FlowSequenceBracketNewlineOptions = [ + FlowSequenceBracketNewlineOption?, +]; + +/** + * Enforce linebreaks after opening and before closing flow sequence brackets. + * + * @see [flow-sequence-bracket-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-sequence-bracket-newline.html) + */ +export type FlowSequenceBracketNewlineRuleConfig = + RuleConfig; + +/** + * Enforce linebreaks after opening and before closing flow sequence brackets. + * + * @see [flow-sequence-bracket-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-sequence-bracket-newline.html) + */ +export interface FlowSequenceBracketNewlineRule { + /** + * Enforce linebreaks after opening and before closing flow sequence brackets. + * + * @see [flow-sequence-bracket-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-sequence-bracket-newline.html) + */ + 'yml/flow-sequence-bracket-newline': FlowSequenceBracketNewlineRuleConfig; +} diff --git a/src/rules/yml/flow-sequence-bracket-spacing.d.ts b/src/rules/yml/flow-sequence-bracket-spacing.d.ts new file mode 100644 index 00000000..668b16de --- /dev/null +++ b/src/rules/yml/flow-sequence-bracket-spacing.d.ts @@ -0,0 +1,45 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface FlowSequenceBracketSpacingConfig { + singleValue?: boolean; + objectsInArrays?: boolean; + arraysInArrays?: boolean; +} + +/** + * Option. + */ +export type FlowSequenceBracketSpacingOption = 'always' | 'never'; + +/** + * Options. + */ +export type FlowSequenceBracketSpacingOptions = [ + FlowSequenceBracketSpacingOption?, + FlowSequenceBracketSpacingConfig?, +]; + +/** + * Enforce consistent spacing inside flow sequence brackets. + * + * @see [flow-sequence-bracket-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-sequence-bracket-spacing.html) + */ +export type FlowSequenceBracketSpacingRuleConfig = + RuleConfig; + +/** + * Enforce consistent spacing inside flow sequence brackets. + * + * @see [flow-sequence-bracket-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-sequence-bracket-spacing.html) + */ +export interface FlowSequenceBracketSpacingRule { + /** + * Enforce consistent spacing inside flow sequence brackets. + * + * @see [flow-sequence-bracket-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-sequence-bracket-spacing.html) + */ + 'yml/flow-sequence-bracket-spacing': FlowSequenceBracketSpacingRuleConfig; +} diff --git a/src/rules/yml/indent.d.ts b/src/rules/yml/indent.d.ts new file mode 100644 index 00000000..b473f198 --- /dev/null +++ b/src/rules/yml/indent.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface IndentConfig { + indentBlockSequences?: boolean; + indicatorValueIndent?: number; +} + +/** + * Option. + */ +export type IndentOption = number; + +/** + * Options. + */ +export type IndentOptions = [IndentOption?, IndentConfig?]; + +/** + * Enforce consistent indentation. + * + * @see [indent](https://ota-meshi.github.io/eslint-plugin-yml/rules/indent.html) + */ +export type IndentRuleConfig = RuleConfig; + +/** + * Enforce consistent indentation. + * + * @see [indent](https://ota-meshi.github.io/eslint-plugin-yml/rules/indent.html) + */ +export interface IndentRule { + /** + * Enforce consistent indentation. + * + * @see [indent](https://ota-meshi.github.io/eslint-plugin-yml/rules/indent.html) + */ + 'yml/indent': IndentRuleConfig; +} diff --git a/src/rules/yml/index.d.ts b/src/rules/yml/index.d.ts new file mode 100644 index 00000000..8bf13c91 --- /dev/null +++ b/src/rules/yml/index.d.ts @@ -0,0 +1,60 @@ +import type { BlockMappingRule } from './block-mapping'; +import type { BlockMappingColonIndicatorNewlineRule } from './block-mapping-colon-indicator-newline'; +import type { BlockMappingQuestionIndicatorNewlineRule } from './block-mapping-question-indicator-newline'; +import type { BlockSequenceRule } from './block-sequence'; +import type { BlockSequenceHyphenIndicatorNewlineRule } from './block-sequence-hyphen-indicator-newline'; +import type { FileExtensionRule } from './file-extension'; +import type { FlowMappingCurlyNewlineRule } from './flow-mapping-curly-newline'; +import type { FlowMappingCurlySpacingRule } from './flow-mapping-curly-spacing'; +import type { FlowSequenceBracketNewlineRule } from './flow-sequence-bracket-newline'; +import type { FlowSequenceBracketSpacingRule } from './flow-sequence-bracket-spacing'; +import type { IndentRule } from './indent'; +import type { KeyNameCasingRule } from './key-name-casing'; +import type { KeySpacingRule } from './key-spacing'; +import type { NoEmptyDocumentRule } from './no-empty-document'; +import type { NoEmptyKeyRule } from './no-empty-key'; +import type { NoEmptyMappingValueRule } from './no-empty-mapping-value'; +import type { NoEmptySequenceEntryRule } from './no-empty-sequence-entry'; +import type { NoIrregularWhitespaceRule } from './no-irregular-whitespace'; +import type { NoMultipleEmptyLinesRule } from './no-multiple-empty-lines'; +import type { NoTabIndentRule } from './no-tab-indent'; +import type { NoTrailingZerosRule } from './no-trailing-zeros'; +import type { PlainScalarRule } from './plain-scalar'; +import type { QuotesRule } from './quotes'; +import type { RequireStringKeyRule } from './require-string-key'; +import type { SortKeysRule } from './sort-keys'; +import type { SortSequenceValuesRule } from './sort-sequence-values'; +import type { SpacedCommentRule } from './spaced-comment'; +import type { VueCustomBlockNoParsingErrorRule } from './vue-custom-block/no-parsing-error'; + +/** + * All Yml rules. + */ +export type YmlRules = BlockMappingColonIndicatorNewlineRule & + BlockMappingQuestionIndicatorNewlineRule & + BlockMappingRule & + BlockSequenceHyphenIndicatorNewlineRule & + BlockSequenceRule & + FileExtensionRule & + FlowMappingCurlyNewlineRule & + FlowMappingCurlySpacingRule & + FlowSequenceBracketNewlineRule & + FlowSequenceBracketSpacingRule & + IndentRule & + KeyNameCasingRule & + KeySpacingRule & + NoEmptyDocumentRule & + NoEmptyKeyRule & + NoEmptyMappingValueRule & + NoEmptySequenceEntryRule & + NoIrregularWhitespaceRule & + NoMultipleEmptyLinesRule & + NoTabIndentRule & + NoTrailingZerosRule & + PlainScalarRule & + QuotesRule & + RequireStringKeyRule & + SortKeysRule & + SortSequenceValuesRule & + SpacedCommentRule & + VueCustomBlockNoParsingErrorRule; diff --git a/src/rules/yml/key-name-casing.d.ts b/src/rules/yml/key-name-casing.d.ts new file mode 100644 index 00000000..b9e15b30 --- /dev/null +++ b/src/rules/yml/key-name-casing.d.ts @@ -0,0 +1,39 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface KeyNameCasingOption { + camelCase?: boolean; + PascalCase?: boolean; + SCREAMING_SNAKE_CASE?: boolean; + 'kebab-case'?: boolean; + snake_case?: boolean; + ignores?: string[]; +} + +/** + * Options. + */ +export type KeyNameCasingOptions = [KeyNameCasingOption?]; + +/** + * Enforce naming convention to key names. + * + * @see [key-name-casing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-name-casing.html) + */ +export type KeyNameCasingRuleConfig = RuleConfig; + +/** + * Enforce naming convention to key names. + * + * @see [key-name-casing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-name-casing.html) + */ +export interface KeyNameCasingRule { + /** + * Enforce naming convention to key names. + * + * @see [key-name-casing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-name-casing.html) + */ + 'yml/key-name-casing': KeyNameCasingRuleConfig; +} diff --git a/src/rules/yml/key-spacing.d.ts b/src/rules/yml/key-spacing.d.ts new file mode 100644 index 00000000..8eb04182 --- /dev/null +++ b/src/rules/yml/key-spacing.d.ts @@ -0,0 +1,83 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type KeySpacingOption = + | { + align?: + | ('colon' | 'value') + | { + on?: 'colon' | 'value'; + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + }; + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + } + | { + singleLine?: { + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + }; + multiLine?: { + align?: + | ('colon' | 'value') + | { + on?: 'colon' | 'value'; + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + }; + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + }; + } + | { + singleLine?: { + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + }; + multiLine?: { + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + }; + align?: { + on?: 'colon' | 'value'; + mode?: 'strict' | 'minimum'; + beforeColon?: boolean; + afterColon?: boolean; + }; + }; + +/** + * Options. + */ +export type KeySpacingOptions = [KeySpacingOption?]; + +/** + * Enforce consistent spacing between keys and values in mapping pairs. + * + * @see [key-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-spacing.html) + */ +export type KeySpacingRuleConfig = RuleConfig; + +/** + * Enforce consistent spacing between keys and values in mapping pairs. + * + * @see [key-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-spacing.html) + */ +export interface KeySpacingRule { + /** + * Enforce consistent spacing between keys and values in mapping pairs. + * + * @see [key-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-spacing.html) + */ + 'yml/key-spacing': KeySpacingRuleConfig; +} diff --git a/src/rules/yml/no-empty-document.d.ts b/src/rules/yml/no-empty-document.d.ts new file mode 100644 index 00000000..bfb8bf8b --- /dev/null +++ b/src/rules/yml/no-empty-document.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow empty document. + * + * @see [no-empty-document](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-document.html) + */ +export type NoEmptyDocumentRuleConfig = RuleConfig<[]>; + +/** + * Disallow empty document. + * + * @see [no-empty-document](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-document.html) + */ +export interface NoEmptyDocumentRule { + /** + * Disallow empty document. + * + * @see [no-empty-document](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-document.html) + */ + 'yml/no-empty-document': NoEmptyDocumentRuleConfig; +} diff --git a/src/rules/yml/no-empty-key.d.ts b/src/rules/yml/no-empty-key.d.ts new file mode 100644 index 00000000..ea5c7ea9 --- /dev/null +++ b/src/rules/yml/no-empty-key.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow empty mapping keys. + * + * @see [no-empty-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-key.html) + */ +export type NoEmptyKeyRuleConfig = RuleConfig<[]>; + +/** + * Disallow empty mapping keys. + * + * @see [no-empty-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-key.html) + */ +export interface NoEmptyKeyRule { + /** + * Disallow empty mapping keys. + * + * @see [no-empty-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-key.html) + */ + 'yml/no-empty-key': NoEmptyKeyRuleConfig; +} diff --git a/src/rules/yml/no-empty-mapping-value.d.ts b/src/rules/yml/no-empty-mapping-value.d.ts new file mode 100644 index 00000000..4241860f --- /dev/null +++ b/src/rules/yml/no-empty-mapping-value.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow empty mapping values. + * + * @see [no-empty-mapping-value](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-mapping-value.html) + */ +export type NoEmptyMappingValueRuleConfig = RuleConfig<[]>; + +/** + * Disallow empty mapping values. + * + * @see [no-empty-mapping-value](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-mapping-value.html) + */ +export interface NoEmptyMappingValueRule { + /** + * Disallow empty mapping values. + * + * @see [no-empty-mapping-value](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-mapping-value.html) + */ + 'yml/no-empty-mapping-value': NoEmptyMappingValueRuleConfig; +} diff --git a/src/rules/yml/no-empty-sequence-entry.d.ts b/src/rules/yml/no-empty-sequence-entry.d.ts new file mode 100644 index 00000000..35e38c8f --- /dev/null +++ b/src/rules/yml/no-empty-sequence-entry.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow empty sequence entries. + * + * @see [no-empty-sequence-entry](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-sequence-entry.html) + */ +export type NoEmptySequenceEntryRuleConfig = RuleConfig<[]>; + +/** + * Disallow empty sequence entries. + * + * @see [no-empty-sequence-entry](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-sequence-entry.html) + */ +export interface NoEmptySequenceEntryRule { + /** + * Disallow empty sequence entries. + * + * @see [no-empty-sequence-entry](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-sequence-entry.html) + */ + 'yml/no-empty-sequence-entry': NoEmptySequenceEntryRuleConfig; +} diff --git a/src/rules/yml/no-irregular-whitespace.d.ts b/src/rules/yml/no-irregular-whitespace.d.ts new file mode 100644 index 00000000..1cdd0339 --- /dev/null +++ b/src/rules/yml/no-irregular-whitespace.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoIrregularWhitespaceOption { + skipComments?: boolean; + skipQuotedScalars?: boolean; +} + +/** + * Options. + */ +export type NoIrregularWhitespaceOptions = [NoIrregularWhitespaceOption?]; + +/** + * Disallow irregular whitespace. + * + * @see [no-irregular-whitespace](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-irregular-whitespace.html) + */ +export type NoIrregularWhitespaceRuleConfig = + RuleConfig; + +/** + * Disallow irregular whitespace. + * + * @see [no-irregular-whitespace](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-irregular-whitespace.html) + */ +export interface NoIrregularWhitespaceRule { + /** + * Disallow irregular whitespace. + * + * @see [no-irregular-whitespace](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-irregular-whitespace.html) + */ + 'yml/no-irregular-whitespace': NoIrregularWhitespaceRuleConfig; +} diff --git a/src/rules/yml/no-multiple-empty-lines.d.ts b/src/rules/yml/no-multiple-empty-lines.d.ts new file mode 100644 index 00000000..b54b0320 --- /dev/null +++ b/src/rules/yml/no-multiple-empty-lines.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoMultipleEmptyLinesOption { + max: number; + maxEOF?: number; + maxBOF?: number; +} + +/** + * Options. + */ +export type NoMultipleEmptyLinesOptions = [NoMultipleEmptyLinesOption?]; + +/** + * Disallow multiple empty lines. + * + * @see [no-multiple-empty-lines](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-multiple-empty-lines.html) + */ +export type NoMultipleEmptyLinesRuleConfig = + RuleConfig; + +/** + * Disallow multiple empty lines. + * + * @see [no-multiple-empty-lines](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-multiple-empty-lines.html) + */ +export interface NoMultipleEmptyLinesRule { + /** + * Disallow multiple empty lines. + * + * @see [no-multiple-empty-lines](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-multiple-empty-lines.html) + */ + 'yml/no-multiple-empty-lines': NoMultipleEmptyLinesRuleConfig; +} diff --git a/src/rules/yml/no-tab-indent.d.ts b/src/rules/yml/no-tab-indent.d.ts new file mode 100644 index 00000000..f2dc3da5 --- /dev/null +++ b/src/rules/yml/no-tab-indent.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow tabs for indentation. + * + * @see [no-tab-indent](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-tab-indent.html) + */ +export type NoTabIndentRuleConfig = RuleConfig<[]>; + +/** + * Disallow tabs for indentation. + * + * @see [no-tab-indent](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-tab-indent.html) + */ +export interface NoTabIndentRule { + /** + * Disallow tabs for indentation. + * + * @see [no-tab-indent](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-tab-indent.html) + */ + 'yml/no-tab-indent': NoTabIndentRuleConfig; +} diff --git a/src/rules/yml/no-trailing-zeros.d.ts b/src/rules/yml/no-trailing-zeros.d.ts new file mode 100644 index 00000000..ee99c3a7 --- /dev/null +++ b/src/rules/yml/no-trailing-zeros.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow trailing zeros for floats. + * + * @see [no-trailing-zeros](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-trailing-zeros.html) + */ +export type NoTrailingZerosRuleConfig = RuleConfig<[]>; + +/** + * Disallow trailing zeros for floats. + * + * @see [no-trailing-zeros](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-trailing-zeros.html) + */ +export interface NoTrailingZerosRule { + /** + * Disallow trailing zeros for floats. + * + * @see [no-trailing-zeros](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-trailing-zeros.html) + */ + 'yml/no-trailing-zeros': NoTrailingZerosRuleConfig; +} diff --git a/src/rules/yml/plain-scalar.d.ts b/src/rules/yml/plain-scalar.d.ts new file mode 100644 index 00000000..c215dc8b --- /dev/null +++ b/src/rules/yml/plain-scalar.d.ts @@ -0,0 +1,39 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface PlainScalarConfig { + ignorePatterns?: string[]; +} + +/** + * Option. + */ +export type PlainScalarOption = 'always' | 'never'; + +/** + * Options. + */ +export type PlainScalarOptions = [PlainScalarOption?, PlainScalarConfig?]; + +/** + * Require or disallow plain style scalar. + * + * @see [plain-scalar](https://ota-meshi.github.io/eslint-plugin-yml/rules/plain-scalar.html) + */ +export type PlainScalarRuleConfig = RuleConfig; + +/** + * Require or disallow plain style scalar. + * + * @see [plain-scalar](https://ota-meshi.github.io/eslint-plugin-yml/rules/plain-scalar.html) + */ +export interface PlainScalarRule { + /** + * Require or disallow plain style scalar. + * + * @see [plain-scalar](https://ota-meshi.github.io/eslint-plugin-yml/rules/plain-scalar.html) + */ + 'yml/plain-scalar': PlainScalarRuleConfig; +} diff --git a/src/rules/yml/quotes.d.ts b/src/rules/yml/quotes.d.ts new file mode 100644 index 00000000..f504f841 --- /dev/null +++ b/src/rules/yml/quotes.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface QuotesOption { + prefer?: 'double' | 'single'; + avoidEscape?: boolean; +} + +/** + * Options. + */ +export type QuotesOptions = [QuotesOption?]; + +/** + * Enforce the consistent use of either double, or single quotes. + * + * @see [quotes](https://ota-meshi.github.io/eslint-plugin-yml/rules/quotes.html) + */ +export type QuotesRuleConfig = RuleConfig; + +/** + * Enforce the consistent use of either double, or single quotes. + * + * @see [quotes](https://ota-meshi.github.io/eslint-plugin-yml/rules/quotes.html) + */ +export interface QuotesRule { + /** + * Enforce the consistent use of either double, or single quotes. + * + * @see [quotes](https://ota-meshi.github.io/eslint-plugin-yml/rules/quotes.html) + */ + 'yml/quotes': QuotesRuleConfig; +} diff --git a/src/rules/yml/require-string-key.d.ts b/src/rules/yml/require-string-key.d.ts new file mode 100644 index 00000000..93ca184a --- /dev/null +++ b/src/rules/yml/require-string-key.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow mapping keys other than strings. + * + * @see [require-string-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/require-string-key.html) + */ +export type RequireStringKeyRuleConfig = RuleConfig<[]>; + +/** + * Disallow mapping keys other than strings. + * + * @see [require-string-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/require-string-key.html) + */ +export interface RequireStringKeyRule { + /** + * Disallow mapping keys other than strings. + * + * @see [require-string-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/require-string-key.html) + */ + 'yml/require-string-key': RequireStringKeyRuleConfig; +} diff --git a/src/rules/yml/sort-keys.d.ts b/src/rules/yml/sort-keys.d.ts new file mode 100644 index 00000000..ed812cd0 --- /dev/null +++ b/src/rules/yml/sort-keys.d.ts @@ -0,0 +1,91 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type SortKeysOption = + | [ + { + pathPattern: string; + hasProperties?: string[]; + order: + | ( + | string + | { + keyPattern?: string; + order?: { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + } + )[] + | { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + minKeys?: number; + allowLineSeparatedGroups?: boolean; + }, + ...{ + pathPattern: string; + hasProperties?: string[]; + order: + | ( + | string + | { + keyPattern?: string; + order?: { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + } + )[] + | { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + minKeys?: number; + allowLineSeparatedGroups?: boolean; + }[], + ] + | [] + | ['asc' | 'desc'] + | [ + 'asc' | 'desc', + { + caseSensitive?: boolean; + natural?: boolean; + minKeys?: number; + allowLineSeparatedGroups?: boolean; + }, + ]; + +/** + * Options. + */ +export type SortKeysOptions = SortKeysOption; + +/** + * Require mapping keys to be sorted. + * + * @see [sort-keys](https://ota-meshi.github.io/eslint-plugin-yml/rules/sort-keys.html) + */ +export type SortKeysRuleConfig = RuleConfig; + +/** + * Require mapping keys to be sorted. + * + * @see [sort-keys](https://ota-meshi.github.io/eslint-plugin-yml/rules/sort-keys.html) + */ +export interface SortKeysRule { + /** + * Require mapping keys to be sorted. + * + * @see [sort-keys](https://ota-meshi.github.io/eslint-plugin-yml/rules/sort-keys.html) + */ + 'yml/sort-keys': SortKeysRuleConfig; +} diff --git a/src/rules/yml/sort-sequence-values.d.ts b/src/rules/yml/sort-sequence-values.d.ts new file mode 100644 index 00000000..5b815794 --- /dev/null +++ b/src/rules/yml/sort-sequence-values.d.ts @@ -0,0 +1,79 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +/** + * @minItems 1 + */ +export type SortSequenceValuesOption = [ + { + pathPattern: string; + order: + | ( + | string + | { + valuePattern?: string; + order?: { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + } + )[] + | { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + minValues?: number; + }, + ...{ + pathPattern: string; + order: + | ( + | string + | { + valuePattern?: string; + order?: { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + } + )[] + | { + type?: 'asc' | 'desc'; + caseSensitive?: boolean; + natural?: boolean; + }; + minValues?: number; + }[], +]; + +/** + * Options. + */ +export type SortSequenceValuesOptions = SortSequenceValuesOption; + +/** + * Require sequence values to be sorted. + * + * @see [sort-sequence-values](https://ota-meshi.github.io/eslint-plugin-yml/rules/sort-sequence-values.html) + */ +export type SortSequenceValuesRuleConfig = + RuleConfig; + +/** + * Require sequence values to be sorted. + * + * @see [sort-sequence-values](https://ota-meshi.github.io/eslint-plugin-yml/rules/sort-sequence-values.html) + */ +export interface SortSequenceValuesRule { + /** + * Require sequence values to be sorted. + * + * @see [sort-sequence-values](https://ota-meshi.github.io/eslint-plugin-yml/rules/sort-sequence-values.html) + */ + 'yml/sort-sequence-values': SortSequenceValuesRuleConfig; +} diff --git a/src/rules/yml/spaced-comment.d.ts b/src/rules/yml/spaced-comment.d.ts new file mode 100644 index 00000000..6b76bd4e --- /dev/null +++ b/src/rules/yml/spaced-comment.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export interface SpacedCommentConfig { + exceptions?: string[]; + markers?: string[]; +} + +/** + * Option. + */ +export type SpacedCommentOption = 'always' | 'never'; + +/** + * Options. + */ +export type SpacedCommentOptions = [SpacedCommentOption?, SpacedCommentConfig?]; + +/** + * Enforce consistent spacing after the `#` in a comment. + * + * @see [spaced-comment](https://ota-meshi.github.io/eslint-plugin-yml/rules/spaced-comment.html) + */ +export type SpacedCommentRuleConfig = RuleConfig; + +/** + * Enforce consistent spacing after the `#` in a comment. + * + * @see [spaced-comment](https://ota-meshi.github.io/eslint-plugin-yml/rules/spaced-comment.html) + */ +export interface SpacedCommentRule { + /** + * Enforce consistent spacing after the `#` in a comment. + * + * @see [spaced-comment](https://ota-meshi.github.io/eslint-plugin-yml/rules/spaced-comment.html) + */ + 'yml/spaced-comment': SpacedCommentRuleConfig; +} diff --git a/src/rules/yml/vue-custom-block/no-parsing-error.d.ts b/src/rules/yml/vue-custom-block/no-parsing-error.d.ts new file mode 100644 index 00000000..6a640b64 --- /dev/null +++ b/src/rules/yml/vue-custom-block/no-parsing-error.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../../rule-config'; + +/** + * Disallow parsing errors in Vue custom blocks. + * + * @see [vue-custom-block/no-parsing-error](https://ota-meshi.github.io/eslint-plugin-yml/rules/vue-custom-block/no-parsing-error.html) + */ +export type VueCustomBlockNoParsingErrorRuleConfig = RuleConfig<[]>; + +/** + * Disallow parsing errors in Vue custom blocks. + * + * @see [vue-custom-block/no-parsing-error](https://ota-meshi.github.io/eslint-plugin-yml/rules/vue-custom-block/no-parsing-error.html) + */ +export interface VueCustomBlockNoParsingErrorRule { + /** + * Disallow parsing errors in Vue custom blocks. + * + * @see [vue-custom-block/no-parsing-error](https://ota-meshi.github.io/eslint-plugin-yml/rules/vue-custom-block/no-parsing-error.html) + */ + 'yml/vue-custom-block/no-parsing-error': VueCustomBlockNoParsingErrorRuleConfig; +}