Skip to content

Commit 8c69a5e

Browse files
authored
js-packages: Fix some JS lints ahead of the eslint 9 upgrade (#40489)
1 parent 753e400 commit 8c69a5e

File tree

60 files changed

+108
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+108
-69
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/ai-client/src/data-flow/context.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import React, { createContext } from 'react';
88
import SuggestionsEventSource from '../suggestions-event-source/index.js';
99
import type { AskQuestionOptionsArgProps } from '../ask-question/index.js';
1010
import type { RequestingErrorProps } from '../hooks/use-ai-suggestions/index.js';
11-
import type { PromptProp } from '../types.js';
12-
import type { RequestingStateProp } from '../types.js';
11+
import type { PromptProp, RequestingStateProp } from '../types.js';
1312

1413
export type AiDataContextProps = {
1514
/*

projects/js-packages/ai-client/src/hooks/use-ai-suggestions/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
*/
2222
import type { AskQuestionOptionsArgProps } from '../../ask-question/index.js';
2323
import type SuggestionsEventSource from '../../suggestions-event-source/index.js';
24-
import type { PromptProp, SuggestionErrorCode } from '../../types.js';
25-
import type { RequestingStateProp } from '../../types.js';
24+
import type { PromptProp, SuggestionErrorCode, RequestingStateProp } from '../../types.js';
2625

2726
export type RequestingErrorProps = {
2827
/*

projects/js-packages/ai-client/src/logo-generator/components/logo-presenter.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ export const LogoPresenter: React.FC< LogoPresenterProps > = ( {
200200
logoAccepted = false,
201201
siteId,
202202
} ) => {
203-
// eslint-disable-next-line @wordpress/no-unused-vars-before-return -- @todo Start extending jetpack-js-tools/eslintrc/react in eslintrc, then we can remove this disable comment.
204203
const { isRequestingImage } = useLogoGenerator();
205204
const { saveToLibraryError, logoUpdateError } = useRequestErrors();
206205

projects/js-packages/ai-client/src/logo-generator/components/prompt.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { Button, Tooltip, SelectControl } from '@wordpress/components';
66
import { __, sprintf } from '@wordpress/i18n';
77
import { Icon, info } from '@wordpress/icons';
88
import debugFactory from 'debug';
9-
import { useCallback, useEffect, useState, useRef } from 'react';
10-
import { Dispatch, SetStateAction } from 'react';
9+
import { useCallback, useEffect, useState, useRef, Dispatch, SetStateAction } from 'react';
1110
/**
1211
* Internal dependencies
1312
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/babel-plugin-replace-textdomain/tests/plugin.test.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/order */
2-
31
const mockOrigDebug = jest.requireActual( 'debug' );
42
const mockDebug = jest.fn();
53
jest.mock( 'debug', () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/boost-score-api/src/utils/json-types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-use-before-define */
21
/**
32
* Generic type for handling JSON-like objects.
43
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/components/components/boost-score-bar/test/component.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ describe( 'BoostScrollBar', () => {
1818
it( 'renders the boost scroll bar when active is true', () => {
1919
const { container } = render( <BoostScoreBar { ...defaultProps } /> );
2020

21-
// eslint-disable-next-line testing-library/no-node-access
2221
expect( container.firstChild ).toHaveAttribute( 'class', 'jb-score-bar jb-score-bar--desktop' );
2322
} );
2423

2524
it( 'does not render the boost scroll bar when active is false', () => {
2625
const { container } = render( <BoostScoreBar { ...defaultProps } active={ false } /> );
2726

28-
// eslint-disable-next-line testing-library/no-node-access
2927
expect( container ).toBeEmptyDOMElement();
3028
} );
3129

projects/js-packages/components/components/boost-score-graph/tooltips-plugin.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ export function tooltipsPlugin( periods ) {
1717
/**
1818
* Initializes the tooltips plugin.
1919
*
20-
* @param {uPlot} u - The uPlot instance.
21-
* @param {object} _opts - Options for the uPlot instance.
20+
* @param {uPlot} u - The uPlot instance.
2221
*/
23-
function init( u: uPlot, _opts: object ) {
22+
function init( u: uPlot ) {
2423
container.classList.add( 'jb-score-tooltips-container' );
2524
if ( ! reactDom ) {
2625
reactDom = ReactDOM.createRoot( reactRoot );

projects/js-packages/components/components/dialog/stories/index.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/react-in-jsx-scope */
21
import React from 'react';
32
import Dialog from '..';
43
import ProductOffer from '../../product-offer';

projects/js-packages/components/components/diff-viewer/stories/index.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/react-in-jsx-scope */
21
import React from 'react';
32
import DiffViewer from '..';
43

projects/js-packages/components/components/number-slider/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const NumberSlider: React.FC< NumberSliderProps > = ( {
6868
min={ minValue }
6969
step={ step }
7070
renderThumb={ renderThumbCallback } // eslint-disable-line react/jsx-no-bind
71-
onChange={ onChange } // eslint-disable-line react/jsx-no-bind
71+
onChange={ onChange }
7272
onBeforeChange={ onBeforeChangeCallback } // eslint-disable-line react/jsx-no-bind
7373
onAfterChange={ onAfterChangeCallback } // eslint-disable-line react/jsx-no-bind
7474
/>

projects/js-packages/components/components/pricing-table/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { __, sprintf } from '@wordpress/i18n';
22
import { Icon, check, closeSmall } from '@wordpress/icons';
33
import clsx from 'clsx';
4-
import {
4+
import React, {
55
createContext,
66
useContext,
77
Children,
88
cloneElement,
99
PropsWithChildren,
1010
ReactElement,
11+
CSSProperties,
1112
} from 'react';
12-
import React, { CSSProperties } from 'react';
1313
import IconTooltip from '../icon-tooltip';
1414
import useBreakpointMatch from '../layout/use-breakpoint-match';
1515
import TermsOfService from '../terms-of-service';

projects/js-packages/components/components/pricing-table/test/component.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ describe( 'PricingTable', () => {
3636
render( <PricingTable { ...testProps }></PricingTable> );
3737
expect( screen.getAllByText( 'Dummy Item 1' ) ).toHaveLength( 2 );
3838
expect( screen.getAllByText( 'Dummy Item 2' ) ).toHaveLength( 2 );
39-
expect( screen.getAllByText( 'Dummy Item 3' ) ).toHaveLength( 1 ); // eslint-disable-line jest-dom/prefer-in-document
39+
expect( screen.getAllByText( 'Dummy Item 3' ) ).toHaveLength( 1 );
4040
} );
4141
} );

projects/js-packages/components/components/spinner/stories/index.stories.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/react-in-jsx-scope */
21
import React from 'react';
32
import Spinner from '../index.jsx';
43

projects/js-packages/components/components/upsell-banner/stories/index.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export default {
99
},
1010
};
1111

12-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1312
const BannerTemplate = args => {
1413
// Set up the first CTA
1514
const secondaryCtaLabel = 'Learn more';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/connection/components/connect-screen/basic/stories/index.stories.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/react-in-jsx-scope */
21
import { action } from '@storybook/addon-actions';
32
import React from 'react';
43
import ConnectScreenVisual from '../visual';

projects/js-packages/connection/components/connect-screen/basic/visual.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ActionButton, TermsOfService } from '@automattic/jetpack-components';
2-
import { getRedirectUrl } from '@automattic/jetpack-components';
1+
import { ActionButton, TermsOfService, getRedirectUrl } from '@automattic/jetpack-components';
32
import { createInterpolateElement } from '@wordpress/element';
43
import { __ } from '@wordpress/i18n';
54
import React from 'react';

projects/js-packages/connection/components/connect-screen/required-plan/stories/index.stories.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/react-in-jsx-scope */
21
import { action } from '@storybook/addon-actions';
32
import React from 'react';
43
import ConnectScreenRequiredPlanVisual from '../visual';

projects/js-packages/connection/components/disconnect-dialog/steps/step-survey.jsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
2-
31
import { __ } from '@wordpress/i18n';
42
import PropTypes from 'prop-types';
53
import React from 'react';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/eslint-config-target-es/src/flatconfig/base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ try {
1414
if ( globals?.es2022 ) {
1515
flatBase.languageOptions.globals = globals.es2022;
1616
}
17-
} catch ( e ) {
17+
} catch {
1818
// `globals` is optional.
1919
}
2020

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/i18n-loader-webpack-plugin/tests/globals.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class I18nLoader {
2323
if ( ret === null ) {
2424
throw new Error( `Path ${ path } was requested multiple times` );
2525
}
26-
this.expect[ expect ] = null;
26+
this.expect[ path ] = null;
2727
return ret( domain );
2828
}
2929

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/licensing/components/golden-token-modal/index.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ function GoldenTokenModal( {
7979
onClick={ maybeReanimate }
8080
role="presentation"
8181
>
82-
{ /* eslint-disable-next-line jsx-a11y/media-has-caption */ }
8382
<video
8483
ref={ videoRef }
8584
src="https://videos.files.wordpress.com/oSlNIBQO/jetpack-golden-token.mp4"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/publicize-components/src/components/connection-management/tests/pageObjects/PanelPage.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getByRole, queryByRole, screen } from '@testing-library/react';
1+
import { screen, within } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33

44
export class Panel {
@@ -11,19 +11,21 @@ export class Panel {
1111
}
1212

1313
get disconnectButton() {
14-
return queryByRole( this.container, 'button', { name: 'Disconnect' } );
14+
return within( this.container ).queryByRole( 'button', { name: 'Disconnect' } );
1515
}
1616

1717
get closeButton() {
18-
return getByRole( this.container, 'button', { name: 'Close panel' } );
18+
return within( this.container ).getByRole( 'button', { name: 'Close panel' } );
1919
}
2020

2121
get openButton() {
22-
return getByRole( this.container, 'button', { name: 'Open panel' } );
22+
return within( this.container ).getByRole( 'button', { name: 'Open panel' } );
2323
}
2424

2525
get markAsSharedToggle() {
26-
return queryByRole( this.container, 'checkbox', { name: 'Mark the connection as shared' } );
26+
return within( this.container ).queryByRole( 'checkbox', {
27+
name: 'Mark the connection as shared',
28+
} );
2729
}
2830

2931
isOpen() {

projects/js-packages/publicize-components/src/components/manage-connections-modal/confirmation-form/index.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { Button, useGlobalNotices } from '@automattic/jetpack-components';
2-
import { getRedirectUrl } from '@automattic/jetpack-components';
1+
import { Button, useGlobalNotices, getRedirectUrl } from '@automattic/jetpack-components';
32
import {
43
BaseControl,
54
FlexBlock,
65
__experimentalHStack as HStack, // eslint-disable-line @wordpress/no-unsafe-wp-apis
6+
ExternalLink,
77
} from '@wordpress/components';
8-
import { ExternalLink } from '@wordpress/components';
98
import { useDispatch, useSelect } from '@wordpress/data';
109
import { useCallback, useMemo } from '@wordpress/element';
1110
import { __, _x } from '@wordpress/i18n';

projects/js-packages/publicize-components/src/components/share-buttons/share-buttons.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { SocialServiceIcon, Button, Text } from '@automattic/jetpack-components';
2-
import { CopyToClipboard } from '@automattic/jetpack-components';
1+
import { SocialServiceIcon, Button, Text, CopyToClipboard } from '@automattic/jetpack-components';
32
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
43
import { useCallback } from '@wordpress/element';
54
import { __, sprintf } from '@wordpress/i18n';

projects/js-packages/publicize-components/src/components/social-post-modal/preview-section.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
2-
import { TabPanel } from '@wordpress/components';
3-
import { ToggleControl } from '@wordpress/components';
2+
import { TabPanel, ToggleControl } from '@wordpress/components';
43
import { useDispatch, useSelect } from '@wordpress/data';
54
import { __, _x } from '@wordpress/i18n';
65
import { useCallback } from 'react';

projects/js-packages/publicize-components/src/components/video-preview/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable jsx-a11y/media-has-caption */
21
import { useCallback, useRef, useState, useEffect } from '@wordpress/element';
32
import styles from './styles.module.scss';
43

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/react-data-sync-client/src/DataSync.ts

-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ export class DataSync< Schema extends z.ZodSchema, Value extends z.infer< Schema
223223
try {
224224
data = JSON.parse( text );
225225
} catch ( error ) {
226-
// eslint-disable-next-line no-console
227226
throw new DataSyncError( 'Failed to JSON.parse() the response from the server.', {
228227
...this.describeSelf(),
229228
location: url,

projects/js-packages/react-data-sync-client/src/DataSyncHooks.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import {
88
useMutation,
99
QueryClientProvider,
1010
} from '@tanstack/react-query';
11-
import React from 'react';
12-
import { useRef, useEffect } from 'react';
11+
import React, { useRef, useEffect } from 'react';
1312
import { z } from 'zod';
1413
import { DataSync } from './DataSync';
1514
import { DataSyncError } from './DataSyncError';

projects/js-packages/react-data-sync-client/tests/jest.config.cjs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
21
const path = require( 'path' );
32
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' );
43

projects/js-packages/react-data-sync-client/webpack.config.cjs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// eslint-disable-next-line @typescript-eslint/no-var-requires
21
const path = require( 'path' );
3-
// eslint-disable-next-line @typescript-eslint/no-var-requires
42
const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' );
53

64
module.exports = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/shared-extension-utils/src/modules-state/actions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function* updateJetpackModuleStatus( settings ) {
2525
const data = yield fetchJetpackModules();
2626
yield setJetpackModules( { data } );
2727
return true;
28-
} catch ( e ) {
28+
} catch {
2929
const oldSettings = select( JETPACK_MODULES_STORE_ID ).getJetpackModules();
3030
yield setJetpackModules( oldSettings );
3131
return false;
@@ -49,7 +49,7 @@ export function* fetchModules() {
4949
const data = yield fetchJetpackModules();
5050
yield setJetpackModules( { data } );
5151
return true;
52-
} catch ( e ) {
52+
} catch {
5353
const oldSettings = select( JETPACK_MODULES_STORE_ID ).getJetpackModules();
5454
yield setJetpackModules( oldSettings );
5555
return false;

projects/js-packages/shared-extension-utils/src/register-jetpack-plugin.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default function registerJetpackPlugin( name, settings ) {
1313
const unavailable = ! available;
1414

1515
if ( unavailable ) {
16+
// eslint-disable-next-line no-undef -- webpack defines it
1617
if ( 'production' !== process.env.NODE_ENV ) {
1718
// eslint-disable-next-line no-console
1819
console.warn(

projects/js-packages/shared-extension-utils/src/with-has-warning-is-interactive-class-names/index.jsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable react/react-in-jsx-scope */
2-
31
import { createHigherOrderComponent } from '@wordpress/compose';
42

53
import './style.scss';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
Comment: Fix some JS lints ahead of eslint 9 upgrade.
4+
5+

projects/js-packages/storybook/storybook/preview.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { ThemeProvider } from '@automattic/jetpack-components';
22
import React from 'react';
33

4-
/* eslint-disable no-restricted-syntax */
54
// import '@wordpress/components/build-style/style.css';
6-
/* eslint-enable no-restricted-syntax */
75

86
import './style.scss';
97

0 commit comments

Comments
 (0)