eslint-plugin-yml 3.3.2 → 3.5.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.d.mts +2 -1
- package/lib/index.mjs +98 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -257,6 +257,7 @@ The rules with the following star :star: are included in the config.
|
|
|
257
257
|
| [yml/key-spacing](https://ota-meshi.github.io/eslint-plugin-yml/rules/key-spacing.html) | enforce consistent spacing between keys and values in mapping pairs | :wrench: | | :star: |
|
|
258
258
|
| [yml/no-irregular-whitespace](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-irregular-whitespace.html) | disallow irregular whitespace | | :star: | :star: |
|
|
259
259
|
| [yml/no-multiple-empty-lines](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-multiple-empty-lines.html) | disallow multiple empty lines | :wrench: | | :star: |
|
|
260
|
+
| [yml/no-trailing-spaces](https://ota-meshi.github.io/eslint-plugin-yml/rules/no-trailing-spaces.html) | disallow trailing whitespace at the end of lines | :wrench: | | :star: |
|
|
260
261
|
| [yml/spaced-comment](https://ota-meshi.github.io/eslint-plugin-yml/rules/spaced-comment.html) | enforce consistent spacing after the `#` in a comment | :wrench: | | :star: |
|
|
261
262
|
|
|
262
263
|
<!--RULES_TABLE_END-->
|
package/lib/index.d.mts
CHANGED
|
@@ -7,10 +7,11 @@ import { Linter, Scope } from "eslint";
|
|
|
7
7
|
|
|
8
8
|
//#region src/meta.d.ts
|
|
9
9
|
declare namespace meta_d_exports {
|
|
10
|
-
export { name, version };
|
|
10
|
+
export { name, namespace, version };
|
|
11
11
|
}
|
|
12
12
|
declare const name: string;
|
|
13
13
|
declare const version: string;
|
|
14
|
+
declare const namespace = "yml";
|
|
14
15
|
//#endregion
|
|
15
16
|
//#region src/language/yaml-source-code.d.ts
|
|
16
17
|
/**
|
package/lib/index.mjs
CHANGED
|
@@ -3376,6 +3376,99 @@ var no_tab_indent_default = createRule("no-tab-indent", {
|
|
|
3376
3376
|
}
|
|
3377
3377
|
});
|
|
3378
3378
|
//#endregion
|
|
3379
|
+
//#region src/rules/no-trailing-spaces.ts
|
|
3380
|
+
const BLANK_CLASS = "[\\t \\u00a0\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u200b\\u3000]";
|
|
3381
|
+
const TRAILING_SPACES = new RegExp(`${BLANK_CLASS}+$`, "u");
|
|
3382
|
+
const BLANK_LINE = new RegExp(`^${BLANK_CLASS}*$`, "u");
|
|
3383
|
+
/** Check whether a reported whitespace range is fully inside a known range. */
|
|
3384
|
+
function isInRange(rangeStart, rangeEnd, range) {
|
|
3385
|
+
return range[0] <= rangeStart && rangeEnd <= range[1];
|
|
3386
|
+
}
|
|
3387
|
+
var no_trailing_spaces_default = createRule("no-trailing-spaces", {
|
|
3388
|
+
meta: {
|
|
3389
|
+
docs: {
|
|
3390
|
+
description: "disallow trailing whitespace at the end of lines",
|
|
3391
|
+
categories: ["standard"],
|
|
3392
|
+
extensionRule: "no-trailing-spaces",
|
|
3393
|
+
layout: true
|
|
3394
|
+
},
|
|
3395
|
+
fixable: "whitespace",
|
|
3396
|
+
schema: [{
|
|
3397
|
+
type: "object",
|
|
3398
|
+
properties: {
|
|
3399
|
+
skipBlankLines: {
|
|
3400
|
+
type: "boolean",
|
|
3401
|
+
default: false
|
|
3402
|
+
},
|
|
3403
|
+
ignoreComments: {
|
|
3404
|
+
type: "boolean",
|
|
3405
|
+
default: false
|
|
3406
|
+
}
|
|
3407
|
+
},
|
|
3408
|
+
additionalProperties: false
|
|
3409
|
+
}],
|
|
3410
|
+
messages: { trailingSpace: "Trailing spaces not allowed." },
|
|
3411
|
+
type: "layout"
|
|
3412
|
+
},
|
|
3413
|
+
create(context) {
|
|
3414
|
+
const sourceCode = context.sourceCode;
|
|
3415
|
+
if (!sourceCode.parserServices?.isYAML) return {};
|
|
3416
|
+
const options = context.options[0] || {};
|
|
3417
|
+
const skipBlankLines = Boolean(options.skipBlankLines);
|
|
3418
|
+
const ignoreComments = Boolean(options.ignoreComments);
|
|
3419
|
+
const scalarRanges = [];
|
|
3420
|
+
/** Check ranges that should not be reported or fixed. */
|
|
3421
|
+
function isIgnoredRange(lineNumber, rangeStart, rangeEnd) {
|
|
3422
|
+
if (ignoreComments && sourceCode.getAllComments().some((comment) => isInRange(rangeStart, rangeEnd, comment.range))) return true;
|
|
3423
|
+
return scalarRanges.some((scalar) => lineNumber > scalar.startLine && isInRange(rangeStart, rangeEnd, scalar.range));
|
|
3424
|
+
}
|
|
3425
|
+
return {
|
|
3426
|
+
YAMLScalar(node) {
|
|
3427
|
+
if (node.loc.start.line < node.loc.end.line) scalarRanges.push({
|
|
3428
|
+
range: node.range,
|
|
3429
|
+
startLine: node.loc.start.line
|
|
3430
|
+
});
|
|
3431
|
+
},
|
|
3432
|
+
"Program:exit"() {
|
|
3433
|
+
for (let lineIndex = 0; lineIndex < sourceCode.lines.length; lineIndex++) {
|
|
3434
|
+
const line = sourceCode.lines[lineIndex];
|
|
3435
|
+
const match = TRAILING_SPACES.exec(line);
|
|
3436
|
+
if (!match) continue;
|
|
3437
|
+
if (skipBlankLines && BLANK_LINE.test(line)) continue;
|
|
3438
|
+
const lineNumber = lineIndex + 1;
|
|
3439
|
+
const startColumn = match.index;
|
|
3440
|
+
const endColumn = line.length;
|
|
3441
|
+
const rangeStart = sourceCode.getIndexFromLoc({
|
|
3442
|
+
line: lineNumber,
|
|
3443
|
+
column: startColumn
|
|
3444
|
+
});
|
|
3445
|
+
const rangeEnd = sourceCode.getIndexFromLoc({
|
|
3446
|
+
line: lineNumber,
|
|
3447
|
+
column: endColumn
|
|
3448
|
+
});
|
|
3449
|
+
if (isIgnoredRange(lineNumber, rangeStart, rangeEnd)) continue;
|
|
3450
|
+
context.report({
|
|
3451
|
+
loc: {
|
|
3452
|
+
start: {
|
|
3453
|
+
line: lineNumber,
|
|
3454
|
+
column: startColumn
|
|
3455
|
+
},
|
|
3456
|
+
end: {
|
|
3457
|
+
line: lineNumber,
|
|
3458
|
+
column: endColumn
|
|
3459
|
+
}
|
|
3460
|
+
},
|
|
3461
|
+
messageId: "trailingSpace",
|
|
3462
|
+
fix(fixer) {
|
|
3463
|
+
return fixer.removeRange([rangeStart, rangeEnd]);
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
};
|
|
3469
|
+
}
|
|
3470
|
+
});
|
|
3471
|
+
//#endregion
|
|
3379
3472
|
//#region src/rules/no-trailing-zeros.ts
|
|
3380
3473
|
var no_trailing_zeros_default = createRule("no-trailing-zeros", {
|
|
3381
3474
|
meta: {
|
|
@@ -5088,6 +5181,7 @@ const rules$1 = [
|
|
|
5088
5181
|
no_irregular_whitespace_default,
|
|
5089
5182
|
no_multiple_empty_lines_default,
|
|
5090
5183
|
no_tab_indent_default,
|
|
5184
|
+
no_trailing_spaces_default,
|
|
5091
5185
|
no_trailing_zeros_default,
|
|
5092
5186
|
plain_scalar_default,
|
|
5093
5187
|
quotes_default,
|
|
@@ -5269,6 +5363,7 @@ var standard_default = [...base_default, { rules: {
|
|
|
5269
5363
|
"yml/no-irregular-whitespace": "error",
|
|
5270
5364
|
"yml/no-multiple-empty-lines": "error",
|
|
5271
5365
|
"yml/no-tab-indent": "error",
|
|
5366
|
+
"yml/no-trailing-spaces": "error",
|
|
5272
5367
|
"yml/no-trailing-zeros": "error",
|
|
5273
5368
|
"yml/plain-scalar": "error",
|
|
5274
5369
|
"yml/quotes": "error",
|
|
@@ -5288,17 +5383,19 @@ var prettier_default = [...base_default, { rules: {
|
|
|
5288
5383
|
"yml/indent": "off",
|
|
5289
5384
|
"yml/key-spacing": "off",
|
|
5290
5385
|
"yml/no-multiple-empty-lines": "off",
|
|
5386
|
+
"yml/no-trailing-spaces": "off",
|
|
5291
5387
|
"yml/no-trailing-zeros": "off",
|
|
5292
5388
|
"yml/quotes": "off"
|
|
5293
5389
|
} }];
|
|
5294
5390
|
//#endregion
|
|
5295
5391
|
//#region package.json
|
|
5296
5392
|
var name$1 = "eslint-plugin-yml";
|
|
5297
|
-
var version$1 = "3.
|
|
5393
|
+
var version$1 = "3.5.0";
|
|
5298
5394
|
//#endregion
|
|
5299
5395
|
//#region src/meta.ts
|
|
5300
5396
|
var meta_exports = /* @__PURE__ */ __exportAll({
|
|
5301
5397
|
name: () => name,
|
|
5398
|
+
namespace: () => "yml",
|
|
5302
5399
|
version: () => version
|
|
5303
5400
|
});
|
|
5304
5401
|
const name = name$1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-yml",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "This ESLint plugin provides linting rules for YAML.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.mjs",
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
"eslint": ">=9.38.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@changesets/changelog-github": "^0.
|
|
79
|
+
"@changesets/changelog-github": "^0.7.0",
|
|
80
80
|
"@changesets/cli": "^2.24.2",
|
|
81
81
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
82
82
|
"@eslint/eslintrc": "^3.1.0",
|
|
83
83
|
"@eslint/js": "^10.0.0",
|
|
84
|
-
"@eslint/json": "^
|
|
84
|
+
"@eslint/json": "^2.0.0",
|
|
85
85
|
"@ota-meshi/eslint-plugin": "^0.20.0",
|
|
86
86
|
"@ota-meshi/site-kit-eslint-editor-vue": "^0.2.0",
|
|
87
87
|
"@stylistic/eslint-plugin": "^5.7.0",
|
|
@@ -89,19 +89,19 @@
|
|
|
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.62.0",
|
|
93
|
+
"@typescript-eslint/parser": "~8.62.0",
|
|
94
94
|
"cross-env": "^10.0.0",
|
|
95
95
|
"env-cmd": "^11.0.0",
|
|
96
96
|
"eslint": "^10.0.0",
|
|
97
97
|
"eslint-config-prettier": "^10.0.0",
|
|
98
98
|
"eslint-plugin-eslint-plugin": "^7.0.0",
|
|
99
99
|
"eslint-plugin-eslint-rule-tester": "^0.6.0",
|
|
100
|
-
"eslint-plugin-jsdoc": "^
|
|
100
|
+
"eslint-plugin-jsdoc": "^63.0.0",
|
|
101
101
|
"eslint-plugin-json-schema-validator": "^6.0.0",
|
|
102
102
|
"eslint-plugin-jsonc": "^3.0.0",
|
|
103
103
|
"eslint-plugin-markdown": "^5.0.0",
|
|
104
|
-
"eslint-plugin-n": "^
|
|
104
|
+
"eslint-plugin-n": "^18.0.0",
|
|
105
105
|
"eslint-plugin-node-dependencies": "^2.0.0",
|
|
106
106
|
"eslint-plugin-prettier": "^5.0.0",
|
|
107
107
|
"eslint-plugin-regexp": "^3.0.0",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"stylelint-config-standard": "^40.0.0",
|
|
120
120
|
"stylelint-config-standard-vue": "^1.0.0",
|
|
121
121
|
"stylelint-stylus": "^1.0.0",
|
|
122
|
-
"tsdown": "^0.
|
|
122
|
+
"tsdown": "^0.22.0",
|
|
123
123
|
"tsx": "^4.21.0",
|
|
124
124
|
"typescript": "~6.0.0",
|
|
125
125
|
"typescript-eslint": "^8.0.0",
|