Skip to content

Switch linter to double quotes #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint_src.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"prefer-spread": 2,
"quotes": [
2,
"single",
"double",
{
"avoidEscape": true
}
Expand Down
16 changes: 8 additions & 8 deletions fluent-dom/src/dom_localization.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import overlayElement from './overlay';
import Localization from './localization';
import overlayElement from "./overlay";
import Localization from "./localization";

const L10NID_ATTR_NAME = 'data-l10n-id';
const L10NARGS_ATTR_NAME = 'data-l10n-args';
const L10NID_ATTR_NAME = "data-l10n-id";
const L10NARGS_ATTR_NAME = "data-l10n-args";

const L10N_ELEMENT_QUERY = `[${L10NID_ATTR_NAME}]`;

Expand Down Expand Up @@ -128,7 +128,7 @@ export default class DOMLocalization extends Localization {
if (root === newRoot ||
root.contains(newRoot) ||
newRoot.contains(root)) {
throw new Error('Cannot add a root that overlaps with existing root.');
throw new Error("Cannot add a root that overlaps with existing root.");
}
}

Expand Down Expand Up @@ -198,10 +198,10 @@ export default class DOMLocalization extends Localization {
translateMutations(mutations) {
for (const mutation of mutations) {
switch (mutation.type) {
case 'attributes':
case "attributes":
this.pendingElements.add(mutation.target);
break;
case 'childList':
case "childList":
for (const addedNode of mutation.addedNodes) {
if (addedNode.nodeType === addedNode.ELEMENT_NODE) {
if (addedNode.childElementCount) {
Expand Down Expand Up @@ -298,7 +298,7 @@ export default class DOMLocalization extends Localization {
getTranslatables(element) {
const nodes = Array.from(element.querySelectorAll(L10N_ELEMENT_QUERY));

if (typeof element.hasAttribute === 'function' &&
if (typeof element.hasAttribute === "function" &&
element.hasAttribute(L10NID_ATTR_NAME)) {
nodes.push(element);
}
Expand Down
4 changes: 2 additions & 2 deletions fluent-dom/src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as DOMLocalization } from './dom_localization';
export { default as Localization } from './localization';
export { default as DOMLocalization } from "./dom_localization";
export { default as Localization } from "./localization";
8 changes: 4 additions & 4 deletions fluent-dom/src/localization.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
/* global console */

import { CachedIterable } from '../../fluent/src/index';
import { CachedIterable } from "../../fluent/src/index";

/**
* Specialized version of an Error used to indicate errors that are result
Expand All @@ -16,7 +16,7 @@ import { CachedIterable } from '../../fluent/src/index';
class L10nError extends Error {
constructor(message) {
super();
this.name = 'L10nError';
this.name = "L10nError";
this.message = message;
}
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export default class Localization {
for (let ctx of this.ctxs) {
// This can operate on synchronous and asynchronous
// contexts coming from the iterator.
if (typeof ctx.then === 'function') {
if (typeof ctx.then === "function") {
ctx = await ctx;
}
const errors = keysFromContext(method, ctx, keys, translations);
Expand Down Expand Up @@ -290,7 +290,7 @@ function keysFromContext(method, ctx, keys, translations) {
hasErrors = true;
}

if (messageErrors.length && typeof console !== 'undefined') {
if (messageErrors.length && typeof console !== "undefined") {
messageErrors.forEach(error => console.warn(error));
}
});
Expand Down
62 changes: 31 additions & 31 deletions fluent-dom/src/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ const reOverlay = /<|&#?\w+;/;
* Source: https://www.w3.org/TR/html5/text-level-semantics.html
*/
const LOCALIZABLE_ELEMENTS = {
'http://www.w3.org/1999/xhtml': [
'a', 'em', 'strong', 'small', 's', 'cite', 'q', 'dfn', 'abbr', 'data',
'time', 'code', 'var', 'samp', 'kbd', 'sub', 'sup', 'i', 'b', 'u',
'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'span', 'br', 'wbr'
"http://www.w3.org/1999/xhtml": [
"a", "em", "strong", "small", "s", "cite", "q", "dfn", "abbr", "data",
"time", "code", "var", "samp", "kbd", "sub", "sup", "i", "b", "u",
"mark", "ruby", "rt", "rp", "bdi", "bdo", "span", "br", "wbr"
],
};

const LOCALIZABLE_ATTRIBUTES = {
'http://www.w3.org/1999/xhtml': {
global: ['title', 'aria-label', 'aria-valuetext', 'aria-moz-hint'],
a: ['download'],
area: ['download', 'alt'],
"http://www.w3.org/1999/xhtml": {
global: ["title", "aria-label", "aria-valuetext", "aria-moz-hint"],
a: ["download"],
area: ["download", "alt"],
// value is special-cased in isAttrNameLocalizable
input: ['alt', 'placeholder'],
menuitem: ['label'],
menu: ['label'],
optgroup: ['label'],
option: ['label'],
track: ['label'],
img: ['alt'],
textarea: ['placeholder'],
th: ['abbr']
input: ["alt", "placeholder"],
menuitem: ["label"],
menu: ["label"],
optgroup: ["label"],
option: ["label"],
track: ["label"],
img: ["alt"],
textarea: ["placeholder"],
th: ["abbr"]
},
'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul': {
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul": {
global: [
'accesskey', 'aria-label', 'aria-valuetext', 'aria-moz-hint', 'label'
"accesskey", "aria-label", "aria-valuetext", "aria-moz-hint", "label"
],
key: ['key', 'keycode'],
textbox: ['placeholder'],
toolbarbutton: ['tooltiptext'],
key: ["key", "keycode"],
textbox: ["placeholder"],
toolbarbutton: ["tooltiptext"],
}
};

Expand All @@ -52,15 +52,15 @@ const LOCALIZABLE_ATTRIBUTES = {
export default function overlayElement(targetElement, translation) {
const value = translation.value;

if (typeof value === 'string') {
if (typeof value === "string") {
if (!reOverlay.test(value)) {
// If the translation doesn't contain any markup skip the overlay logic.
targetElement.textContent = value;
} else {
// Else parse the translation's HTML using an inert template element,
// sanitize it and replace the targetElement's content.
const templateElement = targetElement.ownerDocument.createElementNS(
'http://www.w3.org/1999/xhtml', 'template');
"http://www.w3.org/1999/xhtml", "template");
templateElement.innerHTML = value;
targetElement.appendChild(
// The targetElement will be cleared at the end of sanitization.
Expand All @@ -69,9 +69,9 @@ export default function overlayElement(targetElement, translation) {
}
}

const explicitlyAllowed = targetElement.hasAttribute('data-l10n-attrs')
? targetElement.getAttribute('data-l10n-attrs')
.split(',').map(i => i.trim())
const explicitlyAllowed = targetElement.hasAttribute("data-l10n-attrs")
? targetElement.getAttribute("data-l10n-attrs")
.split(",").map(i => i.trim())
: null;

// Remove localizable attributes which may have been set by a previous
Expand Down Expand Up @@ -159,7 +159,7 @@ function sanitizeUsing(translationFragment, sourceElement) {

// SourceElement might have been already modified by shiftNamedElement.
// Let's clear it to make sure other code doesn't rely on random leftovers.
sourceElement.textContent = '';
sourceElement.textContent = "";

return translationFragment;
}
Expand Down Expand Up @@ -251,10 +251,10 @@ function isAttrNameLocalizable(name, element, explicitlyAllowed = null) {
}

// Special case for value on HTML inputs with type button, reset, submit
if (element.namespaceURI === 'http://www.w3.org/1999/xhtml' &&
elemName === 'input' && attrName === 'value') {
if (element.namespaceURI === "http://www.w3.org/1999/xhtml" &&
elemName === "input" && attrName === "value") {
const type = element.type.toLowerCase();
if (type === 'submit' || type === 'button' || type === 'reset') {
if (type === "submit" || type === "button" || type === "reset") {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions fluent-gecko/src/dom_localization.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global L10nRegistry, Services */
import DOMLocalization from '../../fluent-dom/src/dom_localization';
import DOMLocalization from "../../fluent-dom/src/dom_localization";

/**
* The default localization strategy for Gecko. It comabines locales
Expand Down Expand Up @@ -32,4 +32,4 @@ class GeckoDOMLocalization extends DOMLocalization {
}

this.DOMLocalization = GeckoDOMLocalization;
this.EXPORTED_SYMBOLS = ['DOMLocalization'];
this.EXPORTED_SYMBOLS = ["DOMLocalization"];
14 changes: 7 additions & 7 deletions fluent-gecko/src/l10n.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global Components, document, window */
{
const { DOMLocalization } =
Components.utils.import('resource://gre/modules/DOMLocalization.jsm');
Components.utils.import("resource://gre/modules/DOMLocalization.jsm");

/**
* Polyfill for document.ready polyfill.
Expand All @@ -10,23 +10,23 @@
* @returns {Promise}
*/
function documentReady() {
if (document.contentType === 'application/vnd.mozilla.xul+xml') {
if (document.contentType === "application/vnd.mozilla.xul+xml") {
// XUL
return new Promise(
resolve => document.addEventListener(
'MozBeforeInitialXULLayout', resolve, { once: true }
"MozBeforeInitialXULLayout", resolve, { once: true }
)
);
}

// HTML
const rs = document.readyState;
if (rs === 'interactive' || rs === 'completed') {
if (rs === "interactive" || rs === "completed") {
return Promise.resolve();
}
return new Promise(
resolve => document.addEventListener(
'readystatechange', resolve, { once: true }
"readystatechange", resolve, { once: true }
)
);
}
Expand All @@ -39,7 +39,7 @@
*/
function getResourceLinks(elem) {
return Array.from(elem.querySelectorAll('link[rel="localization"]')).map(
el => el.getAttribute('href')
el => el.getAttribute("href")
);
}

Expand All @@ -52,7 +52,7 @@

document.l10n.ready = documentReady().then(() => {
document.l10n.registerObservers();
window.addEventListener('unload', () => {
window.addEventListener("unload", () => {
document.l10n.unregisterObservers();
});
document.l10n.connectRoot(document.documentElement);
Expand Down
10 changes: 5 additions & 5 deletions fluent-gecko/src/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const Cc = Components.classes;
const Ci = Components.interfaces;

const { L10nRegistry } =
Cu.import('resource://gre/modules/L10nRegistry.jsm', {});
Cu.import("resource://gre/modules/L10nRegistry.jsm", {});
const ObserverService =
Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
const { Services } =
Cu.import('resource://gre/modules/Services.jsm', {});
Cu.import("resource://gre/modules/Services.jsm", {});


import Localization from '../../fluent-dom/src/localization';
import Localization from "../../fluent-dom/src/localization";

/**
* The default localization strategy for Gecko. It comabines locales
Expand Down Expand Up @@ -41,4 +41,4 @@ class GeckoLocalization extends Localization {
}

this.Localization = GeckoLocalization;
this.EXPORTED_SYMBOLS = ['Localization'];
this.EXPORTED_SYMBOLS = ["Localization"];
4 changes: 2 additions & 2 deletions fluent-gecko/src/message_context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageContext } from '../../fluent/src/index';
import { MessageContext } from "../../fluent/src/index";

this.MessageContext = MessageContext;
this.EXPORTED_SYMBOLS = ['MessageContext'];
this.EXPORTED_SYMBOLS = ["MessageContext"];
2 changes: 1 addition & 1 deletion fluent-intl-polyfill/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*
*/

export { default as PluralRules } from 'intl-pluralrules';
export { default as PluralRules } from "intl-pluralrules";
10 changes: 5 additions & 5 deletions fluent-langneg/src/accepted_languages.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function acceptedLanguages(string = '') {
if (typeof string !== 'string') {
throw new TypeError('Argument must be a string');
export default function acceptedLanguages(string = "") {
if (typeof string !== "string") {
throw new TypeError("Argument must be a string");
}
const tokens = string.split(',').map(t => t.trim());
return tokens.filter(t => t !== '').map(t => t.split(';')[0]);
const tokens = string.split(",").map(t => t.trim());
return tokens.filter(t => t !== "").map(t => t.split(";")[0]);
}
4 changes: 2 additions & 2 deletions fluent-langneg/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
*
*/

export { default as negotiateLanguages } from './negotiate_languages';
export { default as acceptedLanguages } from './accepted_languages';
export { default as negotiateLanguages } from "./negotiate_languages";
export { default as acceptedLanguages } from "./accepted_languages";
Loading