eslint-plugin-yml 0.10.0 → 0.10.1
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/lib/rules/block-mapping-question-indicator-newline.js +2 -2
- package/lib/rules/block-mapping.js +10 -10
- package/lib/rules/block-sequence-hyphen-indicator-newline.js +2 -2
- package/lib/rules/block-sequence.js +17 -17
- package/lib/rules/flow-mapping-curly-newline.js +15 -15
- package/lib/rules/flow-mapping-curly-spacing.js +5 -4
- package/lib/rules/flow-sequence-bracket-newline.js +14 -14
- package/lib/rules/flow-sequence-bracket-spacing.js +5 -4
- package/lib/rules/indent.js +20 -4
- package/lib/rules/key-name-casing.js +2 -2
- package/lib/rules/key-spacing.js +3 -3
- package/lib/rules/no-empty-document.js +1 -1
- package/lib/rules/no-empty-key.js +1 -1
- package/lib/rules/no-empty-mapping-value.js +1 -1
- package/lib/rules/no-empty-sequence-entry.js +4 -4
- package/lib/rules/no-irregular-whitespace.js +3 -3
- package/lib/rules/no-tab-indent.js +1 -1
- package/lib/rules/plain-scalar.js +3 -3
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/require-string-key.js +1 -1
- package/lib/rules/sort-keys.js +5 -5
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/vue-custom-block/no-parsing-error.js +1 -1
- package/lib/types.d.ts +2 -0
- package/lib/utils/casing.js +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/yaml.js +2 -2
- package/package.json +7 -7
|
@@ -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;
|
package/lib/rules/indent.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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++) {
|
|
@@ -4,7 +4,7 @@ const yaml_eslint_parser_1 = require("yaml-eslint-parser");
|
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const casing_1 = require("../utils/casing");
|
|
6
6
|
const casing_2 = require("../utils/casing");
|
|
7
|
-
exports.default = utils_1.createRule("key-name-casing", {
|
|
7
|
+
exports.default = (0, utils_1.createRule)("key-name-casing", {
|
|
8
8
|
meta: {
|
|
9
9
|
docs: {
|
|
10
10
|
description: "enforce naming convention to key names",
|
|
@@ -79,7 +79,7 @@ exports.default = utils_1.createRule("key-name-casing", {
|
|
|
79
79
|
if (!node.key) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
const name = String(yaml_eslint_parser_1.getStaticYAMLValue(node.key));
|
|
82
|
+
const name = String((0, yaml_eslint_parser_1.getStaticYAMLValue)(node.key));
|
|
83
83
|
if (!isValid(name)) {
|
|
84
84
|
context.report({
|
|
85
85
|
loc: node.key.loc,
|
package/lib/rules/key-spacing.js
CHANGED
|
@@ -100,7 +100,7 @@ const ALIGN_OBJECT_SCHEMA = {
|
|
|
100
100
|
properties: Object.assign({ on: ON_SCHEMA }, OBJECT_WITHOUT_ON_SCHEMA.properties),
|
|
101
101
|
additionalProperties: false,
|
|
102
102
|
};
|
|
103
|
-
exports.default = utils_1.createRule("key-spacing", {
|
|
103
|
+
exports.default = (0, utils_1.createRule)("key-spacing", {
|
|
104
104
|
meta: {
|
|
105
105
|
docs: {
|
|
106
106
|
description: "enforce consistent spacing between keys and values in mapping pairs",
|
|
@@ -182,7 +182,7 @@ function create(context) {
|
|
|
182
182
|
function canChangeSpaces(property, side) {
|
|
183
183
|
if (side === "value") {
|
|
184
184
|
const before = sourceCode.getTokenBefore(property.key);
|
|
185
|
-
if (ast_utils_1.isQuestion(before) &&
|
|
185
|
+
if ((0, ast_utils_1.isQuestion)(before) &&
|
|
186
186
|
property.key.loc.end.line < property.value.loc.start.line) {
|
|
187
187
|
return false;
|
|
188
188
|
}
|
|
@@ -201,7 +201,7 @@ function create(context) {
|
|
|
201
201
|
if (property.parent.style === "block") {
|
|
202
202
|
if (containsLineTerminator(whitespace)) {
|
|
203
203
|
const before = sourceCode.getTokenBefore(property.key);
|
|
204
|
-
if (ast_utils_1.isQuestion(before)) {
|
|
204
|
+
if ((0, ast_utils_1.isQuestion)(before)) {
|
|
205
205
|
return false;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
-
exports.default = utils_1.createRule("no-empty-document", {
|
|
4
|
+
exports.default = (0, utils_1.createRule)("no-empty-document", {
|
|
5
5
|
meta: {
|
|
6
6
|
docs: {
|
|
7
7
|
description: "disallow empty document",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
-
exports.default = utils_1.createRule("no-empty-key", {
|
|
4
|
+
exports.default = (0, utils_1.createRule)("no-empty-key", {
|
|
5
5
|
meta: {
|
|
6
6
|
docs: {
|
|
7
7
|
description: "disallow empty mapping keys",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
-
exports.default = utils_1.createRule("no-empty-mapping-value", {
|
|
4
|
+
exports.default = (0, utils_1.createRule)("no-empty-mapping-value", {
|
|
5
5
|
meta: {
|
|
6
6
|
docs: {
|
|
7
7
|
description: "disallow empty mapping values",
|
|
@@ -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("no-empty-sequence-entry", {
|
|
5
|
+
exports.default = (0, utils_1.createRule)("no-empty-sequence-entry", {
|
|
6
6
|
meta: {
|
|
7
7
|
docs: {
|
|
8
8
|
description: "disallow empty sequence entries",
|
|
@@ -48,17 +48,17 @@ exports.default = utils_1.createRule("no-empty-sequence-entry", {
|
|
|
48
48
|
function getHyphen(node, index) {
|
|
49
49
|
if (index === 0) {
|
|
50
50
|
const token = sourceCode.getFirstToken(node);
|
|
51
|
-
return ast_utils_1.isHyphen(token) ? token : null;
|
|
51
|
+
return (0, ast_utils_1.isHyphen)(token) ? token : null;
|
|
52
52
|
}
|
|
53
53
|
const prev = node.entries[index - 1];
|
|
54
54
|
if (prev) {
|
|
55
55
|
const token = sourceCode.getTokenAfter(prev);
|
|
56
|
-
return ast_utils_1.isHyphen(token) ? token : null;
|
|
56
|
+
return (0, ast_utils_1.isHyphen)(token) ? token : null;
|
|
57
57
|
}
|
|
58
58
|
const prevHyphen = getHyphen(node, index - 1);
|
|
59
59
|
if (prevHyphen) {
|
|
60
60
|
const token = sourceCode.getTokenAfter(prevHyphen);
|
|
61
|
-
return ast_utils_1.isHyphen(token) ? token : null;
|
|
61
|
+
return (0, ast_utils_1.isHyphen)(token) ? token : null;
|
|
62
62
|
}
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
4
|
const ALL_IRREGULARS = /[\v\f\u0085\u00a0\u1680\u180e\u2000-\u200b\u2028\u2029\u202f\u205f\u3000\ufeff]/u;
|
|
5
|
-
const IRREGULAR_WHITESPACE = /[\v\f\u0085\u00a0\u1680\u180e\u2000-\u200b\u202f\u205f\u3000\ufeff]+/
|
|
6
|
-
const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/
|
|
7
|
-
exports.default = utils_1.createRule("no-irregular-whitespace", {
|
|
5
|
+
const IRREGULAR_WHITESPACE = /[\v\f\u0085\u00a0\u1680\u180e\u2000-\u200b\u202f\u205f\u3000\ufeff]+/gu;
|
|
6
|
+
const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/gu;
|
|
7
|
+
exports.default = (0, utils_1.createRule)("no-irregular-whitespace", {
|
|
8
8
|
meta: {
|
|
9
9
|
docs: {
|
|
10
10
|
description: "disallow irregular whitespace",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
-
exports.default = utils_1.createRule("no-tab-indent", {
|
|
4
|
+
exports.default = (0, utils_1.createRule)("no-tab-indent", {
|
|
5
5
|
meta: {
|
|
6
6
|
docs: {
|
|
7
7
|
description: "disallow tabs for indentation.",
|
|
@@ -25,7 +25,7 @@ function toRegExps(patterns) {
|
|
|
25
25
|
function isStringScalar(node) {
|
|
26
26
|
return typeof node.value === "string";
|
|
27
27
|
}
|
|
28
|
-
exports.default = utils_1.createRule("plain-scalar", {
|
|
28
|
+
exports.default = (0, utils_1.createRule)("plain-scalar", {
|
|
29
29
|
meta: {
|
|
30
30
|
docs: {
|
|
31
31
|
description: "require or disallow plain style scalar.",
|
|
@@ -115,8 +115,8 @@ exports.default = utils_1.createRule("plain-scalar", {
|
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
try {
|
|
118
|
-
const result = yaml_eslint_parser_1.parseForESLint(node.value);
|
|
119
|
-
if (yaml_eslint_parser_1.getStaticYAMLValue(result.ast) !== node.value) {
|
|
118
|
+
const result = (0, yaml_eslint_parser_1.parseForESLint)(node.value);
|
|
119
|
+
if ((0, yaml_eslint_parser_1.getStaticYAMLValue)(result.ast) !== node.value) {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
}
|
package/lib/rules/quotes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
-
exports.default = utils_1.createRule("quotes", {
|
|
4
|
+
exports.default = (0, utils_1.createRule)("quotes", {
|
|
5
5
|
meta: {
|
|
6
6
|
docs: {
|
|
7
7
|
description: "enforce the consistent use of either double, or single quotes",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
|
-
exports.default = utils_1.createRule("require-string-key", {
|
|
4
|
+
exports.default = (0, utils_1.createRule)("require-string-key", {
|
|
5
5
|
meta: {
|
|
6
6
|
docs: {
|
|
7
7
|
description: "disallow mapping keys other than strings",
|
package/lib/rules/sort-keys.js
CHANGED
|
@@ -34,7 +34,7 @@ function isCompatibleWithESLintOptions(options) {
|
|
|
34
34
|
}
|
|
35
35
|
function buildValidatorFromType(order, insensitive, natural) {
|
|
36
36
|
let compare = natural
|
|
37
|
-
? ([a, b]) => natural_compare_1.default(a, b) <= 0
|
|
37
|
+
? ([a, b]) => (0, natural_compare_1.default)(a, b) <= 0
|
|
38
38
|
: ([a, b]) => a <= b;
|
|
39
39
|
if (insensitive) {
|
|
40
40
|
const baseCompare = compare;
|
|
@@ -128,7 +128,7 @@ function parseOptions(options, sourceCode) {
|
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
const allowOrderTypes = ["asc", "desc"];
|
|
131
|
-
exports.default = utils_1.createRule("sort-keys", {
|
|
131
|
+
exports.default = (0, utils_1.createRule)("sort-keys", {
|
|
132
132
|
meta: {
|
|
133
133
|
docs: {
|
|
134
134
|
description: "require mapping keys to be sorted",
|
|
@@ -342,7 +342,7 @@ exports.default = utils_1.createRule("sort-keys", {
|
|
|
342
342
|
let insertCode, removeRange, insertTargetToken;
|
|
343
343
|
const afterCommaToken = sourceCode.getTokenAfter(node);
|
|
344
344
|
const moveTargetBeforeToken = sourceCode.getTokenBefore(moveTarget);
|
|
345
|
-
if (ast_utils_1.isComma(afterCommaToken)) {
|
|
345
|
+
if ((0, ast_utils_1.isComma)(afterCommaToken)) {
|
|
346
346
|
removeRange = [
|
|
347
347
|
beforeCommaToken.range[1],
|
|
348
348
|
afterCommaToken.range[1],
|
|
@@ -352,7 +352,7 @@ exports.default = utils_1.createRule("sort-keys", {
|
|
|
352
352
|
}
|
|
353
353
|
else {
|
|
354
354
|
removeRange = [beforeCommaToken.range[0], node.range[1]];
|
|
355
|
-
if (ast_utils_1.isComma(moveTargetBeforeToken)) {
|
|
355
|
+
if ((0, ast_utils_1.isComma)(moveTargetBeforeToken)) {
|
|
356
356
|
insertCode = sourceCode.text.slice(...removeRange);
|
|
357
357
|
insertTargetToken = sourceCode.getTokenBefore(moveTargetBeforeToken);
|
|
358
358
|
}
|
|
@@ -408,7 +408,7 @@ exports.default = utils_1.createRule("sort-keys", {
|
|
|
408
408
|
let endOfRange, end;
|
|
409
409
|
const afterToken = sourceCode.getTokenAfter(node, {
|
|
410
410
|
includeComments: true,
|
|
411
|
-
filter: (t) => !ast_utils_1.isCommentToken(t) || node.loc.end.line < t.loc.start.line,
|
|
411
|
+
filter: (t) => !(0, ast_utils_1.isCommentToken)(t) || node.loc.end.line < t.loc.start.line,
|
|
412
412
|
});
|
|
413
413
|
if (!afterToken || node.loc.end.line < afterToken.loc.start.line) {
|
|
414
414
|
const line = afterToken
|
|
@@ -48,7 +48,7 @@ function createNeverStylePattern(markers) {
|
|
|
48
48
|
const pattern = `^(${markers.map(escapeText).join("|")})?[ \t]+`;
|
|
49
49
|
return new RegExp(pattern, "u");
|
|
50
50
|
}
|
|
51
|
-
exports.default = utils_1.createRule("spaced-comment", {
|
|
51
|
+
exports.default = (0, utils_1.createRule)("spaced-comment", {
|
|
52
52
|
meta: {
|
|
53
53
|
docs: {
|
|
54
54
|
description: "enforce consistent spacing after the `#` in a comment",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../../utils");
|
|
4
|
-
exports.default = utils_1.createRule("vue-custom-block/no-parsing-error", {
|
|
4
|
+
exports.default = (0, utils_1.createRule)("vue-custom-block/no-parsing-error", {
|
|
5
5
|
meta: {
|
|
6
6
|
docs: {
|
|
7
7
|
description: "disallow parsing errors in Vue custom blocks",
|
package/lib/types.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export interface RuleMetaData {
|
|
|
46
46
|
[messageId: string]: string;
|
|
47
47
|
};
|
|
48
48
|
fixable?: "code" | "whitespace";
|
|
49
|
+
hasSuggestions?: boolean;
|
|
49
50
|
schema: JSONSchema4 | JSONSchema4[];
|
|
50
51
|
deprecated?: boolean;
|
|
51
52
|
type: "problem" | "suggestion" | "layout";
|
|
@@ -69,6 +70,7 @@ export interface PartialRuleMetaData {
|
|
|
69
70
|
[messageId: string]: string;
|
|
70
71
|
};
|
|
71
72
|
fixable?: "code" | "whitespace";
|
|
73
|
+
hasSuggestions?: boolean;
|
|
72
74
|
schema: JSONSchema4 | JSONSchema4[];
|
|
73
75
|
deprecated?: boolean;
|
|
74
76
|
type: "problem" | "suggestion" | "layout";
|
package/lib/utils/casing.js
CHANGED
|
@@ -12,7 +12,7 @@ function capitalize(str) {
|
|
|
12
12
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
13
13
|
}
|
|
14
14
|
function hasSymbols(str) {
|
|
15
|
-
return /[
|
|
15
|
+
return /[\u0021-\u0023\u0025-\u002c./\u003a-\u0040\u005b-\u005e`\u007b-\u007d]/u.test(str);
|
|
16
16
|
}
|
|
17
17
|
function hasUpper(str) {
|
|
18
18
|
return /[A-Z]/u.test(str);
|
package/lib/utils/index.js
CHANGED
|
@@ -26,7 +26,7 @@ exports.getCoreRule = exports.isNode = exports.getProxyNode = exports.defineWrap
|
|
|
26
26
|
const yamlESLintParser = __importStar(require("yaml-eslint-parser"));
|
|
27
27
|
const debug_1 = __importDefault(require("debug"));
|
|
28
28
|
const path_1 = __importDefault(require("path"));
|
|
29
|
-
const log = debug_1.default("eslint-plugin-yml:utils/index");
|
|
29
|
+
const log = (0, debug_1.default)("eslint-plugin-yml:utils/index");
|
|
30
30
|
function createRule(ruleName, rule) {
|
|
31
31
|
return {
|
|
32
32
|
meta: Object.assign(Object.assign({}, rule.meta), { docs: Object.assign(Object.assign({}, rule.meta.docs), { url: `https://ota-meshi.github.io/eslint-plugin-yml/rules/${ruleName}.html`, ruleId: `yml/${ruleName}`, ruleName }) }),
|
package/lib/utils/yaml.js
CHANGED
|
@@ -38,7 +38,7 @@ function calcExpectIndentForPairs(mapping, context) {
|
|
|
38
38
|
}
|
|
39
39
|
if (parentNode.type === "YAMLSequence") {
|
|
40
40
|
const hyphen = sourceCode.getTokenBefore(mapping);
|
|
41
|
-
if (!ast_utils_1.isHyphen(hyphen)) {
|
|
41
|
+
if (!(0, ast_utils_1.isHyphen)(hyphen)) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
if (hyphen.loc.start.line === mapping.loc.start.line) {
|
|
@@ -81,7 +81,7 @@ function calcExpectIndentForEntries(sequence, context) {
|
|
|
81
81
|
}
|
|
82
82
|
if (parentNode.type === "YAMLSequence") {
|
|
83
83
|
const hyphen = sourceCode.getTokenBefore(sequence);
|
|
84
|
-
if (!ast_utils_1.isHyphen(hyphen)) {
|
|
84
|
+
if (!(0, ast_utils_1.isHyphen)(hyphen)) {
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
87
87
|
if (hyphen.loc.start.line === sequence.loc.start.line) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-yml",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "This ESLint plugin provides linting rules for YAML.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test:base": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
|
|
18
18
|
"test": "npm run test:base",
|
|
19
19
|
"cover": "nyc --reporter=lcov npm run test:base",
|
|
20
|
-
"test:debug": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot",
|
|
20
|
+
"test:debug": "mocha --require ts-node/register/transpile-only \"tests/src/**/*.ts\" --reporter dot",
|
|
21
21
|
"update": "node --require ts-node/register ./tools/update.ts && npm run eslint-fix && npm run cover",
|
|
22
22
|
"new": "ts-node ./tools/new-rule.ts",
|
|
23
23
|
"predocs:watch": "npm run build:ts",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"eslint": ">=6.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@ota-meshi/eslint-plugin": "^0.
|
|
57
|
+
"@ota-meshi/eslint-plugin": "^0.8.0",
|
|
58
58
|
"@types/debug": "^4.1.5",
|
|
59
59
|
"@types/eslint": "^7.2.0",
|
|
60
60
|
"@types/eslint-scope": "^3.7.0",
|
|
@@ -79,13 +79,13 @@
|
|
|
79
79
|
"eslint-plugin-markdown": "^2.0.0-0",
|
|
80
80
|
"eslint-plugin-node": "^11.1.0",
|
|
81
81
|
"eslint-plugin-prettier": "^3.1.4",
|
|
82
|
-
"eslint-plugin-regexp": "^0.
|
|
82
|
+
"eslint-plugin-regexp": "^1.0.0",
|
|
83
83
|
"eslint-plugin-vue": "^7.0.1",
|
|
84
|
-
"eslint-plugin-yml": "^0.
|
|
84
|
+
"eslint-plugin-yml": "^0.10.0",
|
|
85
85
|
"eslint4b": "^7.3.1",
|
|
86
86
|
"espree": "^8.0.0",
|
|
87
87
|
"mocha": "^9.0.0",
|
|
88
|
-
"monaco-editor": "^0.
|
|
88
|
+
"monaco-editor": "^0.27.0",
|
|
89
89
|
"nyc": "^15.1.0",
|
|
90
90
|
"prettier": "^2.2.1",
|
|
91
91
|
"raw-loader": "^4.0.1",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"stylelint-config-standard": "^22.0.0",
|
|
95
95
|
"stylelint-plugin-stylus": "^0.11.0",
|
|
96
96
|
"ts-node": "^10.0.0",
|
|
97
|
-
"typescript": "
|
|
97
|
+
"typescript": "~4.4.3",
|
|
98
98
|
"vue-eslint-editor": "^1.1.0",
|
|
99
99
|
"vue-eslint-parser": "^7.3.0",
|
|
100
100
|
"vuepress": "^1.5.2"
|