Skip to content

Commit bdf038a

Browse files
committed
refactor: revert out of scope
1 parent 39c112a commit bdf038a

File tree

29 files changed

+795
-412
lines changed

29 files changed

+795
-412
lines changed

e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,29 @@ describe('nx-plugin', () => {
103103
});
104104
});
105105

106+
it('should consider plugin option bin in configuration target', async () => {
107+
const cwd = path.join(testFileDir, 'configuration-option-bin');
108+
registerPluginInWorkspace(tree, {
109+
plugin: '@code-pushup/nx-plugin',
110+
options: {
111+
bin: 'XYZ',
112+
},
113+
});
114+
await materializeTree(tree, cwd);
115+
116+
const { code, projectJson } = await nxShowProjectJson(cwd, project);
117+
118+
expect(code).toBe(0);
119+
120+
expect(projectJson.targets).toStrictEqual({
121+
'code-pushup--configuration': expect.objectContaining({
122+
options: {
123+
command: `nx g XYZ:configuration --skipTarget --targetName="code-pushup" --project="${project}"`,
124+
},
125+
}),
126+
});
127+
});
128+
106129
it('should NOT add config targets dynamically if the project is configured', async () => {
107130
const cwd = path.join(testFileDir, 'configuration-already-configured');
108131
registerPluginInWorkspace(tree, '@code-pushup/nx-plugin');
@@ -166,26 +189,28 @@ describe('nx-plugin', () => {
166189

167190
await materializeTree(tree, cwd);
168191

169-
const { stdout } = await executeProcess({
192+
const { stdout, stderr } = await executeProcess({
170193
command: 'npx',
171-
args: ['nx', 'run', `${project}:code-pushup`, '--dryRun', '--verbose'],
194+
args: ['nx', 'run', `${project}:code-pushup`, '--dryRun'],
172195
cwd,
173196
});
174197

198+
const cleanStderr = removeColorCodes(stderr);
199+
// @TODO create test environment for working plugin. This here misses package-lock.json to execute correctly
200+
expect(cleanStderr).toContain('DryRun execution of: npx @code-pushup/cli');
201+
175202
const cleanStdout = removeColorCodes(stdout);
176-
expect(cleanStdout).toContain('nx run my-lib:code-pushup');
177-
expect(cleanStdout).toContain('$ npx @code-pushup/cli ');
178-
expect(cleanStdout).toContain('--dryRun --verbose');
179-
expect(cleanStdout).toContain(`--upload.project=\\"${project}\\"`);
203+
expect(cleanStdout).toContain(
204+
'NX Successfully ran target code-pushup for project my-lib',
205+
);
180206
});
181207

182-
it('should consider plugin option cliBin in executor target', async () => {
183-
const cwd = path.join(testFileDir, 'executor-option-cliBin');
184-
const cliBinPath = `packages/cli/dist`;
208+
it('should consider plugin option bin in executor target', async () => {
209+
const cwd = path.join(testFileDir, 'configuration-option-bin');
185210
registerPluginInWorkspace(tree, {
186211
plugin: '@code-pushup/nx-plugin',
187212
options: {
188-
cliBin: cliBinPath,
213+
bin: 'XYZ',
189214
},
190215
});
191216
const { root } = readProjectConfiguration(tree, project);
@@ -198,15 +223,13 @@ describe('nx-plugin', () => {
198223

199224
expect(projectJson.targets).toStrictEqual({
200225
'code-pushup': expect.objectContaining({
201-
options: {
202-
bin: cliBinPath,
203-
},
226+
executor: 'XYZ:cli',
204227
}),
205228
});
206229
});
207230

208231
it('should consider plugin option projectPrefix in executor target', async () => {
209-
const cwd = path.join(testFileDir, 'executor-option-projectPrefix');
232+
const cwd = path.join(testFileDir, 'configuration-option-bin');
210233
registerPluginInWorkspace(tree, {
211234
plugin: '@code-pushup/nx-plugin',
212235
options: {
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+
`;

0 commit comments

Comments
 (0)