diff --git a/lib/tasks/verify-readme.js b/lib/tasks/verify-readme.js index 6a035a7b..086a7f8a 100644 --- a/lib/tasks/verify-readme.js +++ b/lib/tasks/verify-readme.js @@ -1,29 +1,29 @@ -"use strict"; +'use strict'; -const process = require("process"); +const process = require('process'); const { promises: {readFile}, -} = require("fs"); -const path = require("path"); -const isCI = require("is-ci"); -const vfile = require("vfile"); +} = require('fs'); +const path = require('path'); +const isCI = require('is-ci'); +const vfile = require('vfile'); const fs = require('fs-extra'); -const remark = require("remark"); -const remarkLint = require("remark-lint"); -const origamiPreset = require("remark-preset-lint-origami-component"); -const report = require("vfile-reporter"); +const remark = require('remark'); +const remarkLint = require('remark-lint'); +const origamiPreset = require('remark-preset-lint-origami-component'); +const report = require('vfile-reporter'); const log = require('../helpers/log'); async function origamiJson(config) { // Error if there is no readme to verify. - const readmePath = path.join(config.cwd, "/README.md"); + const readmePath = path.join(config.cwd, '/README.md'); const hasReadme = await fs.exists(readmePath); if (!hasReadme) { throw new Error('Components require a README.md with documentation.'); } const contents = await readFile(readmePath, { - encoding: "utf-8", + encoding: 'utf-8', }); const readme = vfile({ @@ -50,22 +50,22 @@ async function origamiJson(config) { if (result.messages.length) { if (isCI) { result.messages.forEach(issue => { - const newLine = "%0A"; + const newLine = '%0A'; const message = issue.message.replace(/\n/g, newLine); const line = issue.line; const column = issue.column; const code = issue.ruleId; - const severity = issue.severity === 2 ? "error" : "warning"; + const severity = issue.severity === 2 ? 'error' : 'warning'; console.log( `::${severity} file=README.md,line=${line},col=${column},code=${code},severity=${severity}::${message}` ); }); } else { log.secondary( - "README.md errors: \n\n" + + 'README.md errors: \n\n' + report(result, { color: false, - }).replace(new RegExp(config.cwd, "gi"), ".") + }).replace(new RegExp(config.cwd, 'gi'), '.') ); } } @@ -76,7 +76,7 @@ module.exports = cfg => { config.cwd = config.cwd || process.cwd(); return { - title: "Verifying your component's README.md", + title: 'Verifying your component\'s README.md', task: () => origamiJson(config), }; };