@lvce-editor/eslint-plugin-github-actions 2.4.0 → 2.6.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.
Files changed (2) hide show
  1. package/dist/index.js +229 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,19 +12,23 @@ const platforms = {
12
12
  macos: 'macos'
13
13
  };
14
14
  const actions = {
15
- 'actions/checkout': ['actions/checkout@v4'],
15
+ 'actions/checkout': ['actions/checkout@v5'],
16
16
  'actions/setup-node': ['actions/setup-node@v6'],
17
17
  'actions/cache': ['actions/cache@v4'],
18
18
  'actions/upload-pages-artifact': ['actions/upload-pages-artifact@v4'],
19
19
  'actions/deploy-pages': ['actions/deploy-pages@v4'],
20
20
  'actions/download-artifact': ['actions/download-artifact@v4'],
21
- 'actions/upload-artifact': ['actions/upload-artifact@v4']
21
+ 'actions/upload-artifact': ['actions/upload-artifact@v4'],
22
+ 'actions/create-release': ['actions/create-release@v1']
22
23
  };
24
+ const npmRegistries = ['https://registry.npmjs.org', 'https://npm.pkg.github.com'];
25
+ const onProperties = ['push', 'pull_request'];
26
+ const npmCommands = ['run', 'test', 'publish', 'install', 'ci'];
23
27
 
24
28
  const isSupported = (actions, value) => {
25
29
  return actions.includes(value);
26
30
  };
27
- const meta$2 = {
31
+ const meta$7 = {
28
32
  type: 'problem',
29
33
  docs: {
30
34
  description: 'Disallow unsupported action versions'
@@ -33,7 +37,7 @@ const meta$2 = {
33
37
  unsupportedActionVersion: 'Unsupported action version: {{value}}'
34
38
  }
35
39
  };
36
- const create$2 = context => {
40
+ const create$7 = context => {
37
41
  const sourceCode = getSourceCode(context);
38
42
  if (!sourceCode.parserServices?.isYAML) {
39
43
  return {};
@@ -60,8 +64,8 @@ const create$2 = context => {
60
64
 
61
65
  const actionVersions = {
62
66
  __proto__: null,
63
- create: create$2,
64
- meta: meta$2
67
+ create: create$7,
68
+ meta: meta$7
65
69
  };
66
70
 
67
71
  const parseVersion = value => {
@@ -85,7 +89,7 @@ const isSupportedMacosversion = version => {
85
89
  const isSupportedWindowsVersion = version => {
86
90
  return config.windows.includes(version);
87
91
  };
88
- const meta$1 = {
92
+ const meta$6 = {
89
93
  type: 'problem',
90
94
  docs: {
91
95
  description: 'Disallow unsupported ci versions'
@@ -94,7 +98,7 @@ const meta$1 = {
94
98
  unsupportedCiVersion: 'Unsupported ci version: {{value}}'
95
99
  }
96
100
  };
97
- const create$1 = context => {
101
+ const create$6 = context => {
98
102
  const sourceCode = getSourceCode(context);
99
103
  if (!sourceCode.parserServices?.isYAML) {
100
104
  return {};
@@ -137,11 +141,161 @@ const create$1 = context => {
137
141
 
138
142
  const ciVersions = {
139
143
  __proto__: null,
140
- create: create$1,
141
- meta: meta$1
144
+ create: create$6,
145
+ meta: meta$6
142
146
  };
143
147
 
144
- const meta = {
148
+ const meta$5 = {
149
+ type: 'problem',
150
+ docs: {
151
+ description: 'Disallow unsupported fail fast values'
152
+ },
153
+ messages: {
154
+ unsupportedFailFast: 'Unsupported fail fast value: {{value}}'
155
+ }
156
+ };
157
+ const create$5 = context => {
158
+ const sourceCode = getSourceCode(context);
159
+ if (!sourceCode.parserServices?.isYAML) {
160
+ return {};
161
+ }
162
+ return {
163
+ YAMLPair(node) {
164
+ if (node && node.type === 'YAMLPair' && node.key && typeof node.key === 'object' && 'type' in node.key && node.key.type === 'YAMLScalar' && typeof node.key.value === 'string' && node.key.value === 'fail-fast' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar' && typeof node.value.value !== 'boolean') {
165
+ const nodeValue = node.value.value;
166
+ context.report({
167
+ node,
168
+ messageId: 'unsupportedFailFast',
169
+ data: {
170
+ value: nodeValue
171
+ }
172
+ });
173
+ }
174
+ }
175
+ };
176
+ };
177
+
178
+ const failFast = {
179
+ __proto__: null,
180
+ create: create$5,
181
+ meta: meta$5
182
+ };
183
+
184
+ const meta$4 = {
185
+ type: 'problem',
186
+ docs: {
187
+ description: 'Disallow unsupported max parallel values'
188
+ },
189
+ messages: {
190
+ unsupportedMaxParallel: 'Unsupported max parallel value: {{value}}'
191
+ }
192
+ };
193
+ const create$4 = context => {
194
+ const sourceCode = getSourceCode(context);
195
+ if (!sourceCode.parserServices?.isYAML) {
196
+ return {};
197
+ }
198
+ return {
199
+ YAMLPair(node) {
200
+ if (node && node.type === 'YAMLPair' && node.key && typeof node.key === 'object' && 'type' in node.key && node.key.type === 'YAMLScalar' && typeof node.key.value === 'string' && node.key.value === 'max-parallel' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar' && typeof node.value.value !== 'number') {
201
+ const nodeValue = node.value.value;
202
+ context.report({
203
+ node,
204
+ messageId: 'unsupportedMaxParallel',
205
+ data: {
206
+ value: nodeValue
207
+ }
208
+ });
209
+ }
210
+ }
211
+ };
212
+ };
213
+
214
+ const maxParallel = {
215
+ __proto__: null,
216
+ create: create$4,
217
+ meta: meta$4
218
+ };
219
+
220
+ const meta$3 = {
221
+ type: 'problem',
222
+ docs: {
223
+ description: 'Disallow unsupported npm registry values'
224
+ },
225
+ messages: {
226
+ unsupportedNpmRegistry: 'Unsupported npm registry value: {{value}}'
227
+ }
228
+ };
229
+ const create$3 = context => {
230
+ const sourceCode = getSourceCode(context);
231
+ if (!sourceCode.parserServices?.isYAML) {
232
+ return {};
233
+ }
234
+ return {
235
+ YAMLPair(node) {
236
+ if (node && node.type === 'YAMLPair' && node.key && typeof node.key === 'object' && 'type' in node.key && node.key.type === 'YAMLScalar' && typeof node.key.value === 'string' && node.key.value === 'registry-url' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar') {
237
+ const nodeValue = node.value.value;
238
+ if (typeof nodeValue !== 'string' || !npmRegistries.includes(nodeValue)) {
239
+ context.report({
240
+ node,
241
+ messageId: 'unsupportedNpmRegistry',
242
+ data: {
243
+ value: nodeValue
244
+ }
245
+ });
246
+ }
247
+ }
248
+ }
249
+ };
250
+ };
251
+
252
+ const npmRegistry = {
253
+ __proto__: null,
254
+ create: create$3,
255
+ meta: meta$3
256
+ };
257
+
258
+ const meta$2 = {
259
+ type: 'problem',
260
+ docs: {
261
+ description: 'Disallow unsupported on values'
262
+ },
263
+ messages: {
264
+ unsupportedOn: 'Unsupported on value: {{value}}'
265
+ }
266
+ };
267
+ const create$2 = context => {
268
+ const sourceCode = getSourceCode(context);
269
+ if (!sourceCode.parserServices?.isYAML) {
270
+ return {};
271
+ }
272
+ return {
273
+ YAMLPair(node) {
274
+ if (node && node.type === 'YAMLPair' && node.key && typeof node.key === 'object' && 'type' in node.key && node.key.type === 'YAMLScalar' && typeof node.key.value === 'string' && node.key.value === 'on' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLMapping') {
275
+ const pairs = node.value.pairs;
276
+ for (const pair of pairs) {
277
+ if (pair.key && pair.key.type === 'YAMLScalar' && typeof pair.key.value === 'string' && !onProperties.includes(pair.key.value)) {
278
+ context.report({
279
+ node,
280
+ messageId: 'unsupportedOn',
281
+ data: {
282
+ value: pair.key.value
283
+ }
284
+ });
285
+ }
286
+ }
287
+ }
288
+ }
289
+ };
290
+ };
291
+
292
+ const on = {
293
+ __proto__: null,
294
+ create: create$2,
295
+ meta: meta$2
296
+ };
297
+
298
+ const meta$1 = {
145
299
  type: 'problem',
146
300
  docs: {
147
301
  description: 'Disallow unsupported timeout minute values'
@@ -150,7 +304,7 @@ const meta = {
150
304
  unsupportedTimeoutMinutes: 'Unsupported timeout minutes value: {{value}}'
151
305
  }
152
306
  };
153
- const create = context => {
307
+ const create$1 = context => {
154
308
  const sourceCode = getSourceCode(context);
155
309
  if (!sourceCode.parserServices?.isYAML) {
156
310
  return {};
@@ -172,6 +326,55 @@ const create = context => {
172
326
  };
173
327
 
174
328
  const timeoutMinutes = {
329
+ __proto__: null,
330
+ create: create$1,
331
+ meta: meta$1
332
+ };
333
+
334
+ const meta = {
335
+ type: 'problem',
336
+ docs: {
337
+ description: 'Disallow unsupported npm commands'
338
+ },
339
+ messages: {
340
+ unsupportedNpmCommand: 'Unsupported npm command: {{value}}'
341
+ }
342
+ };
343
+ const isSupportedNpmCommand = value => {
344
+ for (const npmCommand of npmCommands) {
345
+ if (value.startsWith(npmCommand)) {
346
+ return true;
347
+ }
348
+ }
349
+ return false;
350
+ };
351
+ const create = context => {
352
+ const sourceCode = getSourceCode(context);
353
+ if (!sourceCode.parserServices?.isYAML) {
354
+ return {};
355
+ }
356
+ return {
357
+ YAMLPair(node) {
358
+ if (node && node.type === 'YAMLPair' && node.key && typeof node.key === 'object' && 'type' in node.key && node.key.type === 'YAMLScalar' && typeof node.key.value === 'string' && node.key.value === 'run' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar' && typeof node.value.value === 'string') {
359
+ const nodeValue = node.value.value;
360
+ if (nodeValue.startsWith('npm ')) {
361
+ const rest = nodeValue.slice('npm '.length);
362
+ if (!isSupportedNpmCommand(rest)) {
363
+ context.report({
364
+ node,
365
+ messageId: 'unsupportedNpmCommand',
366
+ data: {
367
+ value: nodeValue
368
+ }
369
+ });
370
+ }
371
+ }
372
+ }
373
+ }
374
+ };
375
+ };
376
+
377
+ const npm = {
175
378
  __proto__: null,
176
379
  create,
177
380
  meta
@@ -183,9 +386,14 @@ const plugin = {
183
386
  version: '0.0.1'
184
387
  },
185
388
  rules: {
186
- 'ci-versions': ciVersions,
187
389
  'action-versions': actionVersions,
188
- 'timeout-minutes': timeoutMinutes
390
+ 'ci-versions': ciVersions,
391
+ 'fail-fast': failFast,
392
+ 'max-parallel': maxParallel,
393
+ 'npm-registry': npmRegistry,
394
+ 'timeout-minutes': timeoutMinutes,
395
+ on: on,
396
+ npm: npm
189
397
  }
190
398
  };
191
399
  const recommended = [{
@@ -197,8 +405,14 @@ const recommended = [{
197
405
  parser: parserYAML
198
406
  },
199
407
  rules: {
408
+ 'github-actions/action-versions': 'error',
200
409
  'github-actions/ci-versions': 'error',
201
- 'github-actions/action-versions': 'error'
410
+ 'github-actions/fail-fast': 'error',
411
+ 'github-actions/max-parallel': 'error',
412
+ 'github-actions/npm-registry': 'error',
413
+ 'github-actions/npm': 'error',
414
+ 'github-actions/on': 'error',
415
+ 'github-actions/timeout-minutes': 'error'
202
416
  }
203
417
  }];
204
418
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-github-actions",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],