diff --git a/karma.conf.js b/karma.conf.js index 0c7cab0262..1c5f9d1117 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,7 +1,7 @@ // Karma configuration // Generated on Fri Feb 26 2016 13:09:51 GMT+1100 (AEDT) "use strict"; -module.exports = function(config) { +module.exports = function (config) { const options = { // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", diff --git a/package-lock.json b/package-lock.json index 1dc989fb94..91f6e161be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/package.json b/package.json index 072c1d8d0e..e841a5e3a0 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/core/dfn-finder.js b/src/core/dfn-finder.js index dfa16587b2..a19590b680 100644 --- a/src/core/dfn-finder.js +++ b/src/core/dfn-finder.js @@ -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}`; } diff --git a/src/core/examples.js b/src/core/examples.js index 0f72e6d26d..bb1af0948e 100644 --- a/src/core/examples.js +++ b/src/core/examples.js @@ -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` - : ${report.title} - ` + ? html` : ${report.title} ` : ""; return html`
diff --git a/src/core/expose-modules.js b/src/core/expose-modules.js index 2e62919bd5..5bb3510050 100644 --- a/src/core/expose-modules.js +++ b/src/core/expose-modules.js @@ -6,7 +6,7 @@ if (!inAmd) { * @param {string[]} deps * @param {(...modules: any[]) => void} callback */ - const require = function(deps, callback) { + const require = function (deps, callback) { const modules = deps.map(dep => { if (!(dep in window.require.modules)) { throw new Error(`Unsupported dependency name: ${dep}`); diff --git a/src/core/jquery-enhanced.js b/src/core/jquery-enhanced.js index d24a92ffae..8a5ce61456 100644 --- a/src/core/jquery-enhanced.js +++ b/src/core/jquery-enhanced.js @@ -15,10 +15,10 @@ window.$ = window.jQuery = $; // --- JQUERY EXTRAS ----------------------------------------------------------------------- // Applies to any jQuery object containing elements, changes their name to the one give, and // return a jQuery object containing the new elements -window.$.fn.renameElement = function(name) { +window.$.fn.renameElement = function (name) { const arr = []; // @ts-ignore - this.each(function() { + this.each(function () { // @ts-ignore const elem = this; 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 // instead of an @lt (as per specprod mailing list discussion). -window.$.fn.getDfnTitles = function() { +window.$.fn.getDfnTitles = function () { return getDfnTitles(this[0]); }; @@ -55,19 +55,19 @@ window.$.fn.getDfnTitles = function() { // * {for: "int2", title: "int3.member"} // * {for: "int3", title: "member"} // * {for: "", title: "int3.member"} -window.$.fn.linkTargets = function() { +window.$.fn.linkTargets = function () { return getLinkTargets(this[0]); }; // Applied to an element, sets an ID for it (and returns it), using a specific prefix // 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]; return addId(elem, pfx, txt, noLC); }; // 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. -window.$.fn.allTextNodes = function(exclusions) { +window.$.fn.allTextNodes = function (exclusions) { return getTextNodes(this[0], exclusions); }; diff --git a/src/core/linter-rules/check-charset.js b/src/core/linter-rules/check-charset.js index 8486ad2964..bdbdb76b66 100644 --- a/src/core/linter-rules/check-charset.js +++ b/src/core/linter-rules/check-charset.js @@ -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"); diff --git a/src/dini/conformance.js b/src/dini/conformance.js index 6cd24b89ae..8edd6c8fc4 100644 --- a/src/dini/conformance.js +++ b/src/dini/conformance.js @@ -68,10 +68,7 @@ function processConformance(conformance, conf) { // Put in the 2119 clause and reference const keywords = htmlJoinAnd( terms.sort(), - item => - html` - ${item} - ` + item => html` ${item} ` ); const plural = terms.length > 1; const content = html` diff --git a/src/dini/headers.js b/src/dini/headers.js index ae9a1d736c..7f30102f78 100644 --- a/src/dini/headers.js +++ b/src/dini/headers.js @@ -94,7 +94,7 @@ export function run(conf) { ); conf.publishYear = conf.publishDate.getUTCFullYear(); 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.orcid) { try { diff --git a/src/dini/templates/headers.js b/src/dini/templates/headers.js index f0c15f0adb..3259053b68 100644 --- a/src/dini/templates/headers.js +++ b/src/dini/templates/headers.js @@ -147,9 +147,7 @@ export default conf => { * @param {string=} cssClass */ function linkLicense(text, url, cssClass) { - return html` - ${text} - `; + return html` ${text} `; } function renderCopyright(conf) { diff --git a/src/dini/templates/show-link.js b/src/dini/templates/show-link.js index be61277cc1..2c91ab6e7e 100644 --- a/src/dini/templates/show-link.js +++ b/src/dini/templates/show-link.js @@ -21,9 +21,7 @@ function showLinkData(data) { return html`
${data.href - ? html` - ${data.value || data.href} - ` + ? html` ${data.value || data.href} ` : ""}
`; diff --git a/src/dini/templates/show-logo.js b/src/dini/templates/show-logo.js index 3de6a8dde5..447cf5deb9 100644 --- a/src/dini/templates/show-logo.js +++ b/src/dini/templates/show-logo.js @@ -4,9 +4,7 @@ import { showInlineWarning } from "../../core/utils.js"; export default obj => { /** @type {HTMLAnchorElement} */ - const a = html` - - `; + const a = html` `; if (!obj.alt) { showInlineWarning(a, "Found spec logo without an `alt` attribute"); } diff --git a/src/dini/templates/show-people.js b/src/dini/templates/show-people.js index 868ccaaf17..ad51385af9 100644 --- a/src/dini/templates/show-people.js +++ b/src/dini/templates/show-people.js @@ -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` -
- `; + const dd = html`
`; const span = document.createDocumentFragment(); const contents = []; if (p.mailto) { @@ -71,11 +59,7 @@ export default (items = []) => { ${personName} `); } else { - contents.push( - html` - ${personName} - ` - ); + contents.push(html` ${personName} `); } 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` - - `; + const span = html` `; let textContainer = span; if (extra.href) { - textContainer = html` - - `; + textContainer = html` `; span.appendChild(textContainer); } textContainer.textContent = extra.name; diff --git a/src/w3c/conformance.js b/src/w3c/conformance.js index 3a4e112c34..c989fc34ac 100644 --- a/src/w3c/conformance.js +++ b/src/w3c/conformance.js @@ -68,10 +68,7 @@ function processConformance(conformance, conf) { // Put in the 2119 clause and reference const keywords = htmlJoinAnd( terms.sort(), - item => - html` - ${item} - ` + item => html` ${item} ` ); const plural = terms.length > 1; const content = html` diff --git a/src/w3c/headers.js b/src/w3c/headers.js index cbcbd97fba..164df23948 100644 --- a/src/w3c/headers.js +++ b/src/w3c/headers.js @@ -370,7 +370,7 @@ export function run(conf) { } if (conf.prevRecShortname && !conf.prevRecURI) 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.orcid) { try { diff --git a/src/w3c/templates/cgbg-headers.js b/src/w3c/templates/cgbg-headers.js index b6ed041af3..08bd83447c 100644 --- a/src/w3c/templates/cgbg-headers.js +++ b/src/w3c/templates/cgbg-headers.js @@ -17,11 +17,7 @@ export default (conf, options) => { return html`
${conf.logos.map(showLogo)} ${specTitleElem} - ${conf.subtitle - ? html` -

${conf.subtitle}

- ` - : ""} + ${conf.subtitle ? html`

${conf.subtitle}

` : ""}

${conf.longStatus}