eslint-remote-tester
Version:
Tool for running ESLint on multiple repositories
55 lines (51 loc) • 1.6 kB
JavaScript
const NEW_LINE_REGEX = /\n/g;
export const ComparisonTypes = ['added', 'removed'];
// prettier-ignore
const RESULT_TEMPLATE_PLAINTEXT = (result) => `Rule: ${result.rule}
Message: ${result.message}
Path: ${result.path}
Link: ${result.link}
${result.source}
${result.error ? `
Error:
${result.error}
` : ''}`;
// prettier-ignore
const RESULT_TEMPLATE_MARKDOWN = (result) => `## Rule: ${result.rule}
- Message: \`${result.message.replace(NEW_LINE_REGEX, ' ')}\`
- Path: \`${result.path}\`
- [Link](${result.link})
\`\`\`${result.extension || ''}
${result.source || ''}
\`\`\`
${result.error ? `
\`\`\`
${result.error}
\`\`\`
` : ''}`;
// prettier-ignore
export const RESULTS_TEMPLATE_CI_BASE = (result) => `Repository: ${result.repositoryOwner}/${result.repository}`;
export const RESULT_PARSER_TO_TEMPLATE = {
plaintext: RESULT_TEMPLATE_PLAINTEXT,
markdown: RESULT_TEMPLATE_MARKDOWN,
};
const COMPARISON_RESULT_HEADER_PLAINTEXT = (type) => `${upperCaseFirstLetter(type)}:`;
const COMPARISON_RESULT_HEADER_MARKDOWN = (type) => `# ${upperCaseFirstLetter(type)}:`;
export const RESULT_PARSER_TO_COMPARE_TEMPLATE = {
plaintext: {
header: COMPARISON_RESULT_HEADER_PLAINTEXT,
results: RESULT_TEMPLATE_PLAINTEXT,
},
markdown: {
header: COMPARISON_RESULT_HEADER_MARKDOWN,
results: RESULT_TEMPLATE_MARKDOWN,
},
};
export const RESULT_PARSER_TO_EXTENSION = {
plaintext: '',
markdown: '.md',
};
function upperCaseFirstLetter(text) {
const [firstLetter, ...letters] = text;
return [firstLetter.toUpperCase(), ...letters].join('');
}