@lvce-editor/eslint-plugin-github-actions 2.5.0 → 2.6.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 +80 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23,11 +23,12 @@ const actions = {
23
23
  };
24
24
  const npmRegistries = ['https://registry.npmjs.org', 'https://npm.pkg.github.com'];
25
25
  const onProperties = ['push', 'pull_request'];
26
+ const npmCommands = ['run', 'test', 'publish', 'install', 'ci'];
26
27
 
27
28
  const isSupported = (actions, value) => {
28
29
  return actions.includes(value);
29
30
  };
30
- const meta$6 = {
31
+ const meta$7 = {
31
32
  type: 'problem',
32
33
  docs: {
33
34
  description: 'Disallow unsupported action versions'
@@ -36,7 +37,7 @@ const meta$6 = {
36
37
  unsupportedActionVersion: 'Unsupported action version: {{value}}'
37
38
  }
38
39
  };
39
- const create$6 = context => {
40
+ const create$7 = context => {
40
41
  const sourceCode = getSourceCode(context);
41
42
  if (!sourceCode.parserServices?.isYAML) {
42
43
  return {};
@@ -63,8 +64,8 @@ const create$6 = context => {
63
64
 
64
65
  const actionVersions = {
65
66
  __proto__: null,
66
- create: create$6,
67
- meta: meta$6
67
+ create: create$7,
68
+ meta: meta$7
68
69
  };
69
70
 
70
71
  const parseVersion = value => {
@@ -88,7 +89,7 @@ const isSupportedMacosversion = version => {
88
89
  const isSupportedWindowsVersion = version => {
89
90
  return config.windows.includes(version);
90
91
  };
91
- const meta$5 = {
92
+ const meta$6 = {
92
93
  type: 'problem',
93
94
  docs: {
94
95
  description: 'Disallow unsupported ci versions'
@@ -97,7 +98,7 @@ const meta$5 = {
97
98
  unsupportedCiVersion: 'Unsupported ci version: {{value}}'
98
99
  }
99
100
  };
100
- const create$5 = context => {
101
+ const create$6 = context => {
101
102
  const sourceCode = getSourceCode(context);
102
103
  if (!sourceCode.parserServices?.isYAML) {
103
104
  return {};
@@ -140,11 +141,11 @@ const create$5 = context => {
140
141
 
141
142
  const ciVersions = {
142
143
  __proto__: null,
143
- create: create$5,
144
- meta: meta$5
144
+ create: create$6,
145
+ meta: meta$6
145
146
  };
146
147
 
147
- const meta$4 = {
148
+ const meta$5 = {
148
149
  type: 'problem',
149
150
  docs: {
150
151
  description: 'Disallow unsupported fail fast values'
@@ -153,7 +154,7 @@ const meta$4 = {
153
154
  unsupportedFailFast: 'Unsupported fail fast value: {{value}}'
154
155
  }
155
156
  };
156
- const create$4 = context => {
157
+ const create$5 = context => {
157
158
  const sourceCode = getSourceCode(context);
158
159
  if (!sourceCode.parserServices?.isYAML) {
159
160
  return {};
@@ -176,11 +177,11 @@ const create$4 = context => {
176
177
 
177
178
  const failFast = {
178
179
  __proto__: null,
179
- create: create$4,
180
- meta: meta$4
180
+ create: create$5,
181
+ meta: meta$5
181
182
  };
182
183
 
183
- const meta$3 = {
184
+ const meta$4 = {
184
185
  type: 'problem',
185
186
  docs: {
186
187
  description: 'Disallow unsupported max parallel values'
@@ -189,7 +190,7 @@ const meta$3 = {
189
190
  unsupportedMaxParallel: 'Unsupported max parallel value: {{value}}'
190
191
  }
191
192
  };
192
- const create$3 = context => {
193
+ const create$4 = context => {
193
194
  const sourceCode = getSourceCode(context);
194
195
  if (!sourceCode.parserServices?.isYAML) {
195
196
  return {};
@@ -212,11 +213,11 @@ const create$3 = context => {
212
213
 
213
214
  const maxParallel = {
214
215
  __proto__: null,
215
- create: create$3,
216
- meta: meta$3
216
+ create: create$4,
217
+ meta: meta$4
217
218
  };
218
219
 
219
- const meta$2 = {
220
+ const meta$3 = {
220
221
  type: 'problem',
221
222
  docs: {
222
223
  description: 'Disallow unsupported npm registry values'
@@ -225,7 +226,7 @@ const meta$2 = {
225
226
  unsupportedNpmRegistry: 'Unsupported npm registry value: {{value}}'
226
227
  }
227
228
  };
228
- const create$2 = context => {
229
+ const create$3 = context => {
229
230
  const sourceCode = getSourceCode(context);
230
231
  if (!sourceCode.parserServices?.isYAML) {
231
232
  return {};
@@ -250,11 +251,11 @@ const create$2 = context => {
250
251
 
251
252
  const npmRegistry = {
252
253
  __proto__: null,
253
- create: create$2,
254
- meta: meta$2
254
+ create: create$3,
255
+ meta: meta$3
255
256
  };
256
257
 
257
- const meta$1 = {
258
+ const meta$2 = {
258
259
  type: 'problem',
259
260
  docs: {
260
261
  description: 'Disallow unsupported on values'
@@ -263,7 +264,7 @@ const meta$1 = {
263
264
  unsupportedOn: 'Unsupported on value: {{value}}'
264
265
  }
265
266
  };
266
- const create$1 = context => {
267
+ const create$2 = context => {
267
268
  const sourceCode = getSourceCode(context);
268
269
  if (!sourceCode.parserServices?.isYAML) {
269
270
  return {};
@@ -290,11 +291,11 @@ const create$1 = context => {
290
291
 
291
292
  const on = {
292
293
  __proto__: null,
293
- create: create$1,
294
- meta: meta$1
294
+ create: create$2,
295
+ meta: meta$2
295
296
  };
296
297
 
297
- const meta = {
298
+ const meta$1 = {
298
299
  type: 'problem',
299
300
  docs: {
300
301
  description: 'Disallow unsupported timeout minute values'
@@ -303,7 +304,7 @@ const meta = {
303
304
  unsupportedTimeoutMinutes: 'Unsupported timeout minutes value: {{value}}'
304
305
  }
305
306
  };
306
- const create = context => {
307
+ const create$1 = context => {
307
308
  const sourceCode = getSourceCode(context);
308
309
  if (!sourceCode.parserServices?.isYAML) {
309
310
  return {};
@@ -325,6 +326,55 @@ const create = context => {
325
326
  };
326
327
 
327
328
  const timeoutMinutes = {
329
+ __proto__: null,
330
+ create: create$1,
331
+ meta: meta$1
332
+ };
333
+
334
+ const meta = {
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 = 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,
365
+ messageId: 'unsupportedNpmCommand',
366
+ data: {
367
+ value: nodeValue
368
+ }
369
+ });
370
+ }
371
+ }
372
+ }
373
+ }
374
+ };
375
+ };
376
+
377
+ const npm = {
328
378
  __proto__: null,
329
379
  create,
330
380
  meta
@@ -338,11 +388,12 @@ const plugin = {
338
388
  rules: {
339
389
  'action-versions': actionVersions,
340
390
  'ci-versions': ciVersions,
391
+ 'fail-fast': failFast,
341
392
  'max-parallel': maxParallel,
342
393
  'npm-registry': npmRegistry,
343
- 'fail-fast': failFast,
344
394
  'timeout-minutes': timeoutMinutes,
345
- on: on
395
+ on: on,
396
+ npm: npm
346
397
  }
347
398
  };
348
399
  const recommended = [{
@@ -359,6 +410,7 @@ const recommended = [{
359
410
  'github-actions/fail-fast': 'error',
360
411
  'github-actions/max-parallel': 'error',
361
412
  'github-actions/npm-registry': 'error',
413
+ 'github-actions/npm': 'error',
362
414
  'github-actions/on': 'error',
363
415
  'github-actions/timeout-minutes': 'error'
364
416
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-github-actions",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],