From f0da55cf6b0cef6da756b58e1fdc46103ea4e8a8 Mon Sep 17 00:00:00 2001 From: Syed Ali Abbas Zaidi Date: Wed, 10 May 2023 13:10:10 +0500 Subject: [PATCH] refactor: apply amnesty on remaining issues --- .eslintrc.json | 2 +- cms/static/js/models/location.js | 1 + .../common/js/discussion/views/discussion_content_view.js | 2 ++ common/static/common/js/spec_helpers/jasmine-stealth.js | 1 + lms/static/js/Markdown.Editor.js | 1 + lms/static/js/Markdown.Sanitizer.js | 5 +++-- .../spec/program_details_sidebar_view_spec.js | 2 ++ .../js/learner_dashboard/spec/program_details_view_spec.js | 2 ++ .../learner_dashboard/views/program_details_sidebar_view.js | 1 + .../js/learner_dashboard/views/program_details_view.js | 1 + .../js/learner_dashboard/views/upgrade_message_view.js | 1 + .../static/course_experience/js/spec/Currency_spec.js | 5 +++++ webpack.common.config.js | 1 + xmodule/js/src/poll/poll_main.js | 2 ++ 14 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 22dbc24aab7d..9f92d07d48bb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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" } diff --git a/cms/static/js/models/location.js b/cms/static/js/models/location.js index b2ee1711d722..a359c4400cb0 100644 --- a/cms/static/js/models/location.js +++ b/cms/static/js/models/location.js @@ -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')) + '/' diff --git a/common/static/common/js/discussion/views/discussion_content_view.js b/common/static/common/js/discussion/views/discussion_content_view.js index 4e57cd3ebe63..2145130b214c 100644 --- a/common/static/common/js/discussion/views/discussion_content_view.js +++ b/common/static/common/js/discussion/views/discussion_content_view.js @@ -238,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]); }; diff --git a/common/static/common/js/spec_helpers/jasmine-stealth.js b/common/static/common/js/spec_helpers/jasmine-stealth.js index 0a59d20e1c22..e51fa419e8d3 100644 --- a/common/static/common/js/spec_helpers/jasmine-stealth.js +++ b/common/static/common/js/spec_helpers/jasmine-stealth.js @@ -52,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); }; diff --git a/lms/static/js/Markdown.Editor.js b/lms/static/js/Markdown.Editor.js index a0ed814b51c9..4081069297e8 100644 --- a/lms/static/js/Markdown.Editor.js +++ b/lms/static/js/Markdown.Editor.js @@ -1396,6 +1396,7 @@ button.removeAttribute('aria-disabled'); } else { image.style.backgroundPosition = button.XShift + ' ' + disabledYShift; + // eslint-disable-next-line no-multi-assign button.onmouseover = button.onmouseout = button.onclick = function() { }; // This line does not appear in vanilla WMD. It was added by edX to improve accessibility. // It should become a separate commit applied to WMD's official HEAD if we remove this edited version diff --git a/lms/static/js/Markdown.Sanitizer.js b/lms/static/js/Markdown.Sanitizer.js index 4472978807a3..ee16371ea645 100644 --- a/lms/static/js/Markdown.Sanitizer.js +++ b/lms/static/js/Markdown.Sanitizer.js @@ -64,7 +64,8 @@ tagname = tags[ctag].replace(/<\/?(\w+).*/, '$1'); // skip any already paired tags // and skip tags in our ignore list; assume they're self-closed - if (tagpaired[ctag] || ignoredtags.search('<' + tagname + '>') > -1) { continue; } // eslint-disable-line max-len, xss-lint: disable=javascript-concat-html + // eslint-disable-next-line no-continue + if (tagpaired[ctag] || ignoredtags.search('<' + tagname + '>') > -1) { continue; } // xss-lint: disable=javascript-concat-html tag = tags[ctag]; match = -1; @@ -73,7 +74,7 @@ // this is an opening tag // search forwards (next tags), look for closing tags for (var ntag = ctag + 1; ntag < tagcount; ntag++) { - if (!tagpaired[ntag] && tags[ntag] === '') { // eslint-disable-line max-len, xss-lint: disable=javascript-concat-html + if (!tagpaired[ntag] && tags[ntag] === '') { // xss-lint: disable=javascript-concat-html match = ntag; break; } diff --git a/lms/static/js/learner_dashboard/spec/program_details_sidebar_view_spec.js b/lms/static/js/learner_dashboard/spec/program_details_sidebar_view_spec.js index 7148e6a46d3a..7e400219c65e 100644 --- a/lms/static/js/learner_dashboard/spec/program_details_sidebar_view_spec.js +++ b/lms/static/js/learner_dashboard/spec/program_details_sidebar_view_spec.js @@ -61,7 +61,9 @@ describe('Program Progress View', () => { const testSubscriptionState = (state, heading, body) => { isSubscriptionEligible = true; subscriptionData.subscription_state = state; + // eslint-disable-next-line no-use-before-define view = initView(); + // eslint-disable-next-line no-param-reassign body += ' on the Orders and subscriptions page'; expect(view.$('.js-subscription-info')[0]).toBeInDOM(); diff --git a/lms/static/js/learner_dashboard/spec/program_details_view_spec.js b/lms/static/js/learner_dashboard/spec/program_details_view_spec.js index ef21eb70784e..d648a1b6ee9d 100644 --- a/lms/static/js/learner_dashboard/spec/program_details_view_spec.js +++ b/lms/static/js/learner_dashboard/spec/program_details_view_spec.js @@ -531,7 +531,9 @@ describe('Program Details View', () => { 'YYYY-MM-DDTHH:mm:ss[Z]', ); } + // eslint-disable-next-line no-use-before-define view = initView({ + // eslint-disable-next-line no-undef programData: $.extend({}, options.programData, { subscription_eligible: true, }), diff --git a/lms/static/js/learner_dashboard/views/program_details_sidebar_view.js b/lms/static/js/learner_dashboard/views/program_details_sidebar_view.js index 9260c2ca7a4d..d79aad39ad62 100644 --- a/lms/static/js/learner_dashboard/views/program_details_sidebar_view.js +++ b/lms/static/js/learner_dashboard/views/program_details_sidebar_view.js @@ -43,6 +43,7 @@ class ProgramDetailsSidebarView extends Backbone.View { } render() { + // eslint-disable-next-line no-undef const data = $.extend( {}, this.model.toJSON(), diff --git a/lms/static/js/learner_dashboard/views/program_details_view.js b/lms/static/js/learner_dashboard/views/program_details_view.js index df7abd17b33a..6eeb8509fafd 100644 --- a/lms/static/js/learner_dashboard/views/program_details_view.js +++ b/lms/static/js/learner_dashboard/views/program_details_view.js @@ -108,6 +108,7 @@ class ProgramDetailsView extends Backbone.View { isSubscriptionEligible: this.options.isSubscriptionEligible, restartIcon, }; + // eslint-disable-next-line no-undef data = $.extend( data, this.programModel.toJSON(), diff --git a/lms/static/js/learner_dashboard/views/upgrade_message_view.js b/lms/static/js/learner_dashboard/views/upgrade_message_view.js index cad777b3a836..9c609480a614 100644 --- a/lms/static/js/learner_dashboard/views/upgrade_message_view.js +++ b/lms/static/js/learner_dashboard/views/upgrade_message_view.js @@ -31,6 +31,7 @@ class UpgradeMessageView extends Backbone.View { } render() { + // eslint-disable-next-line no-undef const data = $.extend( {}, this.model.toJSON(), diff --git a/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js b/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js index 976633d6f9ef..7197ba1d4df0 100644 --- a/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js +++ b/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js @@ -42,26 +42,31 @@ describe('Currency factory', () => { longitude: 137.737495, }, }; + // eslint-disable-next-line object-curly-spacing $.cookie('edx-price-l10n', null, { path: '/' }); }); describe('converts price to local currency', () => { it('when location is the default (US)', () => { + // eslint-disable-next-line object-curly-spacing $.cookie('edx-price-l10n', '{"rate":1,"code":"USD","symbol":"$","countryCode":"US"}', { path: '/' }); currency = new Currency(); expect($('[name="verified_mode"].no-discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($100 USD)'); }); it('when cookie is set to a different country', () => { + // eslint-disable-next-line object-curly-spacing $.cookie('edx-price-l10n', '{"rate":2.2,"code":"CAD","symbol":"$","countryCode":"CAN"}', { expires: 1 }); currency = new Currency(); expect($('[name="verified_mode"].no-discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($220 CAD)'); }); it('when cookie is set to a different country with a discount', () => { + // eslint-disable-next-line object-curly-spacing $.cookie('edx-price-l10n', '{"rate":2.2,"code":"CAD","symbol":"$","countryCode":"CAN"}', { expires: 1 }); currency = new Currency(); expect($('[name="verified_mode"].discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($198 CAD $220 CAD)'); }); it('should send event on initial load', () => { + // eslint-disable-next-line object-curly-spacing $.cookie('edx-price-l10n', '{"rate":1,"code":"USD","symbol":"$","countryCode":"US"}', { path: '/' }); currency = new Currency(); expect(window.analytics.track).toHaveBeenCalledWith('edx.bi.user.track_selection.local_currency_cookie_set'); diff --git a/webpack.common.config.js b/webpack.common.config.js index fbf056634252..50d0ca57df9f 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -388,6 +388,7 @@ module.exports = Merge.smart({ // https://github.com/webpack/webpack/issues/304#issuecomment-272150177 // (I've tried every other suggestion solution on that page, this // was the only one that worked.) + // eslint-disable-next-line no-path-concat sinon: __dirname + '/node_modules/sinon/pkg/sinon.js', hls: 'hls.js/dist/hls.js' }, diff --git a/xmodule/js/src/poll/poll_main.js b/xmodule/js/src/poll/poll_main.js index ed953867c881..49eb10446a53 100644 --- a/xmodule/js/src/poll/poll_main.js +++ b/xmodule/js/src/poll/poll_main.js @@ -81,6 +81,7 @@ // Send the data to the server as an AJAX request. Attach a callback that will // be fired on server's response. $.postWithPrefix( + // eslint-disable-next-line no-useless-concat this.ajax_url + '/' + 'reset_poll', {}, function(response) { @@ -294,6 +295,7 @@ this.jsonConfig = JSON.parse(this.questionEl.children('.poll_question_div').html()); $.postWithPrefix( + // eslint-disable-next-line no-useless-concat '' + this.questionEl.data('ajax-url') + '/' + 'get_state', {}, function(response) { _this.jsonConfig.poll_answer = response.poll_answer;