Skip to content

Commit

Permalink
use common eslint config
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alicewriteswrongs committed Sep 27, 2017
1 parent 619d6bd commit 57c31e2
Show file tree
Hide file tree
Showing 159 changed files with 1,628 additions and 1,671 deletions.
86 changes: 1 addition & 85 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -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"
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions static/js/actions/course_enrollments_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion static/js/actions/profile_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
8 changes: 4 additions & 4 deletions static/js/actions/util_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion static/js/components/CouponNotificationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions static/js/components/CourseEnrollmentDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -114,7 +114,7 @@ export default class CourseEnrollmentDialog extends React.Component {
</Button>
)
}
auditButton = (
const auditButton = (
<Button
key="audit"
onClick={this.handleAuditClick}
Expand Down
2 changes: 1 addition & 1 deletion static/js/components/CourseEnrollmentDialog_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("CourseEnrollmentDialog", () => {
}
}
)
let el: HTMLElement = (document.querySelector(
const el: HTMLElement = (document.querySelector(
".course-enrollment-dialog"
): any)
return el
Expand Down
44 changes: 22 additions & 22 deletions static/js/components/EducationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class EducationForm extends ProfileFormFields {
setEducationDialogVisibility
} = this.props

let education = profile["education"][index]
const education = profile["education"][index]
setEducationDialogIndex(index)
setEducationDegreeLevel(education.degree_name)
setEducationDialogVisibility(true)
Expand All @@ -93,7 +93,7 @@ class EducationForm extends ProfileFormFields {
setEducationDialogVisibility,
validator
} = this.props
let clone = {
const clone = {
...profile,
education: [...profile.education, generateNewEducation(level)]
}
Expand All @@ -105,7 +105,7 @@ class EducationForm extends ProfileFormFields {

deleteEducationEntry = (): Promise<*> => {
const { saveProfile, profile, ui } = this.props
let clone = _.cloneDeep(profile)
const clone = _.cloneDeep(profile)
if (ui.deletionIndex !== undefined && ui.deletionIndex !== null) {
clone["education"].splice(ui.deletionIndex, 1)
}
Expand All @@ -114,8 +114,8 @@ class EducationForm extends ProfileFormFields {

educationLevelRadioSwitch = (level: Option): React$Element<*> => {
const { ui: { educationLevelAnswers } } = this.props
let radioIconStyle = { marginRight: "8px" }
let valueSelected = level.value in educationLevelAnswers ? "false" : null
const radioIconStyle = { marginRight: "8px" }
const valueSelected = level.value in educationLevelAnswers ? "false" : null
return (
<RadioButtonGroup
className={`profile-radio-switch ${level.value}`}
Expand Down Expand Up @@ -159,9 +159,9 @@ class EducationForm extends ProfileFormFields {
}

renderEducationQuestionForm(level: Option): React$Element<*> {
let label = level.label
let prefix = label.toLowerCase().startsWith("a") ? "an" : "a"
let levelName = !label.endsWith("degree")
const label = level.label
const prefix = label.toLowerCase().startsWith("a") ? "an" : "a"
const levelName = !label.endsWith("degree")
? `${label.toLowerCase()} degree`
: label.toLowerCase()
return (
Expand All @@ -183,7 +183,7 @@ class EducationForm extends ProfileFormFields {
let title
if (!_.isNil(level)) {
levelValue = level.value
let label = EDUCATION_LEVEL_LABELS[levelValue]
const label = EDUCATION_LEVEL_LABELS[levelValue]
filterDegreeName = ([, entry]) => entry.degree_name === level.value
title = (
<Cell col={12} className="profile-form-row" key="header-row">
Expand Down Expand Up @@ -235,20 +235,20 @@ class EducationForm extends ProfileFormFields {
// don't show new educations, wait until we saved on the server before showing them
return
}
let deleteEntry = () => this.openEducationDeleteDialog(index)
let editEntry = () => this.openEditEducationForm(index)
let validationAlert = () => {
const deleteEntry = () => this.openEducationDeleteDialog(index)
const editEntry = () => this.openEditEducationForm(index)
const validationAlert = () => {
if (_.get(errors, ["education", String(index)])) {
return <IconButton name="error" onClick={editEntry} />
}
}

let level
if (showLevel) {
let degree = EDUCATION_LEVEL_LABELS[education.degree_name]
const degree = EDUCATION_LEVEL_LABELS[education.degree_name]
level = <div>{degree}</div>
}
let icons = () => (
const icons = () => (
<div className="profile-row-icons">
{validationAlert()}
<IconButton className="edit-button" name="edit" onClick={editEntry} />
Expand Down Expand Up @@ -317,12 +317,12 @@ class EducationForm extends ProfileFormFields {
editEducationForm = (): React$Element<*> => {
const { ui: { educationDialogIndex }, showSwitch, profile } = this.props

let keySet = (key): any => ["education", educationDialogIndex, key]
let educationDegreeLevel = _.get(profile, keySet("degree_name"))
let id = _.get(profile, keySet("id"))
let title = id !== undefined ? "Edit Education" : "Add Education"
const keySet = (key): any => ["education", educationDialogIndex, key]
const educationDegreeLevel = _.get(profile, keySet("degree_name"))
const id = _.get(profile, keySet("id"))
const title = id !== undefined ? "Edit Education" : "Add Education"

let fieldOfStudy = () => {
const fieldOfStudy = () => {
if (educationDegreeLevel !== HIGH_SCHOOL) {
return (
<Cell col={12}>
Expand All @@ -337,7 +337,7 @@ class EducationForm extends ProfileFormFields {
)
}
}
let levelForm = () => {
const levelForm = () => {
if (!showSwitch) {
return (
<Cell col={12}>
Expand Down Expand Up @@ -398,7 +398,7 @@ class EducationForm extends ProfileFormFields {
renderCard() {
const { showSwitch, profile } = this.props

let cardClass = levelValue =>
const cardClass = levelValue =>
this.hasEducationAtLevel(levelValue) ? "" : "collapsed"

if (showSwitch) {
Expand Down Expand Up @@ -439,7 +439,7 @@ class EducationForm extends ProfileFormFields {
}

render() {
let {
const {
ui: { showEducationDeleteDialog, educationDialogVisibility },
profilePatchStatus
} = this.props
Expand Down
8 changes: 4 additions & 4 deletions static/js/components/EducationForm_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { USER_PROFILE_RESPONSE } from "../test_constants"
import { labelSort } from "../util/util"

describe("EducationForm", () => {
let renderEducationForm = (props = {}) => {
const renderEducationForm = (props = {}) => {
return shallow(
<EducationForm
ui={{
Expand All @@ -26,11 +26,11 @@ describe("EducationForm", () => {
}

it("sorts the fields of study in order", () => {
let wrapper = renderEducationForm()
let field = wrapper
const wrapper = renderEducationForm()
const field = wrapper
.find("SelectField")
.filterWhere(field => field.props().label === "Field of Study")
let options = field.props().options
const options = field.props().options
assert.deepEqual(options, labelSort(options))
})
})
10 changes: 5 additions & 5 deletions static/js/components/EmailCampaignsCard_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("EmailCampaignsCard", () => {
const headers = ["Email name / subject", "Start date", "Stop date", "Active"]

it("should render all emails and header text, if Right", () => {
let cardText = renderCard().text()
const cardText = renderCard().text()
GET_AUTOMATIC_EMAILS_RESPONSE.forEach(email => {
assert.include(cardText, email.email_subject)
})
Expand All @@ -46,15 +46,15 @@ describe("EmailCampaignsCard", () => {

it("should render an error message and no header text, if Left", () => {
emailCardProps.getEmails.returns(S.Left(<div>I'm a message</div>))
let cardText = renderCard().text()
const cardText = renderCard().text()
assert.include(cardText, "I'm a message")
headers.forEach(header => {
assert.notInclude(cardText, header)
})
})

it("should render a switch, and call toggleEmailActive on click", () => {
let card = renderCard()
const card = renderCard()
card
.find(Switch)
.first()
Expand All @@ -68,7 +68,7 @@ describe("EmailCampaignsCard", () => {
})

it('should render an "edit" button, and call openEmailComposer with the AutomaticEmail on click', () => {
let card = renderCard()
const card = renderCard()
card
.find("a")
.first()
Expand All @@ -82,7 +82,7 @@ describe("EmailCampaignsCard", () => {

it("should show a spinner when a request is in-flight", () => {
emailCardProps.emailsInFlight.add(GET_AUTOMATIC_EMAILS_RESPONSE[0].id)
let card = renderCard()
const card = renderCard()
assert.lengthOf(card.find(Spinner), 1)
})
})
Loading

0 comments on commit 57c31e2

Please sign in to comment.