Skip to content
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

Added eslint rules #3768

Merged
merged 1 commit into from
Mar 14, 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
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
"no-shadow": "off",
"no-undef": "warn",
"no-underscore-dangle": "off",
"no-unused-vars": "off",
"no-unused-vars": "warn",
"no-use-before-define": "error",
"object-curly-spacing": "off",
"one-var": "error",
"padded-blocks": "off",
"quote-props": "off",
"quotes": "off",
"semi": "off",
"space-before-function-paren": "off",
"space-unary-ops": "off",
"semi": "error",
"space-before-function-paren": "error",
"space-unary-ops": "error",
"spaced-comment": "off",
"vars-on-top": "off",
}
Expand Down
10 changes: 5 additions & 5 deletions readthedocs/builds/static-src/builds/js/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var ko = require('knockout');
var $ = require('jquery');


function BuildCommand (data) {
function BuildCommand(data) {
var self = this;
self.id = ko.observable(data.id);
self.command = ko.observable(data.command);
Expand All @@ -25,7 +25,7 @@ function BuildCommand (data) {
});
}

function BuildDetailView (instance) {
function BuildDetailView(instance) {
var self = this;
var instance = instance || {};

Expand All @@ -46,7 +46,7 @@ function BuildDetailView (instance) {
var n;
for (n in commands_raw) {
var command = new BuildCommand(commands_raw[n]);
commands_display.push(command)
commands_display.push(command);
}
return commands_display;
});
Expand All @@ -58,7 +58,7 @@ function BuildDetailView (instance) {
self.legacy_output(true);
};

function poll_api () {
function poll_api() {
if (self.finished()) {
return;
}
Expand All @@ -75,7 +75,7 @@ function BuildDetailView (instance) {
var command = data.commands[n];
var match = ko.utils.arrayFirst(
self.commands(),
function(command_cmp) {
function (command_cmp) {
return (command_cmp.id === command.id);
}
);
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/core/static-src/core/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module.exports = function (selector, url) {
$(selector).autocomplete({
source: url,
minLength: 2,
open: function(event, ui) {
open: function (event, ui) {
var ac_top = $('.ui-autocomplete').css('top');
$('.ui-autocomplete').css({'width': '233px', 'top': ac_top + 10 });
}
});
}
};
4 changes: 2 additions & 2 deletions readthedocs/core/static-src/core/js/doc-embed/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
var exports = {
THEME_RTD: 'sphinx_rtd_theme',
THEME_ALABASTER: 'alabaster',
THEME_CELERY: 'sphinx_celery',
THEME_CELERY: 'sphinx_celery'
};

exports.PROMO_SUPPORTED_THEMES = [
exports.THEME_RTD,
exports.THEME_ALABASTER,
exports.THEME_CELERY,
exports.THEME_CELERY
];

exports.PROMO_TYPES = {
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static-src/core/js/doc-embed/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function setupBookmarkCSRFToken() {
}

$.ajaxSetup({
beforeSend: function(xhr, settings) {
beforeSend: function (xhr, settings) {
if (!csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", $('a.bookmark[token]').attr('token'));
}
Expand Down
6 changes: 3 additions & 3 deletions readthedocs/core/static-src/core/js/doc-embed/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ function attach_elastic_search_query(data) {
xhrFields: {
withCredentials: true,
},
complete: function(resp, status_code) {
if (typeof(resp.responseJSON) === 'undefined' ||
typeof(resp.responseJSON.results) === 'undefined') {
complete: function (resp, status_code) {
if (typeof (resp.responseJSON) === 'undefined' ||
typeof (resp.responseJSON.results) === 'undefined') {
return search_def.reject();
}
return search_def.resolve(resp.responseJSON.results);
Expand Down
6 changes: 3 additions & 3 deletions readthedocs/core/static-src/core/js/doc-embed/sphinx.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function init() {
var rtd = rtddata.get();

/// Click tracking on flyout
$(document).on('click', "[data-toggle='rst-current-version']", function() {
$(document).on('click', "[data-toggle='rst-current-version']", function () {
var flyout_state = $("[data-toggle='rst-versions']").hasClass('shift-up') ? 'was_open' : 'was_closed';

// This needs to handle both old style legacy analytics for previously built docs
Expand All @@ -34,7 +34,7 @@ function init() {
// already enabled. See:
// https://github.com/snide/sphinx_rtd_theme/issues/250
$(document).ready(function () {
setTimeout(function() {
setTimeout(function () {
if (!theme.navBar) {
theme.enable();
}
Expand All @@ -46,7 +46,7 @@ function init() {
// scroll element, gracefully handle failover by adding it
// dynamically.
var navBar = jquery('div.wy-side-scroll:first');
if (! navBar.length) {
if (!navBar.length) {
var navInner = jquery('nav.wy-nav-side:first');
var navScroll = $('<div />')
.addClass('wy-side-scroll');
Expand Down
8 changes: 4 additions & 4 deletions readthedocs/core/static-src/core/js/doc-embed/sponsorship.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var rtd;
/*
* Creates a sidebar div where an ad could go
*/
function create_sidebar_placement () {
function create_sidebar_placement() {
var element_id = 'rtd-' + (Math.random() + 1).toString(36).substring(4);
var display_type = constants.PROMO_TYPES.LEFTNAV;
var selector = null;
Expand Down Expand Up @@ -36,7 +36,7 @@ function create_sidebar_placement () {
* Creates a sidebar div where an ad could go
* Returns the ID of the div or none if no footer ad is possible
*/
function create_footer_placement () {
function create_footer_placement() {
var element_id = 'rtd-' + (Math.random() + 1).toString(36).substring(4);
var display_type = constants.PROMO_TYPES.FOOTER;
var selector = null;
Expand All @@ -63,7 +63,7 @@ function create_footer_placement () {
/*
* Returns an array of possible places where a promo could go
*/
function get_placements () {
function get_placements() {
var placements = [];
var placement_funcs = [create_footer_placement, create_sidebar_placement];
var placement;
Expand All @@ -78,7 +78,7 @@ function get_placements () {
return placements;
}

function Promo (data) {
function Promo(data) {
this.id = data.id; // analytics id
this.div_id = data.div_id || '';
this.html = data.html || '';
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static-src/core/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ module.exports.handle_notification_dismiss = function () {
}
});
});
}
};
6 changes: 3 additions & 3 deletions readthedocs/core/static-src/core/js/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

var jquery = require('jquery');

function poll_task (data) {
function poll_task(data) {
var defer = jquery.Deferred();
var tries = 5;

function poll_task_loop () {
function poll_task_loop() {
jquery
.getJSON(data.url)
.success(function (task) {
Expand Down Expand Up @@ -40,7 +40,7 @@ function poll_task (data) {
return defer;
}

function trigger_task (config) {
function trigger_task(config) {
var defer = jquery.Deferred();
var url = config.url;
var token = config.token;
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/gold/static-src/gold/js/gold.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var jquery = require('jquery');
var payment = require('readthedocs/payments/static-src/payments/js/base');
var ko = require('knockout');

function GoldView (config) {
function GoldView(config) {
var self = this;
var config = config || {};

Expand All @@ -20,7 +20,7 @@ GoldView.init = function (config, obj) {
var obj = obj || $('#payment-form')[0];
ko.applyBindings(view, obj);
return view;
}
};

GoldView.prototype.submit_form = function (card_digits, token) {
this.form.find('#id_last_4_digits').val(card_digits);
Expand Down
14 changes: 7 additions & 7 deletions readthedocs/projects/static-src/projects/js/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var $ = require('jquery');
var tasks = require('readthedocs/core/static-src/core/js/tasks');


$(function() {
$(function () {
var input = $('#id_repo');
var repo = $('#id_repo_type');

Expand Down Expand Up @@ -37,7 +37,7 @@ $(function() {
});
});

function append_url_params (url, params) {
function append_url_params(url, params) {
var link = $('<a>').attr('href', url).get(0);

Object.keys(params).map(function (key) {
Expand All @@ -49,7 +49,7 @@ function append_url_params (url, params) {
return link.href;
}

function Organization (instance, view) {
function Organization(instance, view) {
var self = this;
self.id = ko.observable(instance.id);
self.name = ko.observable(instance.name);
Expand All @@ -74,7 +74,7 @@ function Organization (instance, view) {
});
}

function Account (instance, view) {
function Account(instance, view) {
var self = this;
self.id = ko.observable(instance.id);
self.username = ko.observable(instance.username);
Expand All @@ -99,7 +99,7 @@ function Account (instance, view) {
});
}

function Project (instance, view) {
function Project(instance, view) {
var self = this;
self.id = ko.observable(instance.id);
self.name = ko.observable(instance.name);
Expand Down Expand Up @@ -167,7 +167,7 @@ function Project (instance, view) {
};
}

function ProjectImportView (instance, config) {
function ProjectImportView(instance, config) {
var self = this;
var instance = instance || {};

Expand Down Expand Up @@ -288,7 +288,7 @@ function ProjectImportView (instance, config) {
})
.always(function () {
self.is_syncing(false);
})
});
};

self.has_projects = ko.computed(function () {
Expand Down
20 changes: 10 additions & 10 deletions readthedocs/projects/static-src/projects/js/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var $ = jquery;


// Modal display
function _show_modal (section) {
function _show_modal(section) {
var embed_container = $('#embed-container');
if (!embed_container.length) {
embed_container = $('<div id="embed-container" class="modal modal-help" />');
Expand All @@ -27,13 +27,13 @@ function _show_modal (section) {
});
}

function EmbedView (config) {
function EmbedView(config) {
var self = this;

// Normalize config
self.config = config || {};
if (typeof(self.config.api_host) === 'undefined') {
self.config.api_host = 'https://readthedocs.org'
if (typeof (self.config.api_host) === 'undefined') {
self.config.api_host = 'https://readthedocs.org';
}

self.help = ko.observable(null);
Expand All @@ -46,7 +46,7 @@ function EmbedView (config) {
ko.computed(function () {
var file = self.file();
self.sections.removeAll();
if (! file) {
if (!file) {
return;
}
self.help('Loading...');
Expand Down Expand Up @@ -149,16 +149,16 @@ function EmbedView (config) {
module.exports.init_embed = function (config) {
var view = new EmbedView(config);
ko.applyBindings(view, $('#tool-embed')[0]);
}
};

// Analytics
function AnalyticsView (config) {
function AnalyticsView(config) {
var self = this;

// Normalize config
self.config = config || {};
if (typeof(self.config.api_host) === 'undefined') {
self.config.api_host = 'https://readthedocs.org'
if (typeof (self.config.api_host) === 'undefined') {
self.config.api_host = 'https://readthedocs.org';
}

self.show_help = function () {
Expand All @@ -173,4 +173,4 @@ function AnalyticsView (config) {
module.exports.init_analytics = function (config) {
var view = new AnalyticsView(config);
ko.applyBindings(view, $('#tool-analytics')[0]);
}
};