chore: apply amnesty on existing not fixable issues (#32215)

* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue

* fix: all autofixable eslint issues

* fix: all react related fixable issues

* fix: autofixable eslint issues

* chore: remove all template literals

* fix: remaining autofixable issues

* chore: apply amnesty on all existing issues

* fix: failing xss-lint issues

* refactor: apply amnesty on remaining issues

* refactor: apply amnesty on new issues

* fix: remove file level suppressions

* refactor: apply amnesty on new issues
This commit is contained in:
Syed Ali Abbas Zaidi
2023-08-07 19:13:19 +05:00
committed by GitHub
parent e94af3c2d3
commit 8480dbc228
305 changed files with 1043 additions and 202 deletions

View File

@@ -27,6 +27,7 @@
"func-names": "off",
"indent": ["error", 4],
"react/jsx-indent": ["error", 4],
"react/jsx-indent-props": ["error", 4],
"new-cap": "off",
"no-else-return": "off",
"no-shadow": "error",
@@ -70,7 +71,6 @@
"prefer-rest-params": "off",
"prefer-template": "off",
"radix": "off",
"react/jsx-indent-props": ["error", 4],
"react/prop-types": "off",
"vars-on-top": "off"
}

View File

@@ -24,9 +24,9 @@ define(
function() {
window.MathJax.Hub.Config({
styles: {
'.MathJax_SVG>svg': { 'max-width': '100%' },
'.MathJax_SVG>svg': {'max-width': '100%'},
// This is to resolve for people who use center mathjax with tables
'table>tbody>tr>td>.MathJax_SVG>svg': { 'max-width': 'inherit'},
'table>tbody>tr>td>.MathJax_SVG>svg': {'max-width': 'inherit'},
},
tex2jax: {
inlineMath: [
@@ -38,9 +38,9 @@ define(
['[mathjax]', '[/mathjax]']
]
},
CommonHTML: { linebreaks: { automatic: true } },
SVG: { linebreaks: { automatic: true } },
"HTML-CSS": { linebreaks: { automatic: true } },
CommonHTML: {linebreaks: {automatic: true}},
SVG: {linebreaks: {automatic: true}},
'HTML-CSS': {linebreaks: {automatic: true}},
});
// In order to eliminate all flashing during interactive
@@ -54,28 +54,29 @@ define(
window.addEventListener('resize', MJrenderer);
let t = -1;
// eslint-disable-next-line prefer-const
let delay = 1000;
let oldWidth = document.documentElement.scrollWidth;
function MJrenderer() {
// don't rerender if the window is the same size as before
if (t >= 0) {
window.clearTimeout(t);
window.clearTimeout(t);
}
if (oldWidth !== document.documentElement.scrollWidth) {
t = window.setTimeout(function() {
oldWidth = document.documentElement.scrollWidth;
MathJax.Hub.Queue(
["Rerender", MathJax.Hub],
[() => $('.MathJax_SVG>svg').toArray().forEach(el => {
if ($(el).width() === 0) {
$(el).css('max-width', 'inherit');
}
})]
);
t = -1;
oldWidth = document.documentElement.scrollWidth;
MathJax.Hub.Queue(
['Rerender', MathJax.Hub],
[() => $('.MathJax_SVG>svg').toArray().forEach(el => {
if ($(el).width() === 0) {
$(el).css('max-width', 'inherit');
}
})]
);
t = -1;
}, delay);
}
};
}
}
);
window.CodeMirror = CodeMirror;

View File

@@ -3,6 +3,7 @@
(function(sandbox) {
'use strict';
// eslint-disable-next-line global-require
require(['jquery', 'backbone', 'cms/js/main', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'jquery.cookie'],
function($, Backbone, main, AjaxHelpers) {
describe('CMS', function() {

View File

@@ -1,6 +1,7 @@
// Custom matcher library for Jasmine test assertions
// http://tobyho.com/2012/01/30/write-a-jasmine-matcher/
// eslint-disable-next-line padded-blocks
define(['jquery'], function($) { // eslint-disable-line no-unused-vars
'use strict';

View File

@@ -8,6 +8,7 @@ import './base';
import 'cms/js/main';
import 'xblock/cms.runtime.v1';
// eslint-disable-next-line no-unused-expressions
'use strict';
export default function ContainerFactory(componentTemplates, XBlockInfoJson, action, options) {
var main_options = {

View File

@@ -1,3 +1,4 @@
import * as ContextCourse from 'js/models/course';
// eslint-disable-next-line import/prefer-default-export
export {ContextCourse};

View File

@@ -6,6 +6,7 @@ import 'cms/js/main';
import 'xblock/cms.runtime.v1';
import 'xmodule/js/src/xmodule'; // Force the XBlockToXModuleShim to load for Static Tabs
// eslint-disable-next-line no-unused-expressions
'use strict';
export default function EditTabsFactory(courseLocation, explicitUrl) {
xmoduleLoader.done(function() {

View File

@@ -9,6 +9,7 @@ import './base';
import 'cms/js/main';
import 'xblock/cms.runtime.v1';
// eslint-disable-next-line no-unused-expressions
'use strict';
export default function LibraryFactory(componentTemplates, XBlockInfoJson, options) {
var main_options = {

View File

@@ -26,6 +26,7 @@ define([
model.useV2CertDisplaySettings = useV2CertDisplaySettings;
model.set('upgrade_deadline', upgradeDeadline);
model.fetch({
// eslint-disable-next-line no-shadow
success: function(model) {
var editor = new MainView({
el: $('.settings-details'),

View File

@@ -4,6 +4,7 @@ import * as TextbookCollection from 'js/collections/textbook';
import * as ListTextbooksView from 'js/views/list_textbooks';
import './base';
// eslint-disable-next-line no-unused-expressions
'use strict';
export default function TextbooksFactory(textbooksJson) {
var textbooks = new TextbookCollection(textbooksJson, {parse: true}),

View File

@@ -1,6 +1,7 @@
import * as XBlockValidationView from 'js/views/xblock_validation';
import * as XBlockValidationModel from 'js/models/xblock_validation';
// eslint-disable-next-line no-unused-expressions
'use strict';
export default function XBlockValidationFactory(validationMessages, hasEditingUrl, isRoot, isUnit, validationEle) {
var model, response;

View File

@@ -129,6 +129,7 @@ define([
},
progressall: function(e, data) {
// eslint-disable-next-line no-mixed-operators
var percentInt = data.loaded / data.total * 100,
percentVal = parseInt(percentInt, 10) + '%',
doneAt;

View File

@@ -3,11 +3,16 @@
import PropTypes from 'prop-types';
import React from 'react';
// eslint-disable-next-line no-unused-vars
import ReactDOM from 'react-dom';
// eslint-disable-next-line import/prefer-default-export
export function CourseOrLibraryListing(props) {
// eslint-disable-next-line prefer-destructuring
const allowReruns = props.allowReruns;
// eslint-disable-next-line prefer-destructuring
const linkClass = props.linkClass;
// eslint-disable-next-line prefer-destructuring
const idBase = props.idBase;
const renderCourseMetadata = (item, i) => (
@@ -84,6 +89,7 @@ export function CourseOrLibraryListing(props) {
CourseOrLibraryListing.propTypes = {
allowReruns: PropTypes.bool.isRequired,
idBase: PropTypes.string.isRequired,
// eslint-disable-next-line react/forbid-prop-types
items: PropTypes.arrayOf(PropTypes.object).isRequired,
linkClass: PropTypes.string.isRequired,
};

View File

@@ -9,6 +9,7 @@ define(['backbone', 'underscore'], function(Backbone, _) {
},
toUrl: function(overrides) {
return;
/* eslint-disable-next-line no-unused-expressions, no-unreachable */
(overrides && overrides.tag ? overrides.tag : this.get('tag')) + '://'
+ (overrides && overrides.org ? overrides.org : this.get('org')) + '/'
+ (overrides && overrides.course ? overrides.course : this.get('course')) + '/'
@@ -16,6 +17,7 @@ define(['backbone', 'underscore'], function(Backbone, _) {
+ (overrides && overrides.name ? overrides.name : this.get('name')) + '/';
},
_tagPattern: /[^:]+/g,
// eslint-disable-next-line prefer-regex-literals
_fieldPattern: new RegExp('[^/]+', 'g'),
parse: function(payload) {

View File

@@ -2,8 +2,10 @@ import * as domReady from 'domReady';
import * as $ from 'jquery';
import 'jquery.smoothScroll';
// eslint-disable-next-line no-unused-expressions
'use strict';
// eslint-disable-next-line import/no-mutable-exports
var toggleSock = function(e) {
e.preventDefault();
@@ -38,4 +40,5 @@ domReady(function() {
$('.cta-show-sock').bind('click', toggleSock);
});
// eslint-disable-next-line import/prefer-default-export
export {toggleSock};

View File

@@ -242,6 +242,7 @@ define([
var collection, injector, mockGettext, initializeGroupModel, cleanUp;
mockGettext = function(returnedValue) {
// eslint-disable-next-line no-shadow
var injector = new Squire();
injector.mock('gettext', function() {
@@ -258,6 +259,7 @@ define([
injector = mockGettext(dict);
injector.require(['js/collections/group'],
// eslint-disable-next-line no-shadow
function(GroupCollection) {
collection = new GroupCollection();
deferred.resolve(collection);
@@ -273,6 +275,7 @@ define([
};
it('returns correct ids', function() {
// eslint-disable-next-line no-shadow
var collection = new GroupCollection();
expect(collection.getGroupId(0)).toBe('A');
@@ -287,6 +290,7 @@ define([
it('just 1 character in the dictionary', function(done) {
initializeGroupModel('1')
// eslint-disable-next-line no-shadow
.then(function(collection) {
expect(collection.getGroupId(0)).toBe('1');
expect(collection.getGroupId(1)).toBe('11');
@@ -300,6 +304,7 @@ define([
it('allow to use unicode characters in the dict', function(done) {
initializeGroupModel('ö诶úeœ')
// eslint-disable-next-line no-shadow
.then(function(collection) {
expect(collection.getGroupId(0)).toBe('ö');
expect(collection.getGroupId(1)).toBe('诶');
@@ -316,6 +321,7 @@ define([
it('return initial value if dictionary is empty', function(done) {
initializeGroupModel('')
// eslint-disable-next-line no-shadow
.then(function(collection) {
expect(collection.getGroupId(0)).toBe('0');
expect(collection.getGroupId(5)).toBe('5');

View File

@@ -48,6 +48,7 @@ define(
});
it('does nothing on tinymce iframe', function() {
// eslint-disable-next-line no-script-url
verify_no_modification('javascript:');
});
});

View File

@@ -154,6 +154,7 @@ define(
describe('processCommand', function() {
var action = 'replace',
errorMessage = 'errorMessage',
// eslint-disable-next-line no-void
videoList = void 0,
extraParamas = 'video_id';
@@ -175,6 +176,7 @@ define(
var defaults = {
action: 'replace',
errorMessage: 'errorMessage',
// eslint-disable-next-line no-void
extraParamas: void 0
};
var args = $.extend({}, defaults, config);
@@ -201,6 +203,7 @@ define(
action,
view.component_locator,
videoList,
// eslint-disable-next-line no-void
void 0
);
expect(view.showError).not.toHaveBeenCalled();
@@ -251,6 +254,7 @@ define(
action,
view.component_locator,
videoList,
// eslint-disable-next-line no-void
void 0
);
expect(view.showError).toHaveBeenCalled();

View File

@@ -219,6 +219,7 @@ define(
});
it('Method: getYoutubeLink', function() {
// eslint-disable-next-line no-shadow
var videoId = 'video_id',
result = Utils.getYoutubeLink(videoId),
expectedResult = 'http://youtu.be/' + videoId;
@@ -262,6 +263,7 @@ define(
describe('Wrong arguments ', function() {
it('youtube videoId is wrong', function() {
// eslint-disable-next-line no-shadow
var videoId = 'wrong_id',
link = 'http://youtu.be/' + videoId,
result = Utils.parseLink(link);

View File

@@ -14,6 +14,7 @@ describe('ModuleEdit', function() {
+ '<li class="component" id="stub-id" data-locator="stub-id">\n'
+ ' <div class="component-editor">\n'
+ ' <div class="module-editor">\n'
// eslint-disable-next-line no-template-curly-in-string
+ ' ${editor}\n'
+ ' </div>\n'
+ ' <a href="#" class="save-button">Save</a>\n'
@@ -73,6 +74,7 @@ describe('ModuleEdit', function() {
window.MockXBlock = function() {
return {};
};
// eslint-disable-next-line no-void
window.loadedXBlockResources = void 0;
this.moduleEdit.render();
return $.ajax.calls.mostRecent().args[0].success({

View File

@@ -12,6 +12,7 @@ import XBlockInfo from 'js/models/xblock_info';
import Course from 'js/models/course';
import 'mock-ajax';
// eslint-disable-next-line padded-blocks
describe('MoveXBlock', function() {
'use strict';
@@ -396,6 +397,7 @@ describe('MoveXBlock', function() {
expectedData,
sourceIndex = sourceIndex || 0; // eslint-disable-line no-redeclare
// eslint-disable-next-line no-multi-assign
responseData = expectedData = {
move_source_locator: xblockLocator,
parent_locator: modal.targetParentXBlockInfo.id

View File

@@ -97,6 +97,7 @@ function parameterized_suite(label, globalPageOptions) {
AjaxHelpers.respondWithJson(requests, options || {});
};
// eslint-disable-next-line no-shadow
handleContainerPageRefresh = function(requests) {
var request = AjaxHelpers.currentRequest(requests);
expect(str.startsWith(request.url,
@@ -551,10 +552,12 @@ function parameterized_suite(label, globalPageOptions) {
describe('Previews', function() {
var getButtonIcon, getButtonText;
// eslint-disable-next-line no-shadow
getButtonIcon = function(containerPage) {
return containerPage.$('.action-toggle-preview .fa');
};
// eslint-disable-next-line no-shadow
getButtonText = function(containerPage) {
return containerPage.$('.action-toggle-preview .preview-text').text().trim();
};

View File

@@ -241,6 +241,7 @@ describe('CourseOutlinePage', function() {
};
it('can be published', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = getMockCourseJSON({
has_changes: true
});
@@ -256,6 +257,7 @@ describe('CourseOutlinePage', function() {
});
it('should show publish button if it is not published and not changed', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = getMockCourseJSON({
has_changes: false,
published: false
@@ -264,6 +266,7 @@ describe('CourseOutlinePage', function() {
});
it('should show publish button if it is published and changed', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = getMockCourseJSON({
has_changes: true,
published: true
@@ -272,6 +275,7 @@ describe('CourseOutlinePage', function() {
});
it('should show publish button if it is not published, but changed', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = getMockCourseJSON({
has_changes: true,
published: false
@@ -280,6 +284,7 @@ describe('CourseOutlinePage', function() {
});
it('should hide publish button if it is not changed, but published', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = getMockCourseJSON({
has_changes: false,
published: true
@@ -589,6 +594,7 @@ describe('CourseOutlinePage', function() {
setSelfPaced();
});
// eslint-disable-next-line prefer-const
createCourse = function(sectionOptions, courseOptions) {
createCourseOutlinePage(this,
createMockCourseJSON(courseOptions, [
@@ -597,14 +603,17 @@ describe('CourseOutlinePage', function() {
);
};
// eslint-disable-next-line prefer-const
createCourseWithHighlights = function(highlights) {
createCourse({highlights: highlights});
};
// eslint-disable-next-line prefer-const
clickSaveOnModal = function() {
$('.wrapper-modal-window .action-save').click();
};
// eslint-disable-next-line prefer-const
clickCancelOnModal = function() {
$('.wrapper-modal-window .action-cancel').click();
};
@@ -1043,6 +1052,7 @@ describe('CourseOutlinePage', function() {
});
it('can display a publish modal with a list of unpublished subsections and units', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = createMockCourseJSON({}, [
createMockSectionJSON({has_changes: true}, [
createMockSubsectionJSON({has_changes: true}, [
@@ -1319,6 +1329,7 @@ describe('CourseOutlinePage', function() {
});
it('can show correct editors for self_paced course', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = createMockCourseJSON({}, [
createMockSectionJSON({}, [
createMockSubsectionJSON({}, [])
@@ -2166,6 +2177,7 @@ describe('CourseOutlinePage', function() {
});
it('can display a publish modal with a list of unpublished units', function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = createMockCourseJSON({}, [
createMockSectionJSON({has_changes: true}, [
createMockSubsectionJSON({has_changes: true}, [
@@ -2193,6 +2205,7 @@ describe('CourseOutlinePage', function() {
describe('Self Paced with Custom Personalized Learner Schedules (PLS)', function() {
beforeEach(function() {
// eslint-disable-next-line no-shadow
var mockCourseJSON = createMockCourseJSON({}, [
createMockSectionJSON({}, [
createMockSubsectionJSON({}, [])

View File

@@ -98,6 +98,7 @@ describe('XBlockEditorView', function() {
it('can render a module with only settings', function() {
var requests = AjaxHelpers.requests(this),
// eslint-disable-next-line no-shadow
mockXModuleEditorHtml;
mockXModuleEditorHtml = readFixtures('templates/mock/mock-xmodule-settings-only-editor.underscore');

View File

@@ -12,6 +12,7 @@ import XModule from 'xmodule/js/src/xmodule';
import 'cms/js/main';
import 'xblock/cms.runtime.v1';
// eslint-disable-next-line import/no-mutable-exports
var installMockXBlock, uninstallMockXBlock, installMockXModule, uninstallMockXModule,
mockComponentTemplates, installEditTemplates, showEditModal, verifyXBlockRequest;
@@ -116,6 +117,7 @@ verifyXBlockRequest = function(requests, expectedJson) {
expect(actualJson).toEqual(expectedJson);
};
// eslint-disable-next-line import/no-mutable-exports
var editHelpers = $.extend(modal_helpers, {
installMockXBlock: installMockXBlock,
uninstallMockXBlock: uninstallMockXBlock,

View File

@@ -287,6 +287,7 @@ function($, ui, _, gettext, Draggabilly, ModuleUtils, NotificationView) {
oldParentLocator = element.data('parent'),
oldParentEle, saving, refreshParent;
// eslint-disable-next-line no-shadow
refreshParent = function(element) {
var refresh = element.data('refresh');
// If drop was into a collapsed parent, the parent will have been

View File

@@ -33,6 +33,7 @@ define(['jquery'], function($) {
// The TinyMCE editor is hosted in an iframe, and before the iframe is
// removed we execute this code. To avoid throwing an error when setting the
// attr, check that the source doesn't start with the value specified by TinyMCE ('javascript:""').
// eslint-disable-next-line no-script-url
else if (ifr_source.lastIndexOf('javascript:', 0) !== 0) {
$(this).attr('src', ifr_source + '?' + wmode);
}

View File

@@ -183,15 +183,18 @@ function($, _, gettext, HtmlUtils, BaseView, AssetModel, PagingView, AssetView,
type: 'POST',
maxChunkSize: self.uploadChunkSizeInBytes,
autoUpload: true,
// eslint-disable-next-line no-shadow
progressall: function(event, data) {
var percentComplete = parseInt((100 * data.loaded) / data.total, 10);
self.showUploadFeedback(event, percentComplete);
},
maxFileSize: self.maxFileSizeInBytes,
maxNumberofFiles: 100,
// eslint-disable-next-line no-shadow
done: function(event, data) {
self.displayFinishedUpload(data.result);
},
// eslint-disable-next-line no-shadow
processfail: function(event, data) {
var filename = data.files[data.index].name;
var error = gettext('File {filename} exceeds maximum size of {maxFileSizeInMBs} MB')
@@ -216,6 +219,7 @@ function($, _, gettext, HtmlUtils, BaseView, AssetModel, PagingView, AssetView,
msg: gettext('Max file size exceeded')
});
},
// eslint-disable-next-line no-shadow
processdone: function(event, data) {
self.largeFileErrorMsg = null;
}

View File

@@ -38,6 +38,7 @@ function($, _, Backbone, gettext, IframeUtils, TemplateUtils, ViewUtils) {
if (!Math.trunc) {
Math.trunc = function(v) {
v = +v; // eslint-disable-line no-param-reassign
// eslint-disable-next-line no-mixed-operators, no-nested-ternary
return (v - v % 1) || (!isFinite(v) || v === 0 ? v : v < 0 ? -0 : 0);
};
}
@@ -45,7 +46,7 @@ function($, _, Backbone, gettext, IframeUtils, TemplateUtils, ViewUtils) {
var _this = this;
// xss-lint: disable=javascript-jquery-insertion
this.render = _.wrap(this.render, function(render, options) {
this.render = _.wrap(this.render, function(render, options) { // eslint-disable-line no-shadow
_this.beforeRender();
render(options);
_this.afterRender();

View File

@@ -12,12 +12,14 @@ define(['js/views/baseview', 'js/views/course_info_update', 'js/views/course_inf
render: function() {
// instantiate the ClassInfoUpdateView and delegate the proper dom to it
// eslint-disable-next-line no-new
new CourseInfoUpdateView({
el: $('body.updates'),
collection: this.model.get('updates'),
base_asset_url: this.model.get('base_asset_url')
});
// eslint-disable-next-line no-new
new CourseInfoHandoutView({
el: this.$('#course-handouts-view'),
model: this.model.get('handouts'),

View File

@@ -48,6 +48,7 @@ function(
refresh: function(viewState) {
var getViewToRefresh, view, expandedLocators;
// eslint-disable-next-line no-shadow
getViewToRefresh = function(view) {
if (view.model.isChapter() || !view.parentView) {
return view;

View File

@@ -153,6 +153,7 @@ function($, Backbone, _, gettext, moment, ViewUtils, HtmlUtils, StringUtils, Tra
this.clearPreferenceErrorState($fidelityContainer);
// Clear active and selected languages.
// eslint-disable-next-line no-multi-assign
this.selectedLanguages = this.activeLanguages = [];
// Also clear selected language.
this.selectedVideoSourceLanguage = '';
@@ -167,6 +168,7 @@ function($, Backbone, _, gettext, moment, ViewUtils, HtmlUtils, StringUtils, Tra
this.clearPreferenceErrorState($videoSourceLanguageContainer);
// Clear active and selected languages.
// eslint-disable-next-line no-multi-assign
this.selectedLanguages = this.activeLanguages = [];
this.renderTargetLanguages();
},
@@ -236,6 +238,7 @@ function($, Backbone, _, gettext, moment, ViewUtils, HtmlUtils, StringUtils, Tra
$(event.target.parentElement).parent().remove();
// Remove language from selected languages.
// eslint-disable-next-line no-multi-assign
this.selectedLanguages = this.activeLanguages = _.without(this.selectedLanguages, selectedLanguage);
// Populate menu again to reflect latest changes.

View File

@@ -50,6 +50,7 @@ define([
});
edx.HtmlUtils.setHtml(this.$el, edx.HtmlUtils.HTML(template));
// eslint-disable-next-line no-shadow
this.collection.each(function(model) {
this.$(this.listContainerCss).append(
this.createItemView({model: model, restrictEditing: this.restrictEditing}).render().el

View File

@@ -105,6 +105,7 @@ function($, _, gettext, BaseView, PromptView, ViewUtils, HtmlUtils) {
var role_name = self.options.roles[i].key;
var role_selector = 'click .user-actions .make-' + role_name;
// eslint-disable-next-line no-loop-func
(function(role) {
roleEvents[role_selector] = function(event) { self.handleRoleButtonClick(event.target, role); };
}(role_name));
@@ -169,6 +170,7 @@ function($, _, gettext, BaseView, PromptView, ViewUtils, HtmlUtils) {
getPossibleRoleChangesForRole: function(role, adminRoleCount) {
var result = [],
// eslint-disable-next-line no-shadow
role_names = _.map(this.roles, function(role) { return role.key; });
if (role === this.admin_role.key && adminRoleCount === 1) {
result.push({notoggle: true});
@@ -177,6 +179,7 @@ function($, _, gettext, BaseView, PromptView, ViewUtils, HtmlUtils) {
// in reverse order to show "Add" buttons to the left, "Remove" to the right
for (var i = this.roles.length - 1; i >= 0; i--) {
var other_role = this.roles[i];
// eslint-disable-next-line no-continue
if (Math.abs(currentRoleIdx - i) !== 1) { continue; } // allows moving only to adjacent roles
result.push({
to_role: other_role.key,

View File

@@ -189,6 +189,7 @@ define(
this.max = Number(options[max]);
this.$el.find('input').attr(max, numToString(this.max));
}
// eslint-disable-next-line no-undef-init
var stepValue = undefined;
if (options.hasOwnProperty(step)) {
// Parse step and convert to String. Polyfill doesn't like float values like ".1" (expects "0.1").
@@ -234,7 +235,9 @@ define(
// This first filtering if statement is take from polyfill to prevent
// non-numeric input (for browsers that don't use polyfill because they DO have a number input type).
var _ref, _ref1;
// eslint-disable-next-line no-cond-assign
if (((_ref = e.keyCode) !== 8 && _ref !== 9 && _ref !== 35 && _ref !== 36 && _ref !== 37 && _ref !== 39)
// eslint-disable-next-line no-cond-assign
&& ((_ref1 = e.which) !== 45 && _ref1 !== 46 && _ref1 !== 48 && _ref1 !== 49 && _ref1 !== 50 && _ref1 !== 51
&& _ref1 !== 52 && _ref1 !== 53 && _ref1 !== 54 && _ref1 !== 55 && _ref1 !== 56 && _ref1 !== 57)) {
e.preventDefault();
@@ -444,6 +447,7 @@ define(
}).reverse();
seconds = _.reduce(list, function(memo, num, index) {
// eslint-disable-next-line prefer-exponentiation-operator, no-restricted-properties
return memo + num * Math.pow(60, index);
}, 0);
@@ -515,6 +519,7 @@ define(
var list = this.$el.find('ol'),
frag = document.createDocumentFragment();
// eslint-disable-next-line no-shadow
_.each(value, function(value, key) {
var template = _.template(
HtmlUtils.joinHtml(

View File

@@ -133,6 +133,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
tabsTemplate = this.loadTemplate('settings-modal-tabs');
HtmlUtils.setHtml(this.$('.modal-section'), HtmlUtils.HTML(tabsTemplate({tabs: tabs})));
_.each(this.options.tabs, function(tab) {
// eslint-disable-next-line prefer-spread
this.options.editors.push.apply(
this.options.editors,
_.map(tab.editors, function(Editor) {
@@ -606,6 +607,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
this.$('.field-exam-review-rules textarea').val(value);
},
isValidTimeLimit: function(timeLimit) {
// eslint-disable-next-line prefer-regex-literals
var pattern = new RegExp('^\\d{1,2}:[0-5][0-9]$');
return pattern.test(timeLimit) && timeLimit !== '00:00';
},
@@ -948,6 +950,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
} else {
$('.un-published-tip').show();
}
// eslint-disable-next-line prefer-const
let enabledForGraded = course.get('discussions_settings').enable_graded_units;
if (this.model.get('graded') && !enabledForGraded) {
$('#discussion_enabled').prop('disabled', true);
@@ -1032,6 +1035,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
} else {
display = 'none';
}
// eslint-disable-next-line no-shadow
$.each(warning, function(_, element) {
element.style.display = display;
});

View File

@@ -23,6 +23,7 @@
var ModuleEdit = (function(_super) {
__extends(ModuleEdit, _super);
// eslint-disable-next-line no-shadow
function ModuleEdit() {
return ModuleEdit.__super__.constructor.apply(this, arguments);
}

View File

@@ -66,6 +66,7 @@ function($, _, gettext, BasePage, XBlockViewUtils, CourseOutlineView, ViewUtils,
},
renderPage: function() {
// eslint-disable-next-line no-shadow
var setInitialExpandState = function(xblockInfo, expandedLocators) {
if (xblockInfo.isCourse() || xblockInfo.isChapter()) {
expandedLocators.add(xblockInfo.get('id'));

View File

@@ -82,6 +82,7 @@ function(ValidatingView, $, _, gettext, CodeMirror, ValidationErrorModal, HtmlUt
var stringValue = $.trim(mirror.getValue());
// update CodeMirror to show the trimmed value.
mirror.setValue(stringValue);
// eslint-disable-next-line no-undef-init
var JSONValue = undefined;
try {
JSONValue = JSON.parse(stringValue);

View File

@@ -229,6 +229,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
// set min/max widths
var cachethis = this;
var widthPerPoint = cachethis.gradeBarWidth / 100;
// eslint-disable-next-line no-shadow
return function(event, ui) {
var barIndex = ui.element.index();
var offset = 1;
@@ -245,6 +246,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
moveBarClosure: function() {
// 0th ele doesn't have a bar; so, will never invoke this
var cachethis = this;
// eslint-disable-next-line no-shadow
return function(event, ui) {
var barIndex = ui.element.index();
var offset = 1;
@@ -254,6 +256,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
: offset);
// minus 2 b/c minus 1 is the element we're effecting. It's max is just shy of the next one above it
var max = (barIndex >= 2 ? cachethis.descendingCutoffs[barIndex - 2].cutoff - offset : 100);
// eslint-disable-next-line no-mixed-operators
var percentage = Math.min(Math.max(ui.size.width / cachethis.gradeBarWidth * 100, min), max);
cachethis.descendingCutoffs[barIndex - 1].cutoff = Math.round(percentage);
cachethis.renderGradeRanges();
@@ -272,6 +275,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
stopDragClosure: function() {
var cachethis = this;
// eslint-disable-next-line no-shadow
return function(event, ui) {
// for some reason the resize is setting height to 0
cachethis.saveCutoffs();
@@ -388,6 +392,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
// Instrument grading scale
// convert cutoffs to inversely ordered list
var modelCutoffs = this.model.get('grade_cutoffs');
// eslint-disable-next-line guard-for-in
for (var cutoff in modelCutoffs) {
this.descendingCutoffs.push({designation: cutoff, cutoff: Math.round(modelCutoffs[cutoff] * 100)});
}

View File

@@ -391,8 +391,11 @@ function(ValidatingView, CodeMirror, _, $, ui, DateUtils, FileUploadModel,
if (!this.useV2CertDisplaySettings) {
return;
}
// eslint-disable-next-line prefer-const
let showDatepicker = this.model.get('certificates_display_behavior') == 'end_with_date';
// eslint-disable-next-line prefer-const
let datepicker = this.$el.find('#certificate-available-date');
// eslint-disable-next-line prefer-const
let certificateAvailableDateField = this.$el.find('#field-certificate-available-date');
if (showDatepicker) {
@@ -451,6 +454,7 @@ function(ValidatingView, CodeMirror, _, $, ui, DateUtils, FileUploadModel,
selector = '',
image_key = '',
image_path_key = '';
// eslint-disable-next-line default-case
switch (event.currentTarget.id) {
case 'upload-course-image':
title = gettext('Upload your course image.');

View File

@@ -28,6 +28,7 @@
TabsEdit = (function(_super) {
__extends(TabsEdit, _super);
// eslint-disable-next-line no-shadow
function TabsEdit() {
var self = this;
this.deleteTab = function() {

View File

@@ -27,6 +27,7 @@ define(['jquery', 'gettext', 'common/js/components/utils/view_utils', 'js/views/
if (detailedReason) {
reason = detailedReason;
}
// eslint-disable-next-line no-empty
} catch (e) {}
}
errorHandler(reason);

View File

@@ -37,6 +37,7 @@ function(HtmlUtils, BaseView, _, $, gettext, NotificationView, AlertView) {
handleValidationError: function(model, error) {
this.clearValidationErrors();
// error is object w/ fields and error strings
// eslint-disable-next-line guard-for-in
for (var field in error) {
var ele = this.$el.find('#' + this.fieldToSelectorMap[field]);
this._cacheValidationErrors.push(ele);

View File

@@ -130,6 +130,7 @@ define(
checkExtValidity: function(file) {
var fileExtension;
if (!file.name) {
// eslint-disable-next-line no-void
return void 0;
}

View File

@@ -223,8 +223,10 @@ define(
}
if (this.$extraVideosBar.hasClass('is-visible')) {
// eslint-disable-next-line prefer-spread
this.closeExtraVideosBar.apply(this, arguments);
} else {
// eslint-disable-next-line prefer-spread
this.openExtraVideosBar.apply(this, arguments);
}
},

View File

@@ -84,6 +84,7 @@ define(['jquery', 'underscore', 'jquery.ajaxQueue'], function($) {
return function(url) {
if (typeof url !== 'string') {
// eslint-disable-next-line no-void
return void 0;
}
@@ -92,6 +93,7 @@ define(['jquery', 'underscore', 'jquery.ajaxQueue'], function($) {
}
var match = url.match(regExp);
// eslint-disable-next-line no-void
cache[url] = (match) ? match[1] : void 0;
return cache[url];
@@ -114,6 +116,7 @@ define(['jquery', 'underscore', 'jquery.ajaxQueue'], function($) {
return function(url) {
if (typeof url !== 'string') {
// eslint-disable-next-line no-void
return void 0;
}
@@ -169,6 +172,7 @@ define(['jquery', 'underscore', 'jquery.ajaxQueue'], function($) {
result;
if (typeof url !== 'string') {
// eslint-disable-next-line no-void
return void 0;
}

View File

@@ -56,6 +56,7 @@ define(
getDropdown: (function() {
var dropdown,
disableOptions = function(element, values) {
// eslint-disable-next-line no-shadow
var dropdown = $(element).clone();
_.each(values, function(value, key) {

View File

@@ -26,6 +26,7 @@ const BLOCK_TYPE_NAME = {
};
const BlockType = PropTypes.shape({
// eslint-disable-next-line react/forbid-prop-types
children: PropTypes.array,
display_name: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
@@ -33,6 +34,7 @@ const BlockType = PropTypes.shape({
type: PropTypes.string.isRequired,
});
// eslint-disable-next-line react/function-component-definition
export const BlockList = ({
blocks, selectedBlock, onSelectBlock, onChangeRoot,
}) => (
@@ -71,7 +73,9 @@ BlockList.defaultProps = {
selectedBlock: null,
};
// eslint-disable-next-line react/function-component-definition
export const BlockBrowser = ({
// eslint-disable-next-line react/prop-types
blocks, selectedBlock, onSelectBlock, onChangeRoot, className,
}) => !!blocks && (
<div className={classNames('block-browser', className)}>

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line no-redeclare
/* global jest,test,describe,expect */
import React from 'react';
import renderer from 'react-test-renderer';

View File

@@ -4,6 +4,7 @@ import courseBlocksActions from '../actions/constants';
export const buildBlockTree = (blocks, excludeBlockTypes) => {
if (!(blocks && blocks.root)) { return null; }
const blockTree = (root, parent) => {
// eslint-disable-next-line prefer-object-spread
const tree = Object.assign({ parent }, blocks.blocks[root]);
if (tree.children) {
tree.children = tree.children.map(block => blockTree(block, root));
@@ -18,6 +19,7 @@ export const buildBlockTree = (blocks, excludeBlockTypes) => {
return blockTree(blocks.root, null);
};
// eslint-disable-next-line default-param-last
export const blocks = (state = {}, action) => {
switch (action.type) {
case courseBlocksActions.fetch.SUCCESS:
@@ -27,6 +29,7 @@ export const blocks = (state = {}, action) => {
}
};
// eslint-disable-next-line default-param-last
export const selectedBlock = (state = '', action) => {
switch (action.type) {
case courseBlocksActions.SELECT_BLOCK:
@@ -36,6 +39,7 @@ export const selectedBlock = (state = '', action) => {
}
};
// eslint-disable-next-line default-param-last
export const rootBlock = (state = null, action) => {
switch (action.type) {
case courseBlocksActions.fetch.SUCCESS:

View File

@@ -3,6 +3,7 @@ import { Provider } from 'react-redux';
import BlockBrowserContainer from './components/BlockBrowser/BlockBrowserContainer';
import store from './data/store';
// eslint-disable-next-line react/function-component-definition
export const BlockBrowser = props => (
<Provider store={store}>
<BlockBrowserContainer {...props} />

View File

@@ -20,6 +20,7 @@ function NextArrow(props) {
}
return (
// eslint-disable-next-line react/button-has-type
<button {...opts}>
<span>Next </span>
<span className="icon fa fa-chevron-right" aria-hidden="true" />
@@ -41,6 +42,7 @@ function PrevArrow(props) {
}
return (
// eslint-disable-next-line react/button-has-type
<button {...opts}>
<span className="icon fa fa-chevron-left" aria-hidden="true" />
<span> Prev</span>
@@ -64,6 +66,7 @@ export default class ExperimentalCarousel extends React.Component {
this.getCarouselContent = this.getCarouselContent.bind(this);
}
// eslint-disable-next-line react/sort-comp
afterChange(activeIndex) {
this.setState({activeIndex});
}
@@ -121,5 +124,6 @@ export default class ExperimentalCarousel extends React.Component {
}
ExperimentalCarousel.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
slides: PropTypes.array.isRequired
};

View File

@@ -379,6 +379,7 @@
var count;
count = 0;
this.get('comments').each(function(comment) {
// eslint-disable-next-line no-return-assign
return count += comment.getCommentsCount() + 1;
});
return count;

View File

@@ -58,6 +58,7 @@
};
Discussion.prototype.setSortComparator = function(sortBy) {
// eslint-disable-next-line default-case
switch (sortBy) {
case 'activity':
this.comparator = this.sortByDateRecentFirst;
@@ -95,6 +96,7 @@
if (_.contains(['unread', 'unanswered', 'flagged'], options.filter)) {
data[options.filter] = true;
}
// eslint-disable-next-line default-case
switch (mode) {
case 'search':
url = DiscussionUtil.urlFor('search');

View File

@@ -30,6 +30,7 @@
DiscussionUtil.isStaff = function(userId) {
var staff;
if (_.isUndefined(userId)) {
// eslint-disable-next-line no-void
userId = this.user ? this.user.id : void 0;
}
if (_.isUndefined(this.roleIds)) {
@@ -42,6 +43,7 @@
DiscussionUtil.isTA = function(userId) {
var ta;
if (_.isUndefined(userId)) {
// eslint-disable-next-line no-void
userId = this.user ? this.user.id : void 0;
}
ta = _.union(this.roleIds['Community TA']);
@@ -52,6 +54,7 @@
var groupTa,
localUserId = userId;
if (_.isUndefined(userId)) {
// eslint-disable-next-line no-void
localUserId = this.user ? this.user.id : void 0;
}
groupTa = _.union(this.roleIds['Group Moderator']);
@@ -394,6 +397,7 @@
htmlString = $div.html();
htmlString = htmlString.replace(/\\\$/g, ESCAPED_DOLLAR);
/* eslint-disable no-loop-func */
// eslint-disable-next-line no-constant-condition
while (true) {
if (RE_INLINEMATH.test(htmlString)) {
htmlString = htmlString.replace(RE_INLINEMATH, function($0, $1, $2, $3) {

View File

@@ -125,6 +125,7 @@
if (this.attrRenderer[attr]) {
_results.push(this.attrRenderer[attr].apply(this, [value]));
} else {
// eslint-disable-next-line no-void
_results.push(void 0);
}
}
@@ -142,6 +143,7 @@
if (this.attrRenderer[attr]) {
_results.push(this.attrRenderer[attr].apply(this, [value]));
} else {
// eslint-disable-next-line no-void
_results.push(void 0);
}
}
@@ -236,9 +238,11 @@
var funcName, selector;
selector = event[0];
funcName = event[1];
// eslint-disable-next-line no-shadow
obj['click ' + selector] = function(event) {
return this[funcName](event);
};
// eslint-disable-next-line no-shadow
obj['keydown ' + selector] = function(event) {
return DiscussionUtil.activateOnSpace(event, this[funcName]);
};

View File

@@ -305,6 +305,7 @@
default:
}
ref = this.collection.last();
// eslint-disable-next-line no-void
lastThread = ref ? ref.get('id') : void 0;
if (lastThread) {
this.once('threads:rendered', function() {
@@ -315,6 +316,7 @@
} else {
this.once('threads:rendered', function() {
var ref1 = $('.forum-nav-thread-link').first();
// eslint-disable-next-line no-void
return ref1 ? ref1.focus() : void 0;
});
}

View File

@@ -33,6 +33,7 @@
this.mode = options.mode || 'inline';
this.startHeader = options.startHeader;
this.is_commentable_divided = options.is_commentable_divided;
// eslint-disable-next-line no-cond-assign
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
throw new Error('invalid mode: ' + this.mode);
}

View File

@@ -85,6 +85,7 @@
this.context = options.context || 'course';
this.options = _.extend({}, options);
this.startHeader = options.startHeader;
// eslint-disable-next-line no-cond-assign
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
throw new Error('invalid mode: ' + this.mode);
}
@@ -188,6 +189,7 @@
),
data: {
resp_skip: this.responses.size(),
// eslint-disable-next-line no-void
resp_limit: responseLimit || void 0
},
$elem: $elem,
@@ -454,6 +456,7 @@
if (!this.model.can('can_delete')) {
return;
}
// eslint-disable-next-line no-alert
if (!confirm(gettext('Are you sure you want to delete this post?'))) {
return;
}

View File

@@ -38,6 +38,7 @@
var _ref;
this.mode = options.mode || 'inline';
this.startHeader = options.startHeader;
// eslint-disable-next-line no-cond-assign
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
throw new Error('invalid mode: ' + this.mode);
}
@@ -199,6 +200,7 @@
url = DiscussionUtil.urlFor('create_thread', topicId);
return DiscussionUtil.safeAjax({
$elem: $(event.target),
// eslint-disable-next-line no-void
$loading: event ? $(event.target) : void 0,
url: url,
type: 'POST',

View File

@@ -102,6 +102,7 @@
if (!this.model.can('can_delete')) {
return;
}
// eslint-disable-next-line no-alert
if (!confirm(gettext('Are you sure you want to delete this comment?'))) {
return;
}

View File

@@ -228,6 +228,7 @@
if (!this.model.can('can_delete')) {
return;
}
// eslint-disable-next-line no-alert
if (!confirm(gettext('Are you sure you want to delete this response?'))) {
return;
}
@@ -328,6 +329,7 @@
url = DiscussionUtil.urlFor('update_comment', this.model.id);
return DiscussionUtil.safeAjax({
$elem: $(event.target),
// eslint-disable-next-line no-void
$loading: event ? $(event.target) : void 0,
url: url,
type: 'POST',

View File

@@ -42,7 +42,9 @@ var path = require('path');
var _ = require('underscore');
var appRoot = path.join(__dirname, '../../../../');
// eslint-disable-next-line import/no-extraneous-dependencies
var webdriver = require('selenium-webdriver');
// eslint-disable-next-line import/no-extraneous-dependencies
var firefox = require('selenium-webdriver/firefox');
var webpackConfig = require(path.join(appRoot, 'webpack.dev.config.js'));

View File

@@ -57,6 +57,7 @@
this.renderSpy = spyOn(AlertView.Confirmation.prototype, 'render').and.callThrough();
this.showSpy = spyOn(AlertView.Confirmation.prototype, 'show').and.callThrough();
this.hideSpy = spyOn(AlertView.Confirmation.prototype, 'hide').and.callThrough();
// eslint-disable-next-line no-return-assign
return this.clock = sinon.useFakeTimers();
});
afterEach(function() {
@@ -317,6 +318,7 @@
this.showSpy.and.callThrough();
this.hideSpy = spyOn(NotificationView.Confirmation.prototype, 'hide');
this.hideSpy.and.callThrough();
// eslint-disable-next-line no-return-assign
return this.clock = sinon.useFakeTimers();
});
afterEach(function() {

View File

@@ -263,6 +263,7 @@
return _.each([
{
val: '',
// eslint-disable-next-line no-void
expectedGroupId: void 0
}, {
val: '1',

View File

@@ -53,6 +53,7 @@
expectedText = 'Test body';
// I really have no idea what it is supposed to mean - probably just iteration, but better be safe
for (
// eslint-disable-next-line no-multi-assign
i = _i = 0, _ref = numberOfImages - 1;
_ref >= 0 ? _i <= _ref : _i >= _ref;
i = _ref >= 0 ? ++_i : --_i
@@ -131,6 +132,7 @@
'body with ' + numImages + ' images and ' + (truncatedText ? 'truncated' : 'untruncated')
+ ' text',
// eslint-disable no-loop-func
// eslint-disable-next-line no-loop-func
function() {
return checkPostWithImages(numImages, truncatedText, this.threadData, this.imageTag);
}

View File

@@ -47,6 +47,7 @@
children: count > 0 ? (function() {
var _i, _results;
_results = [];
// eslint-disable-next-line no-multi-assign
for (index = _i = 1; count >= 1 ? _i <= count : _i >= count; index = count >= 1 ? ++_i : --_i) {
_results.push(createTestResponseJson(index));
}

View File

@@ -8,6 +8,7 @@
this.createTopicView = function(options) {
options = _.extend({
course_settings: this.course_settings,
// eslint-disable-next-line no-void
topicId: void 0
}, options);
this.view = new DiscussionTopicMenuView(options);

View File

@@ -97,7 +97,9 @@
it('initializes children', function() {
XBlock.initializeBlocks($('#jasmine-fixtures'));
// eslint-disable-next-line no-void
expect(XBlock.initializeBlock).toHaveBeenCalledWith(this.vANode, void 0);
// eslint-disable-next-line no-void
expect(XBlock.initializeBlock).toHaveBeenCalledWith(this.vZNode, void 0);
});

View File

@@ -12,6 +12,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// eslint-disable-next-line global-require
require(['jquery'], function($) {
factory(root, $);
});

View File

@@ -13,6 +13,7 @@
_.each(unfakes, function(u) {
return u();
});
// eslint-disable-next-line no-return-assign
return unfakes = [];
};
@@ -21,6 +22,7 @@
originalThing = owner[thingToFake];
owner[thingToFake] = newThing;
return unfakes.push(function() {
// eslint-disable-next-line no-return-assign
return owner[thingToFake] = originalThing;
});
};
@@ -50,6 +52,7 @@
_.each(methodsToSpy, function(methodName) {
spies[methodName] = jasmine.createSpy('' + classToFake + '#' + methodName);
// eslint-disable-next-line no-return-assign
return fakeClass.prototype[methodName] = function() {
return spies[methodName].apply(this, arguments);
};

View File

@@ -80,6 +80,7 @@
maxlength: function($el) {
var max = $el.attr('maxlength') || false;
// eslint-disable-next-line no-extra-boolean-cast
return (!!max) ? max >= $el.val().length : true;
}
},

View File

@@ -7,6 +7,7 @@ Helper function used to require files serially instead of concurrently.
var requireModules = function(paths, callback, modules) {
// If all the modules have been loaded, call the callback.
if (paths.length === 0) {
// eslint-disable-next-line prefer-spread
return callback.apply(null, modules);
}
// Otherwise load the next one.

View File

@@ -66,7 +66,7 @@
//when Check button is clicked
var problem = $('#protex_container').parents('.problem');
var check_button = problem.find('input.check');
var input_field = problem.find('input[type=hidden]');
var input_field = problem.find('input[type=hidden]');
check_button.on('click', function() {
var protex_answer = protexCheckAnswer();
var value = {protex_answer: protex_answer};

View File

@@ -189,12 +189,14 @@
&& (target.draggableList.length === 1)
&& (target.draggableList[0].uniqueId !== this.uniqueId)
) {
// eslint-disable-next-line no-continue
continue;
}
// If the target is on a draggable (from target field), we must make sure that
// this draggable is not the same as "this" one.
if ((target.type === 'on_drag') && (target.draggableObj.uniqueId === this.uniqueId)) {
// eslint-disable-next-line no-continue
continue;
}
@@ -206,6 +208,7 @@
|| (positionIE.left + this.iconWidth * 0.5 < target.offset.left)
|| (positionIE.left + this.iconWidth * 0.5 > target.offset.left + target.w)
) {
// eslint-disable-next-line no-continue
continue;
}

View File

@@ -14,6 +14,7 @@
// Array.prototype.every is a recent addition to the ECMA-262 standard; as such it may not be present in
// other implementations of the standard.
if (!Array.prototype.every) {
// eslint-disable-next-line no-extend-native
Array.prototype.every = function(fun /* , thisp */) {
var thisp, t, len, i;
@@ -22,6 +23,7 @@
}
t = Object(this);
// eslint-disable-next-line no-bitwise
len = t.length >>> 0;
if (typeof fun !== 'function') {
throw new TypeError();

View File

@@ -143,6 +143,7 @@
// draggables.
state.updateArrowOpacity = updateArrowOpacity;
// eslint-disable-next-line no-useless-return
return;
function updateArrowOpacity() {

View File

@@ -29,6 +29,7 @@
} else {
(function(c1) {
while (c1 < state.targets.length) {
// eslint-disable-next-line no-loop-func
(function(c2) {
while (c2 < state.targets[c1].draggableList.length) {
tempObj = {};
@@ -129,11 +130,14 @@
checkBaseDraggable();
// eslint-disable-next-line no-useless-return
return;
function checkBaseDraggable() {
// eslint-disable-next-line no-cond-assign
if ((baseDraggable = getById(state, 'draggables', baseDraggableId, null, false, baseTargetId)) === null) {
createBaseDraggableOnTarget(state, baseDraggableId, baseTargetId, true, function() {
// eslint-disable-next-line no-cond-assign
if ((baseDraggable = getById(state, 'draggables', baseDraggableId, null, false, baseTargetId)) === null) {
console.log('ERROR: Could not successfully create a base draggable on a base target.');
} else {
@@ -158,6 +162,7 @@
}
function checklayeredDraggable() {
// eslint-disable-next-line no-cond-assign
if ((layeredDraggable = getById(state, 'draggables', layeredDraggableId, null, false, layeredTargetId, baseDraggableId, baseTargetId)) === null) {
layeredDraggable = getById(state, 'draggables', layeredDraggableId);
layeredTarget = null;
@@ -185,6 +190,7 @@
function createBaseDraggableOnTarget(state, draggableId, targetId, reportError, funcCallback) {
var draggable, target;
// eslint-disable-next-line no-cond-assign
if ((draggable = getById(state, 'draggables', draggableId)) === null) {
if (reportError !== false) {
console.log(
@@ -197,6 +203,7 @@
return false;
}
// eslint-disable-next-line no-cond-assign
if ((target = getById(state, 'targets', targetId)) === null) {
if (reportError !== false) {
console.log(
@@ -221,9 +228,11 @@
while (c1 < answer.length) {
for (draggableId in answer[c1]) {
if (answer[c1].hasOwnProperty(draggableId) === false) {
// eslint-disable-next-line no-continue
continue;
}
// eslint-disable-next-line no-cond-assign
if ((draggable = getById(state, 'draggables', draggableId)) === null) {
console.log(
'ERROR: In answer there exists a '
@@ -231,6 +240,7 @@
+ 'draggable with this ID could be found.'
);
// eslint-disable-next-line no-continue
continue;
}

View File

@@ -2,6 +2,7 @@ $(function() {
// TODO: someone should fix all of this...
// $("a[rel*=leanModal]").leanModal(); //TODO: Make this work with the new modal library. Try and integrate this with the "slices"
/* eslint-disable no-multi-str */
// xss-lint: disable=javascript-jquery-append
$('body').append('\
<div id="circuit_editor_modal" class="modal hide fade"> \

View File

@@ -34,6 +34,7 @@ describe('Formula Equation Preview', function() {
var formulaEquationPreview = window.formulaEquationPreview;
beforeEach(function() {
// Simulate an environment conducive to a FormulaEquationInput
// eslint-disable-next-line no-multi-assign, no-multi-str
var $fixture = this.$fixture = $('\
<section class="problems-wrapper" data-url="THE_URL">\
<section class="formulaequationinput">\
@@ -50,6 +51,7 @@ describe('Formula Equation Preview', function() {
</section>');
// Modify $ for the test to search the fixture.
// eslint-disable-next-line no-multi-assign
var old$find = this.old$find = $.find;
$.find = function() {
// Given the default context, swap it out for the fixture.
@@ -68,6 +70,7 @@ describe('Formula Equation Preview', function() {
};
// Catch the AJAX requests
// eslint-disable-next-line no-multi-assign
var ajaxTimes = this.ajaxTimes = [];
this.oldProblem = window.Problem;

View File

@@ -233,7 +233,9 @@ var Channel = (function() {
if (origin === '*') {
// we must check all other origins, sadly.
for (var k in s_boundChans) {
// eslint-disable-next-line no-continue
if (!s_boundChans.hasOwnProperty(k)) { continue; }
// eslint-disable-next-line no-continue
if (k === '*') { continue; }
if (typeof s_boundChans[k][scope] === 'object') {
exists = hasWin(s_boundChans[k][scope]);
@@ -288,6 +290,7 @@ var Channel = (function() {
try {
var m = JSON.parse(e.data);
if (typeof m !== 'object' || m === null) { throw 'malformed'; }
// eslint-disable-next-line no-shadow
} catch (e) {
// just ignore any posted messages that do not consist of valid JSON
return;
@@ -387,6 +390,7 @@ var Channel = (function() {
var debug = function(m) {
if (cfg.debugOutput && window.console && window.console.log) {
// try to stringify, if it doesn't work we'll let javascript's built in toString do its magic
// eslint-disable-next-line no-empty
try { if (typeof m !== 'string') { m = JSON.stringify(m); } } catch (e) { }
console.log('[' + chanId + '] ' + m);
}
@@ -415,6 +419,7 @@ var Channel = (function() {
// eslint-disable-next-line brace-style
if (cfg.origin === '*') { validOrigin = true; }
// allow valid domains under http and https. Also, trim paths off otherwise valid origins.
// eslint-disable-next-line no-cond-assign
else if ((oMatch = cfg.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/)) !== null) {
cfg.origin = oMatch[0].toLowerCase();
validOrigin = true;
@@ -541,6 +546,7 @@ var Channel = (function() {
if (typeof obj[cp] !== 'object') { obj[cp] = { }; }
obj = obj[cp];
}
// eslint-disable-next-line no-loop-func
obj[pathItems[pathItems.length - 1]] = (function() {
var cbName = path;
return function(params) {
@@ -569,6 +575,7 @@ var Channel = (function() {
// * if it's an object then we'll look form error and message parameters
else if (typeof e.error === 'string') {
error = e.error;
// eslint-disable-next-line no-ex-assign
if (!e.message) { message = ''; } else if (typeof e.message === 'string') { message = e.message; } else { e = e.message; } // let the stringify/toString message give us a reasonable verbose error string
}
}
@@ -707,6 +714,7 @@ var Channel = (function() {
var callbackNames = [];
var seen = [];
// eslint-disable-next-line no-shadow
var pruneFunctions = function(path, obj) {
if (seen.indexOf(obj) >= 0) {
throw 'params cannot be a recursive data structure';
@@ -715,6 +723,7 @@ var Channel = (function() {
if (typeof obj === 'object') {
for (var k in obj) {
// eslint-disable-next-line no-continue
if (!obj.hasOwnProperty(k)) { continue; }
var np = path + (path.length ? '/' : '') + k;
if (typeof obj[k] === 'function') {

View File

@@ -6,6 +6,7 @@
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript
*/
// eslint-disable-next-line no-shadow-restricted-names
var JSInput = (function($, undefined) {
// Initialize js inputs on current page.
// N.B.: No library assumptions about the iframe can be made (including,
@@ -102,6 +103,7 @@ var JSInput = (function($, undefined) {
channel.call({
method: 'getState',
params: '',
// eslint-disable-next-line no-shadow
success: function(val) {
state = decodeURI(val.toString());
store = {
@@ -159,6 +161,7 @@ var JSInput = (function($, undefined) {
// 200 ms and 5 times are arbitrary but this has functioned with the
// only application that has ever used JSInput, jsVGL. Something
// more sturdy should be put in place.
// eslint-disable-next-line no-inner-declarations
function whileloop(n) {
if (n > 0) {
try {

View File

@@ -8,7 +8,7 @@
<symbolicresponse expect="a_b^c + b_x__d" size="30">
<textline math="1"
preprocessorClassName="SymbolicMathjaxPreprocessor"
preprocessorSrc="/static/js/capa/symbolic_mathjax_preprocessor.js"/>
preprocessorSrc="/static/js/capa/symbolic_mathjax_preprocessor.js"/>
</symbolicresponse>
*/
window.SymbolicMathjaxPreprocessor = function() {

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line max-classes-per-file
import React from 'react';
import ReactDOM from 'react-dom';
@@ -8,6 +9,7 @@ class ReactRendererException extends Error {
}
}
// eslint-disable-next-line import/prefer-default-export
export class ReactRenderer {
constructor({
component, selector, componentName, props = {}

View File

@@ -203,6 +203,7 @@ $(function() {
var SRAlert;
SRAlert = (function() {
// eslint-disable-next-line no-shadow
function SRAlert() {
// This initialization sometimes gets done twice, so take to only create a single reader-feedback div.
var readerFeedbackID = 'reader-feedback',

View File

@@ -76,8 +76,8 @@
select.addEventListener('change', function() {
state.selectedChoice = select.options[select.selectedIndex].text;
feedback.innerText = "You have selected '" + state.selectedChoice +
"'. Click Submit to grade your answer.";
feedback.innerText = "You have selected '" + state.selectedChoice
+ "'. Click Submit to grade your answer.";
});
return {
@@ -85,4 +85,4 @@
setState: setState,
getGrade: getGrade
};
}());
}());

View File

@@ -17,6 +17,7 @@ export default class Main extends React.Component {
handleToggleDropdown() {
this.props.fetchCourseBlocks(this.props.courseId, this.props.excludeBlockTypes);
// eslint-disable-next-line react/no-access-state-in-setstate
this.setState({ showDropdown: !this.state.showDropdown });
}
@@ -36,6 +37,7 @@ export default class Main extends React.Component {
render() {
const { selectedBlock, onSelectBlock } = this.props;
let selectorType = <Button onClick={this.handleToggleDropdown} label={gettext('Select a section or problem')} />;
// eslint-disable-next-line react/prop-types
if (this.props.showBtnUi === 'false') {
selectorType = (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
@@ -62,6 +64,7 @@ export default class Main extends React.Component {
name="problem-location"
value={selectedBlock}
disabled
// eslint-disable-next-line react/prop-types
hidden={this.props.showBtnUi === 'false'}
/>
{this.state.showDropdown
@@ -96,11 +99,13 @@ Main.propTypes = {
selectedBlock: PropTypes.string,
taskStatusEndpoint: PropTypes.string.isRequired,
reportDownloadEndpoint: PropTypes.string.isRequired,
// eslint-disable-next-line react/no-unused-prop-types
ShowBtnUi: PropTypes.string.isRequired,
};
Main.defaultProps = {
excludeBlockTypes: null,
selectedBlock: '',
// eslint-disable-next-line react/default-props-match-prop-types
timeout: null,
};

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line no-redeclare
/* global jest,test,describe,expect */
import { Button } from '@edx/paragon';
import BlockBrowserContainer from 'BlockBrowser/components/BlockBrowser/BlockBrowserContainer';
@@ -69,6 +70,7 @@ describe('ProblemBrowser Main component', () => {
/>
</Provider>,
);
// eslint-disable-next-line prefer-destructuring
const instance = component.root.children[0].instance;
instance.handleToggleDropdown();
expect(fetchCourseBlocksMock.mock.calls.length).toBe(1);

View File

@@ -13,6 +13,7 @@ const mapDispatchToProps = dispatch => ({
(courseId, excludeBlockTypes) => dispatch(fetchCourseBlocks(courseId, excludeBlockTypes)),
createProblemResponsesReportTask:
(problemResponsesEndpoint, taskStatusEndpoint, reportDownloadEndpoint, problemLocation) => dispatch(
// eslint-disable-next-line max-len
createProblemResponsesReportTask(problemResponsesEndpoint, taskStatusEndpoint, reportDownloadEndpoint, problemLocation),
),
});

View File

@@ -4,6 +4,7 @@ import classNames from 'classnames';
import * as PropTypes from 'prop-types';
import * as React from 'react';
// eslint-disable-next-line react/function-component-definition
const ReportStatus = ({
error, succeeded, inProgress, reportPath,
}) => {
@@ -53,7 +54,9 @@ ReportStatus.propTypes = {
ReportStatus.defaultProps = {
error: null,
reportPath: null,
// eslint-disable-next-line react/default-props-match-prop-types
reportPreview: null,
// eslint-disable-next-line react/default-props-match-prop-types
reportName: null,
};

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line no-redeclare
/* global test,describe,expect */
import React from 'react';
import renderer from 'react-test-renderer';

View File

@@ -30,6 +30,7 @@ const problemResponsesRefreshStatus = timeout => ({
timeout,
});
// eslint-disable-next-line max-len
const getTaskStatus = (taskStatusEndpoint, reportDownloadEndpoint, taskId) => dispatch => fetchTaskStatus(taskStatusEndpoint, taskId)
.then((response) => {
if (response.ok) {

View File

@@ -17,6 +17,7 @@ const initialState = {
timeout: null,
};
// eslint-disable-next-line default-param-last
export const reportStatus = (state = initialState, action) => {
switch (action.type) {
case REPORT_GENERATION_REQUEST:

View File

@@ -4,6 +4,7 @@ import { Provider } from 'react-redux';
import store from './data/store';
import MainContainer from './components/Main/MainContainer';
// eslint-disable-next-line react/function-component-definition
export const ProblemBrowser = props => (
<Provider store={store}>
<MainContainer {...props} />

View File

@@ -145,6 +145,7 @@
// it's difficult to show the error message in the UI.
// Since this page is used only by internal staff, I think the
// quick-and-easy way is reasonable.
// eslint-disable-next-line no-alert
alert(jqxhr.responseText);
this.enableButtons();
},

View File

@@ -35,6 +35,7 @@ class EntitlementForm extends React.Component {
this.submitForm = this.submitForm.bind(this);
}
// eslint-disable-next-line react/sort-comp
onClose() {
this.props.closeForm();
}

View File

@@ -7,6 +7,7 @@ import SearchContainer from '../Search/SearchContainer';
import EntitlementSupportTableContainer from '../Table/EntitlementSupportTableContainer';
import EntitlementFormContainer from '../EntitlementForm/container';
// eslint-disable-next-line react/function-component-definition
const Main = props => (
<div className="entitlement-support-wrapper">
<StatusAlert
@@ -27,6 +28,7 @@ const Main = props => (
</div>
);
// eslint-disable-next-line react/function-component-definition
const MainContent = (props) => {
if (props.isFormOpen) {
return <EntitlementFormContainer />;

View File

@@ -49,6 +49,7 @@ const parseEntitlementData = (entitlements, ecommerceUrl, openReissueForm) => en
const {
expiredAt, created, modified, orderNumber, enrollmentCourseRun,
} = entitlement;
// eslint-disable-next-line prefer-object-spread
return Object.assign({}, entitlement, {
expiredAt: expiredAt ? moment(expiredAt).format('lll') : '',
createdAt: moment(created).format('lll'),
@@ -66,6 +67,7 @@ const parseEntitlementData = (entitlements, ecommerceUrl, openReissueForm) => en
});
});
// eslint-disable-next-line react/function-component-definition
const EntitlementSupportTable = props => (
<Table
data={parseEntitlementData(props.entitlements, props.ecommerceUrl, props.openReissueForm)}

View File

@@ -1,5 +1,6 @@
import { entitlementActions } from '../constants/actionTypes';
// eslint-disable-next-line default-param-last
const entitlements = (state = [], action) => {
switch (action.type) {
case entitlementActions.fetch.SUCCESS:

Some files were not shown because too many files have changed in this diff Show More