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

View File

@ -1,7 +1,7 @@
// Karma configuration // Karma configuration
// Generated on Fri Feb 26 2016 13:09:51 GMT+1100 (AEDT) // Generated on Fri Feb 26 2016 13:09:51 GMT+1100 (AEDT)
"use strict"; "use strict";
module.exports = function(config) { module.exports = function (config) {
const options = { const options = {
// base path that will be used to resolve all patterns (eg. files, exclude) // base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "./", basePath: "./",

6
package-lock.json generated
View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ if (!inAmd) {
* @param {string[]} deps * @param {string[]} deps
* @param {(...modules: any[]) => void} callback * @param {(...modules: any[]) => void} callback
*/ */
const require = function(deps, callback) { const require = function (deps, callback) {
const modules = deps.map(dep => { const modules = deps.map(dep => {
if (!(dep in window.require.modules)) { if (!(dep in window.require.modules)) {
throw new Error(`Unsupported dependency name: ${dep}`); throw new Error(`Unsupported dependency name: ${dep}`);

View File

@ -15,10 +15,10 @@ window.$ = window.jQuery = $;
// --- JQUERY EXTRAS ----------------------------------------------------------------------- // --- JQUERY EXTRAS -----------------------------------------------------------------------
// Applies to any jQuery object containing elements, changes their name to the one give, and // Applies to any jQuery object containing elements, changes their name to the one give, and
// return a jQuery object containing the new elements // return a jQuery object containing the new elements
window.$.fn.renameElement = function(name) { window.$.fn.renameElement = function (name) {
const arr = []; const arr = [];
// @ts-ignore // @ts-ignore
this.each(function() { this.each(function () {
// @ts-ignore // @ts-ignore
const elem = this; const elem = this;
const newElem = renameElement(elem, name); const newElem = renameElement(elem, name);
@ -41,7 +41,7 @@ window.$.fn.renameElement = function(name) {
// //
// This method will publish a warning if a title is used on a definition // This method will publish a warning if a title is used on a definition
// instead of an @lt (as per specprod mailing list discussion). // instead of an @lt (as per specprod mailing list discussion).
window.$.fn.getDfnTitles = function() { window.$.fn.getDfnTitles = function () {
return getDfnTitles(this[0]); return getDfnTitles(this[0]);
}; };
@ -55,19 +55,19 @@ window.$.fn.getDfnTitles = function() {
// * {for: "int2", title: "int3.member"} // * {for: "int2", title: "int3.member"}
// * {for: "int3", title: "member"} // * {for: "int3", title: "member"}
// * {for: "", title: "int3.member"} // * {for: "", title: "int3.member"}
window.$.fn.linkTargets = function() { window.$.fn.linkTargets = function () {
return getLinkTargets(this[0]); return getLinkTargets(this[0]);
}; };
// Applied to an element, sets an ID for it (and returns it), using a specific prefix // Applied to an element, sets an ID for it (and returns it), using a specific prefix
// if provided, and a specific text if given. // if provided, and a specific text if given.
window.$.fn.makeID = function(pfx = "", txt = "", noLC = false) { window.$.fn.makeID = function (pfx = "", txt = "", noLC = false) {
const elem = this[0]; const elem = this[0];
return addId(elem, pfx, txt, noLC); return addId(elem, pfx, txt, noLC);
}; };
// Returns all the descendant text nodes of an element. Note that those nodes aren't // Returns all the descendant text nodes of an element. Note that those nodes aren't
// returned as a jQuery array since I'm not sure if that would make too much sense. // returned as a jQuery array since I'm not sure if that would make too much sense.
window.$.fn.allTextNodes = function(exclusions) { window.$.fn.allTextNodes = function (exclusions) {
return getTextNodes(this[0], exclusions); return getTextNodes(this[0], exclusions);
}; };

View File

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

View File

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

View File

@ -94,7 +94,7 @@ export function run(conf) {
); );
conf.publishYear = conf.publishDate.getUTCFullYear(); conf.publishYear = conf.publishDate.getUTCFullYear();
conf.publishHumanDate = DINIDate.format(conf.publishDate); conf.publishHumanDate = DINIDate.format(conf.publishDate);
const peopCheck = function(it) { const peopCheck = function (it) {
if (!it.name) pub("error", "All authors and editors must have a name."); if (!it.name) pub("error", "All authors and editors must have a name.");
if (it.orcid) { if (it.orcid) {
try { try {

View File

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

View File

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

View File

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

View File

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

View File

@ -370,7 +370,7 @@ export function run(conf) {
} }
if (conf.prevRecShortname && !conf.prevRecURI) if (conf.prevRecShortname && !conf.prevRecURI)
conf.prevRecURI = `https://www.w3.org/TR/${conf.prevRecShortname}`; conf.prevRecURI = `https://www.w3.org/TR/${conf.prevRecShortname}`;
const peopCheck = function(it) { const peopCheck = function (it) {
if (!it.name) pub("error", "All authors and editors must have a name."); if (!it.name) pub("error", "All authors and editors must have a name.");
if (it.orcid) { if (it.orcid) {
try { try {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ function testLang() {
}; };
} }
module.exports = function(hljs) { module.exports = function (hljs) {
hljs.registerLanguage("funkytest", testLang); hljs.registerLanguage("funkytest", testLang);
}; };

View File

@ -7,7 +7,7 @@ const testFiles = Object.keys(window.__karma__.files)
// Allows tests to be loaded asynchronously // Allows tests to be loaded asynchronously
// TODO: Remove this when browsers add support for top level await // TODO: Remove this when browsers add support for top level await
window.__karma__.loaded = function() {}; window.__karma__.loaded = function () {};
// Note that import() here is a special ES syntax // Note that import() here is a special ES syntax
// so it cannot be used as .map(import); // so it cannot be used as .map(import);

View File

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