Skip to content

Commit

Permalink
chore: apply amnesty on existing not fixable issues (#32215)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Syed-Ali-Abbas-Zaidi authored Aug 7, 2023
1 parent e94af3c commit 8480dbc
Show file tree
Hide file tree
Showing 305 changed files with 1,067 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
Expand Down
35 changes: 18 additions & 17 deletions cms/djangoapps/pipeline_js/js/xmodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions cms/static/cms/js/spec/main_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/certificates/spec/custom_matchers.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/factories/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/factories/context_course.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as ContextCourse from 'js/models/course';

// eslint-disable-next-line import/prefer-default-export
export {ContextCourse};
1 change: 1 addition & 0 deletions cms/static/js/factories/edit_tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/factories/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/factories/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/factories/textbooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/factories/xblock_validation.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/features/import/factories/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
Expand Down Expand Up @@ -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,
};
2 changes: 2 additions & 0 deletions cms/static/js/models/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ 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')) + '/'
+ (overrides && overrides.category ? overrides.category : this.get('category')) + '/'
+ (overrides && overrides.name ? overrides.name : this.get('name')) + '/';
},
_tagPattern: /[^:]+/g,
// eslint-disable-next-line prefer-regex-literals
_fieldPattern: new RegExp('[^/]+', 'g'),

parse: function(payload) {
Expand Down
3 changes: 3 additions & 0 deletions cms/static/js/sock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -38,4 +40,5 @@ domReady(function() {
$('.cta-show-sock').bind('click', toggleSock);
});

// eslint-disable-next-line import/prefer-default-export
export {toggleSock};
6 changes: 6 additions & 0 deletions cms/static/js/spec/models/group_configuration_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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('诶');
Expand All @@ -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');
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/spec/utils/handle_iframe_binding_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ define(
});

it('does nothing on tinymce iframe', function() {
// eslint-disable-next-line no-script-url
verify_no_modification('javascript:');
});
});
Expand Down
4 changes: 4 additions & 0 deletions cms/static/js/spec/video/transcripts/message_manager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
Expand All @@ -201,6 +203,7 @@ define(
action,
view.component_locator,
videoList,
// eslint-disable-next-line no-void
void 0
);
expect(view.showError).not.toHaveBeenCalled();
Expand Down Expand Up @@ -251,6 +254,7 @@ define(
action,
view.component_locator,
videoList,
// eslint-disable-next-line no-void
void 0
);
expect(view.showError).toHaveBeenCalled();
Expand Down
2 changes: 2 additions & 0 deletions cms/static/js/spec/video/transcripts/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions cms/static/js/spec/views/module_edit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions cms/static/js/spec/views/move_xblock_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cms/static/js/spec/views/pages/container_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
};
Expand Down
Loading

0 comments on commit 8480dbc

Please sign in to comment.