Skip to content

Commit

Permalink
fix: eslint autofixable issues (#32181)
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

* fix: failing js test
  • Loading branch information
Syed-Ali-Abbas-Zaidi authored May 18, 2023
1 parent f2daf37 commit d7053a6
Show file tree
Hide file tree
Showing 140 changed files with 848 additions and 832 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"import/no-dynamic-require": "off",
"import/no-unresolved": "off",
"max-len": "off",
"newline-per-chained-call": "off",
"no-console": "off",
"no-lonely-if": "off",
"no-param-reassign": "off",
Expand All @@ -73,7 +72,6 @@
"radix": "off",
"react/jsx-indent-props": ["error", 4],
"react/prop-types": "off",
"semi": "off",
"vars-on-top": "off"
}
}
15 changes: 8 additions & 7 deletions cms/static/cms/js/spec/main_webpack.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
jasmine.getFixtures().fixturesPath = '/base/templates';

import 'common/js/spec_helpers/jasmine-extensions';
import 'common/js/spec_helpers/jasmine-stealth';
import 'common/js/spec_helpers/jasmine-waituntil';
Expand All @@ -12,11 +10,6 @@ import _ from 'underscore';
import str from 'underscore.string';
import HtmlUtils from 'edx-ui-toolkit/js/utils/html-utils';
import StringUtils from 'edx-ui-toolkit/js/utils/string-utils';
window._ = _;
window._.str = str;
window.edx = window.edx || {};
window.edx.HtmlUtils = HtmlUtils;
window.edx.StringUtils = StringUtils;

// These are the tests that will be run
import './xblock/cms.runtime.v1_spec.js';
Expand All @@ -31,4 +24,12 @@ import '../../../js/spec/views/pages/course_outline_spec.js';
import '../../../js/spec/views/xblock_editor_spec.js';
import '../../../js/spec/views/xblock_string_field_editor_spec.js';

jasmine.getFixtures().fixturesPath = '/base/templates';

window._ = _;
window._.str = str;
window.edx = window.edx || {};
window.edx.HtmlUtils = HtmlUtils;
window.edx.StringUtils = StringUtils;

window.__karma__.start(); // eslint-disable-line no-underscore-dangle
4 changes: 2 additions & 2 deletions cms/static/js/certificates/spec/custom_matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// http://tobyho.com/2012/01/30/write-a-jasmine-matcher/

define(['jquery'], function($) { // eslint-disable-line no-unused-vars
'use strict';

'use strict';

return function() {
jasmine.addMatchers({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel

it('course mode selection updating the link successfully', function() {
selectDropDownByText(this.view.$(SELECTORS.course_modes), 'test1');
expect(this.view.$(SELECTORS.preview_certificate).attr('href')).
toEqual('/users/1/courses/orgX/009/2016?preview=test1');
expect(this.view.$(SELECTORS.preview_certificate).attr('href'))
.toEqual('/users/1/courses/orgX/009/2016?preview=test1');

selectDropDownByText(this.view.$(SELECTORS.course_modes), 'test2');
expect(this.view.$(SELECTORS.preview_certificate).attr('href')).
toEqual('/users/1/courses/orgX/009/2016?preview=test2');
expect(this.view.$(SELECTORS.preview_certificate).attr('href'))
.toEqual('/users/1/courses/orgX/009/2016?preview=test2');

selectDropDownByText(this.view.$(SELECTORS.course_modes), 'test3');
expect(this.view.$(SELECTORS.preview_certificate).attr('href')).
toEqual('/users/1/courses/orgX/009/2016?preview=test3');
expect(this.view.$(SELECTORS.preview_certificate).attr('href'))
.toEqual('/users/1/courses/orgX/009/2016?preview=test3');
});

it('toggle certificate activation event works fine', function() {
Expand Down
4 changes: 2 additions & 2 deletions cms/static/js/factories/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export default function ContainerFactory(componentTemplates, XBlockInfoJson, act
var view = new ContainerPage(_.extend(main_options, options));
view.render();
});
};
}

export {ContainerFactory}
export {ContainerFactory};
2 changes: 1 addition & 1 deletion cms/static/js/factories/context_course.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as ContextCourse from 'js/models/course';

export {ContextCourse}
export {ContextCourse};
4 changes: 2 additions & 2 deletions cms/static/js/factories/edit_tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export default function EditTabsFactory(courseLocation, explicitUrl) {
mast: $('.wrapper-mast')
});
});
};
}

export {EditTabsFactory}
export {EditTabsFactory};
4 changes: 2 additions & 2 deletions cms/static/js/factories/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export default function LibraryFactory(componentTemplates, XBlockInfoJson, optio
var view = new PagedContainerPage(_.extend(main_options, options));
view.render();
});
};
}

export {LibraryFactory}
export {LibraryFactory};
6 changes: 3 additions & 3 deletions cms/static/js/factories/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ define([

// Toggle collapsibles when trigger is clicked
$('.collapsible .collapsible-trigger').click(function() {
const contentId = this.id.replace('-trigger', '-content')
$(`#${contentId}`).toggleClass('collapsed')
})
const contentId = this.id.replace('-trigger', '-content');
$(`#${contentId}`).toggleClass('collapsed');
});

model = new CourseDetailsModel();
model.urlRoot = detailsUrl;
Expand Down
4 changes: 2 additions & 2 deletions cms/static/js/factories/textbooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export default function TextbooksFactory(textbooksJson) {
return gettext('You have unsaved changes. Do you really want to leave this page?');
}
});
};
}

export {TextbooksFactory}
export {TextbooksFactory};
4 changes: 2 additions & 2 deletions cms/static/js/factories/xblock_validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export default function XBlockValidationFactory(validationMessages, hasEditingUr
if (!model.get('empty')) {
new XBlockValidationView({el: validationEle, model: model, root: isRoot}).render();
}
};
}

export {XBlockValidationFactory}
export {XBlockValidationFactory};
2 changes: 1 addition & 1 deletion cms/static/js/models/settings/course_grading_policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader', 'edx-u
grace_period: null, // either null or { hours: n, minutes: m, ...}
minimum_grade_credit: null, // either null or percentage
assignment_count_info: [], // Object with keys mapping assignment type names to a list of
//assignment display names
// assignment display names
},
parse: function(attributes) {
if (attributes.graders) {
Expand Down
6 changes: 3 additions & 3 deletions cms/static/js/sock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'jquery.smoothScroll';

'use strict';

var toggleSock = function (e) {
var toggleSock = function(e) {
e.preventDefault();

var $btnShowSockLabel = $(this).find('.copy-show');
Expand Down Expand Up @@ -33,9 +33,9 @@ var toggleSock = function (e) {
});
};

domReady(function () {
domReady(function() {
// toggling footer additional support
$('.cta-show-sock').bind('click', toggleSock);
});

export {toggleSock}
export {toggleSock};
2 changes: 1 addition & 1 deletion cms/static/js/spec/views/license_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ define(['js/views/license', 'js/models/license', 'common/js/spec_helpers/templat
this.view = new LicenseView({model: this.model, showPreview: true});
this.view.render();
expect(this.view.$('.license-preview').length).toEqual(1);
// Expect default text to be "All Rights Reserved"
// Expect default text to be "All Rights Reserved"
expect(this.view.$('.license-preview')).toContainText('All Rights Reserved');
this.view.$('li[data-license=creative-commons] button').click();
expect(this.view.$('.license-preview').length).toEqual(1);
Expand Down
2 changes: 1 addition & 1 deletion cms/static/js/spec/views/module_edit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('ModuleEdit', function() {
});
});
describe('render', function() {
beforeEach(function () {
beforeEach(function() {
edit_helpers.installEditTemplates(true);
spyOn(this.moduleEdit, 'loadDisplay');
spyOn(this.moduleEdit, 'delegateEvents');
Expand Down
12 changes: 6 additions & 6 deletions cms/static/js/spec/views/pages/container_subviews_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,15 @@ describe('Container Subviews', function() {
it('renders the last published date and user when there are no changes', function() {
renderContainerPage(this, mockContainerXBlockHtml);
fetch({published_on: 'Jul 01, 2014 at 12:45 UTC', published_by: 'amako'});
expect(containerPage.$(lastDraftCss).text()).
toContain('Last published Jul 01, 2014 at 12:45 UTC by amako');
expect(containerPage.$(lastDraftCss).text())
.toContain('Last published Jul 01, 2014 at 12:45 UTC by amako');
});

it('renders the last saved date and user when there are changes', function() {
renderContainerPage(this, mockContainerXBlockHtml);
fetch({has_changes: true, edited_on: 'Jul 02, 2014 at 14:20 UTC', edited_by: 'joe'});
expect(containerPage.$(lastDraftCss).text()).
toContain('Draft saved on Jul 02, 2014 at 14:20 UTC by joe');
expect(containerPage.$(lastDraftCss).text())
.toContain('Draft saved on Jul 02, 2014 at 14:20 UTC by joe');
});

describe('Release Date', function() {
Expand Down Expand Up @@ -596,8 +596,8 @@ describe('Container Subviews', function() {
fetch({
published: true, published_on: 'Jul 01, 2014 at 12:45 UTC', published_by: 'amako'
});
expect(containerPage.$(lastPublishCss).text()).
toContain('Last published Jul 01, 2014 at 12:45 UTC by amako');
expect(containerPage.$(lastPublishCss).text())
.toContain('Last published Jul 01, 2014 at 12:45 UTC by amako');
});

it('renders correctly when the block is published without publish info', function() {
Expand Down
21 changes: 10 additions & 11 deletions cms/static/js/spec/views/pages/course_outline_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('CourseOutlinePage', function() {
selectVisibilitySettings, selectDiscussionSettings, selectAdvancedSettings, createMockCourseJSON, createMockSectionJSON,
createMockSubsectionJSON, verifyTypePublishable, mockCourseJSON, mockEmptyCourseJSON, setSelfPaced, setSelfPacedCustomPLS,
mockSingleSectionCourseJSON, createMockVerticalJSON, createMockIndexJSON, mockCourseEntranceExamJSON,
selectOnboardingExam, createMockCourseJSONWithReviewRules,mockCourseJSONWithReviewRules,
selectOnboardingExam, createMockCourseJSONWithReviewRules, mockCourseJSONWithReviewRules,
mockOutlinePage = readFixtures('templates/mock/mock-course-outline-page.underscore'),
mockRerunNotification = readFixtures('templates/mock/mock-course-rerun-notification.underscore');

Expand Down Expand Up @@ -210,7 +210,7 @@ describe('CourseOutlinePage', function() {
setSelfPacedCustomPLS = function() {
setSelfPaced();
course.set('is_custom_relative_dates_active', true);
}
};

createCourseOutlinePage = function(test, courseJSON, createOnly) {
requests = AjaxHelpers.requests(test);
Expand Down Expand Up @@ -1458,7 +1458,7 @@ describe('CourseOutlinePage', function() {
$('.wrapper-modal-window .action-save').click();
});

it('can select the onboarding exam when a course supports onboarding', function () {
it('can select the onboarding exam when a course supports onboarding', function() {
var mockCourseWithSpecialExamJSON = createMockCourseJSON({}, [
createMockSectionJSON({
has_changes: true,
Expand Down Expand Up @@ -2191,7 +2191,7 @@ describe('CourseOutlinePage', function() {
expect($modalWindow.find('.outline-subsection')).not.toExist();
});

describe('Self Paced with Custom Personalized Learner Schedules (PLS)', function () {
describe('Self Paced with Custom Personalized Learner Schedules (PLS)', function() {
beforeEach(function() {
var mockCourseJSON = createMockCourseJSON({}, [
createMockSectionJSON({}, [
Expand All @@ -2210,7 +2210,7 @@ describe('CourseOutlinePage', function() {

selectRelativeWeeksSubsection = function(weeks) {
$('#due_in').val(weeks).trigger('keyup');
}
};

mockCustomPacingServerValuesJson = createMockSectionJSON({
release_date: 'Jan 01, 2970 at 05:00 UTC'
Expand All @@ -2235,7 +2235,7 @@ describe('CourseOutlinePage', function() {
])
]);

it('can show correct editors for self_paced course with custom pacing', function (){
it('can show correct editors for self_paced course with custom pacing', function() {
outlinePage.$('.outline-subsection .configure-button').click();
expect($('.edit-settings-release').length).toBe(0);
// Due date input exists for custom pacing self paced courses
Expand Down Expand Up @@ -2295,7 +2295,7 @@ describe('CourseOutlinePage', function() {
expectShowCorrectness('never');
});

it ('does not show relative date input when assignment is not graded', function() {
it('does not show relative date input when assignment is not graded', function() {
outlinePage.$('.outline-subsection .configure-button').click();
$('#grading_type').val('Lab').trigger('change');
$('#due_in').val('').trigger('change');
Expand All @@ -2304,7 +2304,7 @@ describe('CourseOutlinePage', function() {
$('#grading_type').val('notgraded').trigger('change');
$('#due_in').val('').trigger('change');
expect($('#relative_date_input').css('display')).toBe('none');
})
});

it('shows validation error on relative date', function() {
outlinePage.$('.outline-subsection .configure-button').click();
Expand Down Expand Up @@ -2371,7 +2371,7 @@ describe('CourseOutlinePage', function() {
'Contains staff only content'
);
});
})
});
});

// Note: most tests for units can be found in Bok Choy
Expand Down Expand Up @@ -2470,13 +2470,12 @@ describe('CourseOutlinePage', function() {
expect(messages).toContainText('Contains staff only content');
});

describe('discussion settings', function () {
describe('discussion settings', function() {
it('hides discussion settings if unit level discussions are disabled', function() {
getUnitStatus({}, {unit_level_discussions: false});
outlinePage.$('.outline-unit .configure-button').click();
expect($('.modal-section .edit-discussion')).not.toExist();
});

});

verifyTypePublishable('unit', function(options) {
Expand Down
4 changes: 2 additions & 2 deletions cms/static/js/spec/views/xblock_validation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ define(['jquery', 'js/models/xblock_validation', 'js/views/xblock_validation', '
it('renders action info', function() {
expect(view.$('a.edit-button .action-button-text').text()).toContain('Summary Action');

expect(view.$('a.notification-action-button .action-button-text').text()).
toContain('First Message Action');
expect(view.$('a.notification-action-button .action-button-text').text())
.toContain('First Message Action');
expect(view.$('a.notification-action-button').data('notification-action')).toBe('fix-up');
});

Expand Down
2 changes: 1 addition & 1 deletion cms/static/js/spec_helpers/edit_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ export {
installEditTemplates,
showEditModal,
verifyXBlockRequest,
}
};
Loading

0 comments on commit d7053a6

Please sign in to comment.