@lvce-editor/eslint-plugin-github-actions 2.7.0 → 2.9.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 +176 -56
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -24,20 +24,22 @@ const actions = {
24
24
  const npmRegistries = ['https://registry.npmjs.org', 'https://npm.pkg.github.com'];
25
25
  const onProperties = ['push', 'pull_request'];
26
26
  const npmCommands = ['run', 'test', 'publish', 'install', 'ci'];
27
+ const shells = ['bash'];
27
28
 
28
29
  const isSupported = (actions, value) => {
29
30
  return actions.includes(value);
30
31
  };
31
- const meta$7 = {
32
+ const meta$a = {
32
33
  type: 'problem',
33
34
  docs: {
34
35
  description: 'Disallow unsupported action versions'
35
36
  },
36
37
  messages: {
37
38
  unsupportedActionVersion: 'Unsupported action version: {{value}}'
38
- }
39
+ },
40
+ fixable: 'code'
39
41
  };
40
- const create$7 = context => {
42
+ const create$a = context => {
41
43
  const sourceCode = getSourceCode(context);
42
44
  if (!sourceCode.parserServices?.isYAML) {
43
45
  return {};
@@ -49,10 +51,14 @@ const create$7 = context => {
49
51
  for (const [key, value] of Object.entries(actions)) {
50
52
  if (nodeValue.startsWith(key) && !isSupported(value, nodeValue)) {
51
53
  context.report({
52
- node,
54
+ node: node.value,
53
55
  messageId: 'unsupportedActionVersion',
54
56
  data: {
55
57
  value: nodeValue
58
+ },
59
+ fix(fixer) {
60
+ const validText = value.at(-1) || '';
61
+ return fixer.replaceText(node.value, validText);
56
62
  }
57
63
  });
58
64
  }
@@ -64,8 +70,8 @@ const create$7 = context => {
64
70
 
65
71
  const actionVersions = {
66
72
  __proto__: null,
67
- create: create$7,
68
- meta: meta$7
73
+ create: create$a,
74
+ meta: meta$a
69
75
  };
70
76
 
71
77
  const parseVersion = value => {
@@ -89,7 +95,7 @@ const isSupportedMacosversion = version => {
89
95
  const isSupportedWindowsVersion = version => {
90
96
  return config.windows.includes(version);
91
97
  };
92
- const meta$6 = {
98
+ const meta$9 = {
93
99
  type: 'problem',
94
100
  docs: {
95
101
  description: 'Disallow unsupported ci versions'
@@ -98,7 +104,7 @@ const meta$6 = {
98
104
  unsupportedCiVersion: 'Unsupported ci version: {{value}}'
99
105
  }
100
106
  };
101
- const create$6 = context => {
107
+ const create$9 = context => {
102
108
  const sourceCode = getSourceCode(context);
103
109
  if (!sourceCode.parserServices?.isYAML) {
104
110
  return {};
@@ -141,11 +147,11 @@ const create$6 = context => {
141
147
 
142
148
  const ciVersions = {
143
149
  __proto__: null,
144
- create: create$6,
145
- meta: meta$6
150
+ create: create$9,
151
+ meta: meta$9
146
152
  };
147
153
 
148
- const meta$5 = {
154
+ const meta$8 = {
149
155
  type: 'problem',
150
156
  docs: {
151
157
  description: 'Disallow unsupported fail fast values'
@@ -154,7 +160,7 @@ const meta$5 = {
154
160
  unsupportedFailFast: 'Unsupported fail fast value: {{value}}'
155
161
  }
156
162
  };
157
- const create$5 = context => {
163
+ const create$8 = context => {
158
164
  const sourceCode = getSourceCode(context);
159
165
  if (!sourceCode.parserServices?.isYAML) {
160
166
  return {};
@@ -164,7 +170,7 @@ const create$5 = context => {
164
170
  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
171
  const nodeValue = node.value.value;
166
172
  context.report({
167
- node,
173
+ node: node.value,
168
174
  messageId: 'unsupportedFailFast',
169
175
  data: {
170
176
  value: nodeValue
@@ -177,11 +183,46 @@ const create$5 = context => {
177
183
 
178
184
  const failFast = {
179
185
  __proto__: null,
180
- create: create$5,
181
- meta: meta$5
186
+ create: create$8,
187
+ meta: meta$8
182
188
  };
183
189
 
184
- const meta$4 = {
190
+ const meta$7 = {
191
+ type: 'problem',
192
+ docs: {
193
+ description: 'Disallow unsupported matrix values'
194
+ },
195
+ messages: {
196
+ unsupportedMatrix: 'Unsupported matrix value: {{value}}'
197
+ }
198
+ };
199
+ const create$7 = context => {
200
+ const sourceCode = getSourceCode(context);
201
+ if (!sourceCode.parserServices?.isYAML) {
202
+ return {};
203
+ }
204
+ return {
205
+ YAMLPair(node) {
206
+ 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 === 'matrix' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type !== 'YAMLSequence') {
207
+ context.report({
208
+ node,
209
+ messageId: 'unsupportedMatrix',
210
+ data: {
211
+ value: node.value
212
+ }
213
+ });
214
+ }
215
+ }
216
+ };
217
+ };
218
+
219
+ const matrix = {
220
+ __proto__: null,
221
+ create: create$7,
222
+ meta: meta$7
223
+ };
224
+
225
+ const meta$6 = {
185
226
  type: 'problem',
186
227
  docs: {
187
228
  description: 'Disallow unsupported max parallel values'
@@ -190,7 +231,7 @@ const meta$4 = {
190
231
  unsupportedMaxParallel: 'Unsupported max parallel value: {{value}}'
191
232
  }
192
233
  };
193
- const create$4 = context => {
234
+ const create$6 = context => {
194
235
  const sourceCode = getSourceCode(context);
195
236
  if (!sourceCode.parserServices?.isYAML) {
196
237
  return {};
@@ -213,11 +254,46 @@ const create$4 = context => {
213
254
 
214
255
  const maxParallel = {
215
256
  __proto__: null,
216
- create: create$4,
217
- meta: meta$4
257
+ create: create$6,
258
+ meta: meta$6
218
259
  };
219
260
 
220
- const meta$3 = {
261
+ const meta$5 = {
262
+ type: 'problem',
263
+ docs: {
264
+ description: 'Disallow unsupported needs values'
265
+ },
266
+ messages: {
267
+ unsupportedNeeds: 'Unsupported needs value: {{value}}'
268
+ }
269
+ };
270
+ const create$5 = context => {
271
+ const sourceCode = getSourceCode(context);
272
+ if (!sourceCode.parserServices?.isYAML) {
273
+ return {};
274
+ }
275
+ return {
276
+ YAMLPair(node) {
277
+ 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 === 'needs' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type !== 'YAMLSequence') {
278
+ context.report({
279
+ node,
280
+ messageId: 'unsupportedNeeds',
281
+ data: {
282
+ value: node.value
283
+ }
284
+ });
285
+ }
286
+ }
287
+ };
288
+ };
289
+
290
+ const needs = {
291
+ __proto__: null,
292
+ create: create$5,
293
+ meta: meta$5
294
+ };
295
+
296
+ const meta$4 = {
221
297
  type: 'problem',
222
298
  docs: {
223
299
  description: 'Disallow unsupported npm registry values'
@@ -226,7 +302,7 @@ const meta$3 = {
226
302
  unsupportedNpmRegistry: 'Unsupported npm registry value: {{value}}'
227
303
  }
228
304
  };
229
- const create$3 = context => {
305
+ const create$4 = context => {
230
306
  const sourceCode = getSourceCode(context);
231
307
  if (!sourceCode.parserServices?.isYAML) {
232
308
  return {};
@@ -250,6 +326,55 @@ const create$3 = context => {
250
326
  };
251
327
 
252
328
  const npmRegistry = {
329
+ __proto__: null,
330
+ create: create$4,
331
+ meta: meta$4
332
+ };
333
+
334
+ const meta$3 = {
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$3 = 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: node.value,
365
+ messageId: 'unsupportedNpmCommand',
366
+ data: {
367
+ value: nodeValue
368
+ }
369
+ });
370
+ }
371
+ }
372
+ }
373
+ }
374
+ };
375
+ };
376
+
377
+ const npm = {
253
378
  __proto__: null,
254
379
  create: create$3,
255
380
  meta: meta$3
@@ -298,10 +423,10 @@ const on = {
298
423
  const meta$1 = {
299
424
  type: 'problem',
300
425
  docs: {
301
- description: 'Disallow unsupported timeout minute values'
426
+ description: 'Disallow unsupported shell values'
302
427
  },
303
428
  messages: {
304
- unsupportedTimeoutMinutes: 'Unsupported timeout minutes value: {{value}}'
429
+ unsupportedShell: 'Unsupported shell value: {{value}}'
305
430
  }
306
431
  };
307
432
  const create$1 = context => {
@@ -311,21 +436,23 @@ const create$1 = context => {
311
436
  }
312
437
  return {
313
438
  YAMLPair(node) {
314
- 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 === 'timeout-minutes' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar' && typeof node.value.value !== 'number') {
439
+ 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 === 'shell' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar') {
315
440
  const nodeValue = node.value.value;
316
- context.report({
317
- node,
318
- messageId: 'unsupportedTimeoutMinutes',
319
- data: {
320
- value: nodeValue
321
- }
322
- });
441
+ if (typeof nodeValue !== 'string' || !shells.includes(nodeValue)) {
442
+ context.report({
443
+ node,
444
+ messageId: 'unsupportedShell',
445
+ data: {
446
+ value: nodeValue
447
+ }
448
+ });
449
+ }
323
450
  }
324
451
  }
325
452
  };
326
453
  };
327
454
 
328
- const timeoutMinutes = {
455
+ const shell = {
329
456
  __proto__: null,
330
457
  create: create$1,
331
458
  meta: meta$1
@@ -334,19 +461,11 @@ const timeoutMinutes = {
334
461
  const meta = {
335
462
  type: 'problem',
336
463
  docs: {
337
- description: 'Disallow unsupported npm commands'
464
+ description: 'Disallow unsupported timeout minute values'
338
465
  },
339
466
  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
- }
467
+ unsupportedTimeoutMinutes: 'Unsupported timeout minutes value: {{value}}'
348
468
  }
349
- return false;
350
469
  };
351
470
  const create = context => {
352
471
  const sourceCode = getSourceCode(context);
@@ -355,26 +474,21 @@ const create = context => {
355
474
  }
356
475
  return {
357
476
  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') {
477
+ 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 === 'timeout-minutes' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar' && typeof node.value.value !== 'number') {
359
478
  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
- });
479
+ context.report({
480
+ node: node.value,
481
+ messageId: 'unsupportedTimeoutMinutes',
482
+ data: {
483
+ value: nodeValue
370
484
  }
371
- }
485
+ });
372
486
  }
373
487
  }
374
488
  };
375
489
  };
376
490
 
377
- const npm = {
491
+ const timeoutMinutes = {
378
492
  __proto__: null,
379
493
  create,
380
494
  meta
@@ -392,8 +506,11 @@ const plugin = {
392
506
  'max-parallel': maxParallel,
393
507
  'npm-registry': npmRegistry,
394
508
  'timeout-minutes': timeoutMinutes,
509
+ matrix: matrix,
510
+ needs: needs,
511
+ npm: npm,
395
512
  on: on,
396
- npm: npm
513
+ shell
397
514
  }
398
515
  };
399
516
  const recommended = [{
@@ -408,10 +525,13 @@ const recommended = [{
408
525
  'github-actions/action-versions': 'error',
409
526
  'github-actions/ci-versions': 'error',
410
527
  'github-actions/fail-fast': 'error',
528
+ 'github-actions/matrix': 'off',
411
529
  'github-actions/max-parallel': 'error',
412
530
  'github-actions/npm-registry': 'error',
413
531
  'github-actions/npm': 'error',
532
+ 'github-actions/needs': 'error',
414
533
  'github-actions/on': 'error',
534
+ 'github-actions/shell': 'error',
415
535
  'github-actions/timeout-minutes': 'error'
416
536
  }
417
537
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-github-actions",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],