diff --git a/.eslintrc.js b/.eslintrc.js index 07ddcba1a3..5ada2d03a7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,6 @@ const legacyCode = { 'no-continue': 'off', 'no-else-return': 'off', 'no-plusplus': 'off', - 'no-prototype-builtins': 'off', 'no-restricted-syntax': 'off', 'no-this-before-super': 'off', }; @@ -71,12 +70,9 @@ module.exports = { files: [ 'client/src/entrypoints/admin/comments.js', 'client/src/entrypoints/admin/core.js', - 'client/src/entrypoints/admin/expanding-formset.js', - 'client/src/entrypoints/admin/filtered-select.js', 'client/src/entrypoints/admin/page-chooser.js', 'client/src/entrypoints/admin/page-editor.js', 'client/src/entrypoints/admin/telepath/widgets.js', - 'client/src/entrypoints/contrib/table_block/table.js', 'client/src/entrypoints/contrib/typed_table_block/typed_table_block.js', 'client/src/entrypoints/images/image-chooser-modal.js', 'client/src/utils/actions.ts', diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 480655a95b..db11c1262a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -22,6 +22,7 @@ Changelog * Clean up some unused utility classes and migrate `unlist` to Tailwind utility class `w-list-none` (Loveth Omokaro) * Ensure that the `rebuild_references_index` command can run without console output if called with `--verbosity 0` (Omerzahid Ali, Aman Pandey) * Add development (contributing to Wagtail) documentation notes for development on Windows (Akua Dokua Asiedu) + * Clean up linting on legacy code and add shared util `hasOwn` in TypeScript (Loveth Omokaro) * Fix: Make sure workflow timeline icons are visible in high-contrast mode (Loveth Omokaro) * Fix: Ensure authentication forms (login, password reset) have a visible border in Windows high-contrast mode (Loveth Omokaro) * Fix: Ensure visual consistency between buttons and links as buttons in Windows high-contrast mode (Albina Starykova) diff --git a/client/src/components/StreamField/blocks/StreamBlock.js b/client/src/components/StreamField/blocks/StreamBlock.js index 82d57808b9..9ba0773588 100644 --- a/client/src/components/StreamField/blocks/StreamBlock.js +++ b/client/src/components/StreamField/blocks/StreamBlock.js @@ -8,6 +8,7 @@ import { BaseInsertionControl, } from './BaseSequenceBlock'; import { escapeHtml as h } from '../../../utils/text'; +import { hasOwn } from '../../../utils/hasOwn'; /* global $ */ @@ -318,7 +319,7 @@ export class StreamBlock extends BaseSequenceBlock { // Check if there are any block types that have count limits this.disabledBlockTypes = new Set(); for (const blockType in this.blockDef.meta.blockCounts) { - if (this.blockDef.meta.blockCounts.hasOwnProperty(blockType)) { + if (hasOwn(this.blockDef.meta.blockCounts, blockType)) { const maxNum = this.getBlockMax(blockType); if (typeof maxNum === 'number') { @@ -459,7 +460,7 @@ export class StreamBlock extends BaseSequenceBlock { // Block errors for (const blockIndex in error.blockErrors) { - if (error.blockErrors.hasOwnProperty(blockIndex)) { + if (hasOwn(error.blockErrors, blockIndex)) { this.children[blockIndex].setError(error.blockErrors[blockIndex]); } } diff --git a/client/src/components/StreamField/blocks/StructBlock.js b/client/src/components/StreamField/blocks/StructBlock.js index e4af0c8564..b092ba42eb 100644 --- a/client/src/components/StreamField/blocks/StructBlock.js +++ b/client/src/components/StreamField/blocks/StructBlock.js @@ -1,6 +1,7 @@ /* global $ */ import { escapeHtml as h } from '../../../utils/text'; +import { hasOwn } from '../../../utils/hasOwn'; export class StructBlockValidationError { constructor(blockErrors) { @@ -96,7 +97,7 @@ export class StructBlock { const error = errorList[0]; for (const blockName in error.blockErrors) { - if (error.blockErrors.hasOwnProperty(blockName)) { + if (hasOwn(error.blockErrors, blockName)) { this.childBlocks[blockName].setError(error.blockErrors[blockName]); } } diff --git a/client/src/entrypoints/admin/expanding-formset.js b/client/src/entrypoints/admin/expanding-formset.js index 8d5cd43879..a4e987b211 100644 --- a/client/src/entrypoints/admin/expanding-formset.js +++ b/client/src/entrypoints/admin/expanding-formset.js @@ -7,7 +7,7 @@ function buildExpandingFormset(prefix, opts = {}) { let formCount = parseInt(totalFormsInput.val(), 10); if (opts.onInit) { - for (let i = 0; i < formCount; i++) { + for (let i = 0; i < formCount; i += 1) { opts.onInit(i); } } @@ -29,7 +29,7 @@ function buildExpandingFormset(prefix, opts = {}) { if (opts.onAdd) opts.onAdd(formCount); if (opts.onInit) opts.onInit(formCount); - formCount++; + formCount += 1; totalFormsInput.val(formCount); }); } diff --git a/client/src/entrypoints/admin/filtered-select.js b/client/src/entrypoints/admin/filtered-select.js index 3ab49a3a35..e83ebb41cb 100644 --- a/client/src/entrypoints/admin/filtered-select.js +++ b/client/src/entrypoints/admin/filtered-select.js @@ -61,7 +61,7 @@ $(() => { filteredValues = optionData; } else { filteredValues = []; - for (let i = 0; i < optionData.length; i++) { + for (let i = 0; i < optionData.length; i += 1) { if ( optionData[i].value === '' || optionData[i].filterValue.indexOf(chosenFilter) !== -1 @@ -72,7 +72,7 @@ $(() => { } let foundValue = false; - for (let i = 0; i < filteredValues.length; i++) { + for (let i = 0; i < filteredValues.length; i += 1) { const option = $('