eslint-plugin-yml 1.0.0 → 1.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 +33 -13
- package/lib/rules/plain-scalar.js +7 -1
- package/package.json +109 -105
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ e.g. [eslint-plugin-yaml](https://www.npmjs.com/package/eslint-plugin-yaml)
|
|
|
35
35
|
These plugins use the processor to parse and return the results independently, without providing the ESLint engine with AST and source code text.
|
|
36
36
|
|
|
37
37
|
Plugins don't provide AST, so you can't use directive comments (e.g. `# eslint-disable`).
|
|
38
|
-
Plugins don't provide source code text, so you can't use it with plugins and rules that use text (e.g. [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier), [eol-last](https://eslint.org/docs/rules/eol-last)).
|
|
38
|
+
Plugins don't provide source code text, so you can't use it with plugins and rules that use text (e.g. [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier), [eol-last](https://eslint.org/docs/rules/eol-last)).
|
|
39
39
|
|
|
40
40
|
**eslint-plugin-yml** works by providing AST and source code text to ESLint.
|
|
41
41
|
|
|
@@ -74,13 +74,13 @@ module.exports = {
|
|
|
74
74
|
extends: [
|
|
75
75
|
// add more generic rulesets here, such as:
|
|
76
76
|
// 'eslint:recommended',
|
|
77
|
-
|
|
77
|
+
"plugin:yml/standard",
|
|
78
78
|
],
|
|
79
79
|
rules: {
|
|
80
80
|
// override/add rules settings here, such as:
|
|
81
81
|
// 'yml/rule-name': 'error'
|
|
82
|
-
}
|
|
83
|
-
}
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
This plugin provides configs:
|
|
@@ -115,6 +115,29 @@ module.exports = {
|
|
|
115
115
|
};
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
+
#### Parser Options
|
|
119
|
+
|
|
120
|
+
The following parser options for `yaml-eslint-parser` are available by specifying them in [parserOptions](https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-parser-options) in the ESLint configuration file.
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
module.exports = {
|
|
124
|
+
// ...
|
|
125
|
+
overrides: [
|
|
126
|
+
{
|
|
127
|
+
files: ["*.yaml", "*.yml"],
|
|
128
|
+
parser: "yaml-eslint-parser",
|
|
129
|
+
// Options used with yaml-eslint-parser.
|
|
130
|
+
parserOptions: {
|
|
131
|
+
defaultYAMLVersion: "1.2",
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
// ...
|
|
136
|
+
};
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
See also [https://github.com/ota-meshi/yaml-eslint-parser#readme](https://github.com/ota-meshi/yaml-eslint-parser#readme).
|
|
140
|
+
|
|
118
141
|
### Running ESLint from the command line
|
|
119
142
|
|
|
120
143
|
If you want to run `eslint` from the command line, make sure you include the `.yaml` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern, because ESLint targets only `.js` files by default.
|
|
@@ -138,11 +161,7 @@ Example **.vscode/settings.json**:
|
|
|
138
161
|
|
|
139
162
|
```json
|
|
140
163
|
{
|
|
141
|
-
|
|
142
|
-
"javascript",
|
|
143
|
-
"javascriptreact",
|
|
144
|
-
"yaml"
|
|
145
|
-
]
|
|
164
|
+
"eslint.validate": ["javascript", "javascriptreact", "yaml"]
|
|
146
165
|
}
|
|
147
166
|
```
|
|
148
167
|
|
|
@@ -153,6 +172,7 @@ Following the steps in their help document, you can add YAML files to the scope
|
|
|
153
172
|
|
|
154
173
|
1. Open the **Settings/Preferences** dialog, go to **Languages and Frameworks** | **JavaScript** | **Code Quality Tools** | **ESLint**, and select **Automatic ESLint configuration** or **Manual ESLint configuration**.
|
|
155
174
|
2. In the **Run for files** field, update the pattern that defines the set of files to be linted to include YAML files as well:
|
|
175
|
+
|
|
156
176
|
```
|
|
157
177
|
{**/*,*}.{js,ts,jsx,tsx,html,vue,yaml,yml}
|
|
158
178
|
^^^^ ^^^
|
|
@@ -232,8 +252,8 @@ Please use GitHub's Issues/PRs.
|
|
|
232
252
|
|
|
233
253
|
### Development Tools
|
|
234
254
|
|
|
235
|
-
- `npm test` runs tests and measures coverage.
|
|
236
|
-
- `npm run update` runs in order to update readme and recommended configuration.
|
|
255
|
+
- `npm test` runs tests and measures coverage.
|
|
256
|
+
- `npm run update` runs in order to update readme and recommended configuration.
|
|
237
257
|
|
|
238
258
|
### Working With Rules
|
|
239
259
|
|
|
@@ -254,7 +274,7 @@ This plugin uses [yaml-eslint-parser](https://github.com/ota-meshi/yaml-eslint-p
|
|
|
254
274
|
|
|
255
275
|
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
|
|
256
276
|
|
|
257
|
-
[
|
|
277
|
+
[yaml]: https://yaml.org/
|
|
258
278
|
[eslint-plugin-json-schema-validator]: https://github.com/ota-meshi/eslint-plugin-json-schema-validator
|
|
259
279
|
[@intlify/eslint-plugin-vue-i18n]: https://github.com/intlify/eslint-plugin-vue-i18n
|
|
260
|
-
[
|
|
280
|
+
[vue i18n]: https://github.com/intlify/vue-i18n-next
|
|
@@ -65,6 +65,7 @@ exports.default = (0, utils_1.createRule)("plain-scalar", {
|
|
|
65
65
|
]
|
|
66
66
|
: []));
|
|
67
67
|
const sourceCode = context.getSourceCode();
|
|
68
|
+
let currentDocument;
|
|
68
69
|
function canToPlain(node) {
|
|
69
70
|
if (node.value !== node.value.trim()) {
|
|
70
71
|
return false;
|
|
@@ -115,7 +116,9 @@ exports.default = (0, utils_1.createRule)("plain-scalar", {
|
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
117
118
|
try {
|
|
118
|
-
const result = (0, yaml_eslint_parser_1.parseForESLint)(node.value
|
|
119
|
+
const result = (0, yaml_eslint_parser_1.parseForESLint)(node.value, {
|
|
120
|
+
defaultYAMLVersion: currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.version,
|
|
121
|
+
});
|
|
119
122
|
if ((0, yaml_eslint_parser_1.getStaticYAMLValue)(result.ast) !== node.value) {
|
|
120
123
|
return;
|
|
121
124
|
}
|
|
@@ -147,6 +150,9 @@ exports.default = (0, utils_1.createRule)("plain-scalar", {
|
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
return {
|
|
153
|
+
YAMLDocument(node) {
|
|
154
|
+
currentDocument = node;
|
|
155
|
+
},
|
|
150
156
|
YAMLScalar(node) {
|
|
151
157
|
if (!isStringScalar(node)) {
|
|
152
158
|
return;
|
package/package.json
CHANGED
|
@@ -1,107 +1,111 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
2
|
+
"name": "eslint-plugin-yml",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "This ESLint plugin provides linting rules for YAML.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib"
|
|
8
|
+
],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": "^14.17.0 || >=16.0.0"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"prebuild": "npm run -s clean",
|
|
14
|
+
"build": "npm run build:ts",
|
|
15
|
+
"build:ts": "tsc --project ./tsconfig.build.json",
|
|
16
|
+
"clean": "rimraf .nyc_output dist coverage",
|
|
17
|
+
"lint": "eslint . --ext .js,.vue,.ts,.json,.md,.yml,.yaml",
|
|
18
|
+
"eslint-fix": "eslint . --ext .js,.vue,.ts,.json,.md,.yml,.yaml --fix",
|
|
19
|
+
"pretest:base": "cross-env DEBUG=eslint-plugin-yml*",
|
|
20
|
+
"test:base": "npm run mocha -- \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
|
|
21
|
+
"test": "npm run test:base",
|
|
22
|
+
"cover": "nyc --reporter=lcov npm run test:base",
|
|
23
|
+
"test:debug": "npm run mocha -- \"tests/src/**/*.ts\" --reporter dot",
|
|
24
|
+
"update": "npm run ts -- ./tools/update.ts && npm run eslint-fix && npm run cover",
|
|
25
|
+
"new": "npm run ts -- ./tools/new-rule.ts",
|
|
26
|
+
"predocs:watch": "npm run build:ts",
|
|
27
|
+
"docs:watch": "export NODE_OPTIONS=--openssl-legacy-provider && vuepress dev --debug docs",
|
|
28
|
+
"docs:build": "export NODE_OPTIONS=--openssl-legacy-provider && npm run build:ts && vuepress build docs --no-cache",
|
|
29
|
+
"preversion": "npm test && git add .",
|
|
30
|
+
"version": "env-cmd -e version npm run update && git add .",
|
|
31
|
+
"update-fixtures": "npm run ts -- ./tools/update-fixtures.ts && npm run eslint-fix",
|
|
32
|
+
"ts": "node -r esbuild-register",
|
|
33
|
+
"mocha": "npm run ts -- ./node_modules/mocha/bin/mocha.js"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/ota-meshi/eslint-plugin-yml.git"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"eslint",
|
|
41
|
+
"eslintplugin",
|
|
42
|
+
"eslint-plugin",
|
|
43
|
+
"yaml",
|
|
44
|
+
"yml"
|
|
45
|
+
],
|
|
46
|
+
"author": "Yosuke Ota",
|
|
47
|
+
"funding": "https://github.com/sponsors/ota-meshi",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/ota-meshi/eslint-plugin-yml/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://ota-meshi.github.io/eslint-plugin-yml/",
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"debug": "^4.3.2",
|
|
55
|
+
"lodash": "^4.17.21",
|
|
56
|
+
"natural-compare": "^1.4.0",
|
|
57
|
+
"yaml-eslint-parser": "^1.1.0"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"eslint": ">=6.0.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@ota-meshi/eslint-plugin": "^0.11.0",
|
|
64
|
+
"@types/debug": "^4.1.5",
|
|
65
|
+
"@types/eslint": "^8.0.0",
|
|
66
|
+
"@types/eslint-scope": "^3.7.0",
|
|
67
|
+
"@types/eslint-visitor-keys": "^1.0.0",
|
|
68
|
+
"@types/estree": "^1.0.0",
|
|
69
|
+
"@types/lodash": "^4.14.158",
|
|
70
|
+
"@types/mocha": "^9.0.0",
|
|
71
|
+
"@types/natural-compare": "^1.4.0",
|
|
72
|
+
"@types/node": "^16.11.3",
|
|
73
|
+
"@types/semver": "^7.3.1",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
75
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
76
|
+
"cross-env": "^7.0.2",
|
|
77
|
+
"env-cmd": "^10.1.0",
|
|
78
|
+
"esbuild": "^0.14.1",
|
|
79
|
+
"esbuild-register": "^3.2.0",
|
|
80
|
+
"eslint": "^8.0.0",
|
|
81
|
+
"eslint-config-prettier": "^8.0.0",
|
|
82
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
83
|
+
"eslint-plugin-eslint-plugin": "^5.0.0",
|
|
84
|
+
"eslint-plugin-json-schema-validator": "^4.0.0",
|
|
85
|
+
"eslint-plugin-jsonc": "^2.0.0",
|
|
86
|
+
"eslint-plugin-markdown": "^3.0.0",
|
|
87
|
+
"eslint-plugin-node": "^11.1.0",
|
|
88
|
+
"eslint-plugin-node-dependencies": "^0.9.0",
|
|
89
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
90
|
+
"eslint-plugin-regexp": "^1.0.0",
|
|
91
|
+
"eslint-plugin-vue": "^9.0.0",
|
|
92
|
+
"eslint-plugin-yml": "^1.0.0",
|
|
93
|
+
"eslint4b": "^7.3.1",
|
|
94
|
+
"espree": "^9.0.0",
|
|
95
|
+
"mocha": "^10.0.0",
|
|
96
|
+
"monaco-editor": "^0.33.0",
|
|
97
|
+
"nyc": "^15.1.0",
|
|
98
|
+
"prettier": "^2.2.1",
|
|
99
|
+
"raw-loader": "^4.0.1",
|
|
100
|
+
"semver": "^7.3.2",
|
|
101
|
+
"stylelint": "^14.9.1",
|
|
102
|
+
"stylelint-config-recommended-vue": "^1.0.0",
|
|
103
|
+
"stylelint-config-standard": "^26.0.0",
|
|
104
|
+
"stylelint-stylus": "^0.16.1",
|
|
105
|
+
"typescript": "~4.7.0",
|
|
106
|
+
"vue-eslint-editor": "^1.1.0",
|
|
107
|
+
"vue-eslint-parser": "^9.0.0",
|
|
108
|
+
"vuepress": "^1.5.2",
|
|
109
|
+
"yaml": "^2.1.1"
|
|
110
|
+
}
|
|
107
111
|
}
|