diff --git a/package.json b/package.json index 74c4779ab..d8bdcf60e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build": "make build", "i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null", "lint": "fedx-scripts eslint --ext .js --ext .jsx .", + "lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .", "snapshot": "fedx-scripts jest --updateSnapshot", "start": "fedx-scripts webpack-dev-server --progress", "test": "fedx-scripts jest --coverage", diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx index 03a0ffb6b..06ca2cb59 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx @@ -33,7 +33,7 @@ export const ScoringCard = ({ summary += ` ${String.fromCharCode(183)} `; summary += unlimited ? intl.formatMessage(messages.unlimitedAttemptsSummary) - : intl.formatMessage(messages.attemptsSummary, { attempts: attempts ? attempts : defaultValue }); + : intl.formatMessage(messages.attemptsSummary, { attempts: attempts || defaultValue }); return summary; }; diff --git a/src/editors/containers/ProblemEditor/data/SettingsParser.js b/src/editors/containers/ProblemEditor/data/SettingsParser.js index 36307b200..d12fe4f0e 100644 --- a/src/editors/containers/ProblemEditor/data/SettingsParser.js +++ b/src/editors/containers/ProblemEditor/data/SettingsParser.js @@ -2,7 +2,7 @@ import _ from 'lodash-es'; import { ShowAnswerTypes, RandomizationTypesKeys } from '../../../data/constants/problem'; -export const popuplateItem = (parentObject, itemName, statekey, metadata, allowNull=false) => { +export const popuplateItem = (parentObject, itemName, statekey, metadata, allowNull = false) => { let parent = parentObject; const item = _.get(metadata, itemName, null); if (!_.isNil(item) || allowNull) { @@ -14,7 +14,7 @@ export const popuplateItem = (parentObject, itemName, statekey, metadata, allowN export const parseScoringSettings = (metadata, defaultSettings) => { let scoring = {}; - let attempts = popuplateItem({}, 'max_attempts', 'number', metadata); + const attempts = popuplateItem({}, 'max_attempts', 'number', metadata); attempts.unlimited = false; // isFinite checks if value is a finite primitive number. diff --git a/src/editors/containers/ProblemEditor/data/SettingsParser.test.js b/src/editors/containers/ProblemEditor/data/SettingsParser.test.js index b415a8422..bb9515154 100644 --- a/src/editors/containers/ProblemEditor/data/SettingsParser.test.js +++ b/src/editors/containers/ProblemEditor/data/SettingsParser.test.js @@ -32,7 +32,7 @@ describe('Test Settings to State Parser', () => { test('Test score settings attempts missing with default max_attempts', () => { const scoreSettings = parseScoringSettings(singleSelectWithHints.metadata, defaultSettings); - expect(scoreSettings.attempts).toStrictEqual({number: 1, unlimited: false}); + expect(scoreSettings.attempts).toStrictEqual({ number: 1, unlimited: false }); }); test('Test negative attempts in score', () => { @@ -47,12 +47,12 @@ describe('Test Settings to State Parser', () => { test('Test score settings missing with default', () => { const settings = parseSettings(singleSelectWithHints.metadata, defaultSettings); - expect(settings.scoring).toStrictEqual({attempts: {number: 1, unlimited: false}}); + expect(settings.scoring).toStrictEqual({ attempts: { number: 1, unlimited: false } }); }); test('Test score settings missing with null default', () => { - const settings = parseSettings(singleSelectWithHints.metadata, {max_attempts: null}); - expect(settings.scoring).toStrictEqual({attempts: {number: '', unlimited: true}}); + const settings = parseSettings(singleSelectWithHints.metadata, { max_attempts: null }); + expect(settings.scoring).toStrictEqual({ attempts: { number: '', unlimited: true } }); }); test('Test invalid randomization', () => {