@lvce-editor/eslint-plugin-github-actions 18.16.0 → 19.0.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 +304 -85
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22,7 +22,8 @@ const actions = {
22
22
  'actions/setup-node': ['actions/setup-node@v6'],
23
23
  'actions/setup-python': ['actions/setup-python@v6'],
24
24
  'actions/upload-artifact': ['actions/upload-artifact@v7'],
25
- 'actions/upload-pages-artifact': ['actions/upload-pages-artifact@v5']
25
+ 'actions/upload-pages-artifact': ['actions/upload-pages-artifact@v5'],
26
+ 'docker/setup-buildx-action': ['docker/setup-buildx-action@v4']
26
27
  };
27
28
  const npmRegistries = ['https://registry.npmjs.org', 'https://npm.pkg.github.com'];
28
29
  const onProperties = ['push', 'pull_request'];
@@ -38,7 +39,7 @@ const permissions$1 = {
38
39
  const isSupported = (actions, value) => {
39
40
  return actions.includes(value);
40
41
  };
41
- const meta$k = {
42
+ const meta$n = {
42
43
  docs: {
43
44
  description: 'Disallow unsupported action versions'
44
45
  },
@@ -48,7 +49,7 @@ const meta$k = {
48
49
  },
49
50
  type: 'problem'
50
51
  };
51
- const create$k = context => {
52
+ const create$n = context => {
52
53
  const sourceCode = getSourceCode(context);
53
54
  if (!sourceCode.parserServices?.isYAML) {
54
55
  return {};
@@ -79,8 +80,96 @@ const create$k = context => {
79
80
 
80
81
  const actionVersions = {
81
82
  __proto__: null,
82
- create: create$k,
83
- meta: meta$k
83
+ create: create$n,
84
+ meta: meta$n
85
+ };
86
+
87
+ const getPair = (mapping, name) => {
88
+ return mapping.pairs.find(pair => pair.key?.type === 'YAMLScalar' && pair.key.value === name);
89
+ };
90
+ const getScalarString = node => {
91
+ if (node?.type === 'YAMLScalar' && typeof node.value === 'string') {
92
+ return node.value;
93
+ }
94
+ return undefined;
95
+ };
96
+ const getMapping = node => {
97
+ return node?.type === 'YAMLMapping' ? node : undefined;
98
+ };
99
+
100
+ // Returns the action name of a `uses` value without its version, for example `actions/cache` for `actions/cache@v6`.
101
+ const getActionName = uses => {
102
+ const atIndex = uses.indexOf('@');
103
+ return (atIndex === -1 ? uses : uses.slice(0, atIndex)).toLowerCase();
104
+ };
105
+ // Returns step information when the mapping is a workflow step that uses an action.
106
+ const getActionStep = step => {
107
+ const usesPair = getPair(step, 'uses');
108
+ const uses = usesPair?.value;
109
+ if (uses?.type !== 'YAMLScalar' || typeof uses.value !== 'string') {
110
+ return undefined;
111
+ }
112
+ const withPair = getPair(step, 'with');
113
+ return {
114
+ actionName: getActionName(uses.value),
115
+ step,
116
+ uses,
117
+ withMapping: getMapping(withPair?.value),
118
+ withPair
119
+ };
120
+ };
121
+
122
+ const meta$m = {
123
+ docs: {
124
+ description: 'Require node_modules cache keys to include the runner architecture'
125
+ },
126
+ fixable: 'code',
127
+ messages: {
128
+ missingArch: 'Include {{expression}} in the node_modules cache key. runner.os is the same on x64 and arm runners, so native modules would be restored on the wrong architecture.'
129
+ },
130
+ type: 'problem'
131
+ };
132
+ const cacheActions = new Set(['actions/cache', 'actions/cache/restore', 'actions/cache/save']);
133
+ const runnerOsPattern = /\$\{\{\s*runner\.os\s*\}\}/;
134
+ const runnerArchPattern = /\$\{\{\s*runner\.arch\s*\}\}/;
135
+ const create$m = context => {
136
+ const sourceCode = getSourceCode(context);
137
+ if (!sourceCode.parserServices?.isYAML) {
138
+ return {};
139
+ }
140
+ return {
141
+ YAMLMapping(node) {
142
+ const actionStep = getActionStep(node);
143
+ if (!actionStep || !cacheActions.has(actionStep.actionName) || !actionStep.withMapping) {
144
+ return;
145
+ }
146
+ const path = getScalarString(getPair(actionStep.withMapping, 'path')?.value);
147
+ const keyNode = getPair(actionStep.withMapping, 'key')?.value;
148
+ const key = getScalarString(keyNode);
149
+ if (key === undefined || !keyNode || !path?.includes('node_modules') || runnerArchPattern.test(key)) {
150
+ return;
151
+ }
152
+ const keyText = sourceCode.getText(keyNode);
153
+ const osMatch = runnerOsPattern.exec(keyText);
154
+ context.report({
155
+ data: {
156
+ expression: '${{ runner.arch }}'
157
+ },
158
+ fix: osMatch ? fixer => {
159
+ const fixedText = `${keyText.slice(0, osMatch.index + osMatch[0].length)}-\${{ runner.arch }}${keyText.slice(osMatch.index + osMatch[0].length)}`;
160
+ return fixer.replaceText(keyNode, fixedText);
161
+ } : null,
162
+ loc: keyNode.loc,
163
+ messageId: 'missingArch'
164
+ });
165
+ }
166
+ };
167
+ };
168
+
169
+ const cacheKeyIncludesArch = {
170
+ __proto__: null,
171
+ create: create$m,
172
+ meta: meta$m
84
173
  };
85
174
 
86
175
  const parseVersion = value => {
@@ -104,7 +193,7 @@ const isSupportedMacosversion = version => {
104
193
  const isSupportedWindowsVersion = version => {
105
194
  return config.windows.includes(version);
106
195
  };
107
- const meta$j = {
196
+ const meta$l = {
108
197
  docs: {
109
198
  description: 'Disallow unsupported ci versions'
110
199
  },
@@ -113,7 +202,7 @@ const meta$j = {
113
202
  },
114
203
  type: 'problem'
115
204
  };
116
- const create$j = context => {
205
+ const create$l = context => {
117
206
  const sourceCode = getSourceCode(context);
118
207
  if (!sourceCode.parserServices?.isYAML) {
119
208
  return {};
@@ -157,11 +246,11 @@ const create$j = context => {
157
246
 
158
247
  const ciVersions = {
159
248
  __proto__: null,
160
- create: create$j,
161
- meta: meta$j
249
+ create: create$l,
250
+ meta: meta$l
162
251
  };
163
252
 
164
- const meta$i = {
253
+ const meta$k = {
165
254
  docs: {
166
255
  description: 'Disallow unsupported fail fast values'
167
256
  },
@@ -170,7 +259,7 @@ const meta$i = {
170
259
  },
171
260
  type: 'problem'
172
261
  };
173
- const create$i = context => {
262
+ const create$k = context => {
174
263
  const sourceCode = getSourceCode(context);
175
264
  if (!sourceCode.parserServices?.isYAML) {
176
265
  return {};
@@ -193,11 +282,11 @@ const create$i = context => {
193
282
 
194
283
  const failFast = {
195
284
  __proto__: null,
196
- create: create$i,
197
- meta: meta$i
285
+ create: create$k,
286
+ meta: meta$k
198
287
  };
199
288
 
200
- const meta$h = {
289
+ const meta$j = {
201
290
  docs: {
202
291
  description: 'Require GitHub Pages deployment best practices'
203
292
  },
@@ -242,7 +331,7 @@ const hasGithubPagesConcurrency = mapping => {
242
331
  }
243
332
  return isYamlScalarString(getMappingValue(mapping, 'group'), 'pages') && isYamlScalarBoolean(getMappingValue(mapping, 'cancel-in-progress'), false);
244
333
  };
245
- const create$h = context => {
334
+ const create$j = context => {
246
335
  const sourceCode = getSourceCode(context);
247
336
  if (!sourceCode.parserServices?.isYAML || !isCiWorkflow(context.filename)) {
248
337
  return {};
@@ -290,11 +379,11 @@ const create$h = context => {
290
379
 
291
380
  const githubPages = {
292
381
  __proto__: null,
293
- create: create$h,
294
- meta: meta$h
382
+ create: create$j,
383
+ meta: meta$j
295
384
  };
296
385
 
297
- const meta$g = {
386
+ const meta$i = {
298
387
  docs: {
299
388
  description: 'Disallow unsupported github token values'
300
389
  },
@@ -303,7 +392,7 @@ const meta$g = {
303
392
  },
304
393
  type: 'problem'
305
394
  };
306
- const create$g = context => {
395
+ const create$i = context => {
307
396
  const sourceCode = getSourceCode(context);
308
397
  if (!sourceCode.parserServices?.isYAML) {
309
398
  return {};
@@ -328,11 +417,11 @@ const create$g = context => {
328
417
 
329
418
  const githubToken = {
330
419
  __proto__: null,
331
- create: create$g,
332
- meta: meta$g
420
+ create: create$i,
421
+ meta: meta$i
333
422
  };
334
423
 
335
- const meta$f = {
424
+ const meta$h = {
336
425
  docs: {
337
426
  description: 'Disallow unsupported matrix values'
338
427
  },
@@ -341,7 +430,7 @@ const meta$f = {
341
430
  },
342
431
  type: 'problem'
343
432
  };
344
- const create$f = context => {
433
+ const create$h = context => {
345
434
  const sourceCode = getSourceCode(context);
346
435
  if (!sourceCode.parserServices?.isYAML) {
347
436
  return {};
@@ -351,8 +440,7 @@ const create$f = context => {
351
440
  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') {
352
441
  context.report({
353
442
  data: {
354
- // @ts-ignore
355
- value: node.value
443
+ value: sourceCode.getText(node.value)
356
444
  },
357
445
  messageId: 'unsupportedMatrix',
358
446
  node
@@ -364,11 +452,11 @@ const create$f = context => {
364
452
 
365
453
  const matrix = {
366
454
  __proto__: null,
367
- create: create$f,
368
- meta: meta$f
455
+ create: create$h,
456
+ meta: meta$h
369
457
  };
370
458
 
371
- const meta$e = {
459
+ const meta$g = {
372
460
  docs: {
373
461
  description: 'Disallow unsupported max parallel values'
374
462
  },
@@ -377,7 +465,7 @@ const meta$e = {
377
465
  },
378
466
  type: 'problem'
379
467
  };
380
- const create$e = context => {
468
+ const create$g = context => {
381
469
  const sourceCode = getSourceCode(context);
382
470
  if (!sourceCode.parserServices?.isYAML) {
383
471
  return {};
@@ -400,11 +488,11 @@ const create$e = context => {
400
488
 
401
489
  const maxParallel = {
402
490
  __proto__: null,
403
- create: create$e,
404
- meta: meta$e
491
+ create: create$g,
492
+ meta: meta$g
405
493
  };
406
494
 
407
- const meta$d = {
495
+ const meta$f = {
408
496
  docs: {
409
497
  description: 'Disallow unsupported needs values'
410
498
  },
@@ -437,7 +525,7 @@ const getValidNeeds = node => {
437
525
  }
438
526
  return validNeeds;
439
527
  };
440
- const create$d = context => {
528
+ const create$f = context => {
441
529
  const sourceCode = getSourceCode(context);
442
530
  if (!sourceCode.parserServices?.isYAML) {
443
531
  return {};
@@ -496,11 +584,82 @@ const create$d = context => {
496
584
 
497
585
  const needs = {
498
586
  __proto__: null,
499
- create: create$d,
500
- meta: meta$d
587
+ create: create$f,
588
+ meta: meta$f
501
589
  };
502
590
 
503
- const meta$c = {
591
+ // cspell:ignore dtolnay erlef
592
+
593
+ const meta$e = {
594
+ docs: {
595
+ description: 'Disallow archived or deprecated GitHub Actions'
596
+ },
597
+ messages: {
598
+ deprecatedAction: '{{action}} is archived and no longer maintained. Use {{replacement}} instead.'
599
+ },
600
+ schema: [{
601
+ additionalProperties: false,
602
+ properties: {
603
+ deprecated: {
604
+ additionalProperties: {
605
+ type: 'string'
606
+ },
607
+ type: 'object'
608
+ }
609
+ },
610
+ type: 'object'
611
+ }],
612
+ type: 'problem'
613
+ };
614
+
615
+ // actions/create-release is reported (and auto-fixed) by github-actions/release-action.
616
+ const defaultDeprecatedActions = {
617
+ 'actions-rs/cargo': 'cargo commands in a run step',
618
+ 'actions-rs/toolchain': 'dtolnay/rust-toolchain',
619
+ 'actions/setup-elixir': 'erlef/setup-beam',
620
+ 'actions/setup-haskell': 'haskell-actions/setup',
621
+ 'actions/setup-ruby': 'ruby/setup-ruby',
622
+ 'actions/upload-release-asset': 'softprops/action-gh-release with files, or gh release upload'
623
+ };
624
+ const create$e = context => {
625
+ const sourceCode = getSourceCode(context);
626
+ if (!sourceCode.parserServices?.isYAML) {
627
+ return {};
628
+ }
629
+ const [options] = context.options;
630
+ const deprecatedActions = new Map(Object.entries({
631
+ ...defaultDeprecatedActions,
632
+ ...options?.deprecated
633
+ }).map(([name, replacement]) => [name.toLowerCase(), replacement]));
634
+ return {
635
+ YAMLPair(node) {
636
+ if (node.key?.type !== 'YAMLScalar' || node.key.value !== 'uses' || node.value?.type !== 'YAMLScalar' || typeof node.value.value !== 'string') {
637
+ return;
638
+ }
639
+ const action = getActionName(node.value.value);
640
+ const replacement = deprecatedActions.get(action);
641
+ if (replacement === undefined) {
642
+ return;
643
+ }
644
+ context.report({
645
+ data: {
646
+ action,
647
+ replacement
648
+ },
649
+ loc: node.value.loc,
650
+ messageId: 'deprecatedAction'
651
+ });
652
+ }
653
+ };
654
+ };
655
+
656
+ const noDeprecatedActions = {
657
+ __proto__: null,
658
+ create: create$e,
659
+ meta: meta$e
660
+ };
661
+
662
+ const meta$d = {
504
663
  docs: {
505
664
  description: 'Disallow e2e tests in release workflows'
506
665
  },
@@ -528,7 +687,7 @@ const runsE2eTests = value => {
528
687
  }
529
688
  return false;
530
689
  };
531
- const create$c = context => {
690
+ const create$d = context => {
532
691
  const sourceCode = getSourceCode(context);
533
692
  if (!sourceCode.parserServices?.isYAML || !isReleaseWorkflow$1(context.filename)) {
534
693
  return {};
@@ -547,11 +706,11 @@ const create$c = context => {
547
706
 
548
707
  const noE2eInRelease = {
549
708
  __proto__: null,
550
- create: create$c,
551
- meta: meta$c
709
+ create: create$d,
710
+ meta: meta$d
552
711
  };
553
712
 
554
- const meta$b = {
713
+ const meta$c = {
555
714
  docs: {
556
715
  description: 'Disallow memory measurement in release workflows'
557
716
  },
@@ -579,7 +738,7 @@ const runsMemoryMeasurement = value => {
579
738
  }
580
739
  return false;
581
740
  };
582
- const create$b = context => {
741
+ const create$c = context => {
583
742
  const sourceCode = getSourceCode(context);
584
743
  if (!sourceCode.parserServices?.isYAML || !isReleaseWorkflow(context.filename)) {
585
744
  return {};
@@ -598,11 +757,11 @@ const create$b = context => {
598
757
 
599
758
  const noMeasureInRelease = {
600
759
  __proto__: null,
601
- create: create$b,
602
- meta: meta$b
760
+ create: create$c,
761
+ meta: meta$c
603
762
  };
604
763
 
605
- const meta$a = {
764
+ const meta$b = {
606
765
  docs: {
607
766
  description: 'Disallow unsupported node version file values'
608
767
  },
@@ -611,7 +770,7 @@ const meta$a = {
611
770
  },
612
771
  type: 'problem'
613
772
  };
614
- const create$a = context => {
773
+ const create$b = context => {
615
774
  const sourceCode = getSourceCode(context);
616
775
  if (!sourceCode.parserServices?.isYAML) {
617
776
  return {};
@@ -636,11 +795,11 @@ const create$a = context => {
636
795
 
637
796
  const nodeVersionFile = {
638
797
  __proto__: null,
639
- create: create$a,
640
- meta: meta$a
798
+ create: create$b,
799
+ meta: meta$b
641
800
  };
642
801
 
643
- const meta$9 = {
802
+ const meta$a = {
644
803
  docs: {
645
804
  description: 'Disallow unsupported npm registry values'
646
805
  },
@@ -649,7 +808,7 @@ const meta$9 = {
649
808
  },
650
809
  type: 'problem'
651
810
  };
652
- const create$9 = context => {
811
+ const create$a = context => {
653
812
  const sourceCode = getSourceCode(context);
654
813
  if (!sourceCode.parserServices?.isYAML) {
655
814
  return {};
@@ -674,11 +833,11 @@ const create$9 = context => {
674
833
 
675
834
  const npmRegistry = {
676
835
  __proto__: null,
677
- create: create$9,
678
- meta: meta$9
836
+ create: create$a,
837
+ meta: meta$a
679
838
  };
680
839
 
681
- const meta$8 = {
840
+ const meta$9 = {
682
841
  docs: {
683
842
  description: 'Require npm tasks to run in a consistent order'
684
843
  },
@@ -720,7 +879,7 @@ const getNpmTaskStep = entry => {
720
879
  const isStepsSequence = node => {
721
880
  return node.parent.type === 'YAMLPair' && node.parent.key?.type === 'YAMLScalar' && node.parent.key.value === 'steps';
722
881
  };
723
- const create$8 = context => {
882
+ const create$9 = context => {
724
883
  const sourceCode = getSourceCode(context);
725
884
  if (!sourceCode.parserServices?.isYAML) {
726
885
  return {};
@@ -760,11 +919,11 @@ const create$8 = context => {
760
919
 
761
920
  const npmTaskOrder$1 = {
762
921
  __proto__: null,
763
- create: create$8,
764
- meta: meta$8
922
+ create: create$9,
923
+ meta: meta$9
765
924
  };
766
925
 
767
- const meta$7 = {
926
+ const meta$8 = {
768
927
  docs: {
769
928
  description: 'Disallow unsupported npm commands'
770
929
  },
@@ -781,7 +940,7 @@ const isSupportedNpmCommand = value => {
781
940
  }
782
941
  return false;
783
942
  };
784
- const create$7 = context => {
943
+ const create$8 = context => {
785
944
  const sourceCode = getSourceCode(context);
786
945
  if (!sourceCode.parserServices?.isYAML) {
787
946
  return {};
@@ -809,11 +968,11 @@ const create$7 = context => {
809
968
 
810
969
  const npm = {
811
970
  __proto__: null,
812
- create: create$7,
813
- meta: meta$7
971
+ create: create$8,
972
+ meta: meta$8
814
973
  };
815
974
 
816
- const meta$6 = {
975
+ const meta$7 = {
817
976
  docs: {
818
977
  description: 'Disallow unsupported on values'
819
978
  },
@@ -822,7 +981,7 @@ const meta$6 = {
822
981
  },
823
982
  type: 'problem'
824
983
  };
825
- const create$6 = context => {
984
+ const create$7 = context => {
826
985
  const sourceCode = getSourceCode(context);
827
986
  if (!sourceCode.parserServices?.isYAML) {
828
987
  return {};
@@ -851,11 +1010,11 @@ const create$6 = context => {
851
1010
 
852
1011
  const on = {
853
1012
  __proto__: null,
854
- create: create$6,
855
- meta: meta$6
1013
+ create: create$7,
1014
+ meta: meta$7
856
1015
  };
857
1016
 
858
- const meta$5 = {
1017
+ const meta$6 = {
859
1018
  docs: {
860
1019
  description: 'Disallow unsupported permission values'
861
1020
  },
@@ -864,7 +1023,7 @@ const meta$5 = {
864
1023
  },
865
1024
  type: 'problem'
866
1025
  };
867
- const create$5 = context => {
1026
+ const create$6 = context => {
868
1027
  const sourceCode = getSourceCode(context);
869
1028
  if (!sourceCode.parserServices?.isYAML) {
870
1029
  return {};
@@ -883,8 +1042,7 @@ const create$5 = context => {
883
1042
  if (!items.includes(pair.value.value)) {
884
1043
  context.report({
885
1044
  data: {
886
- // @ts-ignore
887
- value: pair.value
1045
+ value: pair.value.value
888
1046
  },
889
1047
  messageId: 'unsupportedPermission',
890
1048
  node
@@ -894,8 +1052,7 @@ const create$5 = context => {
894
1052
  } else {
895
1053
  context.report({
896
1054
  data: {
897
- // @ts-ignore
898
- value: pair
1055
+ value: pair.key.value
899
1056
  },
900
1057
  messageId: 'unsupportedPermission',
901
1058
  node: pair.key
@@ -909,11 +1066,11 @@ const create$5 = context => {
909
1066
 
910
1067
  const permissions = {
911
1068
  __proto__: null,
912
- create: create$5,
913
- meta: meta$5
1069
+ create: create$6,
1070
+ meta: meta$6
914
1071
  };
915
1072
 
916
- const meta$4 = {
1073
+ const meta$5 = {
917
1074
  docs: {
918
1075
  description: 'Disallow unsupported python versions'
919
1076
  },
@@ -922,7 +1079,7 @@ const meta$4 = {
922
1079
  },
923
1080
  type: 'problem'
924
1081
  };
925
- const create$4 = context => {
1082
+ const create$5 = context => {
926
1083
  const sourceCode = getSourceCode(context);
927
1084
  if (!sourceCode.parserServices?.isYAML) {
928
1085
  return {};
@@ -947,11 +1104,11 @@ const create$4 = context => {
947
1104
 
948
1105
  const pythonVersion = {
949
1106
  __proto__: null,
950
- create: create$4,
951
- meta: meta$4
1107
+ create: create$5,
1108
+ meta: meta$5
952
1109
  };
953
1110
 
954
- const meta$3 = {
1111
+ const meta$4 = {
955
1112
  docs: {
956
1113
  description: 'Disallow unsupported release action usage'
957
1114
  },
@@ -961,7 +1118,7 @@ const meta$3 = {
961
1118
  },
962
1119
  type: 'problem'
963
1120
  };
964
- const create$3 = context => {
1121
+ const create$4 = context => {
965
1122
  const sourceCode = getSourceCode(context);
966
1123
  if (!sourceCode.parserServices?.isYAML) {
967
1124
  return {};
@@ -1000,11 +1157,11 @@ const create$3 = context => {
1000
1157
 
1001
1158
  const releaseAction = {
1002
1159
  __proto__: null,
1003
- create: create$3,
1004
- meta: meta$3
1160
+ create: create$4,
1161
+ meta: meta$4
1005
1162
  };
1006
1163
 
1007
- const meta$2 = {
1164
+ const meta$3 = {
1008
1165
  docs: {
1009
1166
  description: 'Disallow unsupported shell values'
1010
1167
  },
@@ -1013,7 +1170,7 @@ const meta$2 = {
1013
1170
  },
1014
1171
  type: 'problem'
1015
1172
  };
1016
- const create$2 = context => {
1173
+ const create$3 = context => {
1017
1174
  const sourceCode = getSourceCode(context);
1018
1175
  if (!sourceCode.parserServices?.isYAML) {
1019
1176
  return {};
@@ -1038,11 +1195,11 @@ const create$2 = context => {
1038
1195
 
1039
1196
  const shell = {
1040
1197
  __proto__: null,
1041
- create: create$2,
1042
- meta: meta$2
1198
+ create: create$3,
1199
+ meta: meta$3
1043
1200
  };
1044
1201
 
1045
- const meta$1 = {
1202
+ const meta$2 = {
1046
1203
  docs: {
1047
1204
  description: 'Disallow unsupported timeout minute values'
1048
1205
  },
@@ -1051,7 +1208,7 @@ const meta$1 = {
1051
1208
  },
1052
1209
  type: 'problem'
1053
1210
  };
1054
- const create$1 = context => {
1211
+ const create$2 = context => {
1055
1212
  const sourceCode = getSourceCode(context);
1056
1213
  if (!sourceCode.parserServices?.isYAML) {
1057
1214
  return {};
@@ -1073,6 +1230,62 @@ const create$1 = context => {
1073
1230
  };
1074
1231
 
1075
1232
  const timeoutMinutes = {
1233
+ __proto__: null,
1234
+ create: create$2,
1235
+ meta: meta$2
1236
+ };
1237
+
1238
+ const meta$1 = {
1239
+ docs: {
1240
+ description: 'Require actions/upload-artifact steps to fail when no files are found'
1241
+ },
1242
+ fixable: 'code',
1243
+ messages: {
1244
+ requireIfNoFilesFoundError: 'Set if-no-files-found: error on actions/upload-artifact. The default only warns, so a wrong path silently uploads nothing.'
1245
+ },
1246
+ type: 'problem'
1247
+ };
1248
+ const create$1 = context => {
1249
+ const sourceCode = getSourceCode(context);
1250
+ if (!sourceCode.parserServices?.isYAML) {
1251
+ return {};
1252
+ }
1253
+ return {
1254
+ YAMLMapping(node) {
1255
+ const actionStep = getActionStep(node);
1256
+ if (actionStep?.actionName !== 'actions/upload-artifact') {
1257
+ return;
1258
+ }
1259
+ const {
1260
+ uses,
1261
+ withMapping
1262
+ } = actionStep;
1263
+ const valueNode = withMapping ? getPair(withMapping, 'if-no-files-found')?.value : undefined;
1264
+ if (valueNode?.type === 'YAMLScalar' && valueNode.value === 'error') {
1265
+ return;
1266
+ }
1267
+ if (valueNode) {
1268
+ context.report({
1269
+ fix: fixer => fixer.replaceText(valueNode, 'error'),
1270
+ loc: valueNode.loc,
1271
+ messageId: 'requireIfNoFilesFoundError'
1272
+ });
1273
+ return;
1274
+ }
1275
+ const [firstPair] = withMapping?.pairs ?? [];
1276
+ context.report({
1277
+ fix: firstPair && withMapping?.style === 'block' ? fixer => {
1278
+ const indentation = ' '.repeat(firstPair.loc.start.column);
1279
+ return fixer.insertTextBeforeRange(firstPair.range, `if-no-files-found: error\n${indentation}`);
1280
+ } : null,
1281
+ loc: uses.loc,
1282
+ messageId: 'requireIfNoFilesFoundError'
1283
+ });
1284
+ }
1285
+ };
1286
+ };
1287
+
1288
+ const uploadArtifactIfNoFilesFound = {
1076
1289
  __proto__: null,
1077
1290
  create: create$1,
1078
1291
  meta: meta$1
@@ -1145,6 +1358,7 @@ const plugin = {
1145
1358
  },
1146
1359
  rules: {
1147
1360
  'action-versions': actionVersions,
1361
+ 'cache-key-includes-arch': cacheKeyIncludesArch,
1148
1362
  'ci-versions': ciVersions,
1149
1363
  'fail-fast': failFast,
1150
1364
  'github-pages': githubPages,
@@ -1152,6 +1366,7 @@ const plugin = {
1152
1366
  matrix: matrix,
1153
1367
  'max-parallel': maxParallel,
1154
1368
  needs: needs,
1369
+ 'no-deprecated-actions': noDeprecatedActions,
1155
1370
  'no-e2e-in-release': noE2eInRelease,
1156
1371
  'no-measure-in-release': noMeasureInRelease,
1157
1372
  'node-version-file': nodeVersionFile,
@@ -1164,6 +1379,7 @@ const plugin = {
1164
1379
  'release-action': releaseAction,
1165
1380
  shell,
1166
1381
  'timeout-minutes': timeoutMinutes,
1382
+ 'upload-artifact-if-no-files-found': uploadArtifactIfNoFilesFound,
1167
1383
  'working-directory': workingDirectory
1168
1384
  }
1169
1385
  };
@@ -1177,6 +1393,7 @@ const recommended = [{
1177
1393
  },
1178
1394
  rules: {
1179
1395
  'github-actions/action-versions': 'error',
1396
+ 'github-actions/cache-key-includes-arch': 'error',
1180
1397
  'github-actions/ci-versions': 'error',
1181
1398
  'github-actions/fail-fast': 'error',
1182
1399
  'github-actions/github-pages': 'error',
@@ -1184,6 +1401,7 @@ const recommended = [{
1184
1401
  'github-actions/matrix': 'off',
1185
1402
  'github-actions/max-parallel': 'error',
1186
1403
  'github-actions/needs': 'error',
1404
+ 'github-actions/no-deprecated-actions': 'error',
1187
1405
  'github-actions/no-e2e-in-release': 'error',
1188
1406
  'github-actions/no-measure-in-release': 'error',
1189
1407
  'github-actions/node-version-file': 'error',
@@ -1196,6 +1414,7 @@ const recommended = [{
1196
1414
  'github-actions/release-action': 'error',
1197
1415
  'github-actions/shell': 'error',
1198
1416
  'github-actions/timeout-minutes': 'error',
1417
+ 'github-actions/upload-artifact-if-no-files-found': 'error',
1199
1418
  'github-actions/working-directory': 'error'
1200
1419
  }
1201
1420
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-github-actions",
3
- "version": "18.16.0",
3
+ "version": "19.0.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "license": "MIT",