eslint-plugin-yml 3.0.0 → 3.1.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.
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-yml.svg)](http://www.npmtrends.com/eslint-plugin-yml)
10
10
  [![NPM downloads](https://img.shields.io/npm/dy/eslint-plugin-yml.svg)](http://www.npmtrends.com/eslint-plugin-yml)
11
11
  [![NPM downloads](https://img.shields.io/npm/dt/eslint-plugin-yml.svg)](http://www.npmtrends.com/eslint-plugin-yml)
12
- [![Build Status](https://github.com/ota-meshi/eslint-plugin-yml/workflows/CI/badge.svg?branch=master)](https://github.com/ota-meshi/eslint-plugin-yml/actions?query=workflow%3ACI)
12
+ [![Build Status](https://github.com/ota-meshi/eslint-plugin-yml/actions/workflows/NodeCI.yml/badge.svg)](https://github.com/ota-meshi/eslint-plugin-yml/actions/workflows/NodeCI.yml)
13
13
  [![Coverage Status](https://coveralls.io/repos/github/ota-meshi/eslint-plugin-yml/badge.svg?branch=master)](https://coveralls.io/github/ota-meshi/eslint-plugin-yml?branch=master)
14
14
 
15
15
  ## :name_badge: Features
@@ -1,6 +1,6 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
- var __exportAll = (all, symbols) => {
3
+ var __exportAll = (all, no_symbols) => {
4
4
  let target = {};
5
5
  for (var name in all) {
6
6
  __defProp(target, name, {
@@ -8,7 +8,7 @@ var __exportAll = (all, symbols) => {
8
8
  enumerable: true
9
9
  });
10
10
  }
11
- if (symbols) {
11
+ if (!no_symbols) {
12
12
  __defProp(target, Symbol.toStringTag, { value: "Module" });
13
13
  }
14
14
  return target;
package/lib/index.d.mts CHANGED
@@ -48,8 +48,8 @@ declare class YAMLSourceCode extends TextSourceCodeBase<{
48
48
  readonly visitorKeys: Record<string, string[]>;
49
49
  private readonly tokenStore;
50
50
  /**
51
- * Creates a new instance.
52
- */
51
+ * Creates a new instance.
52
+ */
53
53
  constructor(config: {
54
54
  text: string;
55
55
  ast: AST.YAMLProgram;
@@ -62,29 +62,29 @@ declare class YAMLSourceCode extends TextSourceCodeBase<{
62
62
  });
63
63
  traverse(): Iterable<TraversalStep>;
64
64
  /**
65
- * Gets all tokens and comments.
66
- */
65
+ * Gets all tokens and comments.
66
+ */
67
67
  get tokensAndComments(): YAMLToken[];
68
68
  getLines(): string[];
69
69
  getAllComments(): AST.Comment[];
70
70
  /**
71
- * Returns an array of all inline configuration nodes found in the source code.
72
- * This includes eslint-disable, eslint-enable, eslint-disable-line,
73
- * eslint-disable-next-line, and eslint (for inline config) comments.
74
- */
71
+ * Returns an array of all inline configuration nodes found in the source code.
72
+ * This includes eslint-disable, eslint-enable, eslint-disable-line,
73
+ * eslint-disable-next-line, and eslint (for inline config) comments.
74
+ */
75
75
  getInlineConfigNodes(): AST.Comment[];
76
76
  /**
77
- * Returns directives that enable or disable rules along with any problems
78
- * encountered while parsing the directives.
79
- */
77
+ * Returns directives that enable or disable rules along with any problems
78
+ * encountered while parsing the directives.
79
+ */
80
80
  getDisableDirectives(): {
81
81
  directives: IDirective[];
82
82
  problems: FileProblem[];
83
83
  };
84
84
  /**
85
- * Returns inline rule configurations along with any problems
86
- * encountered while parsing the configurations.
87
- */
85
+ * Returns inline rule configurations along with any problems
86
+ * encountered while parsing the configurations.
87
+ */
88
88
  applyInlineConfig(): {
89
89
  configs: {
90
90
  config: {
@@ -111,19 +111,19 @@ declare class YAMLSourceCode extends TextSourceCodeBase<{
111
111
  getCommentsAfter(nodeOrToken: YAMLSyntaxElement): AST.Comment[];
112
112
  isSpaceBetween(first: YAMLToken, second: YAMLToken): boolean;
113
113
  /**
114
- * Compatibility for ESLint's SourceCode API
115
- * @deprecated YAML does not have scopes
116
- */
114
+ * Compatibility for ESLint's SourceCode API
115
+ * @deprecated YAML does not have scopes
116
+ */
117
117
  getScope(node?: AST.YAMLNode): Scope.Scope | null;
118
118
  /**
119
- * Compatibility for ESLint's SourceCode API
120
- * @deprecated YAML does not have scopes
121
- */
119
+ * Compatibility for ESLint's SourceCode API
120
+ * @deprecated YAML does not have scopes
121
+ */
122
122
  get scopeManager(): Scope.ScopeManager | null;
123
123
  /**
124
- * Compatibility for ESLint's SourceCode API
125
- * @deprecated
126
- */
124
+ * Compatibility for ESLint's SourceCode API
125
+ * @deprecated
126
+ */
127
127
  isSpaceBetweenTokens(first: YAMLToken, second: YAMLToken): boolean;
128
128
  private _getChildren;
129
129
  }
@@ -154,35 +154,35 @@ declare class YAMLLanguage implements Language<{
154
154
  Node: AST.YAMLNode;
155
155
  }> {
156
156
  /**
157
- * The type of file to read.
158
- */
157
+ * The type of file to read.
158
+ */
159
159
  fileType: "text";
160
160
  /**
161
- * The line number at which the parser starts counting.
162
- */
161
+ * The line number at which the parser starts counting.
162
+ */
163
163
  lineStart: 1;
164
164
  /**
165
- * The column number at which the parser starts counting.
166
- */
165
+ * The column number at which the parser starts counting.
166
+ */
167
167
  columnStart: 0;
168
168
  /**
169
- * The name of the key that holds the type of the node.
170
- */
169
+ * The name of the key that holds the type of the node.
170
+ */
171
171
  nodeTypeKey: "type";
172
172
  /**
173
- * Validates the language options.
174
- */
173
+ * Validates the language options.
174
+ */
175
175
  validateLanguageOptions(_languageOptions: YAMLLanguageOptions): void;
176
176
  normalizeLanguageOptions(languageOptions: YAMLLanguageOptions): YAMLLanguageOptions;
177
177
  /**
178
- * Parses the given file into an AST.
179
- */
178
+ * Parses the given file into an AST.
179
+ */
180
180
  parse(file: File, context: {
181
181
  languageOptions?: YAMLLanguageOptions;
182
182
  }): OkParseResult<AST.YAMLProgram> | YAMLParseResult;
183
183
  /**
184
- * Creates a new SourceCode object for the given file and parse result.
185
- */
184
+ * Creates a new SourceCode object for the given file and parse result.
185
+ */
186
186
  createSourceCode(file: File, parseResult: OkParseResult<AST.YAMLProgram> | YAMLParseResult): YAMLSourceCode;
187
187
  }
188
188
  //#endregion
package/lib/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { t as __exportAll } from "./chunk-15K8U1wQ.mjs";
1
+ import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
2
2
  import * as yamlESLintParser from "yaml-eslint-parser";
3
3
  import { VisitorKeys, getStaticYAMLValue, parseForESLint, parseYAML, traverseNodes } from "yaml-eslint-parser";
4
- import path from "path";
4
+ import path from "node:path";
5
5
  import naturalCompare from "natural-compare";
6
6
  import diffModule from "diff-sequences";
7
7
  import escapeStringRegexp from "escape-string-regexp";
@@ -942,10 +942,10 @@ function buildFixFlowToBlock(node, context) {
942
942
  if (p.value) yield* processIndentFix(fixer, baseIndent, p.value, context);
943
943
  } else yield* processIndentFix(fixer, baseIndent, p, context);
944
944
  if (entry.style === "flow") {
945
- const close$1 = sourceCode.getLastToken(entry);
946
- if (close$1.value === "}") {
947
- const actualIndent = getActualIndent(close$1, context);
948
- if (actualIndent != null && compareIndent(actualIndent, baseIndent) < 0) yield fixIndent(fixer, sourceCode, baseIndent, close$1);
945
+ const close = sourceCode.getLastToken(entry);
946
+ if (close.value === "}") {
947
+ const actualIndent = getActualIndent(close, context);
948
+ if (actualIndent != null && compareIndent(actualIndent, baseIndent) < 0) yield fixIndent(fixer, sourceCode, baseIndent, close);
949
949
  }
950
950
  }
951
951
  } else if (entry.type === "YAMLSequence") for (const e of entry.entries) {
@@ -1069,9 +1069,9 @@ function normalizeOptionValue(value) {
1069
1069
  * @param {Token} last Last object property
1070
1070
  * @returns {boolean} `true` if node needs to be checked for missing line breaks
1071
1071
  */
1072
- function areLineBreaksRequired(node, options, first, last$1) {
1072
+ function areLineBreaksRequired(node, options, first, last) {
1073
1073
  const objectProperties = node.pairs;
1074
- return objectProperties.length >= options.minProperties || options.multiline && objectProperties.length > 0 && first.loc.start.line !== last$1.loc.end.line;
1074
+ return objectProperties.length >= options.minProperties || options.multiline && objectProperties.length > 0 && first.loc.start.line !== last.loc.end.line;
1075
1075
  }
1076
1076
  var flow_mapping_curly_newline_default = createRule("flow-mapping-curly-newline", {
1077
1077
  meta: {
@@ -1105,13 +1105,13 @@ var flow_mapping_curly_newline_default = createRule("flow-mapping-curly-newline"
1105
1105
  const openBrace = sourceCode.getFirstToken(node, (token) => token.value === "{");
1106
1106
  const closeBrace = sourceCode.getLastToken(node, (token) => token.value === "}");
1107
1107
  let first = sourceCode.getTokenAfter(openBrace, { includeComments: true });
1108
- let last$1 = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
1109
- const needsLineBreaks = areLineBreaksRequired(node, options, first, last$1);
1108
+ let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
1109
+ const needsLineBreaks = areLineBreaksRequired(node, options, first, last);
1110
1110
  const hasCommentsFirstToken = isCommentToken(first);
1111
- const hasCommentsLastToken = isCommentToken(last$1);
1112
- const hasQuestionsLastToken = isQuestion(last$1);
1111
+ const hasCommentsLastToken = isCommentToken(last);
1112
+ const hasQuestionsLastToken = isQuestion(last);
1113
1113
  first = sourceCode.getTokenAfter(openBrace);
1114
- last$1 = sourceCode.getTokenBefore(closeBrace);
1114
+ last = sourceCode.getTokenBefore(closeBrace);
1115
1115
  if (needsLineBreaks) {
1116
1116
  if (isTokenOnSameLine(openBrace, first)) context.report({
1117
1117
  messageId: "expectedLinebreakAfterOpeningBrace",
@@ -1123,7 +1123,7 @@ var flow_mapping_curly_newline_default = createRule("flow-mapping-curly-newline"
1123
1123
  return fixer.insertTextAfter(openBrace, `\n${indent}`);
1124
1124
  }
1125
1125
  });
1126
- if (isTokenOnSameLine(last$1, closeBrace)) context.report({
1126
+ if (isTokenOnSameLine(last, closeBrace)) context.report({
1127
1127
  messageId: "expectedLinebreakBeforeClosingBrace",
1128
1128
  node,
1129
1129
  loc: closeBrace.loc,
@@ -1136,7 +1136,7 @@ var flow_mapping_curly_newline_default = createRule("flow-mapping-curly-newline"
1136
1136
  } else {
1137
1137
  const consistent = options.consistent;
1138
1138
  const hasLineBreakBetweenOpenBraceAndFirst = !isTokenOnSameLine(openBrace, first);
1139
- const hasLineBreakBetweenCloseBraceAndLast = !isTokenOnSameLine(last$1, closeBrace);
1139
+ const hasLineBreakBetweenCloseBraceAndLast = !isTokenOnSameLine(last, closeBrace);
1140
1140
  if (!consistent && hasLineBreakBetweenOpenBraceAndFirst || consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) context.report({
1141
1141
  messageId: "unexpectedLinebreakAfterOpeningBrace",
1142
1142
  node,
@@ -1154,7 +1154,7 @@ var flow_mapping_curly_newline_default = createRule("flow-mapping-curly-newline"
1154
1154
  loc: closeBrace.loc,
1155
1155
  fix(fixer) {
1156
1156
  if (hasCommentsLastToken || hasTabIndent(context)) return null;
1157
- return fixer.removeRange([last$1.range[1], closeBrace.range[0]]);
1157
+ return fixer.removeRange([last.range[1], closeBrace.range[0]]);
1158
1158
  }
1159
1159
  });
1160
1160
  }
@@ -1303,18 +1303,18 @@ var flow_mapping_curly_spacing_default = createRule("flow-mapping-curly-spacing"
1303
1303
  * @param penultimate The penultimate token to check (should be last before closing brace)
1304
1304
  * @param last The last token to check (should be closing brace)
1305
1305
  */
1306
- function validateBraceSpacing(node, first, second, penultimate, last$1) {
1306
+ function validateBraceSpacing(node, first, second, penultimate, last) {
1307
1307
  if (isTokenOnSameLine(first, second)) {
1308
- const firstSpaced = sourceCode.isSpaceBetweenTokens(first, second);
1308
+ const firstSpaced = sourceCode.isSpaceBetween(first, second);
1309
1309
  if (options.isOpeningCurlyBraceMustBeSpaced(second)) {
1310
1310
  if (!firstSpaced) reportRequiredBeginningSpace(node, first);
1311
1311
  } else if (firstSpaced && second.type !== "Line") reportNoBeginningSpace(node, first);
1312
1312
  }
1313
- if (isTokenOnSameLine(penultimate, last$1)) {
1314
- const lastSpaced = sourceCode.isSpaceBetweenTokens(penultimate, last$1);
1313
+ if (isTokenOnSameLine(penultimate, last)) {
1314
+ const lastSpaced = sourceCode.isSpaceBetween(penultimate, last);
1315
1315
  if (options.isClosingCurlyBraceMustBeSpaced(penultimate)) {
1316
- if (!lastSpaced) reportRequiredEndingSpace(node, last$1);
1317
- } else if (lastSpaced) reportNoEndingSpace(node, last$1);
1316
+ if (!lastSpaced) reportRequiredEndingSpace(node, last);
1317
+ } else if (lastSpaced) reportNoEndingSpace(node, last);
1318
1318
  }
1319
1319
  }
1320
1320
  /**
@@ -1339,8 +1339,8 @@ var flow_mapping_curly_spacing_default = createRule("flow-mapping-curly-spacing"
1339
1339
  function checkForObject(node) {
1340
1340
  if (node.pairs.length === 0) return;
1341
1341
  const first = sourceCode.getFirstToken(node);
1342
- const last$1 = getClosingBraceOfObject(node);
1343
- validateBraceSpacing(node, first, sourceCode.getTokenAfter(first, { includeComments: true }), sourceCode.getTokenBefore(last$1, { includeComments: true }), last$1);
1342
+ const last = getClosingBraceOfObject(node);
1343
+ validateBraceSpacing(node, first, sourceCode.getTokenAfter(first, { includeComments: true }), sourceCode.getTokenBefore(last, { includeComments: true }), last);
1344
1344
  }
1345
1345
  return { YAMLMapping(node) {
1346
1346
  if (node.style === "flow") checkForObject(node);
@@ -1390,7 +1390,7 @@ var flow_sequence_bracket_newline_default = createRule("flow-sequence-bracket-ne
1390
1390
  * @param {string|Object|undefined} option An option value to parse.
1391
1391
  * @returns {{multiline: boolean, minItems: number}} Normalized option object.
1392
1392
  */
1393
- function normalizeOptionValue$1(option) {
1393
+ function normalizeOptionValue(option) {
1394
1394
  let consistent = false;
1395
1395
  let multiline = false;
1396
1396
  let minItems = 0;
@@ -1496,19 +1496,19 @@ var flow_sequence_bracket_newline_default = createRule("flow-sequence-bracket-ne
1496
1496
  function check(node) {
1497
1497
  if (isKeyNode(node)) return;
1498
1498
  const elements = node.entries;
1499
- const options = normalizeOptionValue$1(context.options[0]);
1499
+ const options = normalizeOptionValue(context.options[0]);
1500
1500
  const openBracket = sourceCode.getFirstToken(node);
1501
1501
  const closeBracket = sourceCode.getLastToken(node);
1502
1502
  const firstIncComment = sourceCode.getTokenAfter(openBracket, { includeComments: true });
1503
1503
  const lastIncComment = sourceCode.getTokenBefore(closeBracket, { includeComments: true });
1504
1504
  const first = sourceCode.getTokenAfter(openBracket);
1505
- const last$1 = sourceCode.getTokenBefore(closeBracket);
1505
+ const last = sourceCode.getTokenBefore(closeBracket);
1506
1506
  if (elements.length >= options.minItems || options.multiline && elements.length > 0 && firstIncComment.loc.start.line !== lastIncComment.loc.end.line || elements.length === 0 && firstIncComment.type === "Block" && firstIncComment.loc.start.line !== lastIncComment.loc.end.line && firstIncComment === lastIncComment || options.consistent && openBracket.loc.end.line !== first.loc.start.line) {
1507
1507
  if (isTokenOnSameLine(openBracket, first)) reportRequiredBeginningLinebreak(node, openBracket);
1508
- if (isTokenOnSameLine(last$1, closeBracket)) reportRequiredEndingLinebreak(node, closeBracket);
1508
+ if (isTokenOnSameLine(last, closeBracket)) reportRequiredEndingLinebreak(node, closeBracket);
1509
1509
  } else {
1510
1510
  if (!isTokenOnSameLine(openBracket, first)) reportNoBeginningLinebreak(node, openBracket);
1511
- if (!isTokenOnSameLine(last$1, closeBracket)) reportNoEndingLinebreak(node, closeBracket);
1511
+ if (!isTokenOnSameLine(last, closeBracket)) reportNoEndingLinebreak(node, closeBracket);
1512
1512
  }
1513
1513
  }
1514
1514
  return { YAMLSequence(node) {
@@ -1673,18 +1673,18 @@ var flow_sequence_bracket_spacing_default = createRule("flow-sequence-bracket-sp
1673
1673
  function validateArraySpacing(node) {
1674
1674
  if (options.spaced && node.entries.length === 0) return;
1675
1675
  const first = sourceCode.getFirstToken(node);
1676
- const last$1 = sourceCode.getLastToken(node);
1676
+ const last = sourceCode.getLastToken(node);
1677
1677
  const second = sourceCode.getTokenAfter(first, { includeComments: true });
1678
- const penultimate = sourceCode.getTokenBefore(last$1, { includeComments: true });
1678
+ const penultimate = sourceCode.getTokenBefore(last, { includeComments: true });
1679
1679
  if (isTokenOnSameLine(first, second)) {
1680
1680
  if (options.isOpeningBracketMustBeSpaced(node)) {
1681
- if (!sourceCode.isSpaceBetweenTokens(first, second)) reportRequiredBeginningSpace(node, first);
1682
- } else if (sourceCode.isSpaceBetweenTokens(first, second)) reportNoBeginningSpace(node, first);
1681
+ if (!sourceCode.isSpaceBetween(first, second)) reportRequiredBeginningSpace(node, first);
1682
+ } else if (sourceCode.isSpaceBetween(first, second)) reportNoBeginningSpace(node, first);
1683
1683
  }
1684
- if (first !== penultimate && isTokenOnSameLine(penultimate, last$1)) {
1684
+ if (first !== penultimate && isTokenOnSameLine(penultimate, last)) {
1685
1685
  if (options.isClosingBracketMustBeSpaced(node)) {
1686
- if (!sourceCode.isSpaceBetweenTokens(penultimate, last$1)) reportRequiredEndingSpace(node, last$1);
1687
- } else if (sourceCode.isSpaceBetweenTokens(penultimate, last$1)) reportNoEndingSpace(node, last$1);
1686
+ if (!sourceCode.isSpaceBetween(penultimate, last)) reportRequiredEndingSpace(node, last);
1687
+ } else if (sourceCode.isSpaceBetween(penultimate, last)) reportNoEndingSpace(node, last);
1688
1688
  }
1689
1689
  }
1690
1690
  return { YAMLSequence(node) {
@@ -2033,10 +2033,10 @@ var indent_default = createRule("indent", {
2033
2033
  if (!lineIndent) continue;
2034
2034
  const line = lineIndent.line;
2035
2035
  if (lineIndent.firstToken.type === "Block") {
2036
- const last$1 = commentLines[commentLines.length - 1];
2037
- if (last$1 && last$1.range[1] === line - 1) {
2038
- last$1.range[1] = line;
2039
- last$1.commentLineIndents.push(lineIndent);
2036
+ const last = commentLines[commentLines.length - 1];
2037
+ if (last && last.range[1] === line - 1) {
2038
+ last.range[1] = line;
2039
+ last.commentLineIndents.push(lineIndent);
2040
2040
  } else commentLines.push({
2041
2041
  range: [line, line],
2042
2042
  commentLineIndents: [lineIndent]
@@ -2067,8 +2067,8 @@ var indent_default = createRule("indent", {
2067
2067
  /**
2068
2068
  * Process comments.
2069
2069
  */
2070
- function processComments(commentLines$1, lineIndents$1) {
2071
- for (const { range, commentLineIndents } of commentLines$1) {
2070
+ function processComments(commentLines, lineIndents) {
2071
+ for (const { range, commentLineIndents } of commentLines) {
2072
2072
  let prev = results.slice(0, range[0]).filter((data) => data).pop();
2073
2073
  const next = results.slice(range[1] + 1).filter((data) => data).shift();
2074
2074
  if (isBlockLiteral(prev)) prev = void 0;
@@ -2115,7 +2115,7 @@ var indent_default = createRule("indent", {
2115
2115
  function isBlockLiteral(prev) {
2116
2116
  if (!prev) return false;
2117
2117
  for (let prevLine = prev.line; prevLine >= 0; prevLine--) {
2118
- const prevLineIndent = lineIndents$1[prev.line];
2118
+ const prevLineIndent = lineIndents[prev.line];
2119
2119
  if (!prevLineIndent) continue;
2120
2120
  if (prevLineIndent.lastScalar) {
2121
2121
  const scalarNode = prevLineIndent.lastScalar.node;
@@ -2242,11 +2242,11 @@ var indent_default = createRule("indent", {
2242
2242
  const li = lineIndents[lineIndex];
2243
2243
  if (li?.indentBlockScalar) {
2244
2244
  const blockLiteral = li.indentBlockScalar.node;
2245
- const diff$1 = li.expectedIndent - li.actualIndent;
2245
+ const diff = li.expectedIndent - li.actualIndent;
2246
2246
  const mark = sourceCode.getFirstToken(blockLiteral);
2247
2247
  const num = /\d+/u.exec(mark.value)?.[0];
2248
2248
  if (num != null) {
2249
- if (Number(num) + diff$1 >= 10) return null;
2249
+ if (Number(num) + diff >= 10) return null;
2250
2250
  }
2251
2251
  }
2252
2252
  }
@@ -2277,9 +2277,9 @@ var indent_default = createRule("indent", {
2277
2277
  function* fixLine(fixer, li) {
2278
2278
  if (li.indentBlockScalar) {
2279
2279
  const blockLiteral = li.indentBlockScalar.node;
2280
- const diff$1 = li.expectedIndent - li.actualIndent;
2280
+ const diff = li.expectedIndent - li.actualIndent;
2281
2281
  const mark = sourceCode.getFirstToken(blockLiteral);
2282
- yield fixer.replaceText(mark, mark.value.replace(/\d+/u, (num) => `${Number(num) + diff$1}`));
2282
+ yield fixer.replaceText(mark, mark.value.replace(/\d+/u, (num) => `${Number(num) + diff}`));
2283
2283
  }
2284
2284
  const expectedIndent = li.expectedIndent;
2285
2285
  yield fixer.replaceTextRange([sourceCode.getIndexFromLoc({
@@ -2382,8 +2382,8 @@ const checkersMap = {
2382
2382
  * Return case checker
2383
2383
  * @param name type of checker to return ('camelCase', 'kebab-case', 'PascalCase')
2384
2384
  */
2385
- function getChecker(name$2) {
2386
- return checkersMap[name$2] || isPascalCase;
2385
+ function getChecker(name) {
2386
+ return checkersMap[name] || isPascalCase;
2387
2387
  }
2388
2388
 
2389
2389
  //#endregion
@@ -2441,18 +2441,18 @@ var key_name_casing_default = createRule("key-name-casing", {
2441
2441
  /**
2442
2442
  * Check whether a given name is a valid.
2443
2443
  */
2444
- function isValid(name$2) {
2445
- if (ignores.some((regex) => regex.test(name$2))) return true;
2446
- return checkers.length ? checkers.some((c) => c(name$2)) : true;
2444
+ function isValid(name) {
2445
+ if (ignores.some((regex) => regex.test(name))) return true;
2446
+ return checkers.length ? checkers.some((c) => c(name)) : true;
2447
2447
  }
2448
2448
  return { YAMLPair(node) {
2449
2449
  if (!node.key) return;
2450
- const name$2 = String(getStaticYAMLValue(node.key));
2451
- if (!isValid(name$2)) context.report({
2450
+ const name = String(getStaticYAMLValue(node.key));
2451
+ if (!isValid(name)) context.report({
2452
2452
  loc: node.key.loc,
2453
2453
  messageId: "doesNotMatchFormat",
2454
2454
  data: {
2455
- name: name$2,
2455
+ name,
2456
2456
  formats: formats.join(", ")
2457
2457
  }
2458
2458
  });
@@ -2731,11 +2731,11 @@ function create(context) {
2731
2731
  * @returns {void}
2732
2732
  */
2733
2733
  function report(property, side, whitespace, expected, mode) {
2734
- const diff$1 = whitespace.length - expected;
2734
+ const diff = whitespace.length - expected;
2735
2735
  const nextColon = getNextColon(property.key);
2736
2736
  const tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: true });
2737
2737
  const tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: true });
2738
- if (!((mode === "strict" ? diff$1 !== 0 : diff$1 < 0 || diff$1 > 0 && expected === 0) && !(expected && containsLineTerminator(whitespace)))) return;
2738
+ if (!((mode === "strict" ? diff !== 0 : diff < 0 || diff > 0 && expected === 0) && !(expected && containsLineTerminator(whitespace)))) return;
2739
2739
  if (!canChangeSpaces(property, side) || expected === 0 && !canRemoveSpaces(property, side, whitespace) || whitespace.length === 0 && !canInsertSpaces(property, side)) return;
2740
2740
  const { locStart, locEnd, missingLoc } = side === "key" ? {
2741
2741
  locStart: tokenBeforeColon.loc.end,
@@ -2746,7 +2746,7 @@ function create(context) {
2746
2746
  locEnd: tokenAfterColon.loc.start,
2747
2747
  missingLoc: tokenAfterColon.loc
2748
2748
  };
2749
- const { loc, messageId } = diff$1 > 0 ? {
2749
+ const { loc, messageId } = diff > 0 ? {
2750
2750
  loc: {
2751
2751
  start: locStart,
2752
2752
  end: locEnd
@@ -2762,11 +2762,11 @@ function create(context) {
2762
2762
  messageId,
2763
2763
  data: { key: getKey(property) },
2764
2764
  fix(fixer) {
2765
- if (diff$1 > 0) {
2766
- if (side === "key") return fixer.removeRange([tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diff$1]);
2767
- return fixer.removeRange([tokenAfterColon.range[0] - diff$1, tokenAfterColon.range[0]]);
2765
+ if (diff > 0) {
2766
+ if (side === "key") return fixer.removeRange([tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diff]);
2767
+ return fixer.removeRange([tokenAfterColon.range[0] - diff, tokenAfterColon.range[0]]);
2768
2768
  }
2769
- const spaces = " ".repeat(-diff$1);
2769
+ const spaces = " ".repeat(-diff);
2770
2770
  if (side === "key") return fixer.insertTextAfter(tokenBeforeColon, spaces);
2771
2771
  return fixer.insertTextBefore(tokenAfterColon, spaces);
2772
2772
  }
@@ -2823,7 +2823,7 @@ function create(context) {
2823
2823
  /**
2824
2824
  * Define alignment rule visitor
2825
2825
  */
2826
- function defineAlignmentVisitor(alignmentOptions$1) {
2826
+ function defineAlignmentVisitor(alignmentOptions) {
2827
2827
  return { YAMLMapping(node) {
2828
2828
  if (isSingleLine(node)) verifyListSpacing(node.pairs.filter(isKeyValueProperty), singleLineOptions);
2829
2829
  else verifyAlignment(node);
@@ -2836,17 +2836,17 @@ function create(context) {
2836
2836
  function verifyGroupAlignment(properties) {
2837
2837
  const length = properties.length;
2838
2838
  const widths = properties.map(getKeyWidth);
2839
- const align = alignmentOptions$1.on;
2839
+ const align = alignmentOptions.on;
2840
2840
  let targetWidth = Math.max(...widths);
2841
2841
  let beforeColon, afterColon, mode;
2842
- if (alignmentOptions$1 && length > 1) {
2843
- beforeColon = alignmentOptions$1.beforeColon ? 1 : 0;
2844
- afterColon = alignmentOptions$1.afterColon ? 1 : 0;
2845
- mode = alignmentOptions$1.mode;
2842
+ if (alignmentOptions && length > 1) {
2843
+ beforeColon = alignmentOptions.beforeColon ? 1 : 0;
2844
+ afterColon = alignmentOptions.afterColon ? 1 : 0;
2845
+ mode = alignmentOptions.mode;
2846
2846
  } else {
2847
2847
  beforeColon = multiLineOptions.beforeColon ? 1 : 0;
2848
2848
  afterColon = multiLineOptions.afterColon ? 1 : 0;
2849
- mode = alignmentOptions$1.mode;
2849
+ mode = alignmentOptions.mode;
2850
2850
  }
2851
2851
  targetWidth += align === "colon" ? beforeColon : afterColon;
2852
2852
  for (let i = 0; i < length; i++) {
@@ -3702,7 +3702,7 @@ function calcShortestEditScript(a, b) {
3702
3702
  let aIndex = 0;
3703
3703
  let bIndex = 0;
3704
3704
  const result = [];
3705
- diff(a.length, b.length, (aIndex$1, bIndex$1) => a[aIndex$1] === b[bIndex$1], (nCommon, aCommon, bCommon) => {
3705
+ diff(a.length, b.length, (aIndex, bIndex) => a[aIndex] === b[bIndex], (nCommon, aCommon, bCommon) => {
3706
3706
  pushDelIns(aIndex, aCommon, bIndex, bCommon);
3707
3707
  aIndex = aCommon + nCommon;
3708
3708
  bIndex = bCommon + nCommon;
@@ -3793,20 +3793,20 @@ var YAMLMappingData = class {
3793
3793
  return this.cachedProperties ??= this.node.pairs.map((e, index) => new YAMLPairData(this, e, index, this.anchorAliasMap.get(e)));
3794
3794
  }
3795
3795
  getPath(sourceCode) {
3796
- let path$1 = "";
3796
+ let path = "";
3797
3797
  let curr = this.node;
3798
3798
  let p = curr.parent;
3799
3799
  while (p) {
3800
3800
  if (p.type === "YAMLPair") {
3801
- const name$2 = getPropertyName(p, sourceCode);
3802
- if (/^[$a-z_][\w$]*$/iu.test(name$2)) path$1 = `.${name$2}${path$1}`;
3803
- else path$1 = `[${JSON.stringify(name$2)}]${path$1}`;
3804
- } else if (p.type === "YAMLSequence") path$1 = `[${p.entries.indexOf(curr)}]${path$1}`;
3801
+ const name = getPropertyName(p, sourceCode);
3802
+ if (/^[$a-z_][\w$]*$/iu.test(name)) path = `.${name}${path}`;
3803
+ else path = `[${JSON.stringify(name)}]${path}`;
3804
+ } else if (p.type === "YAMLSequence") path = `[${p.entries.indexOf(curr)}]${path}`;
3805
3805
  curr = p;
3806
3806
  p = curr.parent;
3807
3807
  }
3808
- if (path$1.startsWith(".")) path$1 = path$1.slice(1);
3809
- return path$1;
3808
+ if (path.startsWith(".")) path = path.slice(1);
3809
+ return path;
3810
3810
  }
3811
3811
  };
3812
3812
  /**
@@ -3911,7 +3911,7 @@ function parseOptions$1(options, sourceCode) {
3911
3911
  if (data.node.pairs.length < minKeys) return false;
3912
3912
  if (hasProperties.length > 0) {
3913
3913
  const names = new Set(data.pairs.map((p) => p.name));
3914
- if (!hasProperties.every((name$2) => names.has(name$2))) return false;
3914
+ if (!hasProperties.every((name) => names.has(name))) return false;
3915
3915
  }
3916
3916
  return pathPattern.test(data.getPath(sourceCode));
3917
3917
  }
@@ -4350,19 +4350,19 @@ var sort_keys_default = createRule("sort-keys", {
4350
4350
  };
4351
4351
  const beforeToken = sourceCode.getTokenBefore(node);
4352
4352
  if (beforeToken) {
4353
- const next$1 = sourceCode.getTokenAfter(beforeToken, { includeComments: true });
4354
- if (beforeToken.loc.end.line < next$1.loc.start.line || beforeToken.loc.end.line < node.loc.start.line) {
4355
- const start$1 = {
4356
- line: beforeToken.loc.end.line < next$1.loc.start.line ? next$1.loc.start.line : node.loc.start.line,
4353
+ const next = sourceCode.getTokenAfter(beforeToken, { includeComments: true });
4354
+ if (beforeToken.loc.end.line < next.loc.start.line || beforeToken.loc.end.line < node.loc.start.line) {
4355
+ const start = {
4356
+ line: beforeToken.loc.end.line < next.loc.start.line ? next.loc.start.line : node.loc.start.line,
4357
4357
  column: 0
4358
4358
  };
4359
4359
  return {
4360
- range: [sourceCode.getIndexFromLoc(start$1), end.index],
4360
+ range: [sourceCode.getIndexFromLoc(start), end.index],
4361
4361
  loc: {
4362
- start: start$1,
4362
+ start,
4363
4363
  end: end.loc
4364
4364
  },
4365
- indentColumn: next$1.loc.start.column
4365
+ indentColumn: next.loc.start.column
4366
4366
  };
4367
4367
  }
4368
4368
  return {
@@ -4377,14 +4377,14 @@ var sort_keys_default = createRule("sort-keys", {
4377
4377
  let next = node;
4378
4378
  for (const beforeComment of sourceCode.getTokensBefore(node, { includeComments: true }).reverse()) {
4379
4379
  if (beforeComment.loc.end.line + 1 < next.loc.start.line) {
4380
- const start$1 = {
4380
+ const start = {
4381
4381
  line: next.loc.start.line,
4382
4382
  column: 0
4383
4383
  };
4384
4384
  return {
4385
- range: [sourceCode.getIndexFromLoc(start$1), end.index],
4385
+ range: [sourceCode.getIndexFromLoc(start), end.index],
4386
4386
  loc: {
4387
- start: start$1,
4387
+ start,
4388
4388
  end: end.loc
4389
4389
  },
4390
4390
  indentColumn: next.loc.start.column
@@ -4554,26 +4554,26 @@ function parseOptions(options, sourceCode) {
4554
4554
  */
4555
4555
  function isTargetArray(data) {
4556
4556
  if (data.node.entries.length < minValues) return false;
4557
- let path$1 = "";
4557
+ let path = "";
4558
4558
  let curr = data.node;
4559
4559
  let p = curr.parent;
4560
4560
  while (p) {
4561
4561
  if (p.type === "YAMLPair") {
4562
- const name$2 = getPropertyName$1(p);
4563
- if (/^[$a-z_][\w$]*$/iu.test(name$2)) path$1 = `.${name$2}${path$1}`;
4564
- else path$1 = `[${JSON.stringify(name$2)}]${path$1}`;
4565
- } else if (p.type === "YAMLSequence") path$1 = `[${p.entries.indexOf(curr)}]${path$1}`;
4562
+ const name = getPropertyName(p);
4563
+ if (/^[$a-z_][\w$]*$/iu.test(name)) path = `.${name}${path}`;
4564
+ else path = `[${JSON.stringify(name)}]${path}`;
4565
+ } else if (p.type === "YAMLSequence") path = `[${p.entries.indexOf(curr)}]${path}`;
4566
4566
  curr = p;
4567
4567
  p = curr.parent;
4568
4568
  }
4569
- if (path$1.startsWith(".")) path$1 = path$1.slice(1);
4570
- return pathPattern.test(path$1);
4569
+ if (path.startsWith(".")) path = path.slice(1);
4570
+ return pathPattern.test(path);
4571
4571
  }
4572
4572
  });
4573
4573
  /**
4574
4574
  * Gets the property name of the given `YAMLPair` node.
4575
4575
  */
4576
- function getPropertyName$1(node) {
4576
+ function getPropertyName(node) {
4577
4577
  const prop = node.key;
4578
4578
  if (prop == null) return "";
4579
4579
  const target = prop.type === "YAMLWithMeta" ? prop.value : prop;
@@ -4926,13 +4926,13 @@ var sort_sequence_values_default = createRule("sort-sequence-values", {
4926
4926
  */
4927
4927
  function getBlockEntryEndOffset(data) {
4928
4928
  const valueEndToken = data.node ?? data.aroundTokens.before;
4929
- let last$1 = valueEndToken;
4930
- let afterToken = sourceCode.getTokenAfter(last$1, { includeComments: true });
4929
+ let last = valueEndToken;
4930
+ let afterToken = sourceCode.getTokenAfter(last, { includeComments: true });
4931
4931
  while (afterToken && valueEndToken.loc.end.line === afterToken.loc.start.line) {
4932
- last$1 = afterToken;
4933
- afterToken = sourceCode.getTokenAfter(last$1, { includeComments: true });
4932
+ last = afterToken;
4933
+ afterToken = sourceCode.getTokenAfter(last, { includeComments: true });
4934
4934
  }
4935
- return last$1.range[1];
4935
+ return last.range[1];
4936
4936
  }
4937
4937
  }
4938
4938
  });
@@ -5254,7 +5254,7 @@ var prettier_default = [...base_default, { rules: {
5254
5254
  //#endregion
5255
5255
  //#region package.json
5256
5256
  var name$1 = "eslint-plugin-yml";
5257
- var version$1 = "3.0.0";
5257
+ var version$1 = "3.1.0";
5258
5258
 
5259
5259
  //#endregion
5260
5260
  //#region src/meta.ts
@@ -5686,14 +5686,14 @@ var YAMLSourceCode = class extends TextSourceCodeBase {
5686
5686
  */
5687
5687
  applyInlineConfig() {
5688
5688
  const problems = [];
5689
- const configs$1 = [];
5689
+ const configs = [];
5690
5690
  this.getInlineConfigNodes().forEach((comment) => {
5691
5691
  const directive = commentParser.parseDirective(comment.value);
5692
5692
  if (!directive) return;
5693
5693
  const { label, value } = directive;
5694
5694
  if (label === "eslint") {
5695
5695
  const parseResult = commentParser.parseJSONLikeConfig(value);
5696
- if (parseResult.ok) configs$1.push({
5696
+ if (parseResult.ok) configs.push({
5697
5697
  config: { rules: parseResult.config },
5698
5698
  loc: comment.loc
5699
5699
  });
@@ -5705,7 +5705,7 @@ var YAMLSourceCode = class extends TextSourceCodeBase {
5705
5705
  }
5706
5706
  });
5707
5707
  return {
5708
- configs: configs$1,
5708
+ configs,
5709
5709
  problems
5710
5710
  };
5711
5711
  }
@@ -5721,7 +5721,7 @@ var YAMLSourceCode = class extends TextSourceCodeBase {
5721
5721
  * Finds a node that contains the given index.
5722
5722
  */
5723
5723
  function find(nodes) {
5724
- for (const node$1 of nodes) if (node$1.range[0] <= index && index < node$1.range[1]) return node$1;
5724
+ for (const node of nodes) if (node.range[0] <= index && index < node.range[1]) return node;
5725
5725
  return null;
5726
5726
  }
5727
5727
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-yml",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "This ESLint plugin provides linting rules for YAML.",
5
5
  "type": "module",
6
6
  "main": "lib/index.mjs",
@@ -65,7 +65,7 @@
65
65
  "homepage": "https://ota-meshi.github.io/eslint-plugin-yml/",
66
66
  "dependencies": {
67
67
  "@eslint/core": "^1.0.1",
68
- "@eslint/plugin-kit": "^0.5.1",
68
+ "@eslint/plugin-kit": "^0.6.0",
69
69
  "debug": "^4.3.2",
70
70
  "diff-sequences": "^29.0.0",
71
71
  "escape-string-regexp": "5.0.0",
@@ -81,9 +81,10 @@
81
81
  "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
82
82
  "@eslint/eslintrc": "^3.1.0",
83
83
  "@eslint/js": "^9.5.0",
84
- "@eslint/json": "^0.14.0",
85
- "@ota-meshi/eslint-plugin": "^0.18.0",
84
+ "@eslint/json": "^1.0.0",
85
+ "@ota-meshi/eslint-plugin": "^0.20.0",
86
86
  "@ota-meshi/site-kit-eslint-editor-vue": "^0.2.0",
87
+ "@stylistic/eslint-plugin": "^5.7.0",
87
88
  "@types/debug": "^4.1.5",
88
89
  "@types/eslint": "^9.0.0",
89
90
  "@types/eslint-scope": "^8.0.0",
@@ -93,8 +94,8 @@
93
94
  "@types/natural-compare": "^1.4.0",
94
95
  "@types/node": "^24.0.0",
95
96
  "@types/semver": "^7.3.1",
96
- "@typescript-eslint/eslint-plugin": "~8.53.0",
97
- "@typescript-eslint/parser": "~8.53.0",
97
+ "@typescript-eslint/eslint-plugin": "~8.54.0",
98
+ "@typescript-eslint/parser": "~8.54.0",
98
99
  "cross-env": "^10.0.0",
99
100
  "env-cmd": "^11.0.0",
100
101
  "eslint": "^9.16.0",
@@ -102,15 +103,15 @@
102
103
  "eslint-plugin-eslint-plugin": "^7.0.0",
103
104
  "eslint-plugin-eslint-rule-tester": "^0.6.0",
104
105
  "eslint-plugin-jsdoc": "^62.0.0",
105
- "eslint-plugin-json-schema-validator": "^5.0.0",
106
+ "eslint-plugin-json-schema-validator": "^6.0.0",
106
107
  "eslint-plugin-jsonc": "^2.0.0",
107
108
  "eslint-plugin-markdown": "^5.0.0",
108
109
  "eslint-plugin-n": "^17.0.0",
109
110
  "eslint-plugin-node-dependencies": "^1.0.0",
110
111
  "eslint-plugin-prettier": "^5.0.0",
111
- "eslint-plugin-regexp": "^2.0.0",
112
+ "eslint-plugin-regexp": "^3.0.0",
112
113
  "eslint-plugin-vue": "^10.0.0",
113
- "eslint-plugin-yml": "^2.0.0",
114
+ "eslint-plugin-yml": "^3.0.0",
114
115
  "events": "^3.3.0",
115
116
  "mocha": "^11.0.0",
116
117
  "monaco-editor": "^0.55.0",