From 62905b84d39d3d0f13c43ac1bcb5c76a43ef154e Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 27 Aug 2024 14:25:47 -0400 Subject: [PATCH] eslint: Enable more temporarily-disabled rules (#39057) * `no-undef-init`: One instance fixed. * `no-prototype-builtins`: Swapped a lot of calls to `.hasOwnProperty()` with `Object.hasOwn()`, since all browsers we support appear to support that. * `no-unused-expressions`: Enabled, but with `allowShortCircuit` and `allowTernary` set true since we have a lot of that. Fixing these caught bugs in two different places! Also, moved the `eqeqeq` override ignoring `== null` from "temporarily disabled" to "maybe we want to keep this override permanently", to be decided later. Put the `no-unused-expressions` allowing of short-circuit and ternarys there too. --- .../changelog/add-more-eslint-rules | 5 +++++ .../src/tasks/check-description/index.js | 2 +- .../changelog/add-more-eslint-rules | 5 +++++ .../babel-plugin-replace-textdomain/src/index.js | 2 +- .../changelog/add-more-eslint-rules | 5 +++++ .../boost-score-api/tests/index.test.js | 3 ++- .../components/changelog/add-more-eslint-rules | 5 +++++ .../components/tools/jp-redirect/index.ts | 2 +- .../config/changelog/add-more-eslint-rules | 5 +++++ projects/js-packages/config/src/index.js | 2 +- .../changelog/add-more-eslint-rules | 5 +++++ .../src/GettextExtractor.js | 2 +- .../idc/changelog/add-more-eslint-rules | 5 +++++ .../idc/components/idc-screen/index.jsx | 4 ++-- projects/js-packages/idc/tools/tracking.jsx | 8 ++++---- .../connection/changelog/add-more-eslint-rules | 5 +++++ .../connection/src/identity-crisis/_inc/admin.jsx | 6 +++--- .../changelog/add-more-eslint-rules | 5 +++++ .../common/tour-kit/hooks/use-keydown-handler.ts | 15 ++++++++++++--- .../custom-css/js/core-customizer-css-preview.js | 2 +- .../my-jetpack/_inc/components/idc-modal/index.js | 2 +- .../my-jetpack/changelog/add-more-eslint-rules | 5 +++++ .../search/changelog/add-more-eslint-rules | 5 +++++ .../instant-search/components/search-filters.jsx | 2 +- .../components/tabbed-search-filters.jsx | 2 +- .../videopress/changelog/add-more-eslint-rules | 5 +++++ .../blocks/video/components/player/index.tsx | 2 +- .../utils/map-object-keys-to-camel-case/index.ts | 2 +- .../boost/app/modules/image-guide/src/index.ts | 2 +- .../plugins/boost/changelog/add-more-eslint-rules | 5 +++++ .../tests/e2e/specs/page-cache/page-cache.test.js | 6 +++--- .../debug-helper/changelog/add-more-eslint-rules | 4 ++++ .../debug-helper/modules/inc/js/broken-token.js | 12 ++++++------ .../client/components/jetpack-notices/index.jsx | 5 +++-- .../jetpack-notices/jetpack-connection-errors.jsx | 6 +++--- .../_inc/client/product-descriptions/index.jsx | 2 +- .../product-description/index.jsx | 4 ++-- .../_inc/client/state/connection/reducer.js | 4 ++-- .../_inc/client/state/initial-state/reducer.js | 2 +- .../jetpack/_inc/client/state/site/reducer.js | 6 +++--- .../jetpack/changelog/add-more-eslint-rules | 5 +++++ .../extensions/blocks/button/test/controls.js | 2 +- .../extensions/blocks/map/mapbox-utils/index.js | 2 +- .../extensions/blocks/map/test/controls.js | 2 +- .../blocks/story/player/lib/shadow-root.js | 2 +- .../blocks/subscriptions/deprecated/v1/index.js | 2 +- .../blocks/subscriptions/email-preview.js | 2 +- .../blocks/subscriptions/test/controls.js | 2 +- .../tiled-gallery/deprecated/v1/layout/index.js | 2 +- .../tiled-gallery/deprecated/v2/utils/index.js | 2 +- .../tiled-gallery/deprecated/v3/utils/index.js | 2 +- .../tiled-gallery/deprecated/v4/utils/index.js | 2 +- .../tiled-gallery/deprecated/v6/utils/index.js | 2 +- .../blocks/tiled-gallery/utils/index.js | 2 +- .../components/ai-image/components/carrousel.tsx | 2 +- .../plugins/launchpad-save-modal/index.js | 2 +- .../jetpack/modules/infinite-scroll/infinity.js | 2 +- .../modules/videopress/js/videopress-plupload.js | 2 +- .../modules/widgets/simple-payments/customizer.js | 9 +++++---- projects/plugins/jetpack/modules/wpgroho.js | 2 +- .../tools/static-site-generator-webpack-plugin.js | 2 +- .../protect/changelog/add-more-eslint-rules | 5 +++++ .../src/js/components/marked-lines/index.jsx | 4 ++-- tools/cli/commands/watch.js | 11 +++++------ tools/cli/helpers/json.js | 13 +++++-------- tools/cli/helpers/prefix-stream.js | 3 ++- .../jetpack-live-branches.user.js | 2 +- tools/js-tools/eslintrc/base.js | 7 +++---- 68 files changed, 180 insertions(+), 93 deletions(-) create mode 100644 projects/github-actions/repo-gardening/changelog/add-more-eslint-rules create mode 100644 projects/js-packages/babel-plugin-replace-textdomain/changelog/add-more-eslint-rules create mode 100644 projects/js-packages/boost-score-api/changelog/add-more-eslint-rules create mode 100644 projects/js-packages/components/changelog/add-more-eslint-rules create mode 100644 projects/js-packages/config/changelog/add-more-eslint-rules create mode 100644 projects/js-packages/i18n-check-webpack-plugin/changelog/add-more-eslint-rules create mode 100644 projects/js-packages/idc/changelog/add-more-eslint-rules create mode 100644 projects/packages/connection/changelog/add-more-eslint-rules create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-more-eslint-rules create mode 100644 projects/packages/my-jetpack/changelog/add-more-eslint-rules create mode 100644 projects/packages/search/changelog/add-more-eslint-rules create mode 100644 projects/packages/videopress/changelog/add-more-eslint-rules create mode 100644 projects/plugins/boost/changelog/add-more-eslint-rules create mode 100644 projects/plugins/debug-helper/changelog/add-more-eslint-rules create mode 100644 projects/plugins/jetpack/changelog/add-more-eslint-rules create mode 100644 projects/plugins/protect/changelog/add-more-eslint-rules diff --git a/projects/github-actions/repo-gardening/changelog/add-more-eslint-rules b/projects/github-actions/repo-gardening/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/github-actions/repo-gardening/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/github-actions/repo-gardening/src/tasks/check-description/index.js b/projects/github-actions/repo-gardening/src/tasks/check-description/index.js index c8cfb9e4c5c2c..7a5512750d968 100644 --- a/projects/github-actions/repo-gardening/src/tasks/check-description/index.js +++ b/projects/github-actions/repo-gardening/src/tasks/check-description/index.js @@ -67,7 +67,7 @@ async function hasProgressLabel( octokit, owner, repo, number ) { async function getMilestoneDates( plugin, nextMilestone ) { let releaseDate = 'none scheduled'; let codeFreezeDate; - if ( nextMilestone && nextMilestone.hasOwnProperty( 'due_on' ) && nextMilestone.due_on ) { + if ( nextMilestone && Object.hasOwn( nextMilestone, 'due_on' ) && nextMilestone.due_on ) { releaseDate = moment( nextMilestone.due_on ).format( 'LL' ); // Look for a code freeze date in the milestone description. diff --git a/projects/js-packages/babel-plugin-replace-textdomain/changelog/add-more-eslint-rules b/projects/js-packages/babel-plugin-replace-textdomain/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/js-packages/babel-plugin-replace-textdomain/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/js-packages/babel-plugin-replace-textdomain/src/index.js b/projects/js-packages/babel-plugin-replace-textdomain/src/index.js index 02a26a2d71398..86241269e7486 100644 --- a/projects/js-packages/babel-plugin-replace-textdomain/src/index.js +++ b/projects/js-packages/babel-plugin-replace-textdomain/src/index.js @@ -50,7 +50,7 @@ module.exports = ( babel, opts ) => { callee = callee.expressions[ callee.expressions.length - 1 ]; } const funcName = t.isMemberExpression( callee ) ? callee.property.name : callee.name; - if ( ! functions.hasOwnProperty( funcName ) ) { + if ( ! Object.hasOwn( functions, funcName ) ) { return; } const idx = functions[ funcName ]; diff --git a/projects/js-packages/boost-score-api/changelog/add-more-eslint-rules b/projects/js-packages/boost-score-api/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/js-packages/boost-score-api/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/js-packages/boost-score-api/tests/index.test.js b/projects/js-packages/boost-score-api/tests/index.test.js index 16f3ad24ccf98..3453f99e98bd2 100644 --- a/projects/js-packages/boost-score-api/tests/index.test.js +++ b/projects/js-packages/boost-score-api/tests/index.test.js @@ -82,7 +82,8 @@ describe( 'getScoreMovementPercentage', () => { expect( getScoreMovementPercentage( changedMockData.scores ) ).toBe( 0 ); - ( changedMockData.scores.noBoost.desktop = 80 ), ( changedMockData.scores.noBoost.mobile = 70 ); + changedMockData.scores.noBoost.desktop = 80; + changedMockData.scores.noBoost.mobile = 70; expect( getScoreMovementPercentage( changedMockData.scores ) ).toBe( 13 ); } ); diff --git a/projects/js-packages/components/changelog/add-more-eslint-rules b/projects/js-packages/components/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/js-packages/components/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/js-packages/components/tools/jp-redirect/index.ts b/projects/js-packages/components/tools/jp-redirect/index.ts index c2033c2e63343..0058c14d218b2 100644 --- a/projects/js-packages/components/tools/jp-redirect/index.ts +++ b/projects/js-packages/components/tools/jp-redirect/index.ts @@ -45,7 +45,7 @@ export default function getRedirectUrl( source: string, args: GetRedirectUrlArgs if ( ! Object.keys( queryVars ).includes( 'site' ) && typeof jetpack_redirects !== 'undefined' && - jetpack_redirects.hasOwnProperty( 'currentSiteRawUrl' ) + Object.hasOwn( jetpack_redirects, 'currentSiteRawUrl' ) ) { queryVars.site = jetpack_redirects.currentBlogID ?? jetpack_redirects.currentSiteRawUrl; } diff --git a/projects/js-packages/config/changelog/add-more-eslint-rules b/projects/js-packages/config/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/js-packages/config/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/js-packages/config/src/index.js b/projects/js-packages/config/src/index.js index 44a326a2edcc6..e7fd2d8b03b61 100644 --- a/projects/js-packages/config/src/index.js +++ b/projects/js-packages/config/src/index.js @@ -12,7 +12,7 @@ try { } const jetpackConfigHas = key => { - return jetpackConfig.hasOwnProperty( key ); + return Object.hasOwn( jetpackConfig, key ); }; const jetpackConfigGet = key => { diff --git a/projects/js-packages/i18n-check-webpack-plugin/changelog/add-more-eslint-rules b/projects/js-packages/i18n-check-webpack-plugin/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/js-packages/i18n-check-webpack-plugin/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/js-packages/i18n-check-webpack-plugin/src/GettextExtractor.js b/projects/js-packages/i18n-check-webpack-plugin/src/GettextExtractor.js index 6cd362e8f2da1..fb8f6e06c5533 100644 --- a/projects/js-packages/i18n-check-webpack-plugin/src/GettextExtractor.js +++ b/projects/js-packages/i18n-check-webpack-plugin/src/GettextExtractor.js @@ -156,7 +156,7 @@ class GettextExtractor { return; } - if ( ! this.#functions.hasOwnProperty( callee.name ) ) { + if ( ! Object.hasOwn( this.#functions, callee.name ) ) { return; } diff --git a/projects/js-packages/idc/changelog/add-more-eslint-rules b/projects/js-packages/idc/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/js-packages/idc/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/js-packages/idc/components/idc-screen/index.jsx b/projects/js-packages/idc/components/idc-screen/index.jsx index 054b4ecbb80d9..0336fc13345e1 100644 --- a/projects/js-packages/idc/components/idc-screen/index.jsx +++ b/projects/js-packages/idc/components/idc-screen/index.jsx @@ -55,11 +55,11 @@ const IDCScreen = props => { initializeAnalytics( tracksEventData, tracksUserData ); if ( tracksEventData ) { - if ( tracksEventData.hasOwnProperty( 'isAdmin' ) && tracksEventData.isAdmin ) { + if ( Object.hasOwn( tracksEventData, 'isAdmin' ) && tracksEventData.isAdmin ) { trackAndBumpMCStats( 'notice_view' ); } else { trackAndBumpMCStats( 'non_admin_notice_view', { - page: tracksEventData.hasOwnProperty( 'currentScreen' ) + page: Object.hasOwn( tracksEventData, 'currentScreen' ) ? tracksEventData.currentScreen : false, } ); diff --git a/projects/js-packages/idc/tools/tracking.jsx b/projects/js-packages/idc/tools/tracking.jsx index 37af2592521ea..315f919dd834b 100644 --- a/projects/js-packages/idc/tools/tracking.jsx +++ b/projects/js-packages/idc/tools/tracking.jsx @@ -9,18 +9,18 @@ import analytics from '@automattic/jetpack-analytics'; export function initializeAnalytics( tracksEventData, tracksUserData ) { if ( tracksUserData && - tracksUserData.hasOwnProperty( 'userid' ) && - tracksUserData.hasOwnProperty( 'username' ) + Object.hasOwn( tracksUserData, 'userid' ) && + Object.hasOwn( tracksUserData, 'username' ) ) { analytics.initialize( tracksUserData.userid, tracksUserData.username ); } if ( tracksEventData ) { - if ( tracksEventData.hasOwnProperty( 'blogID' ) ) { + if ( Object.hasOwn( tracksEventData, 'blogID' ) ) { analytics.assignSuperProps( { blog_id: tracksEventData.blogID } ); } - if ( tracksEventData.hasOwnProperty( 'platform' ) ) { + if ( Object.hasOwn( tracksEventData, 'platform' ) ) { analytics.assignSuperProps( { platform: tracksEventData.platform } ); } } diff --git a/projects/packages/connection/changelog/add-more-eslint-rules b/projects/packages/connection/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/packages/connection/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/packages/connection/src/identity-crisis/_inc/admin.jsx b/projects/packages/connection/src/identity-crisis/_inc/admin.jsx index 1f899d7932098..8d731738722e0 100644 --- a/projects/packages/connection/src/identity-crisis/_inc/admin.jsx +++ b/projects/packages/connection/src/identity-crisis/_inc/admin.jsx @@ -9,7 +9,7 @@ import './style.scss'; * The initial renderer function. */ function render() { - if ( ! window.hasOwnProperty( 'JP_IDENTITY_CRISIS__INITIAL_STATE' ) ) { + if ( ! Object.hasOwn( window, 'JP_IDENTITY_CRISIS__INITIAL_STATE' ) ) { return; } @@ -47,10 +47,10 @@ function render() { tracksUserData={ tracksUserData || {} } tracksEventData={ tracksEventData } customContent={ - consumerData.hasOwnProperty( 'customContent' ) ? consumerData.customContent : {} + Object.hasOwn( consumerData, 'customContent' ) ? consumerData.customContent : {} } isAdmin={ isAdmin } - logo={ consumerData.hasOwnProperty( 'logo' ) ? consumerData.logo : undefined } + logo={ Object.hasOwn( consumerData, 'logo' ) ? consumerData.logo : undefined } possibleDynamicSiteUrlDetected={ possibleDynamicSiteUrlDetected } isDevelopmentSite={ isDevelopmentSite } /> diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-more-eslint-rules b/projects/packages/jetpack-mu-wpcom/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/packages/jetpack-mu-wpcom/src/common/tour-kit/hooks/use-keydown-handler.ts b/projects/packages/jetpack-mu-wpcom/src/common/tour-kit/hooks/use-keydown-handler.ts index 6ea129fe08f2e..1cdf93219b40e 100644 --- a/projects/packages/jetpack-mu-wpcom/src/common/tour-kit/hooks/use-keydown-handler.ts +++ b/projects/packages/jetpack-mu-wpcom/src/common/tour-kit/hooks/use-keydown-handler.ts @@ -20,13 +20,22 @@ const useKeydownHandler = ( { onEscape, onArrowRight, onArrowLeft }: Props ): vo switch ( event.key ) { case 'Escape': - onEscape && ( onEscape(), ( handled = true ) ); + if ( onEscape ) { + onEscape(); + handled = true; + } break; case 'ArrowRight': - onArrowRight && ( onArrowRight(), ( handled = true ) ); + if ( onArrowRight ) { + onArrowRight(); + handled = true; + } break; case 'ArrowLeft': - onArrowLeft && ( onArrowLeft(), ( handled = true ) ); + if ( onArrowLeft ) { + onArrowLeft(); + handled = true; + } break; default: break; diff --git a/projects/packages/jetpack-mu-wpcom/src/features/custom-css/custom-css/js/core-customizer-css-preview.js b/projects/packages/jetpack-mu-wpcom/src/features/custom-css/custom-css/js/core-customizer-css-preview.js index 51bf49d713f2a..b4b702e369cd4 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/custom-css/custom-css/js/core-customizer-css-preview.js +++ b/projects/packages/jetpack-mu-wpcom/src/features/custom-css/custom-css/js/core-customizer-css-preview.js @@ -20,7 +20,7 @@ // Sass or Less require Partial -- so ajax call to get it from PHP. // We can explicitly override for specific providers by testing if `'sass' === preprocessor` - if ( jpCustomizerCssPreview.preprocessors.hasOwnProperty( preprocessor ) ) { + if ( Object.hasOwn( jpCustomizerCssPreview.preprocessors, preprocessor ) ) { return api.selectiveRefresh.Partial.prototype.refresh.call( partial ); } diff --git a/projects/packages/my-jetpack/_inc/components/idc-modal/index.js b/projects/packages/my-jetpack/_inc/components/idc-modal/index.js index c3184daa30be8..75f61158b362c 100644 --- a/projects/packages/my-jetpack/_inc/components/idc-modal/index.js +++ b/projects/packages/my-jetpack/_inc/components/idc-modal/index.js @@ -16,7 +16,7 @@ function IDCModal() { return null; } - if ( ! window.hasOwnProperty( 'JP_IDENTITY_CRISIS__INITIAL_STATE' ) ) { + if ( ! Object.hasOwn( window, 'JP_IDENTITY_CRISIS__INITIAL_STATE' ) ) { return null; } diff --git a/projects/packages/my-jetpack/changelog/add-more-eslint-rules b/projects/packages/my-jetpack/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/packages/my-jetpack/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/packages/search/changelog/add-more-eslint-rules b/projects/packages/search/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/packages/search/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/packages/search/src/instant-search/components/search-filters.jsx b/projects/packages/search/src/instant-search/components/search-filters.jsx index ce9f773f54b42..599aef5498470 100644 --- a/projects/packages/search/src/instant-search/components/search-filters.jsx +++ b/projects/packages/search/src/instant-search/components/search-filters.jsx @@ -49,7 +49,7 @@ class SearchFilters extends Component { ); renderStaticFilterComponent = configuration => { - if ( configuration.hasOwnProperty( 'visible' ) && ! configuration.visible ) { + if ( Object.hasOwn( configuration, 'visible' ) && ! configuration.visible ) { return null; } diff --git a/projects/packages/search/src/instant-search/components/tabbed-search-filters.jsx b/projects/packages/search/src/instant-search/components/tabbed-search-filters.jsx index cbc990a5dbf06..ddaaea3f3b870 100644 --- a/projects/packages/search/src/instant-search/components/tabbed-search-filters.jsx +++ b/projects/packages/search/src/instant-search/components/tabbed-search-filters.jsx @@ -13,7 +13,7 @@ class TabbedSearchFilters extends Component { }; renderStaticFilterComponent = configuration => { - if ( configuration.hasOwnProperty( 'visible' ) && ! configuration.visible ) { + if ( Object.hasOwn( configuration, 'visible' ) && ! configuration.visible ) { return null; } diff --git a/projects/packages/videopress/changelog/add-more-eslint-rules b/projects/packages/videopress/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/packages/videopress/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/packages/videopress/src/client/block-editor/blocks/video/components/player/index.tsx b/projects/packages/videopress/src/client/block-editor/blocks/video/components/player/index.tsx index c60e8eba1c1f2..6c8ea329fc27e 100644 --- a/projects/packages/videopress/src/client/block-editor/blocks/video/components/player/index.tsx +++ b/projects/packages/videopress/src/client/block-editor/blocks/video/components/player/index.tsx @@ -160,7 +160,7 @@ export default function Player( { const { atTime, previewOnHover, previewAtTime, previewLoopDuration, type } = attributes.posterData; - let timeToSetPlayerPosition = undefined; + let timeToSetPlayerPosition; if ( type === 'video-frame' ) { if ( previewOnHover ) { timeToSetPlayerPosition = previewAtTime; diff --git a/projects/packages/videopress/src/client/utils/map-object-keys-to-camel-case/index.ts b/projects/packages/videopress/src/client/utils/map-object-keys-to-camel-case/index.ts index a09f114eeed67..095228d70f6f2 100644 --- a/projects/packages/videopress/src/client/utils/map-object-keys-to-camel-case/index.ts +++ b/projects/packages/videopress/src/client/utils/map-object-keys-to-camel-case/index.ts @@ -32,7 +32,7 @@ export function mapObjectKeysToCamel( originalObject, deleteOriginalProp = false const object = Object.assign( {}, originalObject ); for ( const key in object ) { - if ( object.hasOwnProperty( key ) && isSnake( key ) ) { + if ( Object.hasOwn( object, key ) && isSnake( key ) ) { object[ snakeToCamel( key ) ] = object[ key ]; if ( deleteOriginalProp ) { diff --git a/projects/plugins/boost/app/modules/image-guide/src/index.ts b/projects/plugins/boost/app/modules/image-guide/src/index.ts index 60ac6042d6077..ac73bdb538e13 100644 --- a/projects/plugins/boost/app/modules/image-guide/src/index.ts +++ b/projects/plugins/boost/app/modules/image-guide/src/index.ts @@ -30,7 +30,7 @@ async function fetchWeightUsingProxy( url: string ): Promise< Response > { // If the JSON data contains the content length, create a new response object with the JSON headers and the original response body. const headers = new Headers(); for ( const key in json.data ) { - if ( json.data.hasOwnProperty( key ) ) { + if ( Object.hasOwn( json.data, key ) ) { headers.set( key, json.data[ key ] ); } } diff --git a/projects/plugins/boost/changelog/add-more-eslint-rules b/projects/plugins/boost/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/plugins/boost/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/plugins/boost/tests/e2e/specs/page-cache/page-cache.test.js b/projects/plugins/boost/tests/e2e/specs/page-cache/page-cache.test.js index c11a43f319288..4d5fda06826c2 100644 --- a/projects/plugins/boost/tests/e2e/specs/page-cache/page-cache.test.js +++ b/projects/plugins/boost/tests/e2e/specs/page-cache/page-cache.test.js @@ -58,7 +58,7 @@ test.describe( 'Cache module', () => { } expect( - response.headers().hasOwnProperty( 'X-Jetpack-Boost-Cache'.toLowerCase() ), + Object.hasOwn( response.headers(), 'X-Jetpack-Boost-Cache'.toLowerCase() ), 'Page Cache header should not be present' ).toBeFalsy(); } ); @@ -122,13 +122,13 @@ test.describe( 'Cache module', () => { // First visit should always be a miss. if ( totalVisits === 1 ) { expect( - responseHeaders.hasOwnProperty( cacheHeaderName ) && + Object.hasOwn( responseHeaders, cacheHeaderName ) && responseHeaders[ cacheHeaderName ] === 'miss', 'Page Cache header should be set to miss on first visit.' ).toBeTruthy(); } else { expect( - responseHeaders.hasOwnProperty( cacheHeaderName ) && + Object.hasOwn( responseHeaders, cacheHeaderName ) && responseHeaders[ cacheHeaderName ] === 'hit', 'Page Cache header should be set to hit on second visit.' ).toBeTruthy(); diff --git a/projects/plugins/debug-helper/changelog/add-more-eslint-rules b/projects/plugins/debug-helper/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..b295a1d1a8826 --- /dev/null +++ b/projects/plugins/debug-helper/changelog/add-more-eslint-rules @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Actually call `e.preventDefault()` in various 'click' handlers. diff --git a/projects/plugins/debug-helper/modules/inc/js/broken-token.js b/projects/plugins/debug-helper/modules/inc/js/broken-token.js index c716f3301ec54..29a865812a8d8 100644 --- a/projects/plugins/debug-helper/modules/inc/js/broken-token.js +++ b/projects/plugins/debug-helper/modules/inc/js/broken-token.js @@ -8,12 +8,12 @@ class BrokenToken { ); this.setCustomBlogTokenButton.addEventListener( 'click', e => { - e.preventDefault; + e.preventDefault(); this.displayEditBlogToken(); } ); this.cancelEditBlogTokenButton.addEventListener( 'click', e => { - e.preventDefault; + e.preventDefault(); this.cancelEditBlogToken(); } ); @@ -26,12 +26,12 @@ class BrokenToken { ); this.setCustomUserTokenButton.addEventListener( 'click', e => { - e.preventDefault; + e.preventDefault(); this.displayEditUserToken(); } ); this.cancelEditUserTokenButton.addEventListener( 'click', e => { - e.preventDefault; + e.preventDefault(); this.cancelEditUserToken(); } ); @@ -41,12 +41,12 @@ class BrokenToken { this.cancelEditBlogIDButton = document.getElementById( 'broken-token-cancel-edit-blog-id' ); this.setCustomBlogIDButton.addEventListener( 'click', e => { - e.preventDefault; + e.preventDefault(); this.displayEditBlogID(); } ); this.cancelEditBlogIDButton.addEventListener( 'click', e => { - e.preventDefault; + e.preventDefault(); this.cancelEditBlogID(); } ); } diff --git a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx index 808bdb3bc04f1..c70ecf81b2e3d 100644 --- a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx +++ b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/index.jsx @@ -185,7 +185,8 @@ class JetpackNotices extends React.Component { this.state = { isMasterbarNoticeDismissed: cookieParsed && - cookieParsed.hasOwnProperty( + Object.hasOwn( + cookieParsed, 'jetpack_deprecate_dismissed[jetpack-masterbar-admin-removal-notice]' ) && '1' === @@ -209,7 +210,7 @@ class JetpackNotices extends React.Component { render() { const siteDataErrors = this.props.siteDataErrors.filter( error => - error.hasOwnProperty( 'action' ) + Object.hasOwn( error, 'action' ) ); const isUserConnectScreen = this.props.location.pathname.startsWith( '/connect-user' ); diff --git a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/jetpack-connection-errors.jsx b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/jetpack-connection-errors.jsx index 5175343774e08..0a73fbb68a955 100644 --- a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/jetpack-connection-errors.jsx +++ b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/jetpack-connection-errors.jsx @@ -56,7 +56,7 @@ export default class JetpackConnectionErrors extends React.Component { error.action, error.message, error.code, - error.hasOwnProperty( 'data' ) ? error.data : {}, + Object.hasOwn( error, 'data' ) ? error.data : {}, supportURl ); @@ -67,10 +67,10 @@ export default class JetpackConnectionErrors extends React.Component { render() { const errorsToDisplay = {}; - const errors = this.props.errors.filter( error => error.hasOwnProperty( 'action' ) ); + const errors = this.props.errors.filter( error => Object.hasOwn( error, 'action' ) ); for ( const error of errors ) { - if ( ! errorsToDisplay.hasOwnProperty( error.action ) ) { + if ( ! Object.hasOwn( errorsToDisplay, error.action ) ) { errorsToDisplay[ error.action ] = error; } } diff --git a/projects/plugins/jetpack/_inc/client/product-descriptions/index.jsx b/projects/plugins/jetpack/_inc/client/product-descriptions/index.jsx index c4fc3eb864be5..6c5134ada0ea2 100644 --- a/projects/plugins/jetpack/_inc/client/product-descriptions/index.jsx +++ b/projects/plugins/jetpack/_inc/client/product-descriptions/index.jsx @@ -24,7 +24,7 @@ const ProductDescriptions = props => { if ( ! isLoading ) { Object.values( SUPPORTED_PRODUCTS ).forEach( function ( key ) { - if ( ! products.hasOwnProperty( key ) ) { + if ( ! Object.hasOwn( products, key ) ) { return; } diff --git a/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/index.jsx b/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/index.jsx index a86bd48175946..57a41fa2f9f76 100644 --- a/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/index.jsx +++ b/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/index.jsx @@ -27,7 +27,7 @@ const getRelatedProductPlan = ( product, availableProductsAndPlans ) => { if ( isEmpty( product.includedInPlans ) || - ! availableProductsAndPlans.hasOwnProperty( upsellPlan ) || + ! Object.hasOwn( availableProductsAndPlans, upsellPlan ) || ! product.includedInPlans.includes( upsellPlan ) ) { return false; @@ -38,7 +38,7 @@ const getRelatedProductPlan = ( product, availableProductsAndPlans ) => { const renderProduct = ( product, offers, priority, hasRelatedPlan ) => { const illustration = - ! hasRelatedPlan && productIllustrations.hasOwnProperty( product.key ) + ! hasRelatedPlan && Object.hasOwn( productIllustrations, product.key ) ? productIllustrations[ product.key ] : undefined; let cta, icon; diff --git a/projects/plugins/jetpack/_inc/client/state/connection/reducer.js b/projects/plugins/jetpack/_inc/client/state/connection/reducer.js index 8e30ae1d751f0..3062aaff5c056 100644 --- a/projects/plugins/jetpack/_inc/client/state/connection/reducer.js +++ b/projects/plugins/jetpack/_inc/client/state/connection/reducer.js @@ -300,7 +300,7 @@ export function isConnectingUser( state ) { * @return {string|null} string if feature label exists, false otherwise. */ export function getConnectingUserFeatureLabel( state ) { - return state.jetpack.connection.requests.hasOwnProperty( 'connectingUserFeatureLabel' ) + return Object.hasOwn( state.jetpack.connection.requests, 'connectingUserFeatureLabel' ) ? state.jetpack.connection.requests.connectingUserFeatureLabel : null; } @@ -312,7 +312,7 @@ export function getConnectingUserFeatureLabel( state ) { * @return {string|null} string if "from" value exists, false otherwise. */ export function getConnectingUserFrom( state ) { - return state.jetpack.connection.requests.hasOwnProperty( 'connectingUserFrom' ) + return Object.hasOwn( state.jetpack.connection.requests, 'connectingUserFrom' ) ? state.jetpack.connection.requests.connectingUserFrom : null; } diff --git a/projects/plugins/jetpack/_inc/client/state/initial-state/reducer.js b/projects/plugins/jetpack/_inc/client/state/initial-state/reducer.js index d7a45a876e9bf..2ae0caf2a9f54 100644 --- a/projects/plugins/jetpack/_inc/client/state/initial-state/reducer.js +++ b/projects/plugins/jetpack/_inc/client/state/initial-state/reducer.js @@ -652,7 +652,7 @@ export function getInitialRecommendationsStep( state ) { */ export function getConnectionErrors( state ) { return get( state.jetpack.initialState, [ 'connectionStatus', 'errors' ], [] ).filter( error => - error.hasOwnProperty( 'action' ) + Object.hasOwn( error, 'action' ) ); } diff --git a/projects/plugins/jetpack/_inc/client/state/site/reducer.js b/projects/plugins/jetpack/_inc/client/state/site/reducer.js index edc49435cbe0d..d74135abe1cd5 100644 --- a/projects/plugins/jetpack/_inc/client/state/site/reducer.js +++ b/projects/plugins/jetpack/_inc/client/state/site/reducer.js @@ -167,14 +167,14 @@ export const errors = ( state = {}, action ) => { } return assign( {}, state, { - message: action.error.hasOwnProperty( 'response' ) + message: Object.hasOwn( action.error, 'response' ) ? action.error.response.message : defaultErrorMessage, action: resolveAction, - code: action.error.hasOwnProperty( 'response' ) + code: Object.hasOwn( action.error, 'response' ) ? action.error.response.code : 'fetch_site_data_fail_other', - data: action.error.hasOwnProperty( 'response' ) ? action.error.response.data : {}, + data: Object.hasOwn( action.error, 'response' ) ? action.error.response.data : {}, } ); default: return state; diff --git a/projects/plugins/jetpack/changelog/add-more-eslint-rules b/projects/plugins/jetpack/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..0f8d7bc5efd93 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/plugins/jetpack/extensions/blocks/button/test/controls.js b/projects/plugins/jetpack/extensions/blocks/button/test/controls.js index 7d19fb1c31d2e..cb282873a9761 100644 --- a/projects/plugins/jetpack/extensions/blocks/button/test/controls.js +++ b/projects/plugins/jetpack/extensions/blocks/button/test/controls.js @@ -21,7 +21,7 @@ beforeAll( () => { 'blockEditor.useSetting.before', 'extensions/blocks/button/test/controls', ( value, path ) => { - if ( overrideSettings.hasOwnProperty( path ) ) { + if ( Object.hasOwn( overrideSettings, path ) ) { return overrideSettings[ path ]; } return value; diff --git a/projects/plugins/jetpack/extensions/blocks/map/mapbox-utils/index.js b/projects/plugins/jetpack/extensions/blocks/map/mapbox-utils/index.js index 621f39398278a..7646b76e9b6ca 100644 --- a/projects/plugins/jetpack/extensions/blocks/map/mapbox-utils/index.js +++ b/projects/plugins/jetpack/extensions/blocks/map/mapbox-utils/index.js @@ -1,5 +1,5 @@ export const googlePoint2Mapbox = google_point => - google_point.hasOwnProperty( 'lat' ) && google_point.hasOwnProperty( 'lng' ) + Object.hasOwn( google_point, 'lat' ) && Object.hasOwn( google_point, 'lng' ) ? google_point // Already a valid Mapbox point. : { // Legacy point, supported here to avoid block deprecation. diff --git a/projects/plugins/jetpack/extensions/blocks/map/test/controls.js b/projects/plugins/jetpack/extensions/blocks/map/test/controls.js index 6bc990eb5a577..b178c98a4f90f 100644 --- a/projects/plugins/jetpack/extensions/blocks/map/test/controls.js +++ b/projects/plugins/jetpack/extensions/blocks/map/test/controls.js @@ -20,7 +20,7 @@ beforeAll( () => { 'blockEditor.useSetting.before', 'extensions/blocks/button/test/controls', ( value, path ) => { - if ( overrideSettings.hasOwnProperty( path ) ) { + if ( Object.hasOwn( overrideSettings, path ) ) { return overrideSettings[ path ]; } return value; diff --git a/projects/plugins/jetpack/extensions/blocks/story/player/lib/shadow-root.js b/projects/plugins/jetpack/extensions/blocks/story/player/lib/shadow-root.js index 03c217d964fa0..d16062f4f567e 100644 --- a/projects/plugins/jetpack/extensions/blocks/story/player/lib/shadow-root.js +++ b/projects/plugins/jetpack/extensions/blocks/story/player/lib/shadow-root.js @@ -1,7 +1,7 @@ import { createPortal, useCallback, useEffect, useState } from '@wordpress/element'; export const shadowRootSupported = - window && window.Element && window.Element.prototype.hasOwnProperty( 'attachShadow' ); + window && window.Element && Object.hasOwn( window.Element.prototype, 'attachShadow' ); export default function ShadowRoot( { enabled, diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/deprecated/v1/index.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/deprecated/v1/index.js index 7a034bf5e7514..e836b8ba35191 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/deprecated/v1/index.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/deprecated/v1/index.js @@ -21,7 +21,7 @@ export default { }, isEligible: attr => { // Newer block versions do not have `subscribeButton` attribute. - if ( ! attr.hasOwnProperty( 'subscribeButton' ) || ! isEmpty( attr.subscribeButton ) ) { + if ( ! Object.hasOwn( attr, 'subscribeButton' ) || ! isEmpty( attr.subscribeButton ) ) { return false; } return true; diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js index 6c12b9d6f7abd..f22b79d9138a0 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js @@ -273,7 +273,7 @@ export function NewsletterPreviewModal( { isOpen, onClose, postId } ) { ); useEffect( () => { - if ( isOpen && ! previewCache.hasOwnProperty( selectedAccess ) ) { + if ( isOpen && ! Object.hasOwn( previewCache, selectedAccess ) ) { fetchPreview( selectedAccess ); } else if ( isOpen ) { setIsLoading( false ); diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js index 77a52f9da4a9e..4116dae5cfc67 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js @@ -23,7 +23,7 @@ beforeAll( () => { 'blockEditor.useSetting.before', 'extensions/blocks/button/test/controls', ( value, path ) => { - if ( overrideSettings.hasOwnProperty( path ) ) { + if ( Object.hasOwn( overrideSettings, path ) ) { return overrideSettings[ path ]; } return value; diff --git a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v1/layout/index.js b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v1/layout/index.js index f10bfcd9eb182..225f208c6c4a9 100644 --- a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v1/layout/index.js +++ b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v1/layout/index.js @@ -130,7 +130,7 @@ function photonWpcomImage( url, opts = {} ) { // Build query for ( const [ k, v ] of Object.entries( opts ) ) { urlObj.searchParams.set( - photonLibMappings.hasOwnProperty( k ) ? photonLibMappings[ k ] : k, + Object.hasOwn( photonLibMappings, k ) ? photonLibMappings[ k ] : k, v ); } diff --git a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v2/utils/index.js b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v2/utils/index.js index 8cb05e2b2a457..35c7fed679c04 100644 --- a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v2/utils/index.js +++ b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v2/utils/index.js @@ -145,7 +145,7 @@ function photonWpcomImage( url, opts = {} ) { // Build query for ( const [ k, v ] of Object.entries( opts ) ) { urlObj.searchParams.set( - photonLibMappings.hasOwnProperty( k ) ? photonLibMappings[ k ] : k, + Object.hasOwn( photonLibMappings, k ) ? photonLibMappings[ k ] : k, v ); } diff --git a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v3/utils/index.js b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v3/utils/index.js index d9b16d62baae8..bd5e423839eb8 100644 --- a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v3/utils/index.js +++ b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v3/utils/index.js @@ -146,7 +146,7 @@ function photonWpcomImage( url, opts = {} ) { // Build query for ( const [ k, v ] of Object.entries( opts ) ) { urlObj.searchParams.set( - photonLibMappings.hasOwnProperty( k ) ? photonLibMappings[ k ] : k, + Object.hasOwn( photonLibMappings, k ) ? photonLibMappings[ k ] : k, v ); } diff --git a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v4/utils/index.js b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v4/utils/index.js index 18380ce3d602f..14c28fe86ca47 100644 --- a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v4/utils/index.js +++ b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v4/utils/index.js @@ -153,7 +153,7 @@ function photonWpcomImage( url, opts = {} ) { // Build query for ( const [ k, v ] of Object.entries( opts ) ) { urlObj.searchParams.set( - photonLibMappings.hasOwnProperty( k ) ? photonLibMappings[ k ] : k, + Object.hasOwn( photonLibMappings, k ) ? photonLibMappings[ k ] : k, v ); } diff --git a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v6/utils/index.js b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v6/utils/index.js index 18380ce3d602f..14c28fe86ca47 100644 --- a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v6/utils/index.js +++ b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/deprecated/v6/utils/index.js @@ -153,7 +153,7 @@ function photonWpcomImage( url, opts = {} ) { // Build query for ( const [ k, v ] of Object.entries( opts ) ) { urlObj.searchParams.set( - photonLibMappings.hasOwnProperty( k ) ? photonLibMappings[ k ] : k, + Object.hasOwn( photonLibMappings, k ) ? photonLibMappings[ k ] : k, v ); } diff --git a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/utils/index.js b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/utils/index.js index d605dc369ec28..9a4e4f2ac3c6e 100644 --- a/projects/plugins/jetpack/extensions/blocks/tiled-gallery/utils/index.js +++ b/projects/plugins/jetpack/extensions/blocks/tiled-gallery/utils/index.js @@ -153,7 +153,7 @@ function photonWpcomImage( url, opts = {} ) { // Build query for ( const [ k, v ] of Object.entries( opts ) ) { urlObj.searchParams.set( - photonLibMappings.hasOwnProperty( k ) ? photonLibMappings[ k ] : k, + Object.hasOwn( photonLibMappings, k ) ? photonLibMappings[ k ] : k, v ); } diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/carrousel.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/carrousel.tsx index 800befe5559cc..a8d97c7c362eb 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/carrousel.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/carrousel.tsx @@ -82,7 +82,7 @@ export default function Carrousel( { ); - const total = images?.filter?.( item => item?.generating || item.hasOwnProperty( 'image' ) ) + const total = images?.filter?.( item => item?.generating || Object.hasOwn( item, 'image' ) ) ?.length; const actual = current === 0 && total === 0 ? 0 : current + 1; diff --git a/projects/plugins/jetpack/extensions/plugins/launchpad-save-modal/index.js b/projects/plugins/jetpack/extensions/plugins/launchpad-save-modal/index.js index 6bd8a22727d09..4415b46466752 100644 --- a/projects/plugins/jetpack/extensions/plugins/launchpad-save-modal/index.js +++ b/projects/plugins/jetpack/extensions/plugins/launchpad-save-modal/index.js @@ -32,7 +32,7 @@ const updateLaunchpadSaveModalBrowserConfig = config => { } for ( const editableProp of LAUNCHPAD_SAVE_MODAL_EDITABLE_PROPS ) { - if ( config.hasOwnProperty( editableProp ) ) { + if ( Object.hasOwn( config, editableProp ) ) { window.Jetpack_LaunchpadSaveModal[ editableProp ] = config[ editableProp ]; } } diff --git a/projects/plugins/jetpack/modules/infinite-scroll/infinity.js b/projects/plugins/jetpack/modules/infinite-scroll/infinity.js index 7f3f422a7f6d6..e880c15bfc9c4 100644 --- a/projects/plugins/jetpack/modules/infinite-scroll/infinity.js +++ b/projects/plugins/jetpack/modules/infinite-scroll/infinity.js @@ -129,7 +129,7 @@ } for ( var key in arguments[ i ] ) { - if ( arguments[ i ].hasOwnProperty( key ) ) { + if ( Object.hasOwn( arguments[ i ], key ) ) { out[ key ] = arguments[ i ][ key ]; } } diff --git a/projects/plugins/jetpack/modules/videopress/js/videopress-plupload.js b/projects/plugins/jetpack/modules/videopress/js/videopress-plupload.js index 99efce6fda2f7..1418b16c57ea1 100644 --- a/projects/plugins/jetpack/modules/videopress/js/videopress-plupload.js +++ b/projects/plugins/jetpack/modules/videopress/js/videopress-plupload.js @@ -99,7 +99,7 @@ window.wp = window.wp || {}; ! isIE && 'flash' === plupload.predictRuntime( this.plupload ) && ( ! this.plupload.required_features || - ! this.plupload.required_features.hasOwnProperty( 'send_binary_string' ) ) + ! Object.hasOwn( this.plupload.required_features, 'send_binary_string' ) ) ) { this.plupload.required_features = this.plupload.required_features || {}; this.plupload.required_features.send_binary_string = true; diff --git a/projects/plugins/jetpack/modules/widgets/simple-payments/customizer.js b/projects/plugins/jetpack/modules/widgets/simple-payments/customizer.js index cef1db3ca143b..08dfffe4fa7b2 100644 --- a/projects/plugins/jetpack/modules/widgets/simple-payments/customizer.js +++ b/projects/plugins/jetpack/modules/widgets/simple-payments/customizer.js @@ -301,9 +301,10 @@ } var productEmail = widgetForm.find( '.jetpack-simple-payments-form-product-email' ).val(); - var isProductEmailValid = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test( - productEmail - ); + var isProductEmailValid = + /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test( + productEmail + ); if ( ! productEmail || ! isProductEmailValid ) { widgetForm.find( '.jetpack-simple-payments-form-product-email' ).addClass( 'invalid' ); errors = true; @@ -378,7 +379,7 @@ }; data.forEach( function ( item ) { - if ( validCodes.hasOwnProperty( item.code ) ) { + if ( Object.hasOwn( validCodes, item.code ) ) { widgetForm .find( '.jetpack-simple-payments-form-' + validCodes[ item.code ] ) .addClass( 'invalid' ); diff --git a/projects/plugins/jetpack/modules/wpgroho.js b/projects/plugins/jetpack/modules/wpgroho.js index 9261fe0c1a659..33c79d5afc90f 100644 --- a/projects/plugins/jetpack/modules/wpgroho.js +++ b/projects/plugins/jetpack/modules/wpgroho.js @@ -7,7 +7,7 @@ if ( ! arguments[ i ] ) continue; for ( var key in arguments[ i ] ) { - if ( arguments[ i ].hasOwnProperty( key ) ) out[ key ] = arguments[ i ][ key ]; + if ( Object.hasOwn( arguments[ i ], key ) ) out[ key ] = arguments[ i ][ key ]; } } diff --git a/projects/plugins/jetpack/tools/static-site-generator-webpack-plugin.js b/projects/plugins/jetpack/tools/static-site-generator-webpack-plugin.js index be3c81d0b1ac4..a9bab50abf2a5 100644 --- a/projects/plugins/jetpack/tools/static-site-generator-webpack-plugin.js +++ b/projects/plugins/jetpack/tools/static-site-generator-webpack-plugin.js @@ -34,7 +34,7 @@ class StaticSiteGeneratorWebpackPlugin { /* includeGlobals: */ true ); - if ( render.hasOwnProperty( 'default' ) ) { + if ( Object.hasOwn( render, 'default' ) ) { render = render.default; } diff --git a/projects/plugins/protect/changelog/add-more-eslint-rules b/projects/plugins/protect/changelog/add-more-eslint-rules new file mode 100644 index 0000000000000..2b32cb03e644c --- /dev/null +++ b/projects/plugins/protect/changelog/add-more-eslint-rules @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix new eslint sniffs. Should be no change in functionality. + + diff --git a/projects/plugins/protect/src/js/components/marked-lines/index.jsx b/projects/plugins/protect/src/js/components/marked-lines/index.jsx index 154513a7cbbde..2010581cd8981 100644 --- a/projects/plugins/protect/src/js/components/marked-lines/index.jsx +++ b/projects/plugins/protect/src/js/components/marked-lines/index.jsx @@ -56,7 +56,7 @@ const MarkedLines = ( { context } ) => {
{ Object.keys( lines ).map( lineNumber => { - const hasMarks = marks.hasOwnProperty( lineNumber ); + const hasMarks = Object.hasOwn( marks, lineNumber ); return (
{
{ Object.keys( lines ).map( lineNumber => { const lineContent = lines[ lineNumber ] || ' '; - const hasMarks = marks.hasOwnProperty( lineNumber ); + const hasMarks = Object.hasOwn( marks, lineNumber ); return (
this.#addPrefix( s ), opts ); this.#prefix = options.prefix || ''; diff --git a/tools/jetpack-live-branches/jetpack-live-branches.user.js b/tools/jetpack-live-branches/jetpack-live-branches.user.js index 2874d22c6391f..e1268ddf81039 100644 --- a/tools/jetpack-live-branches/jetpack-live-branches.user.js +++ b/tools/jetpack-live-branches/jetpack-live-branches.user.js @@ -119,7 +119,7 @@ .then( body => { const plugins = []; - if ( body.hasOwnProperty( 'plugins' ) ) { + if ( Object.hasOwn( body, 'plugins' ) ) { const labels = new Set( $.map( $( '.js-issue-labels a.IssueLabel' ), e => $( e ).data( 'name' ) ) ); diff --git a/tools/js-tools/eslintrc/base.js b/tools/js-tools/eslintrc/base.js index 18fb9eae54bab..3b821a25d58c1 100644 --- a/tools/js-tools/eslintrc/base.js +++ b/tools/js-tools/eslintrc/base.js @@ -210,12 +210,11 @@ module.exports = { ], strict: [ 'error', 'never' ], + // We may want to keep these overrides. To decide later. + eqeqeq: [ 'error', 'always', { null: 'ignore' } ], + 'no-unused-expressions': [ 'error', { allowShortCircuit: true, allowTernary: true } ], // Temporarily override plugin:@wordpress/* so we can clean up failing stuff in separate PRs. - eqeqeq: [ 'error', 'allow-null' ], 'jsx-a11y/label-has-associated-control': [ 'error', { assert: 'either' } ], - 'no-prototype-builtins': 'off', - 'no-undef-init': 'off', - 'no-unused-expressions': 'off', 'object-shorthand': 'off', '@wordpress/no-base-control-with-label-without-id': 'off', '@wordpress/no-global-active-element': 'off',