Skip to content

Commit

Permalink
eslint config update & lintfixes
Browse files Browse the repository at this point in the history
eslint autofix

manual eslint fixes

less ugly hasOwnProperty alternative
  • Loading branch information
arizzitano committed Apr 21, 2017
1 parent 9fa53cc commit 3f8351d
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "eslint-config-edx",
"extends": "eslint-config-edx-es5",
"globals": {
"setFixtures": true // added globally by jasmine-jquery (bad)
}
Expand Down
2 changes: 1 addition & 1 deletion gulp/tasks/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ renameAsMarkdown = function(path) {
generateDocFor = function(options) {
var i, sources,
sourceLength = options.sources.length;
for (i = 0; i < sourceLength; i++) {
for (i = 0; i < sourceLength; i += 1) {
sources = options.sources[i];
console.log('Generating documentation for ' + sources);
gulp.src(sources, {buffer: false})
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
"css-loader": "~0.23.1",
"del": "~2.2.0",
"edx-pattern-library": "~0.12.5",
"eslint": "~2.13.1",
"eslint-config-edx": "~1.2.1",
"eslint": "^3.16.0",
"eslint-config-edx": "^2.0.0",
"eslint-config-edx-es5": "^3.0.0",
"extract-text-webpack-plugin": "^2.1.0",
"gulp": "~3.9.1",
"gulp-coveralls": "~0.1.4",
Expand Down
1 change: 1 addition & 0 deletions src/js/breadcrumbs/breadcrumbs-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
(function(define) {
'use strict';

define(['backbone', 'edx-ui-toolkit/js/utils/html-utils', 'text!./breadcrumbs.underscore'],
function(Backbone, HtmlUtils, breadcrumbsTemplate) {
var BreadcrumbsView = Backbone.View.extend({
Expand Down
3 changes: 2 additions & 1 deletion src/js/dropdown-menu/dropdown-menu-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*/
(function(define) {
'use strict';

define([
'backbone',
'jquery',
Expand Down Expand Up @@ -172,7 +173,7 @@
if (_.contains(this.keyForward, key)) {
this.focusFirstItem();
// if up arrow or left arrow key pressed or shift+tab
} else if (_.contains(this.keyBack, key) || key === constants.keyCodes.tab && event.shiftKey) {
} else if (_.contains(this.keyBack, key) || (key === constants.keyCodes.tab && event.shiftKey)) {
event.preventDefault();
this.focusLastItem();
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/dropdown-menu/specs/dropdown-menu-view-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ define([

expect($(document.activeElement)).not.toHaveClass('js-dropdown-button');

for (i = 0; i < listLength; i++) {
for (i = 0; i < listLength; i += 1) {
singleKeyDown(key);
}
}, timeoutInt);
Expand Down
1 change: 1 addition & 0 deletions src/js/pagination/paging-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
(function(define) {
'use strict';

define(['jquery', 'underscore', 'backbone.paginator'], function($, _, PageableCollection) {
var PagingCollection = PageableCollection.extend({
mode: 'server',
Expand Down
14 changes: 7 additions & 7 deletions src/js/pagination/specs/paging-collection-spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
define(['jquery',
'backbone',
'underscore',
'URI',
'../paging-collection.js',
'../../utils/spec-helpers/ajax-helpers.js',
'../../utils/spec-helpers/spec-helpers.js'
],
'backbone',
'underscore',
'URI',
'../paging-collection.js',
'../../utils/spec-helpers/ajax-helpers.js',
'../../utils/spec-helpers/spec-helpers.js'
],
function($, Backbone, _, URI, PagingCollection, AjaxHelpers, SpecHelpers) {
'use strict';

Expand Down
1 change: 1 addition & 0 deletions src/js/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
(function(define) {
'use strict';

define([], function() {
/**
* Reusable constants.
Expand Down
1 change: 1 addition & 0 deletions src/js/utils/date-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

(function(define) {
'use strict';

define([
'jquery',
'moment',
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils/global-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
requiredModule,
module,
i;
for (i = 0; i < pathCount; i++) {
for (i = 0; i < pathCount; i += 1) {
requiredModule = registeredModules[requiredPaths[i]];
requiredModules.push(requiredModule);
}
Expand Down
3 changes: 2 additions & 1 deletion src/js/utils/html-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
(function(define) {
'use strict';

define(['underscore', 'jquery', 'edx-ui-toolkit/js/utils/string-utils'], function(_, $, StringUtils) {
var HtmlUtils, ensureHtml, interpolateHtml, joinHtml, HTML, template, setHtml, append, prepend;

Expand Down Expand Up @@ -137,7 +138,7 @@
var html = '',
argumentCount = arguments.length,
i;
for (i = 0; i < argumentCount; i++) {
for (i = 0; i < argumentCount; i += 1) {
html += ensureHtml(arguments[i]);
}
return HTML(html);
Expand Down
6 changes: 3 additions & 3 deletions src/js/utils/spec-helpers/ajax-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) {

requests.currentIndex = 0;
requests.restore = function() {
if (xhr && xhr.hasOwnProperty('restore')) {
if (xhr && 'restore' in xhr) {
xhr.restore();
}
};
Expand Down Expand Up @@ -208,7 +208,7 @@ define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) {
var request = currentRequest(requests);
expect(request.readyState).toEqual(XHR_READY_STATES.UNSENT);
// Our ESLint config bans mutating params, but fixing this would require breaking AjaxHelpers API
requests.currentIndex++; // eslint-disable-line no-param-reassign
requests.currentIndex += 1; // eslint-disable-line no-param-reassign
};

/**
Expand All @@ -230,7 +230,7 @@ define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) {
{'Content-Type': contentType},
contentType === 'application/json' ? JSON.stringify(body || {}) : body
);
requests.currentIndex++; // eslint-disable-line no-param-reassign
requests.currentIndex += 1; // eslint-disable-line no-param-reassign
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils/specs/ajax-helpers-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define(
$.ajax(testUrl);

expect(requests instanceof Array).toBeTruthy();
expect(requests.hasOwnProperty('currentIndex')).toBeTruthy();
expect('currentIndex' in requests).toBeTruthy();
AjaxHelpers.expectRequest(requests, 'GET', testUrl);
});
});
Expand Down
1 change: 1 addition & 0 deletions src/js/utils/string-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
(function(define) {
'use strict';

define([], function() {
var interpolate;

Expand Down
3 changes: 2 additions & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ module.exports = function(config, overrideOptions) {
reporters: options.reporters,

coverageReporter: {
dir: 'build', subdir: 'coverage-js',
dir: 'build',
subdir: 'coverage-js',
reporters: [
{type: 'html', subdir: 'coverage-js/html'},
{type: 'cobertura', file: 'coverage.xml'},
Expand Down
1 change: 1 addition & 0 deletions test/require-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ require.config({
exports: 'Backbone',
init: function(_, $) {
'use strict';

var Backbone;
Backbone.$ = $;
return Backbone;
Expand Down
Loading

0 comments on commit 3f8351d

Please sign in to comment.