From 57c31e2c5e1d80374ffefc316c5a06734d177677 Mon Sep 17 00:00:00 2001 From: Alice Pote Date: Wed, 27 Sep 2017 11:47:51 -0400 Subject: [PATCH] use common eslint config Changes the eslint config for MM so that it just extends the common config, instead of having a separate one. Code changes are all linting changes. pr #3560 --- .eslintrc | 86 +------- package.json | 5 +- static/js/actions/course_enrollments_test.js | 4 +- static/js/actions/profile_test.js | 2 +- static/js/actions/util_test.js | 8 +- .../js/components/CouponNotificationDialog.js | 2 +- .../js/components/CourseEnrollmentDialog.js | 4 +- .../components/CourseEnrollmentDialog_test.js | 2 +- static/js/components/EducationForm.js | 44 ++-- static/js/components/EducationForm_test.js | 8 +- .../js/components/EmailCampaignsCard_test.js | 10 +- static/js/components/EmploymentForm.js | 30 +-- static/js/components/EmploymentForm_test.js | 8 +- static/js/components/ErrorMessage.js | 6 +- static/js/components/ErrorMessage_test.js | 40 ++-- static/js/components/FacultyCarousel.js | 2 +- static/js/components/FacultyTile_test.js | 2 +- static/js/components/Learner.js | 2 +- static/js/components/LearnerChip_test.js | 22 +- static/js/components/LearnerInfoCard_test.js | 32 +-- .../LearnerPageAboutMeDialog_test.js | 2 +- static/js/components/LearnerSearch.js | 6 +- static/js/components/Loader_test.js | 8 +- static/js/components/Navbar.js | 2 +- static/js/components/Navbar_test.js | 20 +- static/js/components/OrderSummary.js | 4 +- static/js/components/OrderSummary_test.js | 44 ++-- static/js/components/PersonalTab.js | 2 +- static/js/components/PersonalTab_test.js | 18 +- .../js/components/ProgramEnrollmentDialog.js | 4 +- .../ProgramEnrollmentDialog_test.js | 64 +++--- static/js/components/ProgramSelector.js | 18 +- static/js/components/ProgramSelector_test.js | 46 ++--- .../components/SkipFinancialAidDialog_test.js | 4 +- static/js/components/SpinnerButton.js | 2 + static/js/components/SpinnerButton_test.js | 48 ++--- .../components/StaffLearnerInfoCard_test.js | 18 +- .../js/components/dashboard/CourseAction.js | 2 +- .../components/dashboard/CourseAction_test.js | 28 +-- .../components/dashboard/CourseDescription.js | 6 +- .../dashboard/CourseDescription_test.js | 192 +++++++++--------- .../js/components/dashboard/CourseListCard.js | 2 +- .../dashboard/CourseListCard_test.js | 10 +- static/js/components/dashboard/CourseRow.js | 2 +- .../js/components/dashboard/CourseRow_test.js | 14 +- .../components/dashboard/DashboardUserCard.js | 2 +- .../dashboard/DashboardUserCard_test.js | 8 +- .../dashboard/FinalExamCard_test.js | 34 ++-- .../components/dashboard/FinancialAidCard.js | 4 +- .../dashboard/FinancialAidCard_test.js | 86 ++++---- .../dashboard/courses/GradeDetailPopup.js | 4 +- .../courses/GradeDetailPopup_test.js | 22 +- .../dashboard/courses/Grades_test.js | 20 +- .../dashboard/courses/ProgressMessage.js | 6 +- .../dashboard/courses/ProgressMessage_test.js | 16 +- .../dashboard/courses/Progress_test.js | 6 +- .../dashboard/courses/StatusMessages.js | 20 +- .../dashboard/courses/StatusMessages_test.js | 38 ++-- .../js/components/dashboard/courses/util.js | 10 +- .../components/dashboard/courses/util_test.js | 8 +- static/js/components/dashboard/util_test.js | 4 +- .../email/AutomaticEmailOptions_test.js | 8 +- .../email/EmailCompositionDialog.js | 12 +- .../email/EmailCompositionDialog_test.js | 22 +- static/js/components/email/hoc.js | 14 +- static/js/components/email/hoc_test.js | 10 +- static/js/components/email/lib.js | 2 +- static/js/components/email/lib_test.js | 61 +++--- .../components/inputs/CountrySelectField.js | 2 +- static/js/components/inputs/DateField.js | 38 ++-- static/js/components/inputs/SelectField.js | 6 +- .../js/components/inputs/StateSelectField.js | 2 +- static/js/components/inputs/inputs_test.js | 38 ++-- static/js/components/inputs/util_test.js | 24 ++- .../search/CountryRefinementOption.js | 4 +- .../search/CountryRefinementOption_test.js | 20 +- .../js/components/search/CustomNoHits_test.js | 8 +- .../search/CustomPaginationDisplay.js | 4 +- .../search/CustomPaginationDisplay_test.js | 8 +- .../search/CustomResetFiltersDisplay.js | 2 +- .../search/CustomResetFiltersDisplay_test.js | 2 +- .../search/CustomSortingColumnHeaders.js | 2 +- .../search/CustomSortingColumnHeaders_test.js | 10 +- .../js/components/search/EducationFilter.js | 10 +- .../search/FilterVisibilityToggle.js | 4 +- .../search/FilterVisibilityToggle_test.js | 17 +- .../search/FinalGradeRangeFilter.js | 10 +- static/js/components/search/HitsCount_test.js | 6 +- .../components/search/LearnerResult_test.js | 42 ++-- .../search/ModifiedSelectedFilter.js | 3 +- .../search/NestedAggregatingMenuFilter.js | 14 +- .../components/search/WithSearchkitManager.js | 2 +- .../js/components/search/WorkHistoryFilter.js | 8 +- static/js/components/search/util.js | 34 ++-- static/js/constants_test.js | 18 +- static/js/containers/App_test.js | 28 +-- static/js/containers/AutomaticEmailPage.js | 2 +- .../js/containers/AutomaticEmailPage_test.js | 10 +- static/js/containers/DashboardPage.js | 26 +-- static/js/containers/DashboardPage_test.js | 118 +++++------ .../js/containers/FinancialAidCalculator.js | 18 +- .../containers/FinancialAidCalculator_test.js | 50 ++--- static/js/containers/LearnerPage.js | 6 +- static/js/containers/LearnerPage_test.js | 177 ++++++++-------- static/js/containers/LearnerSearchPage.js | 4 +- .../js/containers/LearnerSearchPage_test.js | 24 +-- static/js/containers/OrderSummaryPage.js | 4 +- static/js/containers/OrderSummaryPage_test.js | 16 +- static/js/containers/ProfileFormContainer.js | 8 +- static/js/containers/ProfileImage_test.js | 26 +-- static/js/containers/ProfilePage.js | 2 +- static/js/containers/ProfilePage_test.js | 51 ++--- static/js/containers/SettingsPage.js | 4 +- static/js/containers/SettingsPage_test.js | 27 +-- static/js/containers/SignupDialog_test.js | 2 +- static/js/entry/dashboard.js | 2 +- static/js/entry/public.js | 2 +- static/js/entry/zendesk_widget.js | 6 +- static/js/factories/dashboard.js | 6 +- static/js/factories/pearson.js | 2 +- static/js/global_init.js | 4 +- static/js/lib/api.js | 8 +- static/js/lib/api_test.js | 56 ++--- static/js/lib/coupon.js | 18 +- static/js/lib/coupon_test.js | 54 ++--- static/js/lib/google_analytics_test.js | 2 +- static/js/lib/pearson.js | 8 +- static/js/lib/pearson_test.js | 4 +- static/js/lib/redux_rest_test.js | 6 +- static/js/lib/redux_test.js | 24 +-- static/js/lib/sanctuary_test.js | 18 +- static/js/lib/validation/date.js | 2 +- static/js/lib/validation/date_test.js | 6 +- static/js/lib/validation/profile.js | 14 +- static/js/lib/validation/profile_test.js | 170 ++++++++-------- static/js/reducers/coupons_test.js | 10 +- static/js/reducers/dashboard.js | 10 +- static/js/reducers/dashboard_test.js | 22 +- static/js/reducers/documents_test.js | 10 +- static/js/reducers/email.js | 8 +- static/js/reducers/email_test.js | 19 +- static/js/reducers/financial_aid_test.js | 24 +-- static/js/reducers/image_upload_test.js | 16 +- static/js/reducers/index.js | 12 +- static/js/reducers/index_test.js | 14 +- static/js/reducers/order_receipt_test.js | 2 +- static/js/reducers/programs.js | 6 +- static/js/reducers/programs_test.js | 4 +- static/js/reducers/util_test.js | 2 +- static/js/store/configureStore.js | 2 +- static/js/util/date_test.js | 8 +- static/js/util/profile_edit.js | 36 ++-- static/js/util/profile_edit_test.js | 154 +++++++------- static/js/util/sorting.js | 8 +- static/js/util/sorting_test.js | 30 +-- static/js/util/test_utils.js | 28 +-- static/js/util/util.js | 37 ++-- static/js/util/util_test.js | 160 +++++++-------- yarn.lock | 22 +- 159 files changed, 1628 insertions(+), 1671 deletions(-) diff --git a/.eslintrc b/.eslintrc index e985dc685b..99cf75fce3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,87 +1,3 @@ { - "parser": "babel-eslint", - "extends": [ - "google", - "eslint:recommended", - "plugin:react/recommended" - ], - "rules": { - "key-spacing": [2, { - "beforeColon": false, - "afterColon": true, - "align": { - "beforeColon": false, - "afterColon": true, - "mode": "minimum", - "on": "value" - } - }], - "quotes": [0], // no opinion on ' vs " - "object-curly-spacing": [0], - "new-cap": [0], // allows function calls like Immutable.Map(...) - "max-len": [0, { - "code": 80, - "ignoreComments": true, - }], - "indent": [2, 2], // no tabs, indent is 2 spaces - "newline-after-var": [0], - "react/jsx-indent-props": [2, 2], // no tabs, indent is two spaces - "react/jsx-key": [2], // validate that key prop exists - "react/jsx-no-undef": [2], // disallow undeclared variables in JSX - "react/prop-types": [0], - "react/display-name" : [0], - "react/no-find-dom-node": [0], - "react/no-unescaped-entities": [0], - "no-unused-vars": [ 2, { - "vars": "local", - "argsIgnorePattern": "action" - }], - "comma-dangle": [0], - "no-unreachable": [2], - "semi": [2, "never"], - "eqeqeq": [2], - "no-var": [2], - "camelcase": [2, { - "properties": "never" - }], - "guard-for-in": [2], - "prefer-template": [2], - "space-infix-ops": [2], - "space-before-blocks": [2], - "space-in-parens": [2], - "flow-vars/define-flow-type": [2], - "flow-vars/use-flow-type": [2], - "flowtype/space-after-type-colon": [0], - "flowtype/space-before-type-colon": [2, "never"], - "flowtype/generic-spacing": [2, "never"], - "flowtype/no-dupe-keys": [2], - "flowtype/no-primitive-constructor-types": [2], - "flowtype/object-type-delimiter": [2, "comma"], - "mocha/no-exclusive-tests": [2], - "mocha/no-skipped-tests": [2], - "mocha/no-sibling-hooks": [2], - "mocha/no-global-tests": [2], - "mocha/handle-done-callback": [2], - "mocha/no-top-level-hooks": [2], - "mocha/no-identical-title": [2], - "mocha/no-nested-tests": [2], - }, - "env": { - "es6": true, - "browser": true, - "node": true, - "mocha": true - }, - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - }, - "plugins": [ - "babel", - "react", - "flowtype", - "flow-vars", - "mocha" - ] + "extends": "eslint-config-mitodl" } diff --git a/package.json b/package.json index c050a04f41..3812a1024c 100644 --- a/package.json +++ b/package.json @@ -46,11 +46,12 @@ "eslint": "4.2.0", "eslint-config-defaults": "9.0.0", "eslint-config-google": "^0.9.1", + "eslint-config-mitodl": "^0.0.3", "eslint-plugin-babel": "^4.1.1", "eslint-plugin-flow-vars": "^0.5.0", "eslint-plugin-flowtype": "^2.35.1", - "eslint-plugin-mocha": "^4.9.0", - "eslint-plugin-react": "^7.0.1", + "eslint-plugin-mocha": "4.11.0", + "eslint-plugin-react": "7.1.0", "express": "^4.15.3", "fetch-mock": "^5.11.0", "file-loader": "^0.11.1", diff --git a/static/js/actions/course_enrollments_test.js b/static/js/actions/course_enrollments_test.js index 1e6149e384..fce6ab6bda 100644 --- a/static/js/actions/course_enrollments_test.js +++ b/static/js/actions/course_enrollments_test.js @@ -22,8 +22,8 @@ describe("show and hide enroll pay later success alert", () => { }) it("should set and reset enroll pay later dialog", () => { - let waitPromise = Promise.resolve() - let waitStub = sandbox.stub(util, "wait").returns(waitPromise) + const waitPromise = Promise.resolve() + const waitStub = sandbox.stub(util, "wait").returns(waitPromise) return dispatchThen(showEnrollPayLaterSuccessMessage("foo/bar/baz"), [ SHOW_ENROLL_PAY_LATER_SUCCESS diff --git a/static/js/actions/profile_test.js b/static/js/actions/profile_test.js index 8a591cc610..85b9cacfa1 100644 --- a/static/js/actions/profile_test.js +++ b/static/js/actions/profile_test.js @@ -7,7 +7,7 @@ import { assert } from "chai" describe("generated profile action helpers", () => { it("should take a username and a keySet", () => { - let action = updateValidationVisibility("my user", ["a", "key", "set"]) + const action = updateValidationVisibility("my user", ["a", "key", "set"]) assert.deepEqual(action, { type: UPDATE_VALIDATION_VISIBILITY, payload: { diff --git a/static/js/actions/util_test.js b/static/js/actions/util_test.js index b2d7a7843b..0ca6db9642 100644 --- a/static/js/actions/util_test.js +++ b/static/js/actions/util_test.js @@ -5,15 +5,15 @@ import { withUsername } from "./util" describe("action creator utils", () => { describe("withUsername", () => { - let TYPE = "TYPE" + const TYPE = "TYPE" it("should return an action creator, given a type", () => { - let creator = withUsername(TYPE) + const creator = withUsername(TYPE) assert.isFunction(creator) }) it("should add a username and a payload", () => { - let creator = withUsername(TYPE) - let action = creator("username", { my: "payload" }) + const creator = withUsername(TYPE) + const action = creator("username", { my: "payload" }) assert.deepEqual(action, { type: TYPE, payload: { my: "payload" }, diff --git a/static/js/components/CouponNotificationDialog.js b/static/js/components/CouponNotificationDialog.js index 2efc775963..c590a318c4 100644 --- a/static/js/components/CouponNotificationDialog.js +++ b/static/js/components/CouponNotificationDialog.js @@ -48,7 +48,7 @@ const CouponNotificationDialog = ({ courseName = `course ID ${objectId}` } - let isDiscount = + const isDiscount = amountType === COUPON_AMOUNT_TYPE_FIXED_DISCOUNT || amountType === COUPON_AMOUNT_TYPE_PERCENT_DISCOUNT diff --git a/static/js/components/CourseEnrollmentDialog.js b/static/js/components/CourseEnrollmentDialog.js index 632602b384..12d1d18e0b 100644 --- a/static/js/components/CourseEnrollmentDialog.js +++ b/static/js/components/CourseEnrollmentDialog.js @@ -69,7 +69,7 @@ export default class CourseEnrollmentDialog extends React.Component { hasUserApplied, pendingFinancialAid } = this.props - let message, payButton, auditButton + let message, payButton if (pendingFinancialAid) { message = `Your Personalized Course Price is still pending approval, but you can sign up now to audit the course for FREE, and then pay later. (Payment is required @@ -114,7 +114,7 @@ export default class CourseEnrollmentDialog extends React.Component { ) } - auditButton = ( + const auditButton = (