chore: update prettier, style changes (#2800)

* style: prettier arrowParens: avoid
* style: inline many html template tags

Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>
This commit is contained in:
Sid Vishnoi 2020-03-22 20:59:56 +05:30 committed by GitHub
parent d6f40c6ee6
commit 5a3c14de89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 60 additions and 155 deletions

6
package-lock.json generated
View File

@ -5041,9 +5041,9 @@
"integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw="
},
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.1.tgz",
"integrity": "sha512-piXGBcY1zoFOG0MvHpNE5reAGseLmaCRifQ/fmfF49BcYkInEs/naD/unxGNAeOKFA5+JxVrPyMvMlpzcd20UA==",
"dev": true
},
"prettier-linter-helpers": {

View File

@ -58,7 +58,7 @@
"mocha": "^7.1.1",
"moment": "^2.24.0",
"pluralize": "^8.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.1",
"rollup": "^2.0.2",
"rollup-plugin-alias": "^2.2.0",
"rollup-plugin-commonjs": "^10.1.0",
@ -105,7 +105,8 @@
"snyk": "^1.297.1"
},
"prettier": {
"trailingComma": "es5"
"trailingComma": "es5",
"arrowParens": "avoid"
},
"snyk": true,
"collective": {

View File

@ -182,10 +182,7 @@ export function decorateDfn(dfnElem, idlAst, parent, name) {
if (!dfnElem.id) {
const lCaseParent = parent.toLowerCase();
const middle = lCaseParent ? `${lCaseParent}-` : "";
let last = name
.toLowerCase()
.replace(/[()]/g, "")
.replace(/\s/g, "-");
let last = name.toLowerCase().replace(/[()]/g, "").replace(/\s/g, "-");
if (last === "") last = "the-empty-string";
dfnElem.id = `dom-${middle}${last}`;
}

View File

@ -62,9 +62,7 @@ function makeTitle(elem, num, report) {
if (report.title) elem.removeAttribute("title");
const number = num > 0 ? ` ${num}` : "";
const title = report.title
? html`
<span class="example-title">: ${report.title}</span>
`
? html` <span class="example-title">: ${report.title}</span> `
: "";
return html`
<div class="marker">

View File

@ -28,12 +28,7 @@ function linterFunction(_, doc) {
const metas = doc.querySelectorAll("meta[charset]");
const val = [];
for (const meta of metas) {
val.push(
meta
.getAttribute("charset")
.trim()
.toLowerCase()
);
val.push(meta.getAttribute("charset").trim().toLowerCase());
}
const utfExists = val.includes("utf-8");

View File

@ -68,10 +68,7 @@ function processConformance(conformance, conf) {
// Put in the 2119 clause and reference
const keywords = htmlJoinAnd(
terms.sort(),
item =>
html`
<em class="rfc2119">${item}</em>
`
item => html` <em class="rfc2119">${item}</em> `
);
const plural = terms.length > 1;
const content = html`

View File

@ -147,9 +147,7 @@ export default conf => {
* @param {string=} cssClass
*/
function linkLicense(text, url, cssClass) {
return html`
<a rel="license" href="${url}" class="${cssClass}">${text}</a>
`;
return html` <a rel="license" href="${url}" class="${cssClass}">${text}</a> `;
}
function renderCopyright(conf) {

View File

@ -21,9 +21,7 @@ function showLinkData(data) {
return html`
<dd class="${data.class ? data.class : null}">
${data.href
? html`
<a href="${data.href}">${data.value || data.href}</a>
`
? html` <a href="${data.href}">${data.value || data.href}</a> `
: ""}
</dd>
`;

View File

@ -4,9 +4,7 @@ import { showInlineWarning } from "../../core/utils.js";
export default obj => {
/** @type {HTMLAnchorElement} */
const a = html`
<a href="${obj.url || ""}" class="logo"></a>
`;
const a = html` <a href="${obj.url || ""}" class="logo"></a> `;
if (!obj.alt) {
showInlineWarning(a, "Found spec logo without an `alt` attribute");
}

View File

@ -10,37 +10,27 @@ import { hyperHTML as html } from "../../core/import-maps.js";
const localizationStrings = {
en: {
until(date) {
return html`
Until ${date}
`;
return html` Until ${date} `;
},
},
es: {
until(date) {
return html`
Hasta ${date}
`;
return html` Hasta ${date} `;
},
},
ko: {
until(date) {
return html`
${date} 이전
`;
return html` ${date} 이전 `;
},
},
ja: {
until(date) {
return html`
${date} 以前
`;
return html` ${date} 以前 `;
},
},
de: {
until(date) {
return html`
bis ${date}
`;
return html` bis ${date} `;
},
},
};
@ -55,9 +45,7 @@ export default (items = []) => {
const personName = [p.name]; // treated as opt-in HTML by hyperHTML
const company = [p.company];
/** @type {HTMLElement} */
const dd = html`
<dd class="p-author h-card vcard"></dd>
`;
const dd = html` <dd class="p-author h-card vcard"></dd> `;
const span = document.createDocumentFragment();
const contents = [];
if (p.mailto) {
@ -71,11 +59,7 @@ export default (items = []) => {
<a class="u-url url p-name fn" href="${p.url}">${personName}</a>
`);
} else {
contents.push(
html`
<span class="p-name fn">${personName}</span>
`
);
contents.push(html` <span class="p-name fn">${personName}</span> `);
}
if (p.orcid) {
contents.push(
@ -115,11 +99,7 @@ export default (items = []) => {
`
);
} else {
contents.push(
html`
(${company})
`
);
contents.push(html` (${company}) `);
}
}
if (p.note) contents.push(document.createTextNode(` (${p.note})`));
@ -148,11 +128,7 @@ export default (items = []) => {
);
}
timeElem.dateTime = toShortIsoDate(retiredDate);
contents.push(
html`
- ${l10n.until(timeElem)}
`
);
contents.push(html` - ${l10n.until(timeElem)} `);
}
// @ts-ignore: hyperhtml types only support Element but we use a DocumentFragment here
@ -162,14 +138,10 @@ export default (items = []) => {
}
function getExtra(extra) {
const span = html`
<span class="${extra.class || null}"></span>
`;
const span = html` <span class="${extra.class || null}"></span> `;
let textContainer = span;
if (extra.href) {
textContainer = html`
<a href="${extra.href}"></a>
`;
textContainer = html` <a href="${extra.href}"></a> `;
span.appendChild(textContainer);
}
textContainer.textContent = extra.name;

View File

@ -68,10 +68,7 @@ function processConformance(conformance, conf) {
// Put in the 2119 clause and reference
const keywords = htmlJoinAnd(
terms.sort(),
item =>
html`
<em class="rfc2119">${item}</em>
`
item => html` <em class="rfc2119">${item}</em> `
);
const plural = terms.length > 1;
const content = html`

View File

@ -17,11 +17,7 @@ export default (conf, options) => {
return html`
<div class="head">
${conf.logos.map(showLogo)} ${specTitleElem}
${conf.subtitle
? html`
<h2 id="subtitle">${conf.subtitle}</h2>
`
: ""}
${conf.subtitle ? html` <h2 id="subtitle">${conf.subtitle}</h2> ` : ""}
<h2>
${conf.longStatus}
<time class="dt-published" datetime="${conf.dashDate}"
@ -129,9 +125,7 @@ export default (conf, options) => {
? `${conf.copyrightStart}-`
: ""}${conf.publishYear}
${conf.additionalCopyrightHolders
? html`
${[conf.additionalCopyrightHolders]} &amp;
`
? html` ${[conf.additionalCopyrightHolders]} &amp; `
: ""}
the Contributors to the ${specTitleElemClone.childNodes}
Specification, published by the

View File

@ -246,9 +246,7 @@ export default (conf, options) => {
* @param {string=} cssClass
*/
function linkLicense(text, url, cssClass) {
return html`
<a rel="license" href="${url}" class="${cssClass}">${text}</a>
`;
return html` <a rel="license" href="${url}" class="${cssClass}">${text}</a> `;
}
function renderCopyright(conf) {
@ -266,9 +264,7 @@ function renderCopyright(conf) {
}
return conf.isUnofficial
? conf.additionalCopyrightHolders
? html`
<p class="copyright">${[conf.additionalCopyrightHolders]}</p>
`
? html` <p class="copyright">${[conf.additionalCopyrightHolders]}</p> `
: conf.overrideCopyright
? [conf.overrideCopyright]
: html`
@ -295,9 +291,7 @@ function renderOfficialCopyright(conf) {
&copy;
${conf.copyrightStart ? `${conf.copyrightStart}-` : ""}${conf.publishYear}
${conf.additionalCopyrightHolders
? html`
${[conf.additionalCopyrightHolders]} &amp;
`
? html` ${[conf.additionalCopyrightHolders]} &amp; `
: ""}
<a href="https://www.w3.org/"
><abbr title="World Wide Web Consortium">W3C</abbr></a

View File

@ -21,9 +21,7 @@ function showLinkData(data) {
return html`
<dd class="${data.class ? data.class : null}">
${data.href
? html`
<a href="${data.href}">${data.value || data.href}</a>
`
? html` <a href="${data.href}">${data.value || data.href}</a> `
: data.value}
</dd>
`;

View File

@ -4,9 +4,7 @@ import { showInlineWarning } from "../../core/utils.js";
export default obj => {
/** @type {HTMLAnchorElement} */
const a = html`
<a href="${obj.url || ""}" class="logo"></a>
`;
const a = html` <a href="${obj.url || ""}" class="logo"></a> `;
if (!obj.alt) {
showInlineWarning(a, "Found spec logo without an `alt` attribute");
}

View File

@ -10,37 +10,27 @@ import { hyperHTML as html } from "../../core/import-maps.js";
const localizationStrings = {
en: {
until(date) {
return html`
Until ${date}
`;
return html` Until ${date} `;
},
},
es: {
until(date) {
return html`
Hasta ${date}
`;
return html` Hasta ${date} `;
},
},
ko: {
until(date) {
return html`
${date} 이전
`;
return html` ${date} 이전 `;
},
},
ja: {
until(date) {
return html`
${date} 以前
`;
return html` ${date} 以前 `;
},
},
de: {
until(date) {
return html`
bis ${date}
`;
return html` bis ${date} `;
},
},
};
@ -72,11 +62,7 @@ export default (items = []) => {
<a class="u-url url p-name fn" href="${p.url}">${personName}</a>
`);
} else {
contents.push(
html`
<span class="p-name fn">${personName}</span>
`
);
contents.push(html` <span class="p-name fn">${personName}</span> `);
}
if (p.orcid) {
contents.push(
@ -116,11 +102,7 @@ export default (items = []) => {
`
);
} else {
contents.push(
html`
(${company})
`
);
contents.push(html` (${company}) `);
}
}
if (p.note) contents.push(document.createTextNode(` (${p.note})`));
@ -149,11 +131,7 @@ export default (items = []) => {
);
}
timeElem.dateTime = toShortIsoDate(retiredDate);
contents.push(
html`
- ${l10n.until(timeElem)}
`
);
contents.push(html` - ${l10n.until(timeElem)} `);
}
// @ts-ignore: hyperhtml types only support Element but we use a DocumentFragment here
@ -163,14 +141,10 @@ export default (items = []) => {
}
function getExtra(extra) {
const span = html`
<span class="${extra.class || null}"></span>
`;
const span = html` <span class="${extra.class || null}"></span> `;
let textContainer = span;
if (extra.href) {
textContainer = html`
<a href="${extra.href}"></a>
`;
textContainer = html` <a href="${extra.href}"></a> `;
span.appendChild(textContainer);
}
textContainer.textContent = extra.name;

View File

@ -122,9 +122,7 @@ export default (conf, opts) => {
>.
</p>
${conf.addPatentNote
? html`
<p>${[conf.addPatentNote]}</p>
`
? html` <p>${[conf.addPatentNote]}</p> `
: ""}
`}
`}
@ -250,9 +248,7 @@ function renderDeliverer(conf) {
${!isNote && !isIGNote
? html`
${multipleWGs
? html`
W3C maintains ${wgPatentHTML}
`
? html` W3C maintains ${wgPatentHTML} `
: html`
W3C maintains a
<a href="${[wgPatentURI]}" rel="disclosure"

View File

@ -125,11 +125,11 @@ async function generateHTML(page, url) {
return await page.evaluate(evaluateHTML, version);
} catch (err) {
const msg = `\n😭 Sorry, there was an error generating the HTML. Please report this issue!\n${colors.debug(
`${`Specification: ${url}\n` +
`${
`Specification: ${url}\n` +
`ReSpec version: ${version.join(".")}\n` +
"File a bug: https://github.com/w3c/respec/\n"}${
err ? `Error: ${err.stack}\n` : ""
}`
"File a bug: https://github.com/w3c/respec/\n"
}${err ? `Error: ${err.stack}\n` : ""}`
)}`;
throw new Error(msg);
}