eslint-plugin-yml 3.6.0 → 3.7.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 +1 -0
- package/lib/index.mjs +77 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -233,6 +233,7 @@ The rules with the following star :star: are included in the config.
|
|
|
233
233
|
| [yml/file-extension](https://ota-meshi.github.io/eslint-plugin-yml/rules/file-extension.html) | enforce YAML file extension | | | |
|
|
234
234
|
| [yml/indent](https://ota-meshi.github.io/eslint-plugin-yml/rules/indent.html) | enforce consistent indentation | :wrench: | | :star: |
|
|
235
235
|
| [yml/key-name-casing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-name-casing.html) | enforce naming convention to key names | | | |
|
|
236
|
+
| [yml/no-boolean-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-boolean-key.html) | disallow boolean mapping keys | | | |
|
|
236
237
|
| [yml/no-empty-document](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-document.html) | disallow empty document | | :star: | :star: |
|
|
237
238
|
| [yml/no-empty-key](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-key.html) | disallow empty mapping keys | | :star: | :star: |
|
|
238
239
|
| [yml/no-empty-mapping-value](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-empty-mapping-value.html) | disallow empty mapping values | | :star: | :star: |
|
package/lib/index.mjs
CHANGED
|
@@ -2985,6 +2985,73 @@ function create(context) {
|
|
|
2985
2985
|
}
|
|
2986
2986
|
}
|
|
2987
2987
|
//#endregion
|
|
2988
|
+
//#region src/rules/no-boolean-key.ts
|
|
2989
|
+
var no_boolean_key_default = createRule("no-boolean-key", {
|
|
2990
|
+
meta: {
|
|
2991
|
+
docs: {
|
|
2992
|
+
description: "disallow boolean mapping keys",
|
|
2993
|
+
categories: null,
|
|
2994
|
+
extensionRule: false,
|
|
2995
|
+
layout: false
|
|
2996
|
+
},
|
|
2997
|
+
schema: [],
|
|
2998
|
+
messages: { unexpectedBoolean: "Boolean mapping keys are not allowed." },
|
|
2999
|
+
type: "suggestion"
|
|
3000
|
+
},
|
|
3001
|
+
create(context) {
|
|
3002
|
+
if (!context.sourceCode.parserServices?.isYAML) return {};
|
|
3003
|
+
let anchors = {};
|
|
3004
|
+
/**
|
|
3005
|
+
* Find the closest preceding anchor for the given alias.
|
|
3006
|
+
*/
|
|
3007
|
+
function findAnchor(alias) {
|
|
3008
|
+
const target = {
|
|
3009
|
+
anchor: null,
|
|
3010
|
+
distance: Infinity
|
|
3011
|
+
};
|
|
3012
|
+
for (const anchor of anchors[alias.name] || []) if (anchor.range[0] < alias.range[0]) {
|
|
3013
|
+
const distance = alias.range[0] - anchor.range[0];
|
|
3014
|
+
if (target.distance >= distance) {
|
|
3015
|
+
target.anchor = anchor;
|
|
3016
|
+
target.distance = distance;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
return target.anchor;
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Check whether the given node resolves to a boolean.
|
|
3023
|
+
*/
|
|
3024
|
+
function isBooleanNode(node) {
|
|
3025
|
+
if (!node) return false;
|
|
3026
|
+
if (node.type === "YAMLWithMeta") {
|
|
3027
|
+
if (node.tag) return node.tag.tag === "tag:yaml.org,2002:bool";
|
|
3028
|
+
return isBooleanNode(node.value);
|
|
3029
|
+
}
|
|
3030
|
+
if (node.type === "YAMLAlias") {
|
|
3031
|
+
const anchor = findAnchor(node);
|
|
3032
|
+
if (!anchor) return false;
|
|
3033
|
+
return isBooleanNode(anchor.parent);
|
|
3034
|
+
}
|
|
3035
|
+
if (node.type !== "YAMLScalar") return false;
|
|
3036
|
+
return typeof node.value === "boolean";
|
|
3037
|
+
}
|
|
3038
|
+
return {
|
|
3039
|
+
YAMLDocument() {
|
|
3040
|
+
anchors = {};
|
|
3041
|
+
},
|
|
3042
|
+
YAMLAnchor(node) {
|
|
3043
|
+
(anchors[node.name] || (anchors[node.name] = [])).push(node);
|
|
3044
|
+
},
|
|
3045
|
+
YAMLPair(node) {
|
|
3046
|
+
if (isBooleanNode(node.key)) context.report({
|
|
3047
|
+
node: node.key || node,
|
|
3048
|
+
messageId: "unexpectedBoolean"
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
};
|
|
3052
|
+
}
|
|
3053
|
+
});
|
|
3054
|
+
//#endregion
|
|
2988
3055
|
//#region src/rules/no-empty-document.ts
|
|
2989
3056
|
var no_empty_document_default = createRule("no-empty-document", {
|
|
2990
3057
|
meta: {
|
|
@@ -4426,7 +4493,10 @@ var sort_keys_default = createRule("sort-keys", {
|
|
|
4426
4493
|
yield fixer.removeRange(removeRange);
|
|
4427
4494
|
yield fixer.insertTextAfterRange(moveTargetRange, `${isAtFileStart ? "\n" : ""}${insertCode}`);
|
|
4428
4495
|
} else {
|
|
4429
|
-
const nextToken = sourceCode.getTokenAfter(data.node, {
|
|
4496
|
+
const nextToken = sourceCode.getTokenAfter(data.node, {
|
|
4497
|
+
includeComments: true,
|
|
4498
|
+
filter: (t) => !isCommentToken(t) || data.node.loc.end.line < t.loc.start.line
|
|
4499
|
+
});
|
|
4430
4500
|
const removeRange = [data.node.range[0], nextToken.range[0]];
|
|
4431
4501
|
yield fixer.removeRange(removeRange);
|
|
4432
4502
|
const insertCode = `\n${sourceCode.text.slice(sourceCode.getIndexFromLoc({
|
|
@@ -4495,7 +4565,10 @@ var sort_keys_default = createRule("sort-keys", {
|
|
|
4495
4565
|
};
|
|
4496
4566
|
const beforeToken = sourceCode.getTokenBefore(node);
|
|
4497
4567
|
if (beforeToken) {
|
|
4498
|
-
const next = sourceCode.getTokenAfter(beforeToken, {
|
|
4568
|
+
const next = sourceCode.getTokenAfter(beforeToken, {
|
|
4569
|
+
includeComments: true,
|
|
4570
|
+
filter: (t) => !isCommentToken(t) || beforeToken.loc.end.line < t.loc.start.line
|
|
4571
|
+
});
|
|
4499
4572
|
if (beforeToken.loc.end.line < next.loc.start.line || beforeToken.loc.end.line < node.loc.start.line) {
|
|
4500
4573
|
const start = {
|
|
4501
4574
|
line: beforeToken.loc.end.line < next.loc.start.line ? next.loc.start.line : node.loc.start.line,
|
|
@@ -5204,6 +5277,7 @@ const rules$1 = [
|
|
|
5204
5277
|
indent_default,
|
|
5205
5278
|
key_name_casing_default,
|
|
5206
5279
|
key_spacing_default,
|
|
5280
|
+
no_boolean_key_default,
|
|
5207
5281
|
no_empty_document_default,
|
|
5208
5282
|
no_empty_key_default,
|
|
5209
5283
|
no_empty_mapping_value_default,
|
|
@@ -5420,7 +5494,7 @@ var prettier_default = [...base_default, { rules: {
|
|
|
5420
5494
|
//#endregion
|
|
5421
5495
|
//#region package.json
|
|
5422
5496
|
var name$1 = "eslint-plugin-yml";
|
|
5423
|
-
var version$1 = "3.
|
|
5497
|
+
var version$1 = "3.7.0";
|
|
5424
5498
|
//#endregion
|
|
5425
5499
|
//#region src/meta.ts
|
|
5426
5500
|
var meta_exports = /* @__PURE__ */ __exportAll({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-yml",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "This ESLint plugin provides linting rules for YAML.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.mjs",
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
"@types/natural-compare": "^1.4.0",
|
|
90
90
|
"@types/node": "^24.0.0",
|
|
91
91
|
"@types/semver": "^7.3.1",
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "~8.
|
|
93
|
-
"@typescript-eslint/parser": "~8.
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "~8.65.0",
|
|
93
|
+
"@typescript-eslint/parser": "~8.65.0",
|
|
94
94
|
"cross-env": "^10.0.0",
|
|
95
95
|
"env-cmd": "^11.0.0",
|
|
96
96
|
"eslint": "^10.0.0",
|
|
@@ -109,15 +109,15 @@
|
|
|
109
109
|
"eslint-plugin-yml": "^3.0.0",
|
|
110
110
|
"events": "^3.3.0",
|
|
111
111
|
"mocha": "^11.0.0",
|
|
112
|
-
"monaco-editor": "^0.
|
|
112
|
+
"monaco-editor": "^0.56.0",
|
|
113
113
|
"nyc": "^18.0.0",
|
|
114
114
|
"pako": "^3.0.0",
|
|
115
115
|
"prettier": "^3.0.3",
|
|
116
116
|
"semver": "^7.3.2",
|
|
117
117
|
"stylelint": "^17.0.0",
|
|
118
|
-
"stylelint-config-recommended-vue": "^
|
|
118
|
+
"stylelint-config-recommended-vue": "^2.0.0",
|
|
119
119
|
"stylelint-config-standard": "^40.0.0",
|
|
120
|
-
"stylelint-config-standard-vue": "^
|
|
120
|
+
"stylelint-config-standard-vue": "^2.0.0",
|
|
121
121
|
"stylelint-stylus": "^1.0.0",
|
|
122
122
|
"tsdown": "^0.22.0",
|
|
123
123
|
"tsx": "^4.21.0",
|