@lvce-editor/eslint-plugin-github-actions 2.17.0 → 2.18.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 +174 -63
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as parserYAML from 'yaml-eslint-parser';
2
2
  import { getSourceCode } from 'eslint-compat-utils';
3
+ import { existsSync } from 'fs';
4
+ import { resolve, relative } from 'path';
3
5
 
4
6
  const config = {
5
7
  ubuntu: ['ubuntu-24.04'],
@@ -12,15 +14,15 @@ const platforms = {
12
14
  macos: 'macos'
13
15
  };
14
16
  const actions = {
15
- 'actions/checkout': ['actions/checkout@v5'],
16
- 'actions/setup-node': ['actions/setup-node@v6'],
17
17
  'actions/cache': ['actions/cache@v4'],
18
- 'actions/upload-pages-artifact': ['actions/upload-pages-artifact@v4'],
18
+ 'actions/checkout': ['actions/checkout@v5'],
19
+ 'actions/create-release': ['actions/create-release@v1'],
19
20
  'actions/deploy-pages': ['actions/deploy-pages@v4'],
20
21
  'actions/download-artifact': ['actions/download-artifact@v6'],
22
+ 'actions/setup-node': ['actions/setup-node@v6'],
23
+ 'actions/setup-python': ['actions/setup-python@v5'],
21
24
  'actions/upload-artifact': ['actions/upload-artifact@v5'],
22
- 'actions/create-release': ['actions/create-release@v1'],
23
- 'actions/setup-python': ['actions/setup-python@v5']
25
+ 'actions/upload-pages-artifact': ['actions/upload-pages-artifact@v4']
24
26
  };
25
27
  const npmRegistries = ['https://registry.npmjs.org', 'https://npm.pkg.github.com'];
26
28
  const onProperties = ['push', 'pull_request'];
@@ -35,7 +37,7 @@ const permissions$1 = {
35
37
  const isSupported = (actions, value) => {
36
38
  return actions.includes(value);
37
39
  };
38
- const meta$c = {
40
+ const meta$d = {
39
41
  type: 'problem',
40
42
  docs: {
41
43
  description: 'Disallow unsupported action versions'
@@ -45,7 +47,7 @@ const meta$c = {
45
47
  },
46
48
  fixable: 'code'
47
49
  };
48
- const create$c = context => {
50
+ const create$d = context => {
49
51
  const sourceCode = getSourceCode(context);
50
52
  if (!sourceCode.parserServices?.isYAML) {
51
53
  return {};
@@ -76,8 +78,8 @@ const create$c = context => {
76
78
 
77
79
  const actionVersions = {
78
80
  __proto__: null,
79
- create: create$c,
80
- meta: meta$c
81
+ create: create$d,
82
+ meta: meta$d
81
83
  };
82
84
 
83
85
  const parseVersion = value => {
@@ -101,7 +103,7 @@ const isSupportedMacosversion = version => {
101
103
  const isSupportedWindowsVersion = version => {
102
104
  return config.windows.includes(version);
103
105
  };
104
- const meta$b = {
106
+ const meta$c = {
105
107
  type: 'problem',
106
108
  docs: {
107
109
  description: 'Disallow unsupported ci versions'
@@ -110,7 +112,7 @@ const meta$b = {
110
112
  unsupportedCiVersion: 'Unsupported ci version: {{value}}'
111
113
  }
112
114
  };
113
- const create$b = context => {
115
+ const create$c = context => {
114
116
  const sourceCode = getSourceCode(context);
115
117
  if (!sourceCode.parserServices?.isYAML) {
116
118
  return {};
@@ -153,11 +155,11 @@ const create$b = context => {
153
155
 
154
156
  const ciVersions = {
155
157
  __proto__: null,
156
- create: create$b,
157
- meta: meta$b
158
+ create: create$c,
159
+ meta: meta$c
158
160
  };
159
161
 
160
- const meta$a = {
162
+ const meta$b = {
161
163
  type: 'problem',
162
164
  docs: {
163
165
  description: 'Disallow unsupported fail fast values'
@@ -166,7 +168,7 @@ const meta$a = {
166
168
  unsupportedFailFast: 'Unsupported fail fast value: {{value}}'
167
169
  }
168
170
  };
169
- const create$a = context => {
171
+ const create$b = context => {
170
172
  const sourceCode = getSourceCode(context);
171
173
  if (!sourceCode.parserServices?.isYAML) {
172
174
  return {};
@@ -189,11 +191,11 @@ const create$a = context => {
189
191
 
190
192
  const failFast = {
191
193
  __proto__: null,
192
- create: create$a,
193
- meta: meta$a
194
+ create: create$b,
195
+ meta: meta$b
194
196
  };
195
197
 
196
- const meta$9 = {
198
+ const meta$a = {
197
199
  type: 'problem',
198
200
  docs: {
199
201
  description: 'Disallow unsupported matrix values'
@@ -202,7 +204,7 @@ const meta$9 = {
202
204
  unsupportedMatrix: 'Unsupported matrix value: {{value}}'
203
205
  }
204
206
  };
205
- const create$9 = context => {
207
+ const create$a = context => {
206
208
  const sourceCode = getSourceCode(context);
207
209
  if (!sourceCode.parserServices?.isYAML) {
208
210
  return {};
@@ -224,11 +226,11 @@ const create$9 = context => {
224
226
 
225
227
  const matrix = {
226
228
  __proto__: null,
227
- create: create$9,
228
- meta: meta$9
229
+ create: create$a,
230
+ meta: meta$a
229
231
  };
230
232
 
231
- const meta$8 = {
233
+ const meta$9 = {
232
234
  type: 'problem',
233
235
  docs: {
234
236
  description: 'Disallow unsupported max parallel values'
@@ -237,7 +239,7 @@ const meta$8 = {
237
239
  unsupportedMaxParallel: 'Unsupported max parallel value: {{value}}'
238
240
  }
239
241
  };
240
- const create$8 = context => {
242
+ const create$9 = context => {
241
243
  const sourceCode = getSourceCode(context);
242
244
  if (!sourceCode.parserServices?.isYAML) {
243
245
  return {};
@@ -260,11 +262,11 @@ const create$8 = context => {
260
262
 
261
263
  const maxParallel = {
262
264
  __proto__: null,
263
- create: create$8,
264
- meta: meta$8
265
+ create: create$9,
266
+ meta: meta$9
265
267
  };
266
268
 
267
- const meta$7 = {
269
+ const meta$8 = {
268
270
  type: 'problem',
269
271
  docs: {
270
272
  description: 'Disallow unsupported needs values'
@@ -273,21 +275,68 @@ const meta$7 = {
273
275
  unsupportedNeeds: 'Unsupported needs value: {{value}}'
274
276
  }
275
277
  };
276
- const create$7 = context => {
278
+ const stringifyValue = node => {
279
+ if (!node) {
280
+ return '';
281
+ }
282
+ if (node.type === 'YAMLScalar') {
283
+ return `${node.value}`;
284
+ }
285
+ return `${node.type}`;
286
+ };
287
+ const getValidNeeds = node => {
288
+ const greatGrandParent = node.parent.parent.parent;
289
+ const validNeeds = [];
290
+ if (greatGrandParent.type === 'YAMLMapping') {
291
+ const pairs = greatGrandParent.pairs;
292
+ for (const pair of pairs) {
293
+ if (pair.key && pair.key.type === 'YAMLScalar' && typeof pair.key.value === 'string') {
294
+ validNeeds.push(pair.key.value);
295
+ }
296
+ }
297
+ }
298
+ return validNeeds;
299
+ };
300
+ const create$8 = context => {
277
301
  const sourceCode = getSourceCode(context);
278
302
  if (!sourceCode.parserServices?.isYAML) {
279
303
  return {};
280
304
  }
281
305
  return {
282
306
  YAMLPair(node) {
283
- 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' && !(node.value.type === 'YAMLScalar' && typeof node.value.value === 'string')) {
284
- context.report({
285
- node,
286
- messageId: 'unsupportedNeeds',
287
- data: {
288
- value: node.value
307
+ 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) {
308
+ if (node.value.type !== 'YAMLSequence') {
309
+ context.report({
310
+ node,
311
+ messageId: 'unsupportedNeeds',
312
+ data: {
313
+ value: stringifyValue(node.value)
314
+ }
315
+ });
316
+ return;
317
+ }
318
+ const validNeeds = getValidNeeds(node);
319
+ for (const item of node.value.entries) {
320
+ if (!item || item.type !== 'YAMLScalar' || typeof item.value !== 'string') {
321
+ context.report({
322
+ node,
323
+ messageId: 'unsupportedNeeds',
324
+ data: {
325
+ value: stringifyValue(item)
326
+ }
327
+ });
328
+ continue;
289
329
  }
290
- });
330
+ if (!validNeeds.includes(item.value)) {
331
+ context.report({
332
+ node,
333
+ messageId: 'unsupportedNeeds',
334
+ data: {
335
+ value: stringifyValue(item)
336
+ }
337
+ });
338
+ }
339
+ }
291
340
  }
292
341
  }
293
342
  };
@@ -295,11 +344,11 @@ const create$7 = context => {
295
344
 
296
345
  const needs = {
297
346
  __proto__: null,
298
- create: create$7,
299
- meta: meta$7
347
+ create: create$8,
348
+ meta: meta$8
300
349
  };
301
350
 
302
- const meta$6 = {
351
+ const meta$7 = {
303
352
  type: 'problem',
304
353
  docs: {
305
354
  description: 'Disallow unsupported npm registry values'
@@ -308,7 +357,7 @@ const meta$6 = {
308
357
  unsupportedNpmRegistry: 'Unsupported npm registry value: {{value}}'
309
358
  }
310
359
  };
311
- const create$6 = context => {
360
+ const create$7 = context => {
312
361
  const sourceCode = getSourceCode(context);
313
362
  if (!sourceCode.parserServices?.isYAML) {
314
363
  return {};
@@ -333,11 +382,11 @@ const create$6 = context => {
333
382
 
334
383
  const npmRegistry = {
335
384
  __proto__: null,
336
- create: create$6,
337
- meta: meta$6
385
+ create: create$7,
386
+ meta: meta$7
338
387
  };
339
388
 
340
- const meta$5 = {
389
+ const meta$6 = {
341
390
  type: 'problem',
342
391
  docs: {
343
392
  description: 'Disallow unsupported npm commands'
@@ -354,7 +403,7 @@ const isSupportedNpmCommand = value => {
354
403
  }
355
404
  return false;
356
405
  };
357
- const create$5 = context => {
406
+ const create$6 = context => {
358
407
  const sourceCode = getSourceCode(context);
359
408
  if (!sourceCode.parserServices?.isYAML) {
360
409
  return {};
@@ -382,11 +431,11 @@ const create$5 = context => {
382
431
 
383
432
  const npm = {
384
433
  __proto__: null,
385
- create: create$5,
386
- meta: meta$5
434
+ create: create$6,
435
+ meta: meta$6
387
436
  };
388
437
 
389
- const meta$4 = {
438
+ const meta$5 = {
390
439
  type: 'problem',
391
440
  docs: {
392
441
  description: 'Disallow unsupported on values'
@@ -395,7 +444,7 @@ const meta$4 = {
395
444
  unsupportedOn: 'Unsupported on value: {{value}}'
396
445
  }
397
446
  };
398
- const create$4 = context => {
447
+ const create$5 = context => {
399
448
  const sourceCode = getSourceCode(context);
400
449
  if (!sourceCode.parserServices?.isYAML) {
401
450
  return {};
@@ -422,11 +471,11 @@ const create$4 = context => {
422
471
 
423
472
  const on = {
424
473
  __proto__: null,
425
- create: create$4,
426
- meta: meta$4
474
+ create: create$5,
475
+ meta: meta$5
427
476
  };
428
477
 
429
- const meta$3 = {
478
+ const meta$4 = {
430
479
  type: 'problem',
431
480
  docs: {
432
481
  description: 'Disallow unsupported permission values'
@@ -435,7 +484,7 @@ const meta$3 = {
435
484
  unsupportedPermission: 'Unsupported permission value: {{value}}'
436
485
  }
437
486
  };
438
- const create$3 = context => {
487
+ const create$4 = context => {
439
488
  const sourceCode = getSourceCode(context);
440
489
  if (!sourceCode.parserServices?.isYAML) {
441
490
  return {};
@@ -477,11 +526,11 @@ const create$3 = context => {
477
526
 
478
527
  const permissions = {
479
528
  __proto__: null,
480
- create: create$3,
481
- meta: meta$3
529
+ create: create$4,
530
+ meta: meta$4
482
531
  };
483
532
 
484
- const meta$2 = {
533
+ const meta$3 = {
485
534
  type: 'problem',
486
535
  docs: {
487
536
  description: 'Disallow unsupported shell values'
@@ -490,7 +539,7 @@ const meta$2 = {
490
539
  unsupportedShell: 'Unsupported shell value: {{value}}'
491
540
  }
492
541
  };
493
- const create$2 = context => {
542
+ const create$3 = context => {
494
543
  const sourceCode = getSourceCode(context);
495
544
  if (!sourceCode.parserServices?.isYAML) {
496
545
  return {};
@@ -515,11 +564,11 @@ const create$2 = context => {
515
564
 
516
565
  const shell = {
517
566
  __proto__: null,
518
- create: create$2,
519
- meta: meta$2
567
+ create: create$3,
568
+ meta: meta$3
520
569
  };
521
570
 
522
- const meta$1 = {
571
+ const meta$2 = {
523
572
  type: 'problem',
524
573
  docs: {
525
574
  description: 'Disallow unsupported timeout minute values'
@@ -528,7 +577,7 @@ const meta$1 = {
528
577
  unsupportedTimeoutMinutes: 'Unsupported timeout minutes value: {{value}}'
529
578
  }
530
579
  };
531
- const create$1 = context => {
580
+ const create$2 = context => {
532
581
  const sourceCode = getSourceCode(context);
533
582
  if (!sourceCode.parserServices?.isYAML) {
534
583
  return {};
@@ -551,11 +600,11 @@ const create$1 = context => {
551
600
 
552
601
  const timeoutMinutes = {
553
602
  __proto__: null,
554
- create: create$1,
555
- meta: meta$1
603
+ create: create$2,
604
+ meta: meta$2
556
605
  };
557
606
 
558
- const meta = {
607
+ const meta$1 = {
559
608
  type: 'problem',
560
609
  docs: {
561
610
  description: 'Disallow unsupported node version file values'
@@ -564,7 +613,7 @@ const meta = {
564
613
  unsupportedNodeVersionFile: 'Unsupported node version file value: {{value}}'
565
614
  }
566
615
  };
567
- const create = context => {
616
+ const create$1 = context => {
568
617
  const sourceCode = getSourceCode(context);
569
618
  if (!sourceCode.parserServices?.isYAML) {
570
619
  return {};
@@ -588,6 +637,66 @@ const create = context => {
588
637
  };
589
638
 
590
639
  const nodeVersionFile = {
640
+ __proto__: null,
641
+ create: create$1,
642
+ meta: meta$1
643
+ };
644
+
645
+ const meta = {
646
+ type: 'problem',
647
+ docs: {
648
+ description: 'Disallow non-existing working directories'
649
+ },
650
+ messages: {
651
+ invalidWorkingDirectory: 'Working directory not found: {{value}}',
652
+ workingDirectoryMustBeOfTypeString: 'Working directory must be of type string'
653
+ }
654
+ };
655
+ const allowedNonExistingWorkingDirectories = ['dist', '.tmp'];
656
+ const isAllowedNonExistingWorkingDirectory = relativePath => {
657
+ for (const item of allowedNonExistingWorkingDirectories) {
658
+ if (relativePath.startsWith(item)) {
659
+ return true;
660
+ }
661
+ }
662
+ return false;
663
+ };
664
+ const create = context => {
665
+ const sourceCode = getSourceCode(context);
666
+ if (!sourceCode.parserServices?.isYAML) {
667
+ return {};
668
+ }
669
+ return {
670
+ YAMLPair(node) {
671
+ 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 === 'working-directory' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar') {
672
+ const nodeValue = node.value.value;
673
+ if (typeof nodeValue !== 'string') {
674
+ context.report({
675
+ node,
676
+ messageId: 'workingDirectoryMustBeOfTypeString',
677
+ data: {
678
+ value: nodeValue
679
+ }
680
+ });
681
+ return;
682
+ }
683
+ const path = resolve(context.cwd, nodeValue);
684
+ const relativePath = relative(context.cwd, path);
685
+ if (!isAllowedNonExistingWorkingDirectory(relativePath) && !existsSync(path)) {
686
+ context.report({
687
+ node,
688
+ messageId: 'invalidWorkingDirectory',
689
+ data: {
690
+ value: nodeValue
691
+ }
692
+ });
693
+ }
694
+ }
695
+ }
696
+ };
697
+ };
698
+
699
+ const workingDirectory = {
591
700
  __proto__: null,
592
701
  create,
593
702
  meta
@@ -606,6 +715,7 @@ const plugin = {
606
715
  'node-version-file': nodeVersionFile,
607
716
  'npm-registry': npmRegistry,
608
717
  'timeout-minutes': timeoutMinutes,
718
+ 'working-directory': workingDirectory,
609
719
  matrix: matrix,
610
720
  needs: needs,
611
721
  npm: npm,
@@ -635,7 +745,8 @@ const recommended = [{
635
745
  'github-actions/on': 'error',
636
746
  'github-actions/permissions': 'off',
637
747
  'github-actions/shell': 'error',
638
- 'github-actions/timeout-minutes': 'error'
748
+ 'github-actions/timeout-minutes': 'error',
749
+ 'github-actions/working-directory': 'error'
639
750
  }
640
751
  }];
641
752
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-github-actions",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],