Add and apply ESLint spacing rules
For now we're only adding rules related to spacing and double quotes, following the same rules we use in Ruby, which are the same rules CoffeeScript followed when compiling these files. We're also using the recommended ESLint rules, which will warn us about many JavaScript common pitfalls, the `strict` rule which enforces using strict mode, and the `no-console` rule, which will prevent us from shipping code meant for debugging. Although it's arguably more common to use the JSON format to define these rules, I've chosen YAML because it's the format we use in all our linters.
This commit is contained in:
67
.eslintrc.yml
Normal file
67
.eslintrc.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
env:
|
||||
browser: true
|
||||
es6: false
|
||||
extends: "eslint:recommended"
|
||||
globals:
|
||||
$: readonly
|
||||
App: readonly
|
||||
annotator: readonly
|
||||
c3: readonly
|
||||
CKEDITOR: readonly
|
||||
L: readonly
|
||||
Turbolinks: readonly
|
||||
parserOptions:
|
||||
ecmaVersion: 5
|
||||
rules:
|
||||
array-bracket-spacing: error
|
||||
block-spacing: error
|
||||
brace-style: error
|
||||
comma-spacing: error
|
||||
computed-property-spacing: error
|
||||
curly: error
|
||||
eol-last: error
|
||||
func-call-spacing: error
|
||||
indent:
|
||||
- error
|
||||
- 2
|
||||
key-spacing: error
|
||||
keyword-spacing: error
|
||||
linebreak-style: error
|
||||
lines-between-class-members: error
|
||||
no-console: error
|
||||
no-multi-spaces: error
|
||||
no-multiple-empty-lines:
|
||||
- error
|
||||
- max: 1
|
||||
no-spaced-func: error
|
||||
no-tabs: error
|
||||
no-trailing-spaces: error
|
||||
no-whitespace-before-property: error
|
||||
object-curly-spacing:
|
||||
- error
|
||||
- always
|
||||
- objectsInObjects: false
|
||||
padded-blocks:
|
||||
- error
|
||||
- never
|
||||
quotes:
|
||||
- error
|
||||
- double
|
||||
- avoidEscape: true
|
||||
semi-spacing: error
|
||||
space-before-blocks: error
|
||||
space-before-function-paren:
|
||||
- error
|
||||
- never
|
||||
space-in-parens: error
|
||||
space-infix-ops: error
|
||||
space-unary-ops: error
|
||||
spaced-comment:
|
||||
- error
|
||||
- always
|
||||
- markers:
|
||||
- "="
|
||||
exceptions:
|
||||
- "-"
|
||||
strict: error
|
||||
switch-colon-spacing: error
|
||||
@@ -5,3 +5,6 @@ scss:
|
||||
erblint:
|
||||
enabled: true
|
||||
config_file: .erb-lint.yml
|
||||
eslint:
|
||||
enabled: true
|
||||
config_file: .eslintrc.yml
|
||||
|
||||
@@ -44,5 +44,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -14,5 +14,4 @@
|
||||
}, ".js-participation");
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -27,5 +27,4 @@
|
||||
App.Answers.nestedAnswers();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
window.App = {};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -116,8 +116,9 @@ var initialize_modules = function() {
|
||||
App.LegislationAdmin.initialize();
|
||||
App.LegislationAllegations.initialize();
|
||||
App.Legislation.initialize();
|
||||
if ( $(".legislation-annotatable").length )
|
||||
if ($(".legislation-annotatable").length) {
|
||||
App.LegislationAnnotatable.initialize();
|
||||
}
|
||||
App.WatchFormChanges.initialize();
|
||||
App.TreeNavigator.initialize();
|
||||
App.Documentable.initialize();
|
||||
@@ -135,14 +136,16 @@ var initialize_modules = function() {
|
||||
App.SendAdminNotificationAlert.initialize();
|
||||
App.ModalDownload.initialize();
|
||||
App.Settings.initialize();
|
||||
if ( $("#js-columns-selector").length )
|
||||
if ($("#js-columns-selector").length) {
|
||||
App.ColumnsSelector.initialize();
|
||||
}
|
||||
App.BudgetEditAssociations.initialize();
|
||||
if ( $("#votation_type_enum_type").length )
|
||||
if ($("#votation_type_enum_type").length) {
|
||||
App.Votations.initialize();
|
||||
}
|
||||
};
|
||||
|
||||
$(function(){
|
||||
$(function() {
|
||||
"use strict";
|
||||
|
||||
Turbolinks.enableProgressBar();
|
||||
|
||||
@@ -25,5 +25,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -38,5 +38,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -14,5 +14,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -14,5 +14,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -84,5 +84,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -69,5 +69,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -30,5 +30,4 @@
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Overrides and adds customized javascripts in this file
|
||||
// Read more on documentation:
|
||||
// Read more on documentation:
|
||||
// * English: https://github.com/consul/consul/blob/master/CUSTOMIZE_EN.md#javascript
|
||||
// * Spanish: https://github.com/consul/consul/blob/master/CUSTOMIZE_ES.md#javascript
|
||||
//
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// TODO: This module is complex enough to require its own tests. Rewrite it using Ecma6 class syntax and
|
||||
// write tests for this feature after consul has been migrated to Rails 5.1
|
||||
(function(){
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
var ProposalGraph = function(url) {
|
||||
@@ -33,7 +33,7 @@
|
||||
.done(this.draw.bind(this));
|
||||
};
|
||||
|
||||
ProposalGraph.prototype.refreshGoals = function () {
|
||||
ProposalGraph.prototype.refreshGoals = function() {
|
||||
return $.ajax({
|
||||
url: this.resourcesUrl,
|
||||
cache: false,
|
||||
@@ -52,11 +52,11 @@
|
||||
});
|
||||
};
|
||||
|
||||
ProposalGraph.prototype.refreshData = function () {
|
||||
ProposalGraph.prototype.refreshData = function() {
|
||||
return $.ajax({
|
||||
url: this.url,
|
||||
cache: false,
|
||||
success: function (data) {
|
||||
success: function(data) {
|
||||
this.parseData(data);
|
||||
}.bind(this),
|
||||
data: {
|
||||
@@ -68,8 +68,8 @@
|
||||
ProposalGraph.prototype.parseData = function(data) {
|
||||
var key;
|
||||
|
||||
this.xColumnValues = [ ];
|
||||
this.progressColumnValues = [ this.progressLabel ];
|
||||
this.xColumnValues = [];
|
||||
this.progressColumnValues = [this.progressLabel];
|
||||
|
||||
for (key in data) {
|
||||
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
||||
@@ -87,7 +87,7 @@
|
||||
return $.ajax({
|
||||
url: this.successfulProposalDataUrl,
|
||||
cache: false,
|
||||
success: function (data) {
|
||||
success: function(data) {
|
||||
this.parseSuccessfulProposalData(data);
|
||||
}.bind(this),
|
||||
data: {
|
||||
@@ -99,7 +99,7 @@
|
||||
ProposalGraph.prototype.parseSuccessfulProposalData = function(data) {
|
||||
var key;
|
||||
|
||||
this.successfulColumnValues = [ this.successLabel ];
|
||||
this.successfulColumnValues = [this.successLabel];
|
||||
|
||||
for (key in data) {
|
||||
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
||||
@@ -113,7 +113,7 @@
|
||||
return $.ajax({
|
||||
url: this.proposalAchievementsUrl,
|
||||
cache: false,
|
||||
success: function (data) {
|
||||
success: function(data) {
|
||||
this.parseAchievements(data);
|
||||
}.bind(this),
|
||||
data: {
|
||||
@@ -138,7 +138,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
ProposalGraph.prototype.addXColumnValue = function (value) {
|
||||
ProposalGraph.prototype.addXColumnValue = function(value) {
|
||||
if (this.xColumnValues.indexOf(value) === -1) {
|
||||
this.xColumnValues.push(value);
|
||||
}
|
||||
@@ -146,7 +146,7 @@
|
||||
|
||||
ProposalGraph.prototype.draw = function() {
|
||||
var colors = {},
|
||||
maximumValue = this.maximumValue === 0 ? this.proposalSuccess : Math.round(this.maximumValue * 1.10);
|
||||
maximumValue = this.maximumValue === 0 ? this.proposalSuccess : Math.round(this.maximumValue * 1.10);
|
||||
|
||||
this.formatXColumnValues();
|
||||
|
||||
@@ -163,14 +163,14 @@
|
||||
this.successfulColumnValues
|
||||
],
|
||||
colors: colors,
|
||||
color: function (color, d) {
|
||||
color: function(color, d) {
|
||||
var achievement;
|
||||
|
||||
if (d.id === this.successfulColumnValues[0] || !Object.prototype.hasOwnProperty.call(d, "x")) {
|
||||
return color;
|
||||
}
|
||||
|
||||
achievement = this.achievements.find(function (element) {
|
||||
achievement = this.achievements.find(function(element) {
|
||||
return element.value === this.xColumnValues[d.index + 1];
|
||||
}.bind(this));
|
||||
|
||||
@@ -211,8 +211,8 @@
|
||||
},
|
||||
tooltip: {
|
||||
format: {
|
||||
title: function (d) {
|
||||
var achievement = this.achievements.find(function (element) {
|
||||
title: function(d) {
|
||||
var achievement = this.achievements.find(function(element) {
|
||||
return element.value === this.xColumnValues[d + 1];
|
||||
}.bind(this));
|
||||
|
||||
@@ -227,11 +227,11 @@
|
||||
});
|
||||
};
|
||||
|
||||
ProposalGraph.prototype.tickYValues = function () {
|
||||
ProposalGraph.prototype.tickYValues = function() {
|
||||
var i,
|
||||
tick = [0],
|
||||
maximumValue = this.maximumValue === 0 ? this.proposalSuccess : Math.round(this.maximumValue * 1.10),
|
||||
step = maximumValue <= 10 ? 1 : Math.round(maximumValue / 10);
|
||||
tick = [0],
|
||||
maximumValue = this.maximumValue === 0 ? this.proposalSuccess : Math.round(this.maximumValue * 1.10),
|
||||
step = maximumValue <= 10 ? 1 : Math.round(maximumValue / 10);
|
||||
|
||||
for (i = step; i < maximumValue; i += step) {
|
||||
tick.push(i);
|
||||
@@ -242,16 +242,16 @@
|
||||
return tick;
|
||||
};
|
||||
|
||||
ProposalGraph.prototype.tickXValues = function () {
|
||||
ProposalGraph.prototype.tickXValues = function() {
|
||||
var i,
|
||||
l,
|
||||
tick = [],
|
||||
step = this.xColumnValues.length < 13 ? 1 : Math.round((this.xColumnValues.length - 1) / 12);
|
||||
l,
|
||||
tick = [],
|
||||
step = this.xColumnValues.length < 13 ? 1 : Math.round((this.xColumnValues.length - 1) / 12);
|
||||
|
||||
if (this.xColumnValues.length > 1) {
|
||||
tick.push(0);
|
||||
|
||||
for(i = step, l = this.xColumnValues.length - 1; i < l; i += step) {
|
||||
for (i = step, l = this.xColumnValues.length - 1; i < l; i += step) {
|
||||
tick.push(i);
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@
|
||||
return tick;
|
||||
};
|
||||
|
||||
ProposalGraph.prototype.formatXColumnValues = function () {
|
||||
ProposalGraph.prototype.formatXColumnValues = function() {
|
||||
var i, l;
|
||||
|
||||
this.xColumnValues = this.xColumnValues.sort();
|
||||
@@ -286,8 +286,8 @@
|
||||
return this.groupBy === undefined || this.groupBy === "" || this.groupBy === null;
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
$("[data-proposal-graph-url]").each(function () {
|
||||
$(document).ready(function() {
|
||||
$("[data-proposal-graph-url]").each(function() {
|
||||
var graph = new ProposalGraph($(this).data("proposal-graph-url"));
|
||||
graph.successfulProposalDataUrl = $(this).data("successful-proposal-graph-url");
|
||||
graph.proposalAchievementsUrl = $(this).data("proposal-achievements-url");
|
||||
|
||||
@@ -166,5 +166,4 @@
|
||||
$("#" + id).remove();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -18,5 +18,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -5,5 +5,4 @@
|
||||
$("#" + resource_id + " .js-flag-actions").html(button).foundation();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -10,5 +10,4 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -64,5 +64,4 @@
|
||||
App.Forms.hideOrShowFieldsAfterSelection();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -26,5 +26,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -37,5 +37,4 @@
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -83,12 +83,12 @@
|
||||
},
|
||||
language_description: function(count) {
|
||||
switch (count) {
|
||||
case 0:
|
||||
return $(".globalize-languages").data("zero-languages-description");
|
||||
case 1:
|
||||
return $(".globalize-languages").data("one-languages-description");
|
||||
default:
|
||||
return $(".globalize-languages").data("other-languages-description");
|
||||
case 0:
|
||||
return $(".globalize-languages").data("zero-languages-description");
|
||||
case 1:
|
||||
return $(".globalize-languages").data("one-languages-description");
|
||||
default:
|
||||
return $(".globalize-languages").data("other-languages-description");
|
||||
}
|
||||
},
|
||||
initialize: function() {
|
||||
@@ -114,5 +114,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -15,5 +15,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -171,5 +171,4 @@
|
||||
$("#new_image_link").removeClass("hide");
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -11,5 +11,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -16,5 +16,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -22,5 +22,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -33,5 +33,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -229,5 +229,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -29,5 +29,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -128,5 +128,4 @@
|
||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -48,5 +48,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -11,5 +11,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
$("#" + id + " .js-moderator-investment-actions:first").hide();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -8,5 +8,4 @@
|
||||
$("#" + id + " .js-moderator-comment-actions").hide();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
$("#" + id + " .js-moderator-debate-actions:first").hide();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -8,5 +8,4 @@
|
||||
$("#" + id + " .js-moderator-proposal-notifications-actions:first").hide();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
$("#" + id + " .js-moderator-proposals-actions:first").hide();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -43,5 +43,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -5,17 +5,16 @@
|
||||
$("select[class='js-poll-shifts']").on({
|
||||
change: function() {
|
||||
switch ($(this).val()) {
|
||||
case "vote_collection":
|
||||
$("select[class='js-shift-vote-collection-dates']").show();
|
||||
$("select[class='js-shift-recount-scrutiny-dates']").hide();
|
||||
break;
|
||||
case "recount_scrutiny":
|
||||
$("select[class='js-shift-recount-scrutiny-dates']").show();
|
||||
$("select[class='js-shift-vote-collection-dates']").hide();
|
||||
case "vote_collection":
|
||||
$("select[class='js-shift-vote-collection-dates']").show();
|
||||
$("select[class='js-shift-recount-scrutiny-dates']").hide();
|
||||
break;
|
||||
case "recount_scrutiny":
|
||||
$("select[class='js-shift-recount-scrutiny-dates']").show();
|
||||
$("select[class='js-shift-vote-collection-dates']").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -45,5 +45,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -10,5 +10,4 @@
|
||||
App.Questions.nestedQuestions();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -29,5 +29,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -14,5 +14,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -34,5 +34,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -9,7 +9,7 @@ var initialize_stats_modules = function() {
|
||||
App.Stats.initialize();
|
||||
};
|
||||
|
||||
$(function(){
|
||||
$(function() {
|
||||
"use strict";
|
||||
|
||||
$(document).ready(initialize_stats_modules);
|
||||
|
||||
@@ -33,5 +33,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -34,5 +34,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -30,5 +30,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -44,5 +44,4 @@
|
||||
App.TagAutocomplete.init_autocomplete();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -22,5 +22,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -39,5 +39,4 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -5,5 +5,4 @@
|
||||
$(".initialjs-avatar").initial();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -33,5 +33,4 @@
|
||||
App.ValuationBudgetInvestmentForm.showFeasibilityFieldsOnChange();
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -53,5 +53,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -20,5 +20,4 @@
|
||||
App.Votes.hoverize("div.comment-footer");
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -29,5 +29,4 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
Reference in New Issue
Block a user