eslint-plugin-yml 0.9.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +25 -1
  2. package/lib/configs/prettier.d.ts +1 -0
  3. package/lib/configs/prettier.js +1 -0
  4. package/lib/index.d.ts +1 -0
  5. package/lib/rules/block-mapping-question-indicator-newline.js +2 -2
  6. package/lib/rules/block-mapping.js +10 -10
  7. package/lib/rules/block-sequence-hyphen-indicator-newline.js +2 -2
  8. package/lib/rules/block-sequence.js +17 -17
  9. package/lib/rules/flow-mapping-curly-newline.js +15 -15
  10. package/lib/rules/flow-mapping-curly-spacing.js +5 -4
  11. package/lib/rules/flow-sequence-bracket-newline.js +14 -14
  12. package/lib/rules/flow-sequence-bracket-spacing.js +5 -4
  13. package/lib/rules/indent.js +21 -5
  14. package/lib/rules/key-name-casing.js +2 -2
  15. package/lib/rules/key-spacing.js +3 -3
  16. package/lib/rules/no-empty-document.js +1 -1
  17. package/lib/rules/no-empty-key.js +1 -1
  18. package/lib/rules/no-empty-mapping-value.js +1 -1
  19. package/lib/rules/no-empty-sequence-entry.js +4 -4
  20. package/lib/rules/no-irregular-whitespace.js +3 -3
  21. package/lib/rules/no-multiple-empty-lines.d.ts +2 -0
  22. package/lib/rules/no-multiple-empty-lines.js +130 -0
  23. package/lib/rules/no-tab-indent.js +1 -1
  24. package/lib/rules/plain-scalar.js +3 -3
  25. package/lib/rules/quotes.js +1 -1
  26. package/lib/rules/require-string-key.js +1 -1
  27. package/lib/rules/sort-keys.js +25 -35
  28. package/lib/rules/spaced-comment.js +1 -1
  29. package/lib/rules/vue-custom-block/no-parsing-error.js +1 -1
  30. package/lib/types.d.ts +2 -0
  31. package/lib/utils/casing.js +1 -1
  32. package/lib/utils/index.js +1 -1
  33. package/lib/utils/rules.js +2 -0
  34. package/lib/utils/yaml.js +2 -2
  35. package/package.json +34 -30
package/README.md CHANGED
@@ -54,7 +54,7 @@ npm install --save-dev eslint eslint-plugin-yml
54
54
  > **Requirements**
55
55
  >
56
56
  > - ESLint v6.0.0 and above
57
- > - Node.js v8.10.0 and above
57
+ > - Node.js v12.22.x, v14.17.x, v16.x and above
58
58
 
59
59
  <!--DOCS_IGNORE_END-->
60
60
 
@@ -92,6 +92,29 @@ This plugin provides configs:
92
92
 
93
93
  See [the rule list](https://ota-meshi.github.io/eslint-plugin-yml/rules/) to get the `rules` that this plugin provides.
94
94
 
95
+ #### Parser Configuration
96
+
97
+ If you have specified a parser, you need to configure a parser for `.yaml`.
98
+
99
+ For example, if you are using the `"@babel/eslint-parser"`, configure it as follows:
100
+
101
+ ```js
102
+ module.exports = {
103
+ // ...
104
+ extends: ["plugin:yml/standard"],
105
+ // ...
106
+ parser: "@babel/eslint-parser",
107
+ // Add an `overrides` section to add a parser configuration for YAML.
108
+ overrides: [
109
+ {
110
+ files: ["*.yaml", "*.yml"],
111
+ parser: "yaml-eslint-parser",
112
+ },
113
+ ],
114
+ // ...
115
+ };
116
+ ```
117
+
95
118
  ### Running ESLint from the command line
96
119
 
97
120
  If you want to run `eslint` from the command line, make sure you include the `.yaml` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern, because ESLint targets only `.js` files by default.
@@ -165,6 +188,7 @@ The rules with the following star :star: are included in the config.
165
188
  | [yml/flow-sequence-bracket-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/flow-sequence-bracket-spacing.html) | enforce consistent spacing inside flow sequence brackets | :wrench: | | :star: |
166
189
  | [yml/key-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-spacing.html) | enforce consistent spacing between keys and values in mapping pairs | :wrench: | | :star: |
167
190
  | [yml/no-irregular-whitespace](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-irregular-whitespace.html) | disallow irregular whitespace | | :star: | :star: |
191
+ | [yml/no-multiple-empty-lines](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-multiple-empty-lines.html) | disallow multiple empty lines | :wrench: | | |
168
192
  | [yml/sort-keys](https://ota-meshi.github.io/eslint-plugin-yml/rules/sort-keys.html) | require mapping keys to be sorted | :wrench: | | |
169
193
  | [yml/spaced-comment](https://ota-meshi.github.io/eslint-plugin-yml/rules/spaced-comment.html) | enforce consistent spacing after the `#` in a comment | :wrench: | | :star: |
170
194
 
@@ -9,6 +9,7 @@ declare const _default: {
9
9
  "yml/flow-sequence-bracket-spacing": string;
10
10
  "yml/indent": string;
11
11
  "yml/key-spacing": string;
12
+ "yml/no-multiple-empty-lines": string;
12
13
  "yml/quotes": string;
13
14
  };
14
15
  };
@@ -16,6 +16,7 @@ module.exports = {
16
16
  "yml/flow-sequence-bracket-spacing": "off",
17
17
  "yml/indent": "off",
18
18
  "yml/key-spacing": "off",
19
+ "yml/no-multiple-empty-lines": "off",
19
20
  "yml/quotes": "off",
20
21
  },
21
22
  };
package/lib/index.d.ts CHANGED
@@ -60,6 +60,7 @@ declare const _default: {
60
60
  "yml/flow-sequence-bracket-spacing": string;
61
61
  "yml/indent": string;
62
62
  "yml/key-spacing": string;
63
+ "yml/no-multiple-empty-lines": string;
63
64
  "yml/quotes": string;
64
65
  };
65
66
  };
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
4
  const ast_utils_1 = require("../utils/ast-utils");
5
- exports.default = utils_1.createRule("block-mapping-question-indicator-newline", {
5
+ exports.default = (0, utils_1.createRule)("block-mapping-question-indicator-newline", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce consistent line breaks after `?` indicator",
@@ -39,7 +39,7 @@ exports.default = utils_1.createRule("block-mapping-question-indicator-newline",
39
39
  continue;
40
40
  }
41
41
  const question = sourceCode.getFirstToken(pair);
42
- if (!question || !ast_utils_1.isQuestion(question)) {
42
+ if (!question || !(0, ast_utils_1.isQuestion)(question)) {
43
43
  continue;
44
44
  }
45
45
  const hasNewline = question.loc.end.line < key.loc.start.line;
@@ -25,7 +25,7 @@ function parseOptions(option) {
25
25
  }
26
26
  return opt;
27
27
  }
28
- exports.default = utils_1.createRule("block-mapping", {
28
+ exports.default = (0, utils_1.createRule)("block-mapping", {
29
29
  meta: {
30
30
  docs: {
31
31
  description: "require or disallow block style mappings.",
@@ -130,11 +130,11 @@ exports.default = utils_1.createRule("block-mapping", {
130
130
  if (optionType === "never") {
131
131
  return;
132
132
  }
133
- if (yaml_1.isKeyNode(node)) {
133
+ if ((0, yaml_1.isKeyNode)(node)) {
134
134
  return;
135
135
  }
136
136
  const canFix = canFixToBlock(mappingInfo, node) &&
137
- !yaml_1.hasTabIndent(context);
137
+ !(0, yaml_1.hasTabIndent)(context);
138
138
  context.report({
139
139
  loc: node.loc,
140
140
  messageId: "required",
@@ -147,7 +147,7 @@ exports.default = utils_1.createRule("block-mapping", {
147
147
  return;
148
148
  }
149
149
  const canFix = canFixToFlow(mappingInfo, node) &&
150
- !yaml_1.hasTabIndent(context);
150
+ !(0, yaml_1.hasTabIndent)(context);
151
151
  context.report({
152
152
  loc: node.loc,
153
153
  messageId: "disallow",
@@ -182,8 +182,8 @@ function canFixToFlow(mappingInfo, node) {
182
182
  return false;
183
183
  }
184
184
  for (const pair of node.pairs) {
185
- const value = yaml_1.unwrapMeta(pair.value);
186
- const key = yaml_1.unwrapMeta(pair.key);
185
+ const value = (0, yaml_1.unwrapMeta)(pair.value);
186
+ const key = (0, yaml_1.unwrapMeta)(pair.key);
187
187
  if (value && value.type === "YAMLScalar" && value.style === "plain") {
188
188
  if (value.loc.start.line < value.loc.end.line) {
189
189
  return false;
@@ -214,7 +214,7 @@ function buildFixFlowToBlock(node, context) {
214
214
  if ((open === null || open === void 0 ? void 0 : open.value) !== "{" || (close === null || close === void 0 ? void 0 : close.value) !== "}") {
215
215
  return;
216
216
  }
217
- const expectIndent = yaml_1.calcExpectIndentForPairs(node, context);
217
+ const expectIndent = (0, yaml_1.calcExpectIndentForPairs)(node, context);
218
218
  if (expectIndent == null) {
219
219
  return;
220
220
  }
@@ -234,7 +234,7 @@ function buildFixFlowToBlock(node, context) {
234
234
  for (const pair of node.pairs) {
235
235
  const prevToken = sourceCode.getTokenBefore(pair, {
236
236
  includeComments: true,
237
- filter: (token) => !ast_utils_1.isComma(token),
237
+ filter: (token) => !(0, ast_utils_1.isComma)(token),
238
238
  });
239
239
  yield* removeComma(prev, prevToken);
240
240
  yield fixer.replaceTextRange([prevToken.range[1], pair.range[0]], `\n${expectIndent}`);
@@ -245,7 +245,7 @@ function buildFixFlowToBlock(node, context) {
245
245
  }).range[0]) {
246
246
  yield fixer.insertTextAfter(colonToken, " ");
247
247
  }
248
- yield* yaml_1.processIndentFix(fixer, expectIndent, pair.value, context);
248
+ yield* (0, yaml_1.processIndentFix)(fixer, expectIndent, pair.value, context);
249
249
  prev = pair;
250
250
  }
251
251
  yield* removeComma(prev, close);
@@ -254,7 +254,7 @@ function buildFixFlowToBlock(node, context) {
254
254
  for (const token of sourceCode.getTokensBetween(a, b, {
255
255
  includeComments: true,
256
256
  })) {
257
- if (ast_utils_1.isComma(token)) {
257
+ if ((0, ast_utils_1.isComma)(token)) {
258
258
  yield fixer.remove(token);
259
259
  }
260
260
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
4
  const ast_utils_1 = require("../utils/ast-utils");
5
- exports.default = utils_1.createRule("block-sequence-hyphen-indicator-newline", {
5
+ exports.default = (0, utils_1.createRule)("block-sequence-hyphen-indicator-newline", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce consistent line breaks after `-` indicator",
@@ -37,7 +37,7 @@ exports.default = utils_1.createRule("block-sequence-hyphen-indicator-newline",
37
37
  const nestedHyphenStyle = ((_a = context.options[1]) === null || _a === void 0 ? void 0 : _a.nestedHyphen) || "always";
38
38
  function getStyleOption(hyphen) {
39
39
  const next = sourceCode.getTokenAfter(hyphen);
40
- if (next && ast_utils_1.isHyphen(next)) {
40
+ if (next && (0, ast_utils_1.isHyphen)(next)) {
41
41
  return nestedHyphenStyle;
42
42
  }
43
43
  return style;
@@ -25,7 +25,7 @@ function parseOptions(option) {
25
25
  }
26
26
  return opt;
27
27
  }
28
- exports.default = utils_1.createRule("block-sequence", {
28
+ exports.default = (0, utils_1.createRule)("block-sequence", {
29
29
  meta: {
30
30
  docs: {
31
31
  description: "require or disallow block style sequences.",
@@ -130,10 +130,10 @@ exports.default = utils_1.createRule("block-sequence", {
130
130
  if (optionType === "never") {
131
131
  return;
132
132
  }
133
- if (yaml_1.isKeyNode(node)) {
133
+ if ((0, yaml_1.isKeyNode)(node)) {
134
134
  return;
135
135
  }
136
- const canFix = canFixToBlock(sequenceInfo, node, context.getSourceCode()) && !yaml_1.hasTabIndent(context);
136
+ const canFix = canFixToBlock(sequenceInfo, node, context.getSourceCode()) && !(0, yaml_1.hasTabIndent)(context);
137
137
  context.report({
138
138
  loc: node.loc,
139
139
  messageId: "required",
@@ -146,7 +146,7 @@ exports.default = utils_1.createRule("block-sequence", {
146
146
  return;
147
147
  }
148
148
  const canFix = canFixToFlow(sequenceInfo, node, context) &&
149
- !yaml_1.hasTabIndent(context);
149
+ !(0, yaml_1.hasTabIndent)(context);
150
150
  context.report({
151
151
  loc: node.loc,
152
152
  messageId: "disallow",
@@ -197,17 +197,17 @@ function canFixToFlow(sequenceInfo, node, context) {
197
197
  return false;
198
198
  }
199
199
  if (node.parent.type === "YAMLWithMeta") {
200
- const metaIndent = yaml_1.getActualIndent(node.parent, context);
200
+ const metaIndent = (0, yaml_1.getActualIndent)(node.parent, context);
201
201
  if (metaIndent != null) {
202
202
  for (let line = node.loc.start.line; line <= node.loc.end.line; line++) {
203
- if (yaml_1.compareIndent(metaIndent, yaml_1.getActualIndentFromLine(line, context)) > 0) {
203
+ if ((0, yaml_1.compareIndent)(metaIndent, (0, yaml_1.getActualIndentFromLine)(line, context)) > 0) {
204
204
  return false;
205
205
  }
206
206
  }
207
207
  }
208
208
  }
209
209
  for (const entry of node.entries) {
210
- const value = yaml_1.unwrapMeta(entry);
210
+ const value = (0, yaml_1.unwrapMeta)(entry);
211
211
  if (value && value.type === "YAMLScalar" && value.style === "plain") {
212
212
  if (value.strValue.includes(",")) {
213
213
  return false;
@@ -224,7 +224,7 @@ function buildFixFlowToBlock(node, context) {
224
224
  if ((open === null || open === void 0 ? void 0 : open.value) !== "[" || (close === null || close === void 0 ? void 0 : close.value) !== "]") {
225
225
  return;
226
226
  }
227
- const expectIndent = yaml_1.calcExpectIndentForEntries(node, context);
227
+ const expectIndent = (0, yaml_1.calcExpectIndentForEntries)(node, context);
228
228
  if (expectIndent == null) {
229
229
  return;
230
230
  }
@@ -244,7 +244,7 @@ function buildFixFlowToBlock(node, context) {
244
244
  for (const entry of node.entries) {
245
245
  const prevToken = sourceCode.getTokenBefore(entry, {
246
246
  includeComments: true,
247
- filter: (token) => !ast_utils_1.isComma(token),
247
+ filter: (token) => !(0, ast_utils_1.isComma)(token),
248
248
  });
249
249
  yield* removeComma(prev, prevToken);
250
250
  yield fixer.replaceTextRange([prevToken.range[1], entry.range[0]], `\n${expectIndent}- `);
@@ -257,33 +257,33 @@ function buildFixFlowToBlock(node, context) {
257
257
  for (const token of sourceCode.getTokensBetween(a, b, {
258
258
  includeComments: true,
259
259
  })) {
260
- if (ast_utils_1.isComma(token)) {
260
+ if ((0, ast_utils_1.isComma)(token)) {
261
261
  yield fixer.remove(token);
262
262
  }
263
263
  }
264
264
  }
265
265
  function* processEntryIndent(baseIndent, entry) {
266
266
  if (entry.type === "YAMLWithMeta" && entry.value) {
267
- yield* yaml_1.processIndentFix(fixer, baseIndent, entry.value, context);
267
+ yield* (0, yaml_1.processIndentFix)(fixer, baseIndent, entry.value, context);
268
268
  }
269
269
  else if (entry.type === "YAMLMapping") {
270
270
  for (const p of entry.pairs) {
271
271
  if (p.range[0] === entry.range[0]) {
272
272
  if (p.value) {
273
- yield* yaml_1.processIndentFix(fixer, baseIndent, p.value, context);
273
+ yield* (0, yaml_1.processIndentFix)(fixer, baseIndent, p.value, context);
274
274
  }
275
275
  }
276
276
  else {
277
- yield* yaml_1.processIndentFix(fixer, baseIndent, p, context);
277
+ yield* (0, yaml_1.processIndentFix)(fixer, baseIndent, p, context);
278
278
  }
279
279
  }
280
280
  if (entry.style === "flow") {
281
281
  const close = sourceCode.getLastToken(entry);
282
282
  if (close.value === "}") {
283
- const actualIndent = yaml_1.getActualIndent(close, context);
283
+ const actualIndent = (0, yaml_1.getActualIndent)(close, context);
284
284
  if (actualIndent != null &&
285
- yaml_1.compareIndent(actualIndent, baseIndent) < 0) {
286
- yield yaml_1.fixIndent(fixer, sourceCode, baseIndent, close);
285
+ (0, yaml_1.compareIndent)(actualIndent, baseIndent) < 0) {
286
+ yield (0, yaml_1.fixIndent)(fixer, sourceCode, baseIndent, close);
287
287
  }
288
288
  }
289
289
  }
@@ -293,7 +293,7 @@ function buildFixFlowToBlock(node, context) {
293
293
  if (!e) {
294
294
  continue;
295
295
  }
296
- yield* yaml_1.processIndentFix(fixer, baseIndent, e, context);
296
+ yield* (0, yaml_1.processIndentFix)(fixer, baseIndent, e, context);
297
297
  }
298
298
  }
299
299
  }
@@ -56,7 +56,7 @@ function areLineBreaksRequired(node, options, first, last) {
56
56
  objectProperties.length > 0 &&
57
57
  first.loc.start.line !== last.loc.end.line));
58
58
  }
59
- exports.default = utils_1.createRule("flow-mapping-curly-newline", {
59
+ exports.default = (0, utils_1.createRule)("flow-mapping-curly-newline", {
60
60
  meta: {
61
61
  docs: {
62
62
  description: "enforce consistent line breaks inside braces",
@@ -81,7 +81,7 @@ exports.default = utils_1.createRule("flow-mapping-curly-newline", {
81
81
  const sourceCode = context.getSourceCode();
82
82
  const options = normalizeOptionValue(context.options[0]);
83
83
  function check(node) {
84
- if (yaml_1.isKeyNode(node)) {
84
+ if ((0, yaml_1.isKeyNode)(node)) {
85
85
  return;
86
86
  }
87
87
  const openBrace = sourceCode.getFirstToken(node, (token) => token.value === "{");
@@ -93,37 +93,37 @@ exports.default = utils_1.createRule("flow-mapping-curly-newline", {
93
93
  includeComments: true,
94
94
  });
95
95
  const needsLineBreaks = areLineBreaksRequired(node, options, first, last);
96
- const hasCommentsFirstToken = ast_utils_1.isCommentToken(first);
97
- const hasCommentsLastToken = ast_utils_1.isCommentToken(last);
98
- const hasQuestionsLastToken = ast_utils_1.isQuestion(last);
96
+ const hasCommentsFirstToken = (0, ast_utils_1.isCommentToken)(first);
97
+ const hasCommentsLastToken = (0, ast_utils_1.isCommentToken)(last);
98
+ const hasQuestionsLastToken = (0, ast_utils_1.isQuestion)(last);
99
99
  first = sourceCode.getTokenAfter(openBrace);
100
100
  last = sourceCode.getTokenBefore(closeBrace);
101
101
  if (needsLineBreaks) {
102
- if (ast_utils_1.isTokenOnSameLine(openBrace, first)) {
102
+ if ((0, ast_utils_1.isTokenOnSameLine)(openBrace, first)) {
103
103
  context.report({
104
104
  messageId: "expectedLinebreakAfterOpeningBrace",
105
105
  node,
106
106
  loc: openBrace.loc,
107
107
  fix(fixer) {
108
108
  if (hasCommentsFirstToken ||
109
- yaml_1.hasTabIndent(context)) {
109
+ (0, yaml_1.hasTabIndent)(context)) {
110
110
  return null;
111
111
  }
112
- const indent = yaml_1.incIndent(yaml_1.getActualIndentFromLine(openBrace.loc.start.line, context), context);
112
+ const indent = (0, yaml_1.incIndent)((0, yaml_1.getActualIndentFromLine)(openBrace.loc.start.line, context), context);
113
113
  return fixer.insertTextAfter(openBrace, `\n${indent}`);
114
114
  },
115
115
  });
116
116
  }
117
- if (ast_utils_1.isTokenOnSameLine(last, closeBrace)) {
117
+ if ((0, ast_utils_1.isTokenOnSameLine)(last, closeBrace)) {
118
118
  context.report({
119
119
  messageId: "expectedLinebreakBeforeClosingBrace",
120
120
  node,
121
121
  loc: closeBrace.loc,
122
122
  fix(fixer) {
123
- if (hasCommentsLastToken || yaml_1.hasTabIndent(context)) {
123
+ if (hasCommentsLastToken || (0, yaml_1.hasTabIndent)(context)) {
124
124
  return null;
125
125
  }
126
- const indent = yaml_1.getActualIndentFromLine(closeBrace.loc.start.line, context);
126
+ const indent = (0, yaml_1.getActualIndentFromLine)(closeBrace.loc.start.line, context);
127
127
  return fixer.insertTextBefore(closeBrace, `\n${indent}`);
128
128
  },
129
129
  });
@@ -131,8 +131,8 @@ exports.default = utils_1.createRule("flow-mapping-curly-newline", {
131
131
  }
132
132
  else {
133
133
  const consistent = options.consistent;
134
- const hasLineBreakBetweenOpenBraceAndFirst = !ast_utils_1.isTokenOnSameLine(openBrace, first);
135
- const hasLineBreakBetweenCloseBraceAndLast = !ast_utils_1.isTokenOnSameLine(last, closeBrace);
134
+ const hasLineBreakBetweenOpenBraceAndFirst = !(0, ast_utils_1.isTokenOnSameLine)(openBrace, first);
135
+ const hasLineBreakBetweenCloseBraceAndLast = !(0, ast_utils_1.isTokenOnSameLine)(last, closeBrace);
136
136
  if ((!consistent && hasLineBreakBetweenOpenBraceAndFirst) ||
137
137
  (consistent &&
138
138
  hasLineBreakBetweenOpenBraceAndFirst &&
@@ -143,7 +143,7 @@ exports.default = utils_1.createRule("flow-mapping-curly-newline", {
143
143
  loc: openBrace.loc,
144
144
  fix(fixer) {
145
145
  if (hasCommentsFirstToken ||
146
- yaml_1.hasTabIndent(context)) {
146
+ (0, yaml_1.hasTabIndent)(context)) {
147
147
  return null;
148
148
  }
149
149
  return fixer.removeRange([
@@ -165,7 +165,7 @@ exports.default = utils_1.createRule("flow-mapping-curly-newline", {
165
165
  node,
166
166
  loc: closeBrace.loc,
167
167
  fix(fixer) {
168
- if (hasCommentsLastToken || yaml_1.hasTabIndent(context)) {
168
+ if (hasCommentsLastToken || (0, yaml_1.hasTabIndent)(context)) {
169
169
  return null;
170
170
  }
171
171
  return fixer.removeRange([
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const coreRule = utils_1.getCoreRule("object-curly-spacing");
5
- exports.default = utils_1.createRule("flow-mapping-curly-spacing", {
4
+ const coreRule = (0, utils_1.getCoreRule)("object-curly-spacing");
5
+ exports.default = (0, utils_1.createRule)("flow-mapping-curly-spacing", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce consistent spacing inside braces",
@@ -11,6 +11,7 @@ exports.default = utils_1.createRule("flow-mapping-curly-spacing", {
11
11
  layout: true,
12
12
  },
13
13
  fixable: coreRule.meta.fixable,
14
+ hasSuggestions: coreRule.meta.hasSuggestions,
14
15
  schema: coreRule.meta.schema,
15
16
  messages: coreRule.meta.messages,
16
17
  type: coreRule.meta.type,
@@ -19,13 +20,13 @@ exports.default = utils_1.createRule("flow-mapping-curly-spacing", {
19
20
  if (!context.parserServices.isYAML) {
20
21
  return {};
21
22
  }
22
- return utils_1.defineWrapperListener(coreRule, context, {
23
+ return (0, utils_1.defineWrapperListener)(coreRule, context, {
23
24
  options: context.options,
24
25
  createListenerProxy(listener) {
25
26
  return {
26
27
  YAMLMapping(node) {
27
28
  if (node.style === "flow") {
28
- listener.ObjectExpression(utils_1.getProxyNode(node, {
29
+ listener.ObjectExpression((0, utils_1.getProxyNode)(node, {
29
30
  type: "ObjectExpression",
30
31
  get properties() {
31
32
  return node.pairs;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
4
  const yaml_1 = require("../utils/yaml");
5
5
  const ast_utils_1 = require("../utils/ast-utils");
6
- exports.default = utils_1.createRule("flow-sequence-bracket-newline", {
6
+ exports.default = (0, utils_1.createRule)("flow-sequence-bracket-newline", {
7
7
  meta: {
8
8
  docs: {
9
9
  description: "enforce linebreaks after opening and before closing flow sequence brackets",
@@ -81,13 +81,13 @@ exports.default = utils_1.createRule("flow-sequence-bracket-newline", {
81
81
  loc: token.loc,
82
82
  messageId: "unexpectedOpeningLinebreak",
83
83
  fix(fixer) {
84
- if (yaml_1.hasTabIndent(context)) {
84
+ if ((0, yaml_1.hasTabIndent)(context)) {
85
85
  return null;
86
86
  }
87
87
  const nextToken = sourceCode.getTokenAfter(token, {
88
88
  includeComments: true,
89
89
  });
90
- if (ast_utils_1.isCommentToken(nextToken)) {
90
+ if ((0, ast_utils_1.isCommentToken)(nextToken)) {
91
91
  return null;
92
92
  }
93
93
  return fixer.removeRange([
@@ -103,13 +103,13 @@ exports.default = utils_1.createRule("flow-sequence-bracket-newline", {
103
103
  loc: token.loc,
104
104
  messageId: "unexpectedClosingLinebreak",
105
105
  fix(fixer) {
106
- if (yaml_1.hasTabIndent(context)) {
106
+ if ((0, yaml_1.hasTabIndent)(context)) {
107
107
  return null;
108
108
  }
109
109
  const previousToken = sourceCode.getTokenBefore(token, {
110
110
  includeComments: true,
111
111
  });
112
- if (ast_utils_1.isCommentToken(previousToken)) {
112
+ if ((0, ast_utils_1.isCommentToken)(previousToken)) {
113
113
  return null;
114
114
  }
115
115
  return fixer.removeRange([
@@ -125,10 +125,10 @@ exports.default = utils_1.createRule("flow-sequence-bracket-newline", {
125
125
  loc: token.loc,
126
126
  messageId: "missingOpeningLinebreak",
127
127
  fix(fixer) {
128
- if (yaml_1.hasTabIndent(context)) {
128
+ if ((0, yaml_1.hasTabIndent)(context)) {
129
129
  return null;
130
130
  }
131
- const indent = yaml_1.incIndent(yaml_1.getActualIndentFromLine(token.loc.start.line, context), context);
131
+ const indent = (0, yaml_1.incIndent)((0, yaml_1.getActualIndentFromLine)(token.loc.start.line, context), context);
132
132
  return fixer.insertTextAfter(token, `\n${indent}`);
133
133
  },
134
134
  });
@@ -139,16 +139,16 @@ exports.default = utils_1.createRule("flow-sequence-bracket-newline", {
139
139
  loc: token.loc,
140
140
  messageId: "missingClosingLinebreak",
141
141
  fix(fixer) {
142
- if (yaml_1.hasTabIndent(context)) {
142
+ if ((0, yaml_1.hasTabIndent)(context)) {
143
143
  return null;
144
144
  }
145
- const indent = yaml_1.getActualIndentFromLine(token.loc.start.line, context);
145
+ const indent = (0, yaml_1.getActualIndentFromLine)(token.loc.start.line, context);
146
146
  return fixer.insertTextBefore(token, `\n${indent}`);
147
147
  },
148
148
  });
149
149
  }
150
150
  function check(node) {
151
- if (yaml_1.isKeyNode(node)) {
151
+ if ((0, yaml_1.isKeyNode)(node)) {
152
152
  return;
153
153
  }
154
154
  const elements = node.entries;
@@ -176,18 +176,18 @@ exports.default = utils_1.createRule("flow-sequence-bracket-newline", {
176
176
  (options.consistent &&
177
177
  openBracket.loc.end.line !== first.loc.start.line);
178
178
  if (needsLinebreaks) {
179
- if (ast_utils_1.isTokenOnSameLine(openBracket, first)) {
179
+ if ((0, ast_utils_1.isTokenOnSameLine)(openBracket, first)) {
180
180
  reportRequiredBeginningLinebreak(node, openBracket);
181
181
  }
182
- if (ast_utils_1.isTokenOnSameLine(last, closeBracket)) {
182
+ if ((0, ast_utils_1.isTokenOnSameLine)(last, closeBracket)) {
183
183
  reportRequiredEndingLinebreak(node, closeBracket);
184
184
  }
185
185
  }
186
186
  else {
187
- if (!ast_utils_1.isTokenOnSameLine(openBracket, first)) {
187
+ if (!(0, ast_utils_1.isTokenOnSameLine)(openBracket, first)) {
188
188
  reportNoBeginningLinebreak(node, openBracket);
189
189
  }
190
- if (!ast_utils_1.isTokenOnSameLine(last, closeBracket)) {
190
+ if (!(0, ast_utils_1.isTokenOnSameLine)(last, closeBracket)) {
191
191
  reportNoEndingLinebreak(node, closeBracket);
192
192
  }
193
193
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("../utils");
4
- const coreRule = utils_1.getCoreRule("array-bracket-spacing");
5
- exports.default = utils_1.createRule("flow-sequence-bracket-spacing", {
4
+ const coreRule = (0, utils_1.getCoreRule)("array-bracket-spacing");
5
+ exports.default = (0, utils_1.createRule)("flow-sequence-bracket-spacing", {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "enforce consistent spacing inside flow sequence brackets",
@@ -11,6 +11,7 @@ exports.default = utils_1.createRule("flow-sequence-bracket-spacing", {
11
11
  layout: true,
12
12
  },
13
13
  fixable: coreRule.meta.fixable,
14
+ hasSuggestions: coreRule.meta.hasSuggestions,
14
15
  schema: coreRule.meta.schema,
15
16
  messages: coreRule.meta.messages,
16
17
  type: coreRule.meta.type,
@@ -19,13 +20,13 @@ exports.default = utils_1.createRule("flow-sequence-bracket-spacing", {
19
20
  if (!context.parserServices.isYAML) {
20
21
  return {};
21
22
  }
22
- return utils_1.defineWrapperListener(coreRule, context, {
23
+ return (0, utils_1.defineWrapperListener)(coreRule, context, {
23
24
  options: context.options,
24
25
  createListenerProxy(listener) {
25
26
  return {
26
27
  YAMLSequence(node) {
27
28
  if (node.style === "flow") {
28
- listener.ArrayExpression(utils_1.getProxyNode(node, {
29
+ listener.ArrayExpression((0, utils_1.getProxyNode)(node, {
29
30
  type: "ArrayExpression",
30
31
  get elements() {
31
32
  return node.entries;
@@ -6,7 +6,7 @@ const ast_utils_1 = require("../utils/ast-utils");
6
6
  const ITERATION_OPTS = Object.freeze({
7
7
  includeComments: true,
8
8
  });
9
- exports.default = utils_1.createRule("indent", {
9
+ exports.default = (0, utils_1.createRule)("indent", {
10
10
  meta: {
11
11
  docs: {
12
12
  description: "enforce consistent indentation",
@@ -30,10 +30,10 @@ exports.default = utils_1.createRule("indent", {
30
30
  if (!context.parserServices.isYAML) {
31
31
  return {};
32
32
  }
33
- if (yaml_1.hasTabIndent(context)) {
33
+ if ((0, yaml_1.hasTabIndent)(context)) {
34
34
  return {};
35
35
  }
36
- const numOfIndent = yaml_1.getNumOfIndent(context, context.options[0]);
36
+ const numOfIndent = (0, yaml_1.getNumOfIndent)(context, context.options[0]);
37
37
  const sourceCode = context.getSourceCode();
38
38
  const offsets = new Map();
39
39
  const marks = new Set();
@@ -141,7 +141,7 @@ exports.default = utils_1.createRule("indent", {
141
141
  let keyToken = null;
142
142
  let colonToken = null;
143
143
  let valueToken = null;
144
- if (ast_utils_1.isQuestion(pairFirst)) {
144
+ if ((0, ast_utils_1.isQuestion)(pairFirst)) {
145
145
  questionToken = pairFirst;
146
146
  marks.add(questionToken);
147
147
  }
@@ -502,7 +502,7 @@ exports.default = utils_1.createRule("indent", {
502
502
  };
503
503
  }
504
504
  const firstLineActualIndent = lineIndent.actualIndent;
505
- for (let scalarLine = lineIndent.line + 1; scalarLine < scalarNode.loc.end.line; scalarLine++) {
505
+ for (let scalarLine = lineIndent.line + 1; scalarLine <= scalarNode.loc.end.line; scalarLine++) {
506
506
  const actualLineIndent = getActualLineIndent(scalarLine);
507
507
  if (actualLineIndent == null) {
508
508
  continue;
@@ -579,6 +579,7 @@ exports.default = utils_1.createRule("indent", {
579
579
  }
580
580
  }
581
581
  function buildFix(lineIndent, lineIndents) {
582
+ var _a;
582
583
  const { line, expectedIndent } = lineIndent;
583
584
  const document = documents.find((doc) => doc.loc.start.line <= line && line <= doc.loc.end.line) || sourceCode.ast;
584
585
  let startLine = document.loc.start.line;
@@ -614,6 +615,21 @@ exports.default = utils_1.createRule("indent", {
614
615
  break;
615
616
  }
616
617
  }
618
+ for (let lineIndex = startLine; lineIndex <= endLine; lineIndex++) {
619
+ const li = lineIndents[lineIndex];
620
+ if (li === null || li === void 0 ? void 0 : li.indentBlockScalar) {
621
+ const blockLiteral = li.indentBlockScalar.node;
622
+ const diff = li.expectedIndent - li.actualIndent;
623
+ const mark = sourceCode.getFirstToken(blockLiteral);
624
+ const num = (_a = /\d+/u.exec(mark.value)) === null || _a === void 0 ? void 0 : _a[0];
625
+ if (num != null) {
626
+ const newIndent = Number(num) + diff;
627
+ if (newIndent >= 10) {
628
+ return null;
629
+ }
630
+ }
631
+ }
632
+ }
617
633
  return function* (fixer) {
618
634
  let stacks = null;
619
635
  for (let lineIndex = startLine; lineIndex <= endLine; lineIndex++) {