From 8480dbc228670befaefc5e2bafbaa2e8da96788c Mon Sep 17 00:00:00 2001 From: Syed Ali Abbas Zaidi <88369802+Syed-Ali-Abbas-Zaidi@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:13:19 +0500 Subject: [PATCH] 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 --- .eslintrc.json | 2 +- cms/djangoapps/pipeline_js/js/xmodule.js | 35 +-- cms/static/cms/js/spec/main_spec.js | 1 + .../js/certificates/spec/custom_matchers.js | 1 + cms/static/js/factories/container.js | 1 + cms/static/js/factories/context_course.js | 1 + cms/static/js/factories/edit_tabs.js | 1 + cms/static/js/factories/library.js | 1 + cms/static/js/factories/settings.js | 1 + cms/static/js/factories/textbooks.js | 1 + cms/static/js/factories/xblock_validation.js | 1 + .../js/features/import/factories/import.js | 1 + .../studio/CourseOrLibraryListing.jsx | 6 + cms/static/js/models/location.js | 2 + cms/static/js/sock.js | 3 + .../spec/models/group_configuration_spec.js | 6 + .../spec/utils/handle_iframe_binding_spec.js | 1 + .../video/transcripts/message_manager_spec.js | 4 + .../js/spec/video/transcripts/utils_spec.js | 2 + cms/static/js/spec/views/module_edit_spec.js | 2 + cms/static/js/spec/views/move_xblock_spec.js | 2 + .../js/spec/views/pages/container_spec.js | 3 + .../spec/views/pages/course_outline_spec.js | 13 + .../js/spec/views/xblock_editor_spec.js | 1 + cms/static/js/spec_helpers/edit_helpers.js | 2 + cms/static/js/utils/drag_and_drop.js | 1 + cms/static/js/utils/handle_iframe_binding.js | 1 + cms/static/js/views/assets.js | 4 + cms/static/js/views/baseview.js | 3 +- cms/static/js/views/course_info_edit.js | 2 + cms/static/js/views/course_outline.js | 1 + cms/static/js/views/course_video_settings.js | 3 + cms/static/js/views/list.js | 1 + cms/static/js/views/manage_users_and_roles.js | 3 + cms/static/js/views/metadata.js | 5 + .../js/views/modals/course_outline_modals.js | 4 + cms/static/js/views/module_edit.js | 1 + cms/static/js/views/pages/course_outline.js | 1 + cms/static/js/views/settings/advanced.js | 1 + cms/static/js/views/settings/grading.js | 5 + cms/static/js/views/settings/main.js | 4 + cms/static/js/views/tabs.js | 1 + .../js/views/utils/create_library_utils.js | 1 + cms/static/js/views/validation.js | 1 + .../views/video/transcripts/file_uploader.js | 1 + .../video/transcripts/metadata_videolist.js | 2 + .../js/views/video/transcripts/utils.js | 4 + .../js/views/video/translations_editor.js | 1 + .../components/BlockBrowser/BlockBrowser.jsx | 4 + .../BlockBrowser/BlockBrowser.test.jsx | 1 + .../BlockBrowser/data/reducers/index.js | 4 + .../js/components/BlockBrowser/index.jsx | 1 + .../js/components/ExperimentalCarousel.jsx | 4 + common/static/common/js/discussion/content.js | 1 + .../static/common/js/discussion/discussion.js | 2 + common/static/common/js/discussion/utils.js | 4 + .../views/discussion_content_view.js | 4 + .../views/discussion_thread_list_view.js | 2 + .../views/discussion_thread_show_view.js | 1 + .../views/discussion_thread_view.js | 3 + .../js/discussion/views/new_post_view.js | 2 + .../discussion/views/response_comment_view.js | 1 + .../discussion/views/thread_response_view.js | 2 + common/static/common/js/karma.common.conf.js | 2 + .../js/spec/components/feedback_spec.js | 2 + .../view/discussion_thread_list_view_spec.js | 1 + .../discussion_thread_profile_view_spec.js | 2 + .../view/discussion_thread_view_spec.js | 1 + .../view/discussion_topic_menu_view_spec.js | 1 + .../static/common/js/spec/xblock/core_spec.js | 2 + .../js/spec_helpers/jasmine-extensions.js | 1 + .../common/js/spec_helpers/jasmine-stealth.js | 3 + .../common/js/utils/edx.utils.validate.js | 1 + .../static/common/js/utils/require-serial.js | 1 + common/static/js/capa/design-protein-2d.js | 2 +- .../js/capa/drag_and_drop/draggable_logic.js | 3 + common/static/js/capa/drag_and_drop/main.js | 2 + .../static/js/capa/drag_and_drop/scroller.js | 1 + .../js/capa/drag_and_drop/update_input.js | 10 + common/static/js/capa/schematicinput.js | 1 + .../spec/formula_equation_preview_spec.js | 3 + common/static/js/capa/src/jschannel.js | 9 + common/static/js/capa/src/jsinput.js | 3 + .../js/capa/symbolic_mathjax_preprocessor.js | 2 +- common/static/js/src/ReactRenderer.jsx | 2 + common/static/js/src/accessibility_tools.js | 1 + common/test/data/uploads/simple-question.js | 6 +- .../ProblemBrowser/components/Main/Main.jsx | 5 + .../components/Main/Main.test.jsx | 2 + .../components/Main/MainContainer.jsx | 1 + .../components/ReportStatus/ReportStatus.jsx | 3 + .../ReportStatus/ReportStatus.test.jsx | 1 + .../data/actions/problemResponses.js | 1 + .../ProblemBrowser/data/reducers/index.js | 1 + .../instructor/ProblemBrowser/index.jsx | 1 + .../static/support/js/views/certificates.js | 1 + .../components/EntitlementForm/index.jsx | 1 + .../jsx/entitlements/components/Main/Main.jsx | 2 + .../Table/EntitlementSupportTable.jsx | 2 + .../data/reducers/entitlements.js | 1 + .../jsx/entitlements/data/reducers/error.js | 1 + .../jsx/entitlements/data/reducers/form.js | 1 + .../static/support/jsx/entitlements/index.jsx | 1 + .../static/support/jsx/errors_list.jsx | 1 + .../static/support/jsx/file_upload.jsx | 3 + .../static/support/jsx/logged_in_user.jsx | 1 + .../static/support/jsx/logged_out_user.jsx | 1 + .../support/jsx/program_enrollments/index.jsx | 1 + .../jsx/program_enrollments/inspector.jsx | 9 + .../support/jsx/single_support_form.jsx | 21 ++ .../static/support/jsx/upload_progress.jsx | 2 + .../teams/js/spec/views/team_profile_spec.js | 1 + .../teams/static/teams/js/views/teams_tab.js | 8 + .../completion/js/CompletionOnViewService.js | 4 + lms/static/completion/js/ViewedEvent.js | 1 + .../completion/js/spec/ViewedEvent_spec.js | 12 + lms/static/js/Markdown.Editor.js | 21 +- lms/static/js/Markdown.Sanitizer.js | 9 +- .../accessible_components/StatusBarAlert.jsx | 1 + lms/static/js/ajax-error.js | 1 + lms/static/js/ccx/schedule.js | 7 + .../views/certificate_bulk_allowlist.js | 6 +- .../views/certificate_invalidation_view.js | 1 + lms/static/js/dashboard/donation.js | 2 + lms/static/js/dashboard/dropdown.js | 1 + .../DemographicsCollectionBanner.jsx | 3 + .../DemographicsCollectionModal.jsx | 13 + .../MultiselectDropdown.jsx | 11 + .../SelectWithInput.jsx | 2 + .../js/demographics_collection/Wizard.jsx | 10 + lms/static/js/discovery/collection.js | 2 + .../js/discovery/models/search_state.js | 1 + .../js/discovery/views/refine_sidebar.js | 2 + lms/static/js/edxnotes/collections/tabs.js | 1 + lms/static/js/edxnotes/models/tab.js | 1 + .../js/edxnotes/plugins/caret_navigation.js | 1 + lms/static/js/edxnotes/plugins/events.js | 1 + lms/static/js/edxnotes/plugins/scroller.js | 1 + .../edxnotes/plugins/store_error_handler.js | 1 + lms/static/js/edxnotes/utils/logger.js | 3 + lms/static/js/edxnotes/utils/template.js | 1 + lms/static/js/edxnotes/utils/utils.js | 1 + lms/static/js/edxnotes/views/note_group.js | 1 + lms/static/js/edxnotes/views/note_item.js | 1 + lms/static/js/edxnotes/views/notes_factory.js | 2 + lms/static/js/edxnotes/views/notes_page.js | 1 + .../views/notes_visibility_factory.js | 1 + lms/static/js/edxnotes/views/page_factory.js | 1 + lms/static/js/edxnotes/views/search_box.js | 2 + lms/static/js/edxnotes/views/shim.js | 1 + lms/static/js/edxnotes/views/tab_item.js | 1 + lms/static/js/edxnotes/views/tab_panel.js | 1 + lms/static/js/edxnotes/views/tab_view.js | 1 + .../edxnotes/views/tabs/course_structure.js | 2 + .../js/edxnotes/views/tabs/recent_activity.js | 1 + .../js/edxnotes/views/tabs/search_results.js | 1 + lms/static/js/edxnotes/views/tabs/tags.js | 2 + lms/static/js/edxnotes/views/tabs_list.js | 1 + .../js/edxnotes/views/visibility_decorator.js | 1 + lms/static/js/form.ext.js | 3 + lms/static/js/groups/views/cohorts.js | 1 + .../groups/views/cohorts_dashboard_factory.js | 1 + lms/static/js/header/header.js | 1 + lms/static/js/ie11_find_array.js | 1 + .../js/instructor_dashboard/certificates.js | 4 + .../instructor_dashboard/cohort_management.js | 1 + .../instructor_dashboard.js | 2 + .../js/instructor_dashboard/membership.js | 4 + .../js/instructor_dashboard/student_admin.js | 1 + .../js/jwt_auth/AxiosJwtTokenService.js | 2 + .../interceptors/createRetryInterceptor.js | 1 + lms/static/js/leanModal.js | 1 + .../CircleChart.jsx | 6 + .../CircleChartLegend.jsx | 3 + .../Discussions.jsx | 2 + .../learner_analytics_dashboard/DueDates.jsx | 4 + .../GradeTable.jsx | 5 + .../LearnerAnalyticsDashboard.jsx | 6 + .../EnterpriseLearnerPortalModal.jsx | 11 + .../js/learner_dashboard/certificate_api.js | 6 + .../collections/course_card_collection.js | 1 + .../collections/program_collection.js | 1 + .../models/course_card_model.js | 4 + .../models/course_enroll_model.js | 1 + .../models/course_entitlement_model.js | 1 + .../learner_dashboard/program_list_factory.js | 29 +- .../spec/collection_list_view_spec.js | 2 +- .../spec/course_card_view_spec.js | 2 + .../spec/course_enroll_view_spec.js | 10 + .../entitlement_unenrollment_view_spec.js | 25 ++ .../spec/program_alert_list_view_spec.js | 8 +- .../spec/program_card_view_spec.js | 3 + .../spec/program_details_sidebar_view_spec.js | 3 + .../spec/program_details_view_spec.js | 18 ++ .../spec/program_list_header_view_spec.js | 13 +- .../spec/progress_circle_view_spec.js | 1 + .../spec/sidebar_view_spec.js | 6 +- .../spec/unenroll_view_spec.js | 4 + .../views/certificate_status_view.js | 1 + .../views/course_card_view.js | 2 + .../views/course_enroll_view.js | 3 + .../views/course_entitlement_view.js | 16 ++ .../views/entitlement_unenrollment_view.js | 10 + .../views/explore_new_programs_view.js | 2 + .../views/program_alert_list_view.js | 23 +- .../views/program_card_view.js | 2 + .../views/program_details_sidebar_view.js | 4 + .../views/program_details_view.js | 24 +- .../views/program_header_view.js | 3 + .../views/progress_circle_view.js | 2 + .../learner_dashboard/views/sidebar_view.js | 3 +- .../views/subscription_upsell_view.js | 1 + .../learner_dashboard/views/unenroll_view.js | 11 + .../views/upgrade_message_view.js | 1 + lms/static/js/pdf-analytics.js | 1 + lms/static/js/pending_tasks.js | 2 + lms/static/js/shoppingcart/shoppingcart.js | 1 + lms/static/js/spec/ccx/schedule_spec.js | 1 + .../js/spec/components/card/card_spec.js | 1 + .../spec/discovery/views/search_form_spec.js | 1 + lms/static/js/spec/edxnotes/helpers.js | 5 + .../edxnotes/plugins/accessibility_spec.js | 1 + .../views/tabs/course_structure_spec.js | 1 + .../views/tabs/recent_activity_spec.js | 3 + .../views/tabs/search_results_spec.js | 2 + .../instructor_dashboard/send_email_spec.js | 3 + .../account_settings_factory_spec.js | 1 + lms/static/js/spec/views/fields_helpers.js | 2 + lms/static/js/split.js | 5 + .../js/student_account/AccountsClient.js | 1 + .../components/StudentAccountDeletion.jsx | 8 +- .../StudentAccountDeletionModal.jsx | 3 +- .../components/removeLoggedInCookies.js | 1 + .../spec/PasswordResetConfirmation_spec.js | 7 + .../student_account/logistration_factory.js | 1 + .../models/user_account_model.js | 1 + .../models/user_preferences_model.js | 1 + .../js/student_account/multiple_enterprise.js | 2 + .../student_account/views/FinishAuthView.js | 1 + .../js/student_account/views/RegisterView.js | 2 + .../views/account_section_view.js | 1 + .../views/account_settings_factory.js | 3 + .../views/account_settings_fields.js | 1 + .../views/account_settings_view.js | 1 + lms/static/js/toggle_login_modal.js | 4 + lms/static/js/views/file_uploader.js | 2 + lms/static/js/wiki/accessible.js | 1 + lms/static/lms/js/preview/preview_factory.js | 2 + .../lms/js/spec/main_requirejs_coffee.js | 1 + .../announcements/jsx/Announcements.jsx | 7 + .../static/course_experience/js/CourseSock.js | 7 + .../static/course_experience/js/currency.js | 2 + .../js/spec/Currency_spec.js | 11 + scripts/delete-mongo-test-dbs.js | 1 + scripts/xsslint/tests/templates/test.js | 2 + setupTests.js | 2 + webpack.builtinblocks.config.js | 264 +++++++++--------- webpack.common.config.js | 12 +- webpack.dev.config.js | 2 +- webpack.prod.config.js | 2 +- .../LibrarySourcedBlockPicker.jsx | 13 + .../word_cloud/src/js/word_cloud_main.js | 14 + xmodule/assets/word_cloud/webpack.config.js | 1 + xmodule/js/karma_runner_webpack.js | 1 + xmodule/js/spec/capa/imageinput_spec.js | 1 + xmodule/js/spec/collapsible_spec.js | 1 + xmodule/js/spec/main_requirejs.js | 1 + xmodule/js/spec/sequence/display_spec.js | 1 + xmodule/js/spec/time_spec.js | 1 + xmodule/js/spec/video/events_spec.js | 1 + xmodule/js/spec/video/general_spec.js | 2 + xmodule/js/spec/video/html5_video_spec.js | 3 + xmodule/js/spec/video/resizer_spec.js | 1 + xmodule/js/spec/video/social_share_spec.js | 13 +- xmodule/js/spec/video/video_bumper_spec.js | 1 + xmodule/js/spec/video/video_caption_spec.js | 1 + .../js/spec/video/video_context_menu_spec.js | 4 + .../video/video_events_bumper_plugin_spec.js | 1 + .../js/spec/video/video_events_plugin_spec.js | 1 + .../js/spec/video/video_focus_grabber_spec.js | 1 + xmodule/js/spec/video/video_player_spec.js | 2 + .../spec/video/video_progress_slider_spec.js | 1 + .../spec/video/video_quality_control_spec.js | 1 + .../video/video_save_state_plugin_spec.js | 1 + .../js/spec/video/video_speed_control_spec.js | 1 + xmodule/js/spec/video/video_storage_spec.js | 3 + xmodule/js/src/capa/display.js | 6 + xmodule/js/src/capa/imageinput.js | 1 + xmodule/js/src/collapsible.js | 2 + xmodule/js/src/lti/lti.js | 3 + xmodule/js/src/poll/poll_main.js | 3 + xmodule/js/src/problem/edit.js | 3 + xmodule/js/src/time.js | 2 + xmodule/js/src/video/00_component.js | 2 + xmodule/js/src/video/00_resizer.js | 2 + xmodule/js/src/video/01_initialize.js | 2 + .../js/src/video/036_video_social_sharing.js | 12 +- xmodule/js/src/video/03_video_player.js | 9 + xmodule/js/src/video/04_video_full_screen.js | 6 +- .../js/src/video/05_video_quality_control.js | 1 + .../js/src/video/06_video_progress_slider.js | 1 + .../js/src/video/07_video_volume_control.js | 3 + .../js/src/video/08_video_speed_control.js | 3 + .../js/src/video/095_video_context_menu.js | 7 + xmodule/js/src/video/09_video_caption.js | 3 + 305 files changed, 1067 insertions(+), 226 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 22dbc24aab7..9f92d07d48b 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/djangoapps/pipeline_js/js/xmodule.js b/cms/djangoapps/pipeline_js/js/xmodule.js index c51b3280df6..44789c8cc6e 100644 --- a/cms/djangoapps/pipeline_js/js/xmodule.js +++ b/cms/djangoapps/pipeline_js/js/xmodule.js @@ -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; diff --git a/cms/static/cms/js/spec/main_spec.js b/cms/static/cms/js/spec/main_spec.js index 5b59db83315..8b9f27d0bd7 100644 --- a/cms/static/cms/js/spec/main_spec.js +++ b/cms/static/cms/js/spec/main_spec.js @@ -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() { diff --git a/cms/static/js/certificates/spec/custom_matchers.js b/cms/static/js/certificates/spec/custom_matchers.js index 32e19dec6a2..00ac8ca6b95 100644 --- a/cms/static/js/certificates/spec/custom_matchers.js +++ b/cms/static/js/certificates/spec/custom_matchers.js @@ -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'; diff --git a/cms/static/js/factories/container.js b/cms/static/js/factories/container.js index b98e0f99f28..4ad252708a6 100644 --- a/cms/static/js/factories/container.js +++ b/cms/static/js/factories/container.js @@ -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 = { diff --git a/cms/static/js/factories/context_course.js b/cms/static/js/factories/context_course.js index 24745295ec0..db9d5f6cd45 100644 --- a/cms/static/js/factories/context_course.js +++ b/cms/static/js/factories/context_course.js @@ -1,3 +1,4 @@ import * as ContextCourse from 'js/models/course'; +// eslint-disable-next-line import/prefer-default-export export {ContextCourse}; diff --git a/cms/static/js/factories/edit_tabs.js b/cms/static/js/factories/edit_tabs.js index cd82fd2d913..68bbba27bd7 100644 --- a/cms/static/js/factories/edit_tabs.js +++ b/cms/static/js/factories/edit_tabs.js @@ -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() { diff --git a/cms/static/js/factories/library.js b/cms/static/js/factories/library.js index c104b3b049d..a444f81e8ec 100644 --- a/cms/static/js/factories/library.js +++ b/cms/static/js/factories/library.js @@ -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 = { diff --git a/cms/static/js/factories/settings.js b/cms/static/js/factories/settings.js index 34faec2eb11..f8f927287c6 100644 --- a/cms/static/js/factories/settings.js +++ b/cms/static/js/factories/settings.js @@ -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'), diff --git a/cms/static/js/factories/textbooks.js b/cms/static/js/factories/textbooks.js index 4c2cec3130d..c3ba710ebfd 100644 --- a/cms/static/js/factories/textbooks.js +++ b/cms/static/js/factories/textbooks.js @@ -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}), diff --git a/cms/static/js/factories/xblock_validation.js b/cms/static/js/factories/xblock_validation.js index 9936208626d..2fac53f463c 100644 --- a/cms/static/js/factories/xblock_validation.js +++ b/cms/static/js/factories/xblock_validation.js @@ -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; diff --git a/cms/static/js/features/import/factories/import.js b/cms/static/js/features/import/factories/import.js index 6b81540dbe2..5ec2ff09415 100644 --- a/cms/static/js/features/import/factories/import.js +++ b/cms/static/js/features/import/factories/import.js @@ -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; diff --git a/cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx b/cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx index 767287d149f..d9b4493e0c7 100644 --- a/cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx +++ b/cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx @@ -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, }; diff --git a/cms/static/js/models/location.js b/cms/static/js/models/location.js index 75b4ecb633e..a359c4400cb 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')) + '/' @@ -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) { diff --git a/cms/static/js/sock.js b/cms/static/js/sock.js index 1512ec51bc7..c932e1aa2bb 100644 --- a/cms/static/js/sock.js +++ b/cms/static/js/sock.js @@ -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}; diff --git a/cms/static/js/spec/models/group_configuration_spec.js b/cms/static/js/spec/models/group_configuration_spec.js index be1de362d26..2206904bfa8 100644 --- a/cms/static/js/spec/models/group_configuration_spec.js +++ b/cms/static/js/spec/models/group_configuration_spec.js @@ -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'); diff --git a/cms/static/js/spec/utils/handle_iframe_binding_spec.js b/cms/static/js/spec/utils/handle_iframe_binding_spec.js index 9cf632161af..ada1844e824 100644 --- a/cms/static/js/spec/utils/handle_iframe_binding_spec.js +++ b/cms/static/js/spec/utils/handle_iframe_binding_spec.js @@ -48,6 +48,7 @@ define( }); it('does nothing on tinymce iframe', function() { + // eslint-disable-next-line no-script-url verify_no_modification('javascript:'); }); }); diff --git a/cms/static/js/spec/video/transcripts/message_manager_spec.js b/cms/static/js/spec/video/transcripts/message_manager_spec.js index aa09ebf4000..9306cdfe81a 100644 --- a/cms/static/js/spec/video/transcripts/message_manager_spec.js +++ b/cms/static/js/spec/video/transcripts/message_manager_spec.js @@ -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(); diff --git a/cms/static/js/spec/video/transcripts/utils_spec.js b/cms/static/js/spec/video/transcripts/utils_spec.js index 13f948bbbd2..1423c7c875c 100644 --- a/cms/static/js/spec/video/transcripts/utils_spec.js +++ b/cms/static/js/spec/video/transcripts/utils_spec.js @@ -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); diff --git a/cms/static/js/spec/views/module_edit_spec.js b/cms/static/js/spec/views/module_edit_spec.js index a96bbad9959..301d3144188 100644 --- a/cms/static/js/spec/views/module_edit_spec.js +++ b/cms/static/js/spec/views/module_edit_spec.js @@ -14,6 +14,7 @@ describe('ModuleEdit', function() { + '
  • \n' + '
    \n' + '
    \n' + // eslint-disable-next-line no-template-curly-in-string + ' ${editor}\n' + '
    \n' + ' Save\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({ diff --git a/cms/static/js/spec/views/move_xblock_spec.js b/cms/static/js/spec/views/move_xblock_spec.js index fa1eaba99b4..e32f8a043fc 100644 --- a/cms/static/js/spec/views/move_xblock_spec.js +++ b/cms/static/js/spec/views/move_xblock_spec.js @@ -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 diff --git a/cms/static/js/spec/views/pages/container_spec.js b/cms/static/js/spec/views/pages/container_spec.js index 642d092de45..f84efdca89b 100644 --- a/cms/static/js/spec/views/pages/container_spec.js +++ b/cms/static/js/spec/views/pages/container_spec.js @@ -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(); }; diff --git a/cms/static/js/spec/views/pages/course_outline_spec.js b/cms/static/js/spec/views/pages/course_outline_spec.js index 195e5702d09..ed1124d4658 100644 --- a/cms/static/js/spec/views/pages/course_outline_spec.js +++ b/cms/static/js/spec/views/pages/course_outline_spec.js @@ -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({}, []) diff --git a/cms/static/js/spec/views/xblock_editor_spec.js b/cms/static/js/spec/views/xblock_editor_spec.js index 00ed6c98544..5791572ddde 100644 --- a/cms/static/js/spec/views/xblock_editor_spec.js +++ b/cms/static/js/spec/views/xblock_editor_spec.js @@ -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'); diff --git a/cms/static/js/spec_helpers/edit_helpers.js b/cms/static/js/spec_helpers/edit_helpers.js index 0fa81b1e5a0..acfdeff3234 100644 --- a/cms/static/js/spec_helpers/edit_helpers.js +++ b/cms/static/js/spec_helpers/edit_helpers.js @@ -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, diff --git a/cms/static/js/utils/drag_and_drop.js b/cms/static/js/utils/drag_and_drop.js index 88c1301999c..900523d3709 100644 --- a/cms/static/js/utils/drag_and_drop.js +++ b/cms/static/js/utils/drag_and_drop.js @@ -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 diff --git a/cms/static/js/utils/handle_iframe_binding.js b/cms/static/js/utils/handle_iframe_binding.js index b4527afd85d..b7e904c47db 100644 --- a/cms/static/js/utils/handle_iframe_binding.js +++ b/cms/static/js/utils/handle_iframe_binding.js @@ -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); } diff --git a/cms/static/js/views/assets.js b/cms/static/js/views/assets.js index 5aaccda82f9..6d480641879 100644 --- a/cms/static/js/views/assets.js +++ b/cms/static/js/views/assets.js @@ -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; } diff --git a/cms/static/js/views/baseview.js b/cms/static/js/views/baseview.js index c7da2bac660..3893269e6fb 100644 --- a/cms/static/js/views/baseview.js +++ b/cms/static/js/views/baseview.js @@ -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(); diff --git a/cms/static/js/views/course_info_edit.js b/cms/static/js/views/course_info_edit.js index aab15d4f91f..840ebf8939b 100644 --- a/cms/static/js/views/course_info_edit.js +++ b/cms/static/js/views/course_info_edit.js @@ -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'), diff --git a/cms/static/js/views/course_outline.js b/cms/static/js/views/course_outline.js index 3eeeff5b1e0..72647d3edb5 100644 --- a/cms/static/js/views/course_outline.js +++ b/cms/static/js/views/course_outline.js @@ -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; diff --git a/cms/static/js/views/course_video_settings.js b/cms/static/js/views/course_video_settings.js index 4fe5586e120..265efa45cf8 100644 --- a/cms/static/js/views/course_video_settings.js +++ b/cms/static/js/views/course_video_settings.js @@ -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. diff --git a/cms/static/js/views/list.js b/cms/static/js/views/list.js index 714eb5f10a1..4d411845242 100644 --- a/cms/static/js/views/list.js +++ b/cms/static/js/views/list.js @@ -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 diff --git a/cms/static/js/views/manage_users_and_roles.js b/cms/static/js/views/manage_users_and_roles.js index fd34945c67b..e83453a62b0 100644 --- a/cms/static/js/views/manage_users_and_roles.js +++ b/cms/static/js/views/manage_users_and_roles.js @@ -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, diff --git a/cms/static/js/views/metadata.js b/cms/static/js/views/metadata.js index 3c5fa598117..1dda68b3094 100644 --- a/cms/static/js/views/metadata.js +++ b/cms/static/js/views/metadata.js @@ -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( diff --git a/cms/static/js/views/modals/course_outline_modals.js b/cms/static/js/views/modals/course_outline_modals.js index 492bd4b7d0b..d00af0a537f 100644 --- a/cms/static/js/views/modals/course_outline_modals.js +++ b/cms/static/js/views/modals/course_outline_modals.js @@ -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; }); diff --git a/cms/static/js/views/module_edit.js b/cms/static/js/views/module_edit.js index fe3bba58212..f58f02a9c94 100644 --- a/cms/static/js/views/module_edit.js +++ b/cms/static/js/views/module_edit.js @@ -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); } diff --git a/cms/static/js/views/pages/course_outline.js b/cms/static/js/views/pages/course_outline.js index 31227f4aa1d..1d10fb63752 100644 --- a/cms/static/js/views/pages/course_outline.js +++ b/cms/static/js/views/pages/course_outline.js @@ -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')); diff --git a/cms/static/js/views/settings/advanced.js b/cms/static/js/views/settings/advanced.js index 0a3eaf82ae3..14f054bb37c 100644 --- a/cms/static/js/views/settings/advanced.js +++ b/cms/static/js/views/settings/advanced.js @@ -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); diff --git a/cms/static/js/views/settings/grading.js b/cms/static/js/views/settings/grading.js index 2148466a0ed..ac4d170352a 100644 --- a/cms/static/js/views/settings/grading.js +++ b/cms/static/js/views/settings/grading.js @@ -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)}); } diff --git a/cms/static/js/views/settings/main.js b/cms/static/js/views/settings/main.js index ef728b616c8..4f3bf0bb273 100644 --- a/cms/static/js/views/settings/main.js +++ b/cms/static/js/views/settings/main.js @@ -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.'); diff --git a/cms/static/js/views/tabs.js b/cms/static/js/views/tabs.js index 70be63f9257..129bec4d2b4 100644 --- a/cms/static/js/views/tabs.js +++ b/cms/static/js/views/tabs.js @@ -28,6 +28,7 @@ TabsEdit = (function(_super) { __extends(TabsEdit, _super); + // eslint-disable-next-line no-shadow function TabsEdit() { var self = this; this.deleteTab = function() { diff --git a/cms/static/js/views/utils/create_library_utils.js b/cms/static/js/views/utils/create_library_utils.js index 3b8782f152c..ad32a9e0afd 100644 --- a/cms/static/js/views/utils/create_library_utils.js +++ b/cms/static/js/views/utils/create_library_utils.js @@ -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); diff --git a/cms/static/js/views/validation.js b/cms/static/js/views/validation.js index 1cc8635ffb3..e193294ddd2 100644 --- a/cms/static/js/views/validation.js +++ b/cms/static/js/views/validation.js @@ -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); diff --git a/cms/static/js/views/video/transcripts/file_uploader.js b/cms/static/js/views/video/transcripts/file_uploader.js index 5c635fdc4db..e1fba9a9a8d 100644 --- a/cms/static/js/views/video/transcripts/file_uploader.js +++ b/cms/static/js/views/video/transcripts/file_uploader.js @@ -130,6 +130,7 @@ define( checkExtValidity: function(file) { var fileExtension; if (!file.name) { + // eslint-disable-next-line no-void return void 0; } diff --git a/cms/static/js/views/video/transcripts/metadata_videolist.js b/cms/static/js/views/video/transcripts/metadata_videolist.js index 1cbf37467db..961e9fd2590 100644 --- a/cms/static/js/views/video/transcripts/metadata_videolist.js +++ b/cms/static/js/views/video/transcripts/metadata_videolist.js @@ -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); } }, diff --git a/cms/static/js/views/video/transcripts/utils.js b/cms/static/js/views/video/transcripts/utils.js index fae39400bd6..e339626eb91 100644 --- a/cms/static/js/views/video/transcripts/utils.js +++ b/cms/static/js/views/video/transcripts/utils.js @@ -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; } diff --git a/cms/static/js/views/video/translations_editor.js b/cms/static/js/views/video/translations_editor.js index 89df139e7b9..26d0ee23909 100644 --- a/cms/static/js/views/video/translations_editor.js +++ b/cms/static/js/views/video/translations_editor.js @@ -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) { diff --git a/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.jsx b/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.jsx index 9012703ce8a..2433db20d7a 100644 --- a/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.jsx +++ b/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.jsx @@ -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 && (
    diff --git a/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.test.jsx b/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.test.jsx index db4f47d6564..84a3e7a1930 100644 --- a/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.test.jsx +++ b/common/static/common/js/components/BlockBrowser/components/BlockBrowser/BlockBrowser.test.jsx @@ -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'; diff --git a/common/static/common/js/components/BlockBrowser/data/reducers/index.js b/common/static/common/js/components/BlockBrowser/data/reducers/index.js index 64e0bdca88a..b5c9a8420dc 100644 --- a/common/static/common/js/components/BlockBrowser/data/reducers/index.js +++ b/common/static/common/js/components/BlockBrowser/data/reducers/index.js @@ -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: diff --git a/common/static/common/js/components/BlockBrowser/index.jsx b/common/static/common/js/components/BlockBrowser/index.jsx index 0ac85c289bb..fa498e9a25a 100644 --- a/common/static/common/js/components/BlockBrowser/index.jsx +++ b/common/static/common/js/components/BlockBrowser/index.jsx @@ -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 => ( diff --git a/common/static/common/js/components/ExperimentalCarousel.jsx b/common/static/common/js/components/ExperimentalCarousel.jsx index 6d99d6d468c..ba239ae63e6 100644 --- a/common/static/common/js/components/ExperimentalCarousel.jsx +++ b/common/static/common/js/components/ExperimentalCarousel.jsx @@ -20,6 +20,7 @@ function NextArrow(props) { } return ( + // eslint-disable-next-line react/button-has-type