@lvce-editor/eslint-plugin-github-actions 16.3.0 → 16.4.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 +134 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ const permissions$1 = {
38
38
  const isSupported = (actions, value) => {
39
39
  return actions.includes(value);
40
40
  };
41
- const meta$j = {
41
+ const meta$k = {
42
42
  docs: {
43
43
  description: 'Disallow unsupported action versions'
44
44
  },
@@ -48,7 +48,7 @@ const meta$j = {
48
48
  },
49
49
  type: 'problem'
50
50
  };
51
- const create$j = context => {
51
+ const create$k = context => {
52
52
  const sourceCode = getSourceCode(context);
53
53
  if (!sourceCode.parserServices?.isYAML) {
54
54
  return {};
@@ -79,8 +79,8 @@ const create$j = context => {
79
79
 
80
80
  const actionVersions = {
81
81
  __proto__: null,
82
- create: create$j,
83
- meta: meta$j
82
+ create: create$k,
83
+ meta: meta$k
84
84
  };
85
85
 
86
86
  const parseVersion = value => {
@@ -104,7 +104,7 @@ const isSupportedMacosversion = version => {
104
104
  const isSupportedWindowsVersion = version => {
105
105
  return config.windows.includes(version);
106
106
  };
107
- const meta$i = {
107
+ const meta$j = {
108
108
  docs: {
109
109
  description: 'Disallow unsupported ci versions'
110
110
  },
@@ -113,7 +113,7 @@ const meta$i = {
113
113
  },
114
114
  type: 'problem'
115
115
  };
116
- const create$i = context => {
116
+ const create$j = context => {
117
117
  const sourceCode = getSourceCode(context);
118
118
  if (!sourceCode.parserServices?.isYAML) {
119
119
  return {};
@@ -157,11 +157,11 @@ const create$i = context => {
157
157
 
158
158
  const ciVersions = {
159
159
  __proto__: null,
160
- create: create$i,
161
- meta: meta$i
160
+ create: create$j,
161
+ meta: meta$j
162
162
  };
163
163
 
164
- const meta$h = {
164
+ const meta$i = {
165
165
  docs: {
166
166
  description: 'Disallow unsupported fail fast values'
167
167
  },
@@ -170,7 +170,7 @@ const meta$h = {
170
170
  },
171
171
  type: 'problem'
172
172
  };
173
- const create$h = context => {
173
+ const create$i = context => {
174
174
  const sourceCode = getSourceCode(context);
175
175
  if (!sourceCode.parserServices?.isYAML) {
176
176
  return {};
@@ -193,11 +193,11 @@ const create$h = context => {
193
193
 
194
194
  const failFast = {
195
195
  __proto__: null,
196
- create: create$h,
197
- meta: meta$h
196
+ create: create$i,
197
+ meta: meta$i
198
198
  };
199
199
 
200
- const meta$g = {
200
+ const meta$h = {
201
201
  docs: {
202
202
  description: 'Require GitHub Pages deployment best practices'
203
203
  },
@@ -242,7 +242,7 @@ const hasGithubPagesConcurrency = mapping => {
242
242
  }
243
243
  return isYamlScalarString(getMappingValue(mapping, 'group'), 'pages') && isYamlScalarBoolean(getMappingValue(mapping, 'cancel-in-progress'), false);
244
244
  };
245
- const create$g = context => {
245
+ const create$h = context => {
246
246
  const sourceCode = getSourceCode(context);
247
247
  if (!sourceCode.parserServices?.isYAML || !isCiWorkflow(context.filename)) {
248
248
  return {};
@@ -290,11 +290,11 @@ const create$g = context => {
290
290
 
291
291
  const githubPages = {
292
292
  __proto__: null,
293
- create: create$g,
294
- meta: meta$g
293
+ create: create$h,
294
+ meta: meta$h
295
295
  };
296
296
 
297
- const meta$f = {
297
+ const meta$g = {
298
298
  docs: {
299
299
  description: 'Disallow unsupported github token values'
300
300
  },
@@ -303,7 +303,7 @@ const meta$f = {
303
303
  },
304
304
  type: 'problem'
305
305
  };
306
- const create$f = context => {
306
+ const create$g = context => {
307
307
  const sourceCode = getSourceCode(context);
308
308
  if (!sourceCode.parserServices?.isYAML) {
309
309
  return {};
@@ -328,11 +328,11 @@ const create$f = context => {
328
328
 
329
329
  const githubToken = {
330
330
  __proto__: null,
331
- create: create$f,
332
- meta: meta$f
331
+ create: create$g,
332
+ meta: meta$g
333
333
  };
334
334
 
335
- const meta$e = {
335
+ const meta$f = {
336
336
  docs: {
337
337
  description: 'Disallow unsupported matrix values'
338
338
  },
@@ -341,7 +341,7 @@ const meta$e = {
341
341
  },
342
342
  type: 'problem'
343
343
  };
344
- const create$e = context => {
344
+ const create$f = context => {
345
345
  const sourceCode = getSourceCode(context);
346
346
  if (!sourceCode.parserServices?.isYAML) {
347
347
  return {};
@@ -364,11 +364,11 @@ const create$e = context => {
364
364
 
365
365
  const matrix = {
366
366
  __proto__: null,
367
- create: create$e,
368
- meta: meta$e
367
+ create: create$f,
368
+ meta: meta$f
369
369
  };
370
370
 
371
- const meta$d = {
371
+ const meta$e = {
372
372
  docs: {
373
373
  description: 'Disallow unsupported max parallel values'
374
374
  },
@@ -377,7 +377,7 @@ const meta$d = {
377
377
  },
378
378
  type: 'problem'
379
379
  };
380
- const create$d = context => {
380
+ const create$e = context => {
381
381
  const sourceCode = getSourceCode(context);
382
382
  if (!sourceCode.parserServices?.isYAML) {
383
383
  return {};
@@ -400,11 +400,11 @@ const create$d = context => {
400
400
 
401
401
  const maxParallel = {
402
402
  __proto__: null,
403
- create: create$d,
404
- meta: meta$d
403
+ create: create$e,
404
+ meta: meta$e
405
405
  };
406
406
 
407
- const meta$c = {
407
+ const meta$d = {
408
408
  docs: {
409
409
  description: 'Disallow unsupported needs values'
410
410
  },
@@ -437,7 +437,7 @@ const getValidNeeds = node => {
437
437
  }
438
438
  return validNeeds;
439
439
  };
440
- const create$c = context => {
440
+ const create$d = context => {
441
441
  const sourceCode = getSourceCode(context);
442
442
  if (!sourceCode.parserServices?.isYAML) {
443
443
  return {};
@@ -496,11 +496,11 @@ const create$c = context => {
496
496
 
497
497
  const needs = {
498
498
  __proto__: null,
499
- create: create$c,
500
- meta: meta$c
499
+ create: create$d,
500
+ meta: meta$d
501
501
  };
502
502
 
503
- const meta$b = {
503
+ const meta$c = {
504
504
  docs: {
505
505
  description: 'Disallow e2e tests in release workflows'
506
506
  },
@@ -528,7 +528,7 @@ const runsE2eTests = value => {
528
528
  }
529
529
  return false;
530
530
  };
531
- const create$b = context => {
531
+ const create$c = context => {
532
532
  const sourceCode = getSourceCode(context);
533
533
  if (!sourceCode.parserServices?.isYAML || !isReleaseWorkflow$1(context.filename)) {
534
534
  return {};
@@ -547,11 +547,11 @@ const create$b = context => {
547
547
 
548
548
  const noE2eInRelease = {
549
549
  __proto__: null,
550
- create: create$b,
551
- meta: meta$b
550
+ create: create$c,
551
+ meta: meta$c
552
552
  };
553
553
 
554
- const meta$a = {
554
+ const meta$b = {
555
555
  docs: {
556
556
  description: 'Disallow memory measurement in release workflows'
557
557
  },
@@ -579,7 +579,7 @@ const runsMemoryMeasurement = value => {
579
579
  }
580
580
  return false;
581
581
  };
582
- const create$a = context => {
582
+ const create$b = context => {
583
583
  const sourceCode = getSourceCode(context);
584
584
  if (!sourceCode.parserServices?.isYAML || !isReleaseWorkflow(context.filename)) {
585
585
  return {};
@@ -598,11 +598,11 @@ const create$a = context => {
598
598
 
599
599
  const noMeasureInRelease = {
600
600
  __proto__: null,
601
- create: create$a,
602
- meta: meta$a
601
+ create: create$b,
602
+ meta: meta$b
603
603
  };
604
604
 
605
- const meta$9 = {
605
+ const meta$a = {
606
606
  docs: {
607
607
  description: 'Disallow unsupported node version file values'
608
608
  },
@@ -611,7 +611,7 @@ const meta$9 = {
611
611
  },
612
612
  type: 'problem'
613
613
  };
614
- const create$9 = context => {
614
+ const create$a = context => {
615
615
  const sourceCode = getSourceCode(context);
616
616
  if (!sourceCode.parserServices?.isYAML) {
617
617
  return {};
@@ -636,11 +636,11 @@ const create$9 = context => {
636
636
 
637
637
  const nodeVersionFile = {
638
638
  __proto__: null,
639
- create: create$9,
640
- meta: meta$9
639
+ create: create$a,
640
+ meta: meta$a
641
641
  };
642
642
 
643
- const meta$8 = {
643
+ const meta$9 = {
644
644
  docs: {
645
645
  description: 'Disallow unsupported npm registry values'
646
646
  },
@@ -649,7 +649,7 @@ const meta$8 = {
649
649
  },
650
650
  type: 'problem'
651
651
  };
652
- const create$8 = context => {
652
+ const create$9 = context => {
653
653
  const sourceCode = getSourceCode(context);
654
654
  if (!sourceCode.parserServices?.isYAML) {
655
655
  return {};
@@ -673,6 +673,92 @@ const create$8 = context => {
673
673
  };
674
674
 
675
675
  const npmRegistry = {
676
+ __proto__: null,
677
+ create: create$9,
678
+ meta: meta$9
679
+ };
680
+
681
+ const meta$8 = {
682
+ docs: {
683
+ description: 'Require npm tasks to run in a consistent order'
684
+ },
685
+ messages: {
686
+ invalidNpmTaskOrder: '{{task}} must run after {{laterTask}}'
687
+ },
688
+ type: 'problem'
689
+ };
690
+ const npmTaskOrder = ['npm run build', 'npm run build:static', 'npm test', 'npm run type-check', 'npm run lint'];
691
+ const getNpmTask = value => {
692
+ const command = value.trim();
693
+ for (const task of npmTaskOrder) {
694
+ if (command === task || command.startsWith(`${task} `)) {
695
+ return task;
696
+ }
697
+ }
698
+ return undefined;
699
+ };
700
+ const getNpmTaskStep = entry => {
701
+ if (entry?.type !== 'YAMLMapping') {
702
+ return undefined;
703
+ }
704
+ for (const pair of entry.pairs) {
705
+ if (pair.key?.type !== 'YAMLScalar' || pair.key.value !== 'run' || pair.value?.type !== 'YAMLScalar' || typeof pair.value.value !== 'string') {
706
+ continue;
707
+ }
708
+ const task = getNpmTask(pair.value.value);
709
+ if (!task) {
710
+ return undefined;
711
+ }
712
+ return {
713
+ node: pair.value,
714
+ order: npmTaskOrder.indexOf(task),
715
+ task
716
+ };
717
+ }
718
+ return undefined;
719
+ };
720
+ const isStepsSequence = node => {
721
+ return node.parent.type === 'YAMLPair' && node.parent.key?.type === 'YAMLScalar' && node.parent.key.value === 'steps';
722
+ };
723
+ const create$8 = context => {
724
+ const sourceCode = getSourceCode(context);
725
+ if (!sourceCode.parserServices?.isYAML) {
726
+ return {};
727
+ }
728
+ return {
729
+ YAMLSequence(node) {
730
+ if (!isStepsSequence(node)) {
731
+ return;
732
+ }
733
+ const steps = node.entries.flatMap(entry => {
734
+ const step = getNpmTaskStep(entry);
735
+ return step ? [step] : [];
736
+ });
737
+ let earliestLaterStep;
738
+ for (let index = steps.length - 1; index >= 0; index--) {
739
+ const step = steps[index];
740
+ if (!step) {
741
+ continue;
742
+ }
743
+ if (earliestLaterStep && step.order > earliestLaterStep.order) {
744
+ context.report({
745
+ data: {
746
+ laterTask: earliestLaterStep.task,
747
+ task: step.task
748
+ },
749
+ messageId: 'invalidNpmTaskOrder',
750
+ node: step.node
751
+ });
752
+ }
753
+ if (!earliestLaterStep || step.order < earliestLaterStep.order) {
754
+ earliestLaterStep = step;
755
+ }
756
+ }
757
+ }
758
+ };
759
+ };
760
+
761
+ const npmTaskOrder$1 = {
676
762
  __proto__: null,
677
763
  create: create$8,
678
764
  meta: meta$8
@@ -1071,6 +1157,7 @@ const plugin = {
1071
1157
  'node-version-file': nodeVersionFile,
1072
1158
  npm: npm,
1073
1159
  'npm-registry': npmRegistry,
1160
+ 'npm-task-order': npmTaskOrder$1,
1074
1161
  on: on,
1075
1162
  permissions,
1076
1163
  'python-version': pythonVersion,
@@ -1102,6 +1189,7 @@ const recommended = [{
1102
1189
  'github-actions/node-version-file': 'error',
1103
1190
  'github-actions/npm': 'error',
1104
1191
  'github-actions/npm-registry': 'error',
1192
+ 'github-actions/npm-task-order': 'error',
1105
1193
  'github-actions/on': 'error',
1106
1194
  'github-actions/permissions': 'off',
1107
1195
  'github-actions/python-version': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-github-actions",
3
- "version": "16.3.0",
3
+ "version": "16.4.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "license": "MIT",