-
Notifications
You must be signed in to change notification settings - Fork 15
feat(utils): implement a new design for stdout #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,3 +42,4 @@ export { | |
| distinct, | ||
| slugify, | ||
| } from './lib/transformation'; | ||
| export { NEW_LINE } from './lib/md'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 79 additions & 17 deletions
96
packages/utils/src/lib/__snapshots__/report-to-stdout.spec.ts.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,90 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`report-to-stdout > should contain all sections when using the fixture report 1`] = ` | ||
| "[1mCode PushUp Report[22m - @code-pushup/[email protected] | ||
| [3m[90m---[39m[23m | ||
| [3m[90mPackage Name: @code-pushup/core[39m[23m | ||
| [3m[90mVersion: 0.1.0[39m[23m | ||
| [3m[90mCommit: feat(cli): add logic for markdown report - 7eba125ad5643c2f90cb21389fc3442d786f43f9[39m[23m | ||
| [3m[90mDate: today[39m[23m | ||
| [3m[90mDuration: 42ms[39m[23m | ||
| [3m[90mPlugins: 1[39m[23m | ||
| [3m[90mAudits: 1[39m[23m | ||
| [3m[90m---[39m[23m | ||
| "Code PushUp Report - @code-pushup/[email protected] | ||
|
|
||
|
|
||
| 🏷 Category ⭐ Score 🛡 Audits | ||
| Category 1 0 1/1 | ||
| ESLint audits | ||
|
|
||
| ● Disallow assignment operators in conditional expressions 0 | ||
| ● Disallow reassigning \`const\` variables 0 | ||
| ● Disallow the use of \`debugger\` 0 | ||
| ● Disallow invalid regular expression strings in \`RegExp\` construct 0 | ||
| ors | ||
| ● Disallow the use of undeclared variables unless mentioned in \`/*g 0 | ||
| lobal */\` comments | ||
| ● Disallow loops with a body that allows only one iteration 0 | ||
| ● Disallow negating the left operand of relational operators 0 | ||
| ● Disallow use of optional chaining in contexts where the \`undefine 0 | ||
| d\` value is not allowed | ||
| ● Disallow unused variables 1 warning | ||
| ● Require calls to \`isNaN()\` when checking for \`NaN\` 0 | ||
| ● Enforce comparing \`typeof\` expressions against valid strings 0 | ||
| ● Require braces around arrow function bodies 1 warning | ||
| ● Enforce camelcase naming convention 0 | ||
| ● Enforce consistent brace style for all control statements 0 | ||
| ● Require the use of \`===\` and \`!==\` 1 warning | ||
| ● Enforce a maximum number of lines of code in a function 1 warning | ||
| ● Enforce a maximum number of lines per file 0 | ||
| ● Disallow variable declarations from shadowing variables declared 3 warnings | ||
| in the outer scope | ||
| ● Require \`let\` or \`const\` instead of \`var\` 0 | ||
| ● Require or disallow method and property shorthand syntax for obje 3 warnings | ||
| ct literals | ||
| ● Require using arrow functions for callbacks 0 | ||
| ● Require \`const\` declarations for variables that are never reassig 1 warning | ||
| ned after declared | ||
| ● Disallow using Object.assign with an object literal as the first 0 | ||
| argument and prefer the use of object spread instead | ||
| ● Require or disallow \\"Yoda\\" conditions 0 | ||
| ● Disallow missing \`key\` props in iterators/collection literals 1 warning | ||
| ● Disallow missing props validation in a React component definition 6 warnings | ||
| ● Disallow missing React when using JSX 0 | ||
| ● enforces the Rules of Hooks 0 | ||
| ● verifies the list of dependencies for Hooks like useEffect and si 2 warnings | ||
| milar | ||
| ● Disallow missing displayName in a React component definition 0 | ||
| ● Disallow comments from being inserted as text nodes 0 | ||
| ● Disallow duplicate properties in JSX 0 | ||
| ● Disallow \`target=\\"_blank\\"\` attribute without \`rel=\\"noreferrer\\"\` 0 | ||
| ● Disallow undeclared variables in JSX 0 | ||
| ● Disallow React to be incorrectly marked as unused 0 | ||
| ● Disallow variables used in JSX to be incorrectly marked as unused 0 | ||
| ● Disallow passing of children as props 0 | ||
| ● Disallow when a DOM element is using both children and dangerousl 0 | ||
| ySetInnerHTML | ||
| ● Disallow usage of deprecated methods 0 | ||
| ● Disallow direct mutation of this.state 0 | ||
| ● Disallow usage of findDOMNode 0 | ||
| ● Disallow usage of isMounted 0 | ||
| ● Disallow usage of the return value of ReactDOM.render 0 | ||
| ● Disallow using string references 0 | ||
| ● Disallow unescaped HTML entities from appearing in markup 0 | ||
| ● Disallow usage of unknown DOM property 0 | ||
| ● Enforce ES5 or ES6 class for returning value in render function 0 | ||
|
|
||
| [1mCategory 1 0[22m | ||
| - Audit Title (1) | ||
| audit description | ||
| http://www.my-docs.dev | ||
|
|
||
| Lighthouse audits | ||
|
|
||
| ● First Contentful Paint 1.2 s | ||
| ● Largest Contentful Paint 1.5 s | ||
| ● Total Blocking Time 0 ms | ||
| ● Cumulative Layout Shift 0 | ||
| ● Speed Index 1.2 s | ||
|
|
||
| Made with ❤️ by code-pushup.dev" | ||
|
|
||
| Categories | ||
|
|
||
| ┌────────────────┬───────┬────────┐ | ||
| │ Category │ Score │ Audits │ | ||
| ├────────────────┼───────┼────────┤ | ||
| │ Performance │ 92 │ 6 │ | ||
| ├────────────────┼───────┼────────┤ | ||
| │ Bug prevention │ 68 │ 16 │ | ||
| ├────────────────┼───────┼────────┤ | ||
| │ Code style │ 54 │ 13 │ | ||
| └────────────────┴───────┴────────┘ | ||
|
|
||
| Made with ❤ by code-pushup.dev | ||
| " | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,14 @@ | ||
| import { afterEach, beforeEach, describe } from 'vitest'; | ||
| import { minimalReport } from '@code-pushup/models/testing'; | ||
| import { mockConsole, unmockConsole } from '../../test'; | ||
| import { describe } from 'vitest'; | ||
| import { report } from '@code-pushup/models/testing'; | ||
| import { reportToStdout } from './report-to-stdout'; | ||
| import { scoreReport } from './scoring'; | ||
|
|
||
| let logs: string[]; | ||
|
|
||
| describe('report-to-stdout', () => { | ||
| beforeEach(async () => { | ||
| logs = []; | ||
| mockConsole(msg => logs.push(msg)); | ||
| }); | ||
| afterEach(() => { | ||
| unmockConsole(); | ||
| }); | ||
|
|
||
| it('should contain all sections when using the fixture report', () => { | ||
| reportToStdout(scoreReport(minimalReport('tmp'))); | ||
| const logOutput = logs.join('\n'); | ||
| expect(logOutput).toMatchSnapshot(); | ||
| const logOutput = reportToStdout(scoreReport(report())); | ||
| // logOutput.replace(/\u001B\[\d+m/g, '') removes all color codes from the output | ||
| // for snapshot readability | ||
| // eslint-disable-next-line no-control-regex | ||
| expect(logOutput.replace(/\u001B\[\d+m/g, '')).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.