Skip to content

Commit

Permalink
Enforce double quotes on JS (#3092)
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and josepjaume committed Mar 23, 2018
1 parent 720676d commit d5cbd34
Show file tree
Hide file tree
Showing 36 changed files with 275 additions and 275 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"prefer-spread": "error",
"prefer-template": "error",
"quote-props": "off",
"quotes": "off",
"quotes": ["error", "double", { "avoidEscape": true }],
"radix": "error",
"require-jsdoc": "error",
"rest-spread-spacing": "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
$(() => {
// Show category list on click when we are on a small scren
if ($(window).width() < 768) {
$('.category--section').click((event) => {
$(event.currentTarget).next('.category--elements').toggleClass('active');
$(".category--section").click((event) => {
$(event.currentTarget).next(".category--elements").toggleClass("active");
});
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$("#result_decidim_accountability_status_id").change(function () {
/* eslint-disable no-invalid-this */
const progress = $(this).find(':selected').data('progress')
const progress = $(this).find(":selected").data("progress")
if (progress || progress === 0) {
$("#result_progress").val(progress);
}
Expand All @@ -12,34 +12,34 @@ $(function() {
$(document).on("open.zf.reveal", "#data_picker-modal", function () {
let xhr = null;

$('#data_picker-autocomplete').autoComplete({
$("#data_picker-autocomplete").autoComplete({
minChars: 2,
source: function(term, response) {
try {
xhr.abort();
} catch (exception) { xhr = null}

xhr = $.getJSON(
'proposals.json',
"proposals.json",
{ term: term },
function(data) { response(data); }
);
},
renderItem: function (item, search) {
let sanitizedSearch = search.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
let re = new RegExp(`(${sanitizedSearch.split(' ').join('|')})`, "gi");
let sanitizedSearch = search.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
let re = new RegExp(`(${sanitizedSearch.split(" ").join("|")})`, "gi");
let title = item[0]
let modelId = item[1]
let val = `#${modelId}- ${title}`;
return `<div class="autocomplete-suggestion" data-model-id="${modelId}" data-val ="${title}">${val.replace(re, "<b>$1</b>")}</div>`;
},
onSelect: function(event, term, item) {
let choose = $('#proposal-picker-choose')
let modelId = item.data('modelId')
let val = `#${modelId}- ${item.data('val')}`;
choose.data('picker-value', modelId)
choose.data('picker-text', val)
choose.data('picker-choose', '')
let choose = $("#proposal-picker-choose")
let modelId = item.data("modelId")
let val = `#${modelId}- ${item.data("val")}`;
choose.data("picker-value", modelId)
choose.data("picker-text", val)
choose.data("picker-choose", "")
}
})
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ const pageLoad = () => {

toggleNav();

createSortList('#steps tbody', {
createSortList("#steps tbody", {
placeholder: $('<tr style="border-style: dashed; border-color: #000"><td colspan="4">&nbsp;</td></tr>')[0],
onSortUpdate: ($children) => {
const sortUrl = $('#steps tbody').data('sort-url')
const order = $children.map((index, child) => $(child).data('id')).toArray();
const sortUrl = $("#steps tbody").data("sort-url")
const order = $children.map((index, child) => $(child).data("id")).toArray();

$.ajax({
method: 'POST',
method: "POST",
url: sortUrl,
contentType: 'application/json',
contentType: "application/json",
data: JSON.stringify({ items_ids: order }) }, // eslint-disable-line camelcase
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
constructor(sortListSelector, options) {
if ($(sortListSelector).length > 0) {
exports.sortable(sortListSelector, options)[0].addEventListener('sortupdate', (event) => {
exports.sortable(sortListSelector, options)[0].addEventListener("sortupdate", (event) => {
const $children = $(event.target).children();

if (options.onSortUpdate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/
$(() => {
// Event launched by foundation
$('[data-tabs]').on('change.zf.tabs', (event) => {
const $container = $(event.target).next('.tabs-content .tabs-panel.is-active');
$("[data-tabs]").on("change.zf.tabs", (event) => {
const $container = $(event.target).next(".tabs-content .tabs-panel.is-active");
// Detect quilljs editor inside the tabs-panel
let $content = $container.find('.editor .ql-editor');
let $content = $container.find(".editor .ql-editor");
if ($content.length > 0) {
$content.focus();
// Detect if inside the tabs-panel have an input
} else {
$content = $container.find('input:first');
$content = $container.find("input:first");
if ($content.length > 0) {
$content.focus();
}
Expand Down
8 changes: 4 additions & 4 deletions decidim-api/app/assets/javascripts/decidim/api/docs.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ const fetcherFactory = (path) => {
return jQuery.ajax({
url: path,
data: JSON.stringify({ query }),
method: 'POST',
contentType: 'application/json',
dataType: 'json'
method: "POST",
contentType: "application/json",
dataType: "json"
});
};
}

window.renderDocumentation = (path) => {
ReactDOM.render(
<GraphQLDocs.GraphQLDocs fetcher={fetcherFactory(path)} />,
document.getElementById('documentation'),
document.getElementById("documentation"),
);
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
$(() => {
((exports) => {
const $assemblyScopeEnabled = $('#assembly_scopes_enabled');
const $assemblyScopeEnabled = $("#assembly_scopes_enabled");
const $assemblyScopeId = $("#assembly_scope_id");

if ($('.edit_assembly, .new_assembly').length > 0) {
$assemblyScopeEnabled.on('change', (event) => {
if ($(".edit_assembly, .new_assembly").length > 0) {
$assemblyScopeEnabled.on("change", (event) => {
const checked = event.target.checked;
exports.theDataPicker.enabled($assemblyScopeId, checked);
})
exports.theDataPicker.enabled($assemblyScopeId, $assemblyScopeEnabled.prop('checked'));
exports.theDataPicker.enabled($assemblyScopeId, $assemblyScopeEnabled.prop("checked"));
}
})(window);
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
// = require_self

$(() => {
const $projects = $('#projects, #project');
const $budgetSummaryTotal = $('.budget-summary__total');
const $budgetExceedModal = $('#budget-excess');
const $projects = $("#projects, #project");
const $budgetSummaryTotal = $(".budget-summary__total");
const $budgetExceedModal = $("#budget-excess");

const totalBudget = parseInt($budgetSummaryTotal.attr('data-total-budget'), 10);
const totalBudget = parseInt($budgetSummaryTotal.attr("data-total-budget"), 10);

const cancelEvent = (event) => {
event.stopPropagation();
event.preventDefault();
};

$projects.on('click', '.budget--list__action', (event) => {
const currentBudget = parseInt($('.budget-summary__progressbox').attr('data-current-budget'), 10);
$projects.on("click", ".budget--list__action", (event) => {
const currentBudget = parseInt($(".budget-summary__progressbox").attr("data-current-budget"), 10);
const $currentTarget = $(event.currentTarget);
const projectBudget = parseInt($currentTarget.attr('data-budget'), 10);
const projectBudget = parseInt($currentTarget.attr("data-budget"), 10);

if ($currentTarget.attr('disabled')) {
if ($currentTarget.attr("disabled")) {
cancelEvent(event);

} else if ($currentTarget.attr('data-add') && ((currentBudget + projectBudget) > totalBudget)) {
$budgetExceedModal.foundation('toggle');
} else if ($currentTarget.attr("data-add") && ((currentBudget + projectBudget) > totalBudget)) {
$budgetExceedModal.foundation("toggle");
cancelEvent(event);
}
});
Expand Down
10 changes: 5 additions & 5 deletions decidim-comments/app/frontend/support/graphql_transformer.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* eslint-env node */
const gql = require('graphql-tag');
const gql = require("graphql-tag");

// Takes `source` (the source GraphQL query string)
// and `doc` (the parsed GraphQL document) and tacks on
// the imported definitions.
const expandImports = (source) => {
const lines = source.split('\n');
const lines = source.split("\n");
let outputCode = "";

lines.some((line) => {
if (line[0] === '#' && line.slice(1).split(' ')[0] === 'import') {
const importFile = line.slice(1).split(' ')[1];
if (line[0] === "#" && line.slice(1).split(" ")[0] === "import") {
const importFile = line.slice(1).split(" ")[1];
const parseDocument = `require(${importFile})`;
const appendDef = `doc.definitions = doc.definitions.concat(${parseDocument}.definitions);`;
outputCode += `${appendDef}\n`;
}
return (line.length !== 0 && line[0] !== '#');
return (line.length !== 0 && line[0] !== "#");
});

return outputCode;
Expand Down
16 changes: 8 additions & 8 deletions decidim-core/app/assets/javascripts/decidim/account_form.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
* reason field to the hidden field in the form inside the modal.
*/
$(() => {
const $deleteAccountForm = $('.delete-account');
const $deleteAccountModalForm = $('.delete-account-modal');
const $deleteAccountForm = $(".delete-account");
const $deleteAccountModalForm = $(".delete-account-modal");

if ($deleteAccountForm.length > 0) {
const $openModalButton = $('.open-modal-button');
const $modal = $('#deleteConfirm');
const $openModalButton = $(".open-modal-button");
const $modal = $("#deleteConfirm");

$openModalButton.on('click', (event) => {
$openModalButton.on("click", (event) => {
try {
const reasonValue = $deleteAccountForm.find('textarea#delete_account_delete_reason').val();
$deleteAccountModalForm.find('input#delete_account_delete_reason').val(reasonValue);
$modal.foundation('open');
const reasonValue = $deleteAccountForm.find("textarea#delete_account_delete_reason").val();
$deleteAccountModalForm.find("input#delete_account_delete_reason").val(reasonValue);
$modal.foundation("open");
} catch (error) {
console.error(error); // eslint-disable-line no-console
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(function() {
$(() => {
let $appendableElements = $('.js-append');
let $appendableElements = $(".js-append");
$appendableElements.appendAround();
})
}(window));
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
*/
$(() => {
const removeUrlParameter = (url, parameter) => {
const urlParts = url.split('?');
const urlParts = url.split("?");

if (urlParts.length >= 2) {
// Get first part, and remove from array
const urlBase = urlParts.shift();

// Join it back up
const queryString = urlParts.join('?');
const queryString = urlParts.join("?");

const prefix = `${encodeURIComponent(parameter)}=`;
const parts = queryString.split(/[&;]/g);
Expand All @@ -47,7 +47,7 @@ $(() => {
return urlBase;
}

return `${urlBase}?${parts.join('&')}`;
return `${urlBase}?${parts.join("&")}`;
}

return url;
Expand All @@ -66,12 +66,12 @@ $(() => {

$(`${target} a`).attr("href", (index, href) => {
const querystring = jQuery.param({"redirect_url": redirectUrl});
return href + (href.match(/\?/) ? '&' : '?') + querystring;
return href + (href.match(/\?/) ? "&" : "?") + querystring;
});
}
});

$(document).on('closed.zf.reveal', (event) => {
$(document).on("closed.zf.reveal", (event) => {
$("#redirect_url", event.target).remove();
$("a", event.target).attr("href", (index, href) => {
if (href && href.indexOf("redirect_url") !== -1) {
Expand Down
20 changes: 10 additions & 10 deletions decidim-core/app/assets/javascripts/decidim/data_picker.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
activate(picker) {
let $element = $(picker);
let input = "hidden",
name = $element.data('picker-name'),
name = $element.data("picker-name"),
values = $(".picker-values", $element);

if ($element.hasClass("picker-multiple")) {
Expand All @@ -31,7 +31,7 @@

$element.on("click", "a", (event) => {
event.preventDefault();
if ($element.hasClass('disabled')) {
if ($element.hasClass("disabled")) {
return;
}
this._openPicker($element, event.target.parentNode);
Expand Down Expand Up @@ -78,7 +78,7 @@

_openPicker($picker, div) {
this._setCurrentPicker($picker, div);
this._load($("a", div).attr('href'));
this._load($("a", div).attr("href"));
}

_setCurrentPicker($picker, div) {
Expand All @@ -90,7 +90,7 @@
this.current = {
multiple: $picker.hasClass("picker-multiple"),
picker: $picker,
name: $picker.data('picker-name'),
name: $picker.data("picker-name"),
values: $picker.find(".picker-values"),
div: currentDiv
};
Expand All @@ -101,7 +101,7 @@
let modalContent = $(".data_picker-modal-content", this.modal);
modalContent.html(resp);
this._handleLinks(modalContent);
this.modal.foundation('open');
this.modal.foundation("open");
});
}

Expand All @@ -110,16 +110,16 @@
let $link = $(link);
$link.click((event) => {
event.preventDefault();
if ($link.data('data-close')) {
if ($link.data("data-close")) {
return;
}

let chooseUrl = $link.attr('href');
let chooseUrl = $link.attr("href");
if (chooseUrl) {
if (typeof $link.data('picker-choose') === 'undefined') {
if (typeof $link.data("picker-choose") === "undefined") {
this._load(chooseUrl);
} else {
this._choose({url: chooseUrl, value: $link.data('picker-value') || "", text: $link.data('picker-text') || ""});
this._choose({url: chooseUrl, value: $link.data("picker-value") || "", text: $link.data("picker-text") || ""});
}
}
});
Expand Down Expand Up @@ -153,7 +153,7 @@
if (user) {
$input.trigger("change");
this._removeErrors();
this.modal.foundation('close');
this.modal.foundation("close");
}

// Unselect updated value and close modal
Expand Down
Loading

0 comments on commit d5cbd34

Please sign in to comment.