Skip to content

Commit

Permalink
Add yml rules (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwerg committed Jul 30, 2023
1 parent b3a7874 commit 3b2f8d6
Show file tree
Hide file tree
Showing 33 changed files with 1,170 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions scripts/generate-rule-files/src/plugins-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
name: 'VuePug',
module: 'eslint-plugin-vue-pug',
},
yml: {
name: 'Yml',
module: 'eslint-plugin-yml',
},
} as const;

export async function loadPlugin(plugin: Plugin): Promise<Plugin> {
Expand Down
2 changes: 2 additions & 0 deletions src/rules/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -50,5 +51,6 @@ export type Rules = Partial<
VueRules &
VueI18nRules &
VuePugRules &
YmlRules &
Record<string, RuleConfig>
>;
35 changes: 35 additions & 0 deletions src/rules/yml/block-mapping-colon-indicator-newline.d.ts
Original file line number Diff line number Diff line change
@@ -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<BlockMappingColonIndicatorNewlineOptions>;

/**
* 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;
}
35 changes: 35 additions & 0 deletions src/rules/yml/block-mapping-question-indicator-newline.d.ts
Original file line number Diff line number Diff line change
@@ -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<BlockMappingQuestionIndicatorNewlineOptions>;

/**
* 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;
}
37 changes: 37 additions & 0 deletions src/rules/yml/block-mapping.d.ts
Original file line number Diff line number Diff line change
@@ -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<BlockMappingOptions>;

/**
* 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;
}
43 changes: 43 additions & 0 deletions src/rules/yml/block-sequence-hyphen-indicator-newline.d.ts
Original file line number Diff line number Diff line change
@@ -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<BlockSequenceHyphenIndicatorNewlineOptions>;

/**
* 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;
}
37 changes: 37 additions & 0 deletions src/rules/yml/block-sequence.d.ts
Original file line number Diff line number Diff line change
@@ -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<BlockSequenceOptions>;

/**
* 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;
}
35 changes: 35 additions & 0 deletions src/rules/yml/file-extension.d.ts
Original file line number Diff line number Diff line change
@@ -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<FileExtensionOptions>;

/**
* 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;
}
39 changes: 39 additions & 0 deletions src/rules/yml/flow-mapping-curly-newline.d.ts
Original file line number Diff line number Diff line change
@@ -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<FlowMappingCurlyNewlineOptions>;

/**
* 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;
}
44 changes: 44 additions & 0 deletions src/rules/yml/flow-mapping-curly-spacing.d.ts
Original file line number Diff line number Diff line change
@@ -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<FlowMappingCurlySpacingOptions>;

/**
* 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;
}
Loading

0 comments on commit 3b2f8d6

Please sign in to comment.