Skip to content

Commit

Permalink
fix(results): markdown template formatting
Browse files Browse the repository at this point in the history
- markdown template should follow prettiers format
  • Loading branch information
AriPerkkio committed Jan 3, 2021
1 parent 376c7d5 commit c0f62fb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
17 changes: 11 additions & 6 deletions lib/file-client/result-templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ResultParser } from '@config/types';
import { LintMessage } from '@engine/types';

const NEW_LINE_REGEX = /\n/g;

// Note that this is part of public API
export interface ResultTemplateOptions {
repository: string;
Expand Down Expand Up @@ -30,16 +32,19 @@ ${options.error}
// prettier-ignore
const RESULT_TEMPLATE_MARKDOWN = (options: ResultTemplateOptions): string =>
`## Rule: ${options.rule}
- Message: \`${options.message}\`
- Path: \`${options.path}\`
- [Link](${options.link})
- Message: \`${options.message.replace(NEW_LINE_REGEX, ' ')}\`
- Path: \`${options.path}\`
- [Link](${options.link})
\`\`\`${options.extension || ''}
${options.source || ''}
\`\`\`
${options.error ?
`\`\`\`
${options.error ? `
\`\`\`
${options.error}
\`\`\`` : ''}`;
\`\`\`
` : ''}`;

// prettier-ignore
export const RESULTS_TEMPLATE_CI_BASE = (options: ResultTemplateOptions): string =>
Expand Down
43 changes: 27 additions & 16 deletions test/integration/integration.cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ describe('CLI', () => {

expect(sanitizeStackTrace(results)).toMatchInlineSnapshot(`
"## Rule: unable-to-parse-rule-id
- Message: \`Cannot read property 'someAttribute' of undefined
Occurred while linting <text>:2\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/expected-to-crash-linter.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/expected-to-crash-linter.js#L2)
- Message: \`Cannot read property 'someAttribute' of undefined Occurred while linting <text>:2\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/expected-to-crash-linter.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/expected-to-crash-linter.js#L2)
\`\`\`js
// Identifier.name = attributeForCrashing
window.attributeForCrashing();
\`\`\`
\`\`\`
TypeError: Cannot read property 'someAttribute' of undefined
Occurred while linting <text>:2
Expand All @@ -55,10 +57,13 @@ describe('CLI', () => {
at <removed>/node_modules/eslint/lib/linter/linter.js:952:32
at Array.forEach (<anonymous>)
\`\`\`
## Rule: no-undef
- Message: \`'bar' is not defined.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L1-L1)
- Message: \`'bar' is not defined.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L1-L1)
\`\`\`js
var foo = bar;
Expand All @@ -69,9 +74,11 @@ describe('CLI', () => {
\`\`\`
## Rule: no-empty
- Message: \`Empty block statement.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L3-L4)
- Message: \`Empty block statement.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L3-L4)
\`\`\`js
var foo = bar;
Expand All @@ -85,9 +92,11 @@ describe('CLI', () => {
\`\`\`
## Rule: getter-return
- Message: \`Expected to return a value in getter 'name'.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L7-L7)
- Message: \`Expected to return a value in getter 'name'.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L7-L7)
\`\`\`js
if (foo) {
}
Expand All @@ -102,9 +111,11 @@ describe('CLI', () => {
\`\`\`
## Rule: no-compare-neg-zero
- Message: \`Do not use the '===' operator to compare against -0.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L14-L14)
- Message: \`Do not use the '===' operator to compare against -0.\`
- Path: \`AriPerkkio/eslint-remote-tester-integration-test-target/index.js\`
- [Link](https://github.com/AriPerkkio/eslint-remote-tester-integration-test-target/blob/HEAD/index.js#L14-L14)
\`\`\`js
};
p.getName();
Expand Down

0 comments on commit c0f62fb

Please sign in to comment.