@lvce-editor/eslint-plugin-github-actions 16.2.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 +185 -44
  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$i = {
41
+ const meta$k = {
42
42
  docs: {
43
43
  description: 'Disallow unsupported action versions'
44
44
  },
@@ -48,7 +48,7 @@ const meta$i = {
48
48
  },
49
49
  type: 'problem'
50
50
  };
51
- const create$i = 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$i = context => {
79
79
 
80
80
  const actionVersions = {
81
81
  __proto__: null,
82
- create: create$i,
83
- meta: meta$i
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$h = {
107
+ const meta$j = {
108
108
  docs: {
109
109
  description: 'Disallow unsupported ci versions'
110
110
  },
@@ -113,7 +113,7 @@ const meta$h = {
113
113
  },
114
114
  type: 'problem'
115
115
  };
116
- const create$h = 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$h = context => {
157
157
 
158
158
  const ciVersions = {
159
159
  __proto__: null,
160
- create: create$h,
161
- meta: meta$h
160
+ create: create$j,
161
+ meta: meta$j
162
162
  };
163
163
 
164
- const meta$g = {
164
+ const meta$i = {
165
165
  docs: {
166
166
  description: 'Disallow unsupported fail fast values'
167
167
  },
@@ -170,7 +170,7 @@ const meta$g = {
170
170
  },
171
171
  type: 'problem'
172
172
  };
173
- const create$g = 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$g = context => {
193
193
 
194
194
  const failFast = {
195
195
  __proto__: null,
196
- create: create$g,
197
- meta: meta$g
196
+ create: create$i,
197
+ meta: meta$i
198
198
  };
199
199
 
200
- const meta$f = {
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$f = 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$f = context => {
290
290
 
291
291
  const githubPages = {
292
292
  __proto__: null,
293
- create: create$f,
294
- meta: meta$f
293
+ create: create$h,
294
+ meta: meta$h
295
295
  };
296
296
 
297
- const meta$e = {
297
+ const meta$g = {
298
298
  docs: {
299
299
  description: 'Disallow unsupported github token values'
300
300
  },
@@ -303,7 +303,7 @@ const meta$e = {
303
303
  },
304
304
  type: 'problem'
305
305
  };
306
- const create$e = 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$e = context => {
328
328
 
329
329
  const githubToken = {
330
330
  __proto__: null,
331
- create: create$e,
332
- meta: meta$e
331
+ create: create$g,
332
+ meta: meta$g
333
333
  };
334
334
 
335
- const meta$d = {
335
+ const meta$f = {
336
336
  docs: {
337
337
  description: 'Disallow unsupported matrix values'
338
338
  },
@@ -341,7 +341,7 @@ const meta$d = {
341
341
  },
342
342
  type: 'problem'
343
343
  };
344
- const create$d = 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$d = context => {
364
364
 
365
365
  const matrix = {
366
366
  __proto__: null,
367
- create: create$d,
368
- meta: meta$d
367
+ create: create$f,
368
+ meta: meta$f
369
369
  };
370
370
 
371
- const meta$c = {
371
+ const meta$e = {
372
372
  docs: {
373
373
  description: 'Disallow unsupported max parallel values'
374
374
  },
@@ -377,7 +377,7 @@ const meta$c = {
377
377
  },
378
378
  type: 'problem'
379
379
  };
380
- const create$c = 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$c = context => {
400
400
 
401
401
  const maxParallel = {
402
402
  __proto__: null,
403
- create: create$c,
404
- meta: meta$c
403
+ create: create$e,
404
+ meta: meta$e
405
405
  };
406
406
 
407
- const meta$b = {
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$b = 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$b = context => {
496
496
 
497
497
  const needs = {
498
498
  __proto__: null,
499
- create: create$b,
500
- meta: meta$b
499
+ create: create$d,
500
+ meta: meta$d
501
501
  };
502
502
 
503
- const meta$a = {
503
+ const meta$c = {
504
504
  docs: {
505
505
  description: 'Disallow e2e tests in release workflows'
506
506
  },
@@ -509,7 +509,7 @@ const meta$a = {
509
509
  },
510
510
  type: 'problem'
511
511
  };
512
- const isReleaseWorkflow = filename => {
512
+ const isReleaseWorkflow$1 = filename => {
513
513
  const normalized = filename.replaceAll('\\', '/');
514
514
  return normalized.endsWith('/release.yml') || normalized.endsWith('/release.yaml') || normalized === 'release.yml' || normalized === 'release.yaml';
515
515
  };
@@ -528,9 +528,9 @@ const runsE2eTests = value => {
528
528
  }
529
529
  return false;
530
530
  };
531
- const create$a = context => {
531
+ const create$c = context => {
532
532
  const sourceCode = getSourceCode(context);
533
- if (!sourceCode.parserServices?.isYAML || !isReleaseWorkflow(context.filename)) {
533
+ if (!sourceCode.parserServices?.isYAML || !isReleaseWorkflow$1(context.filename)) {
534
534
  return {};
535
535
  }
536
536
  return {
@@ -547,11 +547,62 @@ const create$a = context => {
547
547
 
548
548
  const noE2eInRelease = {
549
549
  __proto__: null,
550
- create: create$a,
551
- meta: meta$a
550
+ create: create$c,
551
+ meta: meta$c
552
552
  };
553
553
 
554
- const meta$9 = {
554
+ const meta$b = {
555
+ docs: {
556
+ description: 'Disallow memory measurement in release workflows'
557
+ },
558
+ messages: {
559
+ noMeasureInRelease: 'Do not run memory measurement in release workflows'
560
+ },
561
+ type: 'problem'
562
+ };
563
+ const isReleaseWorkflow = filename => {
564
+ const normalized = filename.replaceAll('\\', '/');
565
+ return normalized.endsWith('/release.yml') || normalized.endsWith('/release.yaml') || normalized === 'release.yml' || normalized === 'release.yaml';
566
+ };
567
+ const runsMemoryMeasurement = value => {
568
+ const commands = value.replaceAll('\r', '\n').replaceAll('&&', ';').replaceAll('||', ';').split(/[\n;]/);
569
+ for (const command of commands) {
570
+ const tokens = command.trim().split(/\s+/);
571
+ const npmIndex = tokens.indexOf('npm');
572
+ if (npmIndex === -1) {
573
+ continue;
574
+ }
575
+ const scriptName = tokens[npmIndex + 2];
576
+ if (tokens[npmIndex + 1] === 'run' && (scriptName === 'measure' || scriptName?.startsWith('measure:'))) {
577
+ return true;
578
+ }
579
+ }
580
+ return false;
581
+ };
582
+ const create$b = context => {
583
+ const sourceCode = getSourceCode(context);
584
+ if (!sourceCode.parserServices?.isYAML || !isReleaseWorkflow(context.filename)) {
585
+ return {};
586
+ }
587
+ return {
588
+ YAMLPair(node) {
589
+ if (node && node.type === 'YAMLPair' && node.key && typeof node.key === 'object' && 'type' in node.key && node.key.type === 'YAMLScalar' && node.key.value === 'run' && node.value && typeof node.value === 'object' && 'type' in node.value && node.value.type === 'YAMLScalar' && typeof node.value.value === 'string' && runsMemoryMeasurement(node.value.value)) {
590
+ context.report({
591
+ messageId: 'noMeasureInRelease',
592
+ node: node.value
593
+ });
594
+ }
595
+ }
596
+ };
597
+ };
598
+
599
+ const noMeasureInRelease = {
600
+ __proto__: null,
601
+ create: create$b,
602
+ meta: meta$b
603
+ };
604
+
605
+ const meta$a = {
555
606
  docs: {
556
607
  description: 'Disallow unsupported node version file values'
557
608
  },
@@ -560,7 +611,7 @@ const meta$9 = {
560
611
  },
561
612
  type: 'problem'
562
613
  };
563
- const create$9 = context => {
614
+ const create$a = context => {
564
615
  const sourceCode = getSourceCode(context);
565
616
  if (!sourceCode.parserServices?.isYAML) {
566
617
  return {};
@@ -585,11 +636,11 @@ const create$9 = context => {
585
636
 
586
637
  const nodeVersionFile = {
587
638
  __proto__: null,
588
- create: create$9,
589
- meta: meta$9
639
+ create: create$a,
640
+ meta: meta$a
590
641
  };
591
642
 
592
- const meta$8 = {
643
+ const meta$9 = {
593
644
  docs: {
594
645
  description: 'Disallow unsupported npm registry values'
595
646
  },
@@ -598,7 +649,7 @@ const meta$8 = {
598
649
  },
599
650
  type: 'problem'
600
651
  };
601
- const create$8 = context => {
652
+ const create$9 = context => {
602
653
  const sourceCode = getSourceCode(context);
603
654
  if (!sourceCode.parserServices?.isYAML) {
604
655
  return {};
@@ -622,6 +673,92 @@ const create$8 = context => {
622
673
  };
623
674
 
624
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 = {
625
762
  __proto__: null,
626
763
  create: create$8,
627
764
  meta: meta$8
@@ -1016,9 +1153,11 @@ const plugin = {
1016
1153
  'max-parallel': maxParallel,
1017
1154
  needs: needs,
1018
1155
  'no-e2e-in-release': noE2eInRelease,
1156
+ 'no-measure-in-release': noMeasureInRelease,
1019
1157
  'node-version-file': nodeVersionFile,
1020
1158
  npm: npm,
1021
1159
  'npm-registry': npmRegistry,
1160
+ 'npm-task-order': npmTaskOrder$1,
1022
1161
  on: on,
1023
1162
  permissions,
1024
1163
  'python-version': pythonVersion,
@@ -1046,9 +1185,11 @@ const recommended = [{
1046
1185
  'github-actions/max-parallel': 'error',
1047
1186
  'github-actions/needs': 'error',
1048
1187
  'github-actions/no-e2e-in-release': 'error',
1188
+ 'github-actions/no-measure-in-release': 'error',
1049
1189
  'github-actions/node-version-file': 'error',
1050
1190
  'github-actions/npm': 'error',
1051
1191
  'github-actions/npm-registry': 'error',
1192
+ 'github-actions/npm-task-order': 'error',
1052
1193
  'github-actions/on': 'error',
1053
1194
  'github-actions/permissions': 'off',
1054
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.2.0",
3
+ "version": "16.4.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "license": "MIT",