Resolve misc eslint errors
Test plan: - All existing tests pass flag=none Refs DE-1426 Change-Id: I888971eb3febd69fce08ed7c14990faedcb81336 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/303406 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Christopher Soto <christopher.soto@instructure.com> Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com> QA-Review: Kai Bjorkman <kbjorkman@instructure.com> Product-Review: Deborah Kwak <deborah.kwak@instructure.com>
This commit is contained in:
parent
ad730f17ff
commit
03e16bc261
|
@ -41,7 +41,7 @@ function combineAssignmentGroupGrades(assignmentGroupGrades, includeUngraded: bo
|
|||
const submissionCount = sumBy(relevantGroupGrades, 'submission_count')
|
||||
const possible = submissionCount > 0 || includeUngraded ? 100 : 0
|
||||
let score = finalGrade && round(finalGrade, 2)
|
||||
score = isNaN(score) ? null : score
|
||||
score = Number.isNaN(Number(score)) ? null : score
|
||||
|
||||
return {score, possible}
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ const GradeFormatHelper = {
|
|||
|
||||
const delocalizedGrade = numberHelper.parse(localizedGrade.replace('%', ''))
|
||||
|
||||
if (isNaN(delocalizedGrade)) {
|
||||
if (Number.isNaN(Number(delocalizedGrade))) {
|
||||
return localizedGrade
|
||||
}
|
||||
|
||||
|
@ -227,13 +227,13 @@ const GradeFormatHelper = {
|
|||
}
|
||||
|
||||
const gradeNoPercent = grade.replace('%', '')
|
||||
if ('delocalize' in options && !options.delocalize && !isNaN(gradeNoPercent)) {
|
||||
if ('delocalize' in options && !options.delocalize && !Number.isNaN(Number(gradeNoPercent))) {
|
||||
parsedGrade = parseFloat(gradeNoPercent)
|
||||
} else {
|
||||
parsedGrade = numberHelper.parse(gradeNoPercent)
|
||||
}
|
||||
|
||||
if (isNaN(parsedGrade)) {
|
||||
if (Number.isNaN(Number(parsedGrade))) {
|
||||
return grade
|
||||
}
|
||||
|
||||
|
|
|
@ -243,10 +243,8 @@ const GroupStructureNoSelfSignup = ({onChange, errormsg}) => {
|
|||
}
|
||||
|
||||
export const GroupStructure = ({onChange, errormsg}) => {
|
||||
/* eslint-disable prettier/prettier */
|
||||
const {selfSignup, createGroupCount, createGroupMemberCount, bySection, splitGroups, groupLimit} =
|
||||
useContext(GroupContext)
|
||||
/* eslint-enable prettier/prettier */
|
||||
|
||||
function handleChange(key, val) {
|
||||
let result = {createGroupCount, createGroupMemberCount, bySection, splitGroups, groupLimit}
|
||||
|
|
|
@ -20,7 +20,7 @@ import I18n from './i18nObj'
|
|||
|
||||
const numberFormat = {
|
||||
_format(n, options) {
|
||||
if (typeof n !== 'number' || isNaN(n)) {
|
||||
if (typeof n !== 'number' || Number.isNaN(Number(n))) {
|
||||
return n
|
||||
}
|
||||
return I18n.n(n, options)
|
||||
|
|
|
@ -35,12 +35,12 @@ const helper = {
|
|||
})
|
||||
|
||||
// fallback to default delimiters if invalid with locale specific ones
|
||||
if (isNaN(num)) {
|
||||
if (Number.isNaN(Number(num))) {
|
||||
num = helper._parseNumber(input)
|
||||
}
|
||||
|
||||
// final fallback to old parseFloat - this allows us to still support scientific 'e' notation
|
||||
if (input.toString().match(/e/) && isNaN(num)) {
|
||||
if (input.toString().match(/e/) && Number.isNaN(Number(num))) {
|
||||
num = parseFloat(input)
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ const helper = {
|
|||
},
|
||||
|
||||
validate(input) {
|
||||
return !isNaN(helper.parse(input))
|
||||
return !Number.isNaN(Number(helper.parse(input)))
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -83,11 +83,11 @@ type GroupProps = {
|
|||
// CanvasSelectOption and CanvasSelectGroup are components our client can create thru CanvasSelect
|
||||
// to pass us our options. They are never rendered themselves, but get transformed into INSTUI's
|
||||
// Select.Option and Select.Group on rendering CanvasSelect. See renderChildren below.
|
||||
function CanvasSelectOption({id, value}: OptionProps): ReactElement {
|
||||
function CanvasSelectOption(_props: OptionProps): ReactElement {
|
||||
return <div />
|
||||
}
|
||||
|
||||
function CanvasSelectGroup({label}: GroupProps): ReactElement {
|
||||
function CanvasSelectGroup(_props: GroupProps): ReactElement {
|
||||
return <div />
|
||||
}
|
||||
|
||||
|
|
|
@ -76,10 +76,12 @@ $.windowScrollTop = function () {
|
|||
}
|
||||
|
||||
// indicate we want stringified IDs for JSON responses
|
||||
$.ajaxPrefilter('json', (options, originalOptions, jqXHR) => {
|
||||
if (options.accepts.json)
|
||||
options.accepts.json = options.accepts.json + ', application/json+canvas-string-ids'
|
||||
else options.accepts.json = 'application/json+canvas-string-ids'
|
||||
$.ajaxPrefilter('json', (options, _originalOptions, _jqXHR) => {
|
||||
if (options.accepts.json) {
|
||||
options.accepts.json += ', application/json+canvas-string-ids'
|
||||
} else {
|
||||
options.accepts.json = 'application/json+canvas-string-ids'
|
||||
}
|
||||
})
|
||||
|
||||
// see: https://github.com/rails/jquery-ujs/blob/master/src/rails.js#L80
|
||||
|
|
|
@ -37,9 +37,6 @@ $.detect = function (collection, callback) {
|
|||
|
||||
$.encodeToHex = function (str) {
|
||||
let hex = ''
|
||||
const e = str.length
|
||||
const c = 0
|
||||
let h
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
let part = str.charCodeAt(i).toString(16)
|
||||
while (part.length < 2) {
|
||||
|
|
|
@ -35,7 +35,7 @@ export default class FileInputManager {
|
|||
}
|
||||
|
||||
setUpInputTrigger(el, mediaType) {
|
||||
$(el).on('click', e => {
|
||||
$(el).on('click', _e => {
|
||||
this.allowedMedia = mediaType
|
||||
return this.$fileInput.click()
|
||||
})
|
||||
|
|
|
@ -151,17 +151,17 @@ $(document).ready(() => {
|
|||
data.recipients = ids.join(',')
|
||||
return data
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
beforeSubmit(_data) {
|
||||
disableButtons(true)
|
||||
$(this).find('.send_button').text(I18n.t('Sending Message...'))
|
||||
},
|
||||
success(data) {
|
||||
success(_data) {
|
||||
$.flashMessage(I18n.t('Message sent!'))
|
||||
disableButtons(false)
|
||||
$(this).find('.send_button').text(I18n.t('Send Message'))
|
||||
$('#message_students_dialog').dialog('close')
|
||||
},
|
||||
error(data) {
|
||||
error(_data) {
|
||||
disableButtons(false)
|
||||
$(this).find('.send_button').text(I18n.t('Sending Message Failed, please try again'))
|
||||
},
|
||||
|
@ -172,7 +172,7 @@ $(document).ready(() => {
|
|||
const option = currentSettings.options[optionIdx]
|
||||
const studentsHash = $message_students_dialog.data('students_hash')
|
||||
let cutoff = numberHelper.parse($message_students_dialog.find('.cutoff_score').val())
|
||||
if (isNaN(cutoff)) {
|
||||
if (Number.isNaN(Number(cutoff))) {
|
||||
cutoff = null
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ INST.lookupPrerequisites = function () {
|
|||
)
|
||||
$link.prev('a').hide()
|
||||
},
|
||||
data => {
|
||||
_data => {
|
||||
spinner.stop()
|
||||
$('.module_prerequisites_fallback').show()
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class CalculationMethodFormView extends Backbone.View {
|
|||
}
|
||||
|
||||
change(e) {
|
||||
const val = parseInt(numberHelper.parse($(e.target).val()))
|
||||
const val = parseInt(numberHelper.parse($(e.target).val()), 10)
|
||||
if (_.isNaN(val)) return
|
||||
this.model.set({
|
||||
calculation_int: val,
|
||||
|
|
|
@ -205,7 +205,7 @@ export default class OutcomeIconBase extends Backbone.View {
|
|||
helper: 'clone',
|
||||
revert: 'invalid',
|
||||
scroll: false,
|
||||
drag(event, ui) {
|
||||
drag(event, _ui) {
|
||||
const i = $(this).data('draggable')
|
||||
const o = i.options
|
||||
let scrolled = false
|
||||
|
|
|
@ -115,7 +115,7 @@ export default class FindDialog extends DialogBaseView {
|
|||
this.close()
|
||||
return
|
||||
}
|
||||
if (confirm(this.confirmText(model))) {
|
||||
if (window.confirm(this.confirmText(model))) {
|
||||
let dfd, url
|
||||
if (model instanceof OutcomeGroup) {
|
||||
url = this.selectedGroup.get('import_url')
|
||||
|
@ -136,7 +136,7 @@ export default class FindDialog extends DialogBaseView {
|
|||
}
|
||||
this.$el.disableWhileLoading(dfd)
|
||||
return $.when(dfd)
|
||||
.done((response, status, deferred) => {
|
||||
.done((response, _status, _deferred) => {
|
||||
const importedModel = model.clone()
|
||||
if (importedModel instanceof OutcomeGroup) {
|
||||
importedModel.set(response)
|
||||
|
|
|
@ -181,7 +181,9 @@ function wrapGetPageThunk(actions, name, thunk) {
|
|||
if (links.last) {
|
||||
try {
|
||||
successPayload.lastPage = Number(/&page=([0-9]+)&/.exec(links.last)[1])
|
||||
} catch (e) {} // eslint-disable-line
|
||||
} catch (e) {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
dispatch({type: actions.success, payload: successPayload})
|
||||
})
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {act, render, fireEvent} from '@testing-library/react'
|
||||
import {render} from '@testing-library/react'
|
||||
import React from 'react'
|
||||
import ScreenReaderContent from '../screen_reader_content'
|
||||
import assertChange from 'chai-assert-change'
|
||||
|
||||
describe('canvas_quizzes/components/screen_reader_content', () => {
|
||||
it('renders', () => {
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {act, render, fireEvent} from '@testing-library/react'
|
||||
import {render} from '@testing-library/react'
|
||||
import React from 'react'
|
||||
import SightedUserContent from '../sighted_user_content'
|
||||
import assertChange from 'chai-assert-change'
|
||||
|
||||
describe('canvas_quizzes/components/sighted_user_content', () => {
|
||||
it('renders', () => {
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
*/
|
||||
|
||||
export default function round(n, digits) {
|
||||
let scale
|
||||
|
||||
if (digits === undefined) {
|
||||
digits = 0
|
||||
}
|
||||
|
@ -27,7 +25,7 @@ export default function round(n, digits) {
|
|||
n = parseFloat(n)
|
||||
}
|
||||
|
||||
scale = Math.pow(10, parseInt(digits, 10))
|
||||
const scale = Math.pow(10, parseInt(digits, 10))
|
||||
n = Math.round(n * scale) / scale
|
||||
|
||||
return n
|
||||
|
|
|
@ -24,7 +24,10 @@ export default class SessionStarted extends EventTracker {
|
|||
install(deliver) {
|
||||
const {userAgent} = navigator
|
||||
debugConsole.log(`I've been loaded by ${userAgent}.`)
|
||||
if (location.href.indexOf('question') === -1 && location.href.indexOf('take') > 0) {
|
||||
if (
|
||||
window.location.href.indexOf('question') === -1 &&
|
||||
window.location.href.indexOf('take') > 0
|
||||
) {
|
||||
return deliver({
|
||||
user_agent: userAgent,
|
||||
})
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
// You should have received a copy of the GNU Affero General Public License along
|
||||
// with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/* eslint-disable no-bitwise */
|
||||
|
||||
export default function generateUUID() {
|
||||
let now = Date.now()
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, char => {
|
||||
|
|
|
@ -23,11 +23,11 @@ const inputMethods = {
|
|||
const $body = $('body'),
|
||||
$inputCover = $('<div />', {class: 'input_cover'})
|
||||
|
||||
$inputCover.on('mouseleave', function (e) {
|
||||
$inputCover.on('mouseleave', function () {
|
||||
$(this).remove()
|
||||
})
|
||||
|
||||
$(inputs).on('mouseenter', function (e) {
|
||||
$(inputs).on('mouseenter', function () {
|
||||
const $el = $(this),
|
||||
$cover = $inputCover.clone(true)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
const noop = () => {}
|
||||
|
||||
export function beforeCheck(editor = {}, done = noop) {
|
||||
const [_skinStylesheet, ...ourCustomStylesheets] = Array.from(editor.dom.doc.styleSheets)
|
||||
const [, ...ourCustomStylesheets] = Array.from(editor.dom.doc.styleSheets)
|
||||
const hcStyles = window.ENV.url_for_high_contrast_tinymce_editor_css
|
||||
ourCustomStylesheets.forEach(s => (s.disabled = true))
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import rubricEditing from './edit_rubric'
|
||||
import EditRubricPage from '../backbone/views/EditRubricPage'
|
||||
|
||||
document.addEventListener('rubricEditDataReady', e => {
|
||||
document.addEventListener('rubricEditDataReady', () => {
|
||||
new EditRubricPage()
|
||||
rubricEditing.init()
|
||||
})
|
||||
|
|
|
@ -30,6 +30,7 @@ const subComponents = ['Threshold', 'OutcomeIcon', 'LongDescription', 'LongDescr
|
|||
_.toPairs(rubrics).forEach(([key, rubric]) => {
|
||||
const assessment = assessments[key]
|
||||
|
||||
// eslint-disable-next-line jest/valid-describe
|
||||
describe(rubric.title, () => {
|
||||
criteriaTypes.forEach((criteriaType, ix) => {
|
||||
const basicProps = {
|
||||
|
@ -54,6 +55,7 @@ _.toPairs(rubrics).forEach(([key, rubric]) => {
|
|||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jest/valid-describe
|
||||
describe(`with a ${criteriaType} criterion`, () => {
|
||||
describe('by default', () => {
|
||||
testRenderedSnapshots(basicProps)
|
||||
|
|
|
@ -80,7 +80,8 @@ export default class FileSelectBox extends React.Component {
|
|||
isLoading = () => this.fileStore.getState().isLoading || this.folderStore.getState().isLoading
|
||||
|
||||
createFolderFileTreeStructure = () => {
|
||||
let {folders, files} = this.state
|
||||
const {files} = this.state
|
||||
let {folders} = this.state
|
||||
|
||||
// Put files into the right folders.
|
||||
const groupedFiles = _.groupBy(files, 'folder_id')
|
||||
|
|
|
@ -37,9 +37,9 @@ function exportPropsToSelf(properties, keyMethod) {
|
|||
}
|
||||
}
|
||||
|
||||
let keys = keyMethod(properties),
|
||||
keyLength = keys.length,
|
||||
prop
|
||||
const keys = keyMethod(properties)
|
||||
let keyLength = keys.length
|
||||
let prop
|
||||
|
||||
while (keyLength--) {
|
||||
prop = keys[keyLength]
|
||||
|
@ -152,6 +152,7 @@ function TinyMCEContentItem(contentItem) {
|
|||
exportPropsToSelf.call(this, contentItem, Object.getOwnPropertyNames)
|
||||
|
||||
decorate('isLTI', function () {
|
||||
// eslint-disable-next-line no-bitwise
|
||||
return !!~LTI_MIME_TYPES.indexOf(this.mediaType)
|
||||
})
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ import $ from 'jquery'
|
|||
// see also User.name_parts in user.rb
|
||||
export function nameParts(name, prior_surname) {
|
||||
const SUFFIXES = /^(Sn?r\.?|Senior|Jn?r\.?|Junior|II|III|IV|V|VI|Esq\.?|Esquire)$/i
|
||||
let surname, given, suffix, given_parts, prior_surname_parts, name_parts
|
||||
let surname, given, suffix, given_parts, prior_surname_parts
|
||||
if (!name || $.trim(name) === '') {
|
||||
return [null, null, null]
|
||||
}
|
||||
name_parts = $.map(name.split(','), str => $.trim(str))
|
||||
const name_parts = $.map(name.split(','), str => $.trim(str))
|
||||
surname = name_parts[0]
|
||||
given = name_parts[1]
|
||||
suffix = name_parts.slice(2).join(', ')
|
||||
|
|
|
@ -33,8 +33,8 @@ const build = function (base, key, value) {
|
|||
}
|
||||
|
||||
$.fn.toJSON = function () {
|
||||
let json = {},
|
||||
push_counters = {}
|
||||
let json = {}
|
||||
const push_counters = {}
|
||||
|
||||
const push_counter = function (key, i) {
|
||||
if (push_counters[key] === undefined) {
|
||||
|
|
Loading…
Reference in New Issue