Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 3b2f8d6

Browse files
authored
Add yml rules (#218)
1 parent b3a7874 commit 3b2f8d6

33 files changed

+1170
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"eslint-plugin-vitest": "~0.2.6",
9696
"eslint-plugin-vue": "~9.15.1",
9797
"eslint-plugin-vue-pug": "~0.6.0",
98+
"eslint-plugin-yml": "~1.8.0",
9899
"expect-type": "~0.16.0",
99100
"graphql": "~16.7.1",
100101
"json-schema": "~0.4.0",

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate-rule-files/src/plugins-map.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
101101
name: 'VuePug',
102102
module: 'eslint-plugin-vue-pug',
103103
},
104+
yml: {
105+
name: 'Yml',
106+
module: 'eslint-plugin-yml',
107+
},
104108
} as const;
105109

106110
export async function loadPlugin(plugin: Plugin): Promise<Plugin> {

src/rules/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type { VitestRules } from './vitest';
2121
import type { VueRules } from './vue';
2222
import type { VueI18nRules } from './vue-i18n';
2323
import type { VuePugRules } from './vue-pug';
24+
import type { YmlRules } from './yml';
2425

2526
/**
2627
* Rules.
@@ -50,5 +51,6 @@ export type Rules = Partial<
5051
VueRules &
5152
VueI18nRules &
5253
VuePugRules &
54+
YmlRules &
5355
Record<string, RuleConfig>
5456
>;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type BlockMappingColonIndicatorNewlineOption = 'always' | 'never';
7+
8+
/**
9+
* Options.
10+
*/
11+
export type BlockMappingColonIndicatorNewlineOptions = [
12+
BlockMappingColonIndicatorNewlineOption?,
13+
];
14+
15+
/**
16+
* Enforce consistent line breaks after `:` indicator.
17+
*
18+
* @see [block-mapping-colon-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-colon-indicator-newline.html)
19+
*/
20+
export type BlockMappingColonIndicatorNewlineRuleConfig =
21+
RuleConfig<BlockMappingColonIndicatorNewlineOptions>;
22+
23+
/**
24+
* Enforce consistent line breaks after `:` indicator.
25+
*
26+
* @see [block-mapping-colon-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-colon-indicator-newline.html)
27+
*/
28+
export interface BlockMappingColonIndicatorNewlineRule {
29+
/**
30+
* Enforce consistent line breaks after `:` indicator.
31+
*
32+
* @see [block-mapping-colon-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-colon-indicator-newline.html)
33+
*/
34+
'yml/block-mapping-colon-indicator-newline': BlockMappingColonIndicatorNewlineRuleConfig;
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type BlockMappingQuestionIndicatorNewlineOption = 'always' | 'never';
7+
8+
/**
9+
* Options.
10+
*/
11+
export type BlockMappingQuestionIndicatorNewlineOptions = [
12+
BlockMappingQuestionIndicatorNewlineOption?,
13+
];
14+
15+
/**
16+
* Enforce consistent line breaks after `?` indicator.
17+
*
18+
* @see [block-mapping-question-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-question-indicator-newline.html)
19+
*/
20+
export type BlockMappingQuestionIndicatorNewlineRuleConfig =
21+
RuleConfig<BlockMappingQuestionIndicatorNewlineOptions>;
22+
23+
/**
24+
* Enforce consistent line breaks after `?` indicator.
25+
*
26+
* @see [block-mapping-question-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-question-indicator-newline.html)
27+
*/
28+
export interface BlockMappingQuestionIndicatorNewlineRule {
29+
/**
30+
* Enforce consistent line breaks after `?` indicator.
31+
*
32+
* @see [block-mapping-question-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping-question-indicator-newline.html)
33+
*/
34+
'yml/block-mapping-question-indicator-newline': BlockMappingQuestionIndicatorNewlineRuleConfig;
35+
}

src/rules/yml/block-mapping.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type BlockMappingOption =
7+
| ('always' | 'never')
8+
| {
9+
singleline?: 'always' | 'never' | 'ignore';
10+
multiline?: 'always' | 'never' | 'ignore';
11+
};
12+
13+
/**
14+
* Options.
15+
*/
16+
export type BlockMappingOptions = [BlockMappingOption?];
17+
18+
/**
19+
* Require or disallow block style mappings.
20+
*
21+
* @see [block-mapping](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping.html)
22+
*/
23+
export type BlockMappingRuleConfig = RuleConfig<BlockMappingOptions>;
24+
25+
/**
26+
* Require or disallow block style mappings.
27+
*
28+
* @see [block-mapping](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping.html)
29+
*/
30+
export interface BlockMappingRule {
31+
/**
32+
* Require or disallow block style mappings.
33+
*
34+
* @see [block-mapping](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-mapping.html)
35+
*/
36+
'yml/block-mapping': BlockMappingRuleConfig;
37+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Config.
5+
*/
6+
export interface BlockSequenceHyphenIndicatorNewlineConfig {
7+
nestedHyphen?: 'always' | 'never';
8+
}
9+
10+
/**
11+
* Option.
12+
*/
13+
export type BlockSequenceHyphenIndicatorNewlineOption = 'always' | 'never';
14+
15+
/**
16+
* Options.
17+
*/
18+
export type BlockSequenceHyphenIndicatorNewlineOptions = [
19+
BlockSequenceHyphenIndicatorNewlineOption?,
20+
BlockSequenceHyphenIndicatorNewlineConfig?,
21+
];
22+
23+
/**
24+
* Enforce consistent line breaks after `-` indicator.
25+
*
26+
* @see [block-sequence-hyphen-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence-hyphen-indicator-newline.html)
27+
*/
28+
export type BlockSequenceHyphenIndicatorNewlineRuleConfig =
29+
RuleConfig<BlockSequenceHyphenIndicatorNewlineOptions>;
30+
31+
/**
32+
* Enforce consistent line breaks after `-` indicator.
33+
*
34+
* @see [block-sequence-hyphen-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence-hyphen-indicator-newline.html)
35+
*/
36+
export interface BlockSequenceHyphenIndicatorNewlineRule {
37+
/**
38+
* Enforce consistent line breaks after `-` indicator.
39+
*
40+
* @see [block-sequence-hyphen-indicator-newline](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence-hyphen-indicator-newline.html)
41+
*/
42+
'yml/block-sequence-hyphen-indicator-newline': BlockSequenceHyphenIndicatorNewlineRuleConfig;
43+
}

src/rules/yml/block-sequence.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type BlockSequenceOption =
7+
| ('always' | 'never')
8+
| {
9+
singleline?: 'always' | 'never' | 'ignore';
10+
multiline?: 'always' | 'never' | 'ignore';
11+
};
12+
13+
/**
14+
* Options.
15+
*/
16+
export type BlockSequenceOptions = [BlockSequenceOption?];
17+
18+
/**
19+
* Require or disallow block style sequences.
20+
*
21+
* @see [block-sequence](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence.html)
22+
*/
23+
export type BlockSequenceRuleConfig = RuleConfig<BlockSequenceOptions>;
24+
25+
/**
26+
* Require or disallow block style sequences.
27+
*
28+
* @see [block-sequence](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence.html)
29+
*/
30+
export interface BlockSequenceRule {
31+
/**
32+
* Require or disallow block style sequences.
33+
*
34+
* @see [block-sequence](https://ota-meshi.github.io/eslint-plugin-yml/rules/block-sequence.html)
35+
*/
36+
'yml/block-sequence': BlockSequenceRuleConfig;
37+
}

src/rules/yml/file-extension.d.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export interface FileExtensionOption {
7+
extension?: 'yaml' | 'yml';
8+
caseSensitive?: boolean;
9+
}
10+
11+
/**
12+
* Options.
13+
*/
14+
export type FileExtensionOptions = [FileExtensionOption?];
15+
16+
/**
17+
* Enforce YAML file extension.
18+
*
19+
* @see [file-extension](https://ota-meshi.github.io/eslint-plugin-yml/rules/file-extension.html)
20+
*/
21+
export type FileExtensionRuleConfig = RuleConfig<FileExtensionOptions>;
22+
23+
/**
24+
* Enforce YAML file extension.
25+
*
26+
* @see [file-extension](https://ota-meshi.github.io/eslint-plugin-yml/rules/file-extension.html)
27+
*/
28+
export interface FileExtensionRule {
29+
/**
30+
* Enforce YAML file extension.
31+
*
32+
* @see [file-extension](https://ota-meshi.github.io/eslint-plugin-yml/rules/file-extension.html)
33+
*/
34+
'yml/file-extension': FileExtensionRuleConfig;
35+
}

0 commit comments

Comments
 (0)