Skip to content

Commit c8c04d2

Browse files
committed
refactor: revert
1 parent 39c112a commit c8c04d2

38 files changed

+1026
-962
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import eslintPlugin from '@code-pushup/eslint-plugin';
2+
3+
export default {
4+
plugins: [
5+
await eslintPlugin(
6+
{ patterns: ['src/*.js'] },
7+
{
8+
artifacts: {
9+
generateArtifactsCommand:
10+
'npx eslint src/*.js --format json --output-file ./.code-pushup/eslint-report.json',
11+
artifactsPaths: ['./.code-pushup/eslint-report.json'],
12+
},
13+
},
14+
),
15+
],
16+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @type {import('eslint').Linter.Config[]} */
2+
module.exports = [
3+
{
4+
ignores: ['code-pushup.config.ts'],
5+
},
6+
{
7+
rules: {
8+
eqeqeq: 'error',
9+
'max-lines': ['warn', 100],
10+
'no-unused-vars': 'warn',
11+
},
12+
},
13+
];
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function unusedFn() {
2+
return '42';
3+
}
4+
5+
module.exports = function orwell() {
6+
if (2 + 2 == 5) {
7+
console.log(1984);
8+
}
9+
};

e2e/plugin-eslint-e2e/tests/__snapshots__/collect.e2e.test.ts.snap

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,235 @@ exports[`PLUGIN collect report with eslint-plugin NPM package > should run ESLin
225225
],
226226
}
227227
`;
228+
229+
exports[`PLUGIN collect report with eslint-plugin NPM package > should run ESLint plugin with artifacts options 1`] = `
230+
{
231+
"packageName": "@code-pushup/core",
232+
"plugins": [
233+
{
234+
"audits": [
235+
{
236+
"description": "ESLint rule **eqeqeq**.",
237+
"details": {
238+
"issues": [
239+
{
240+
"message": "Expected '===' and instead saw '=='.",
241+
"severity": "error",
242+
"source": {
243+
"file": "tmp/e2e/plugin-eslint-e2e/__test__/artifacts-config/src/index.js",
244+
"position": {
245+
"endColumn": 15,
246+
"endLine": 6,
247+
"startColumn": 13,
248+
"startLine": 6,
249+
},
250+
},
251+
},
252+
],
253+
},
254+
"displayValue": "1 error",
255+
"docsUrl": "https://eslint.org/docs/latest/rules/eqeqeq",
256+
"score": 0,
257+
"slug": "eqeqeq",
258+
"title": "Require the use of \`===\` and \`!==\`",
259+
"value": 1,
260+
},
261+
{
262+
"description": "ESLint rule **max-lines**.
263+
264+
Custom options:
265+
266+
\`\`\`json
267+
100
268+
\`\`\`",
269+
"details": {
270+
"issues": [],
271+
},
272+
"displayValue": "passed",
273+
"docsUrl": "https://eslint.org/docs/latest/rules/max-lines",
274+
"score": 1,
275+
"slug": "max-lines-71b54366cb01f77b",
276+
"title": "Enforce a maximum number of lines per file",
277+
"value": 0,
278+
},
279+
{
280+
"description": "ESLint rule **no-unused-vars**.",
281+
"details": {
282+
"issues": [
283+
{
284+
"message": "'unusedFn' is defined but never used.",
285+
"severity": "warning",
286+
"source": {
287+
"file": "tmp/e2e/plugin-eslint-e2e/__test__/artifacts-config/src/index.js",
288+
"position": {
289+
"endColumn": 18,
290+
"endLine": 1,
291+
"startColumn": 10,
292+
"startLine": 1,
293+
},
294+
},
295+
},
296+
],
297+
},
298+
"displayValue": "1 warning",
299+
"docsUrl": "https://eslint.org/docs/latest/rules/no-unused-vars",
300+
"score": 0,
301+
"slug": "no-unused-vars",
302+
"title": "Disallow unused variables",
303+
"value": 1,
304+
},
305+
],
306+
"description": "Official Code PushUp ESLint plugin",
307+
"docsUrl": "https://www.npmjs.com/package/@code-pushup/eslint-plugin",
308+
"groups": [
309+
{
310+
"description": "Code that either will cause an error or may cause confusing behavior. Developers should consider this a high priority to resolve.",
311+
"refs": [
312+
{
313+
"slug": "no-unused-vars",
314+
"weight": 1,
315+
},
316+
],
317+
"slug": "problems",
318+
"title": "Problems",
319+
},
320+
{
321+
"description": "Something that could be done in a better way but no errors will occur if the code isn't changed.",
322+
"refs": [
323+
{
324+
"slug": "eqeqeq",
325+
"weight": 1,
326+
},
327+
{
328+
"slug": "max-lines-71b54366cb01f77b",
329+
"weight": 1,
330+
},
331+
],
332+
"slug": "suggestions",
333+
"title": "Suggestions",
334+
},
335+
],
336+
"icon": "eslint",
337+
"packageName": "@code-pushup/eslint-plugin",
338+
"slug": "eslint",
339+
"title": "ESLint",
340+
},
341+
],
342+
}
343+
`;
344+
345+
exports[`PLUGIN collect report with eslint-plugin NPM package > should run ESLint plugin with artifacts options and create eslint-report.json and report.json 1`] = `
346+
{
347+
"packageName": "@code-pushup/core",
348+
"plugins": [
349+
{
350+
"audits": [
351+
{
352+
"description": "ESLint rule **eqeqeq**.",
353+
"details": {
354+
"issues": [
355+
{
356+
"message": "Expected '===' and instead saw '=='.",
357+
"severity": "error",
358+
"source": {
359+
"file": "tmp/e2e/plugin-eslint-e2e/__test__/artifacts-config/src/index.js",
360+
"position": {
361+
"endColumn": 15,
362+
"endLine": 6,
363+
"startColumn": 13,
364+
"startLine": 6,
365+
},
366+
},
367+
},
368+
],
369+
},
370+
"displayValue": "1 error",
371+
"docsUrl": "https://eslint.org/docs/latest/rules/eqeqeq",
372+
"score": 0,
373+
"slug": "eqeqeq",
374+
"title": "Require the use of \`===\` and \`!==\`",
375+
"value": 1,
376+
},
377+
{
378+
"description": "ESLint rule **max-lines**.
379+
380+
Custom options:
381+
382+
\`\`\`json
383+
100
384+
\`\`\`",
385+
"details": {
386+
"issues": [],
387+
},
388+
"displayValue": "passed",
389+
"docsUrl": "https://eslint.org/docs/latest/rules/max-lines",
390+
"score": 1,
391+
"slug": "max-lines-71b54366cb01f77b",
392+
"title": "Enforce a maximum number of lines per file",
393+
"value": 0,
394+
},
395+
{
396+
"description": "ESLint rule **no-unused-vars**.",
397+
"details": {
398+
"issues": [
399+
{
400+
"message": "'unusedFn' is defined but never used.",
401+
"severity": "warning",
402+
"source": {
403+
"file": "tmp/e2e/plugin-eslint-e2e/__test__/artifacts-config/src/index.js",
404+
"position": {
405+
"endColumn": 18,
406+
"endLine": 1,
407+
"startColumn": 10,
408+
"startLine": 1,
409+
},
410+
},
411+
},
412+
],
413+
},
414+
"displayValue": "1 warning",
415+
"docsUrl": "https://eslint.org/docs/latest/rules/no-unused-vars",
416+
"score": 0,
417+
"slug": "no-unused-vars",
418+
"title": "Disallow unused variables",
419+
"value": 1,
420+
},
421+
],
422+
"description": "Official Code PushUp ESLint plugin",
423+
"docsUrl": "https://www.npmjs.com/package/@code-pushup/eslint-plugin",
424+
"groups": [
425+
{
426+
"description": "Code that either will cause an error or may cause confusing behavior. Developers should consider this a high priority to resolve.",
427+
"refs": [
428+
{
429+
"slug": "no-unused-vars",
430+
"weight": 1,
431+
},
432+
],
433+
"slug": "problems",
434+
"title": "Problems",
435+
},
436+
{
437+
"description": "Something that could be done in a better way but no errors will occur if the code isn't changed.",
438+
"refs": [
439+
{
440+
"slug": "eqeqeq",
441+
"weight": 1,
442+
},
443+
{
444+
"slug": "max-lines-71b54366cb01f77b",
445+
"weight": 1,
446+
},
447+
],
448+
"slug": "suggestions",
449+
"title": "Suggestions",
450+
},
451+
],
452+
"icon": "eslint",
453+
"packageName": "@code-pushup/eslint-plugin",
454+
"slug": "eslint",
455+
"title": "ESLint",
456+
},
457+
],
458+
}
459+
`;

e2e/plugin-eslint-e2e/tests/collect.e2e.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('PLUGIN collect report with eslint-plugin NPM package', () => {
2020
);
2121
const fixturesFlatConfigDir = path.join(fixturesDir, 'flat-config');
2222
const fixturesLegacyConfigDir = path.join(fixturesDir, 'legacy-config');
23+
const fixturesArtifactsConfigDir = path.join(fixturesDir, 'artifacts-config');
2324

2425
const envRoot = path.join(
2526
E2E_ENVIRONMENTS_DIR,
@@ -28,22 +29,32 @@ describe('PLUGIN collect report with eslint-plugin NPM package', () => {
2829
);
2930
const flatConfigDir = path.join(envRoot, 'flat-config');
3031
const legacyConfigDir = path.join(envRoot, 'legacy-config');
32+
const artifactsConfigDir = path.join(envRoot, 'artifacts-config');
3133
const flatConfigOutputDir = path.join(flatConfigDir, '.code-pushup');
3234
const legacyConfigOutputDir = path.join(legacyConfigDir, '.code-pushup');
35+
const artifactsConfigOutputDir = path.join(
36+
artifactsConfigDir,
37+
'.code-pushup',
38+
);
3339

3440
beforeAll(async () => {
3541
await cp(fixturesFlatConfigDir, flatConfigDir, { recursive: true });
3642
await cp(fixturesLegacyConfigDir, legacyConfigDir, { recursive: true });
43+
await cp(fixturesArtifactsConfigDir, artifactsConfigDir, {
44+
recursive: true,
45+
});
3746
});
3847

3948
afterAll(async () => {
4049
await teardownTestFolder(flatConfigDir);
4150
await teardownTestFolder(legacyConfigDir);
51+
await teardownTestFolder(artifactsConfigDir);
4252
});
4353

4454
afterEach(async () => {
4555
await teardownTestFolder(flatConfigOutputDir);
4656
await teardownTestFolder(legacyConfigOutputDir);
57+
await teardownTestFolder(artifactsConfigOutputDir);
4758
});
4859

4960
it('should run ESLint plugin for flat config and create report.json', async () => {
@@ -80,4 +91,21 @@ describe('PLUGIN collect report with eslint-plugin NPM package', () => {
8091
expect(() => reportSchema.parse(report)).not.toThrow();
8192
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
8293
});
94+
95+
it('should run ESLint plugin with artifacts options and create eslint-report.json and report.json', async () => {
96+
const { code } = await executeProcess({
97+
command: 'npx',
98+
args: ['@code-pushup/cli', 'collect', '--no-progress'],
99+
cwd: artifactsConfigDir,
100+
});
101+
102+
expect(code).toBe(0);
103+
104+
const report = await readJsonFile(
105+
path.join(artifactsConfigOutputDir, 'report.json'),
106+
);
107+
108+
expect(() => reportSchema.parse(report)).not.toThrow();
109+
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
110+
});
83111
});

packages/ci/src/lib/create-execution-observer.int.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('createExecutionObserver', () => {
99
it('should use execute process and use observer to capture stdout message and stderr will be empty', async () => {
1010
const { stdout, stderr } = await executeProcess({
1111
command: 'node',
12-
args: ['-e', `console.log('${message}');`],
12+
args: ['-e', `"console.log('${message}');"`],
1313
observer: createExecutionObserver(),
1414
});
1515

@@ -20,7 +20,7 @@ describe('createExecutionObserver', () => {
2020
it('should use execute process and use observer to capture stdout message and stderr will be error', async () => {
2121
const { stdout, stderr } = await executeProcess({
2222
command: 'node',
23-
args: ['-e', `console.log('${message}'); console.error('${error}');`],
23+
args: ['-e', `"console.log('${message}'); console.error('${error}');"`],
2424
observer: createExecutionObserver(),
2525
});
2626

@@ -31,7 +31,7 @@ describe('createExecutionObserver', () => {
3131
it('should use execute process and use observer to capture stderr error and ignore stdout message', async () => {
3232
const { stdout, stderr } = await executeProcess({
3333
command: 'node',
34-
args: ['-e', `console.log('${message}'); console.error('${error}');`],
34+
args: ['-e', `"console.log('${message}'); console.error('${error}');"`],
3535
observer: createExecutionObserver({ silent: true }),
3636
});
3737

packages/nx-plugin/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
"@nx/devkit": ">=17.0.0",
3838
"ansis": "^3.3.0",
3939
"nx": ">=17.0.0",
40-
"zod": "^4.0.5",
41-
"chalk": "5.3.0"
40+
"zod": "^4.0.5"
4241
},
4342
"files": [
4443
"src",

packages/nx-plugin/src/executors/cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ Show what will be executed without actually executing it:
7272
| ----------------- | --------- | ------------------------------------------------------------------ |
7373
| **projectPrefix** | `string` | prefix for upload.project on non root projects |
7474
| **dryRun** | `boolean` | To debug the executor, dry run the command without real execution. |
75-
| **cliBin** | `string` | Path to Code PushUp CLI |
75+
| **bin** | `string` | Path to Code PushUp CLI |
7676

7777
For all other options see the [CLI autorun documentation](../../../../cli/README.md#autorun-command).

0 commit comments

Comments
 (0)