eslint-plugin-yml 3.6.1 → 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 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: {
@@ -5210,6 +5277,7 @@ const rules$1 = [
5210
5277
  indent_default,
5211
5278
  key_name_casing_default,
5212
5279
  key_spacing_default,
5280
+ no_boolean_key_default,
5213
5281
  no_empty_document_default,
5214
5282
  no_empty_key_default,
5215
5283
  no_empty_mapping_value_default,
@@ -5426,7 +5494,7 @@ var prettier_default = [...base_default, { rules: {
5426
5494
  //#endregion
5427
5495
  //#region package.json
5428
5496
  var name$1 = "eslint-plugin-yml";
5429
- var version$1 = "3.6.1";
5497
+ var version$1 = "3.7.0";
5430
5498
  //#endregion
5431
5499
  //#region src/meta.ts
5432
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.6.1",
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",
@@ -115,9 +115,9 @@
115
115
  "prettier": "^3.0.3",
116
116
  "semver": "^7.3.2",
117
117
  "stylelint": "^17.0.0",
118
- "stylelint-config-recommended-vue": "^1.0.0",
118
+ "stylelint-config-recommended-vue": "^2.0.0",
119
119
  "stylelint-config-standard": "^40.0.0",
120
- "stylelint-config-standard-vue": "^1.0.0",
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",