Skip to content

Commit

Permalink
js-packages: Fix some JS lints ahead of the eslint 9 upgrade (#40489)
Browse files Browse the repository at this point in the history
  • Loading branch information
anomiex authored Dec 6, 2024
1 parent 753e400 commit 8c69a5e
Show file tree
Hide file tree
Showing 60 changed files with 108 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


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


3 changes: 1 addition & 2 deletions projects/js-packages/ai-client/src/data-flow/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import React, { createContext } from 'react';
import SuggestionsEventSource from '../suggestions-event-source/index.js';
import type { AskQuestionOptionsArgProps } from '../ask-question/index.js';
import type { RequestingErrorProps } from '../hooks/use-ai-suggestions/index.js';
import type { PromptProp } from '../types.js';
import type { RequestingStateProp } from '../types.js';
import type { PromptProp, RequestingStateProp } from '../types.js';

export type AiDataContextProps = {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import {
*/
import type { AskQuestionOptionsArgProps } from '../../ask-question/index.js';
import type SuggestionsEventSource from '../../suggestions-event-source/index.js';
import type { PromptProp, SuggestionErrorCode } from '../../types.js';
import type { RequestingStateProp } from '../../types.js';
import type { PromptProp, SuggestionErrorCode, RequestingStateProp } from '../../types.js';

export type RequestingErrorProps = {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ export const LogoPresenter: React.FC< LogoPresenterProps > = ( {
logoAccepted = false,
siteId,
} ) => {
// 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.
const { isRequestingImage } = useLogoGenerator();
const { saveToLibraryError, logoUpdateError } = useRequestErrors();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { Button, Tooltip, SelectControl } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { Icon, info } from '@wordpress/icons';
import debugFactory from 'debug';
import { useCallback, useEffect, useState, useRef } from 'react';
import { Dispatch, SetStateAction } from 'react';
import { useCallback, useEffect, useState, useRef, Dispatch, SetStateAction } from 'react';
/**
* Internal dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/order */

const mockOrigDebug = jest.requireActual( 'debug' );
const mockDebug = jest.fn();
jest.mock( 'debug', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


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


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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ export function tooltipsPlugin( periods ) {
/**
* Initializes the tooltips plugin.
*
* @param {uPlot} u - The uPlot instance.
* @param {object} _opts - Options for the uPlot instance.
* @param {uPlot} u - The uPlot instance.
*/
function init( u: uPlot, _opts: object ) {
function init( u: uPlot ) {
container.classList.add( 'jb-score-tooltips-container' );
if ( ! reactDom ) {
reactDom = ReactDOM.createRoot( reactRoot );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/react-in-jsx-scope */
import React from 'react';
import Dialog from '..';
import ProductOffer from '../../product-offer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/react-in-jsx-scope */
import React from 'react';
import DiffViewer from '..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const NumberSlider: React.FC< NumberSliderProps > = ( {
min={ minValue }
step={ step }
renderThumb={ renderThumbCallback } // eslint-disable-line react/jsx-no-bind
onChange={ onChange } // eslint-disable-line react/jsx-no-bind
onChange={ onChange }
onBeforeChange={ onBeforeChangeCallback } // eslint-disable-line react/jsx-no-bind
onAfterChange={ onAfterChangeCallback } // eslint-disable-line react/jsx-no-bind
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { __, sprintf } from '@wordpress/i18n';
import { Icon, check, closeSmall } from '@wordpress/icons';
import clsx from 'clsx';
import {
import React, {
createContext,
useContext,
Children,
cloneElement,
PropsWithChildren,
ReactElement,
CSSProperties,
} from 'react';
import React, { CSSProperties } from 'react';
import IconTooltip from '../icon-tooltip';
import useBreakpointMatch from '../layout/use-breakpoint-match';
import TermsOfService from '../terms-of-service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ describe( 'PricingTable', () => {
render( <PricingTable { ...testProps }></PricingTable> );
expect( screen.getAllByText( 'Dummy Item 1' ) ).toHaveLength( 2 );
expect( screen.getAllByText( 'Dummy Item 2' ) ).toHaveLength( 2 );
expect( screen.getAllByText( 'Dummy Item 3' ) ).toHaveLength( 1 ); // eslint-disable-line jest-dom/prefer-in-document
expect( screen.getAllByText( 'Dummy Item 3' ) ).toHaveLength( 1 );
} );
} );
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/react-in-jsx-scope */
import React from 'react';
import Spinner from '../index.jsx';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default {
},
};

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


Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/react-in-jsx-scope */
import { action } from '@storybook/addon-actions';
import React from 'react';
import ConnectScreenVisual from '../visual';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ActionButton, TermsOfService } from '@automattic/jetpack-components';
import { getRedirectUrl } from '@automattic/jetpack-components';
import { ActionButton, TermsOfService, getRedirectUrl } from '@automattic/jetpack-components';
import { createInterpolateElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/react-in-jsx-scope */
import { action } from '@storybook/addon-actions';
import React from 'react';
import ConnectScreenRequiredPlanVisual from '../visual';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */

import { __ } from '@wordpress/i18n';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ try {
if ( globals?.es2022 ) {
flatBase.languageOptions.globals = globals.es2022;
}
} catch ( e ) {
} catch {
// `globals` is optional.
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class I18nLoader {
if ( ret === null ) {
throw new Error( `Path ${ path } was requested multiple times` );
}
this.expect[ expect ] = null;
this.expect[ path ] = null;
return ret( domain );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


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


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getByRole, queryByRole, screen } from '@testing-library/react';
import { screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

export class Panel {
Expand All @@ -11,19 +11,21 @@ export class Panel {
}

get disconnectButton() {
return queryByRole( this.container, 'button', { name: 'Disconnect' } );
return within( this.container ).queryByRole( 'button', { name: 'Disconnect' } );
}

get closeButton() {
return getByRole( this.container, 'button', { name: 'Close panel' } );
return within( this.container ).getByRole( 'button', { name: 'Close panel' } );
}

get openButton() {
return getByRole( this.container, 'button', { name: 'Open panel' } );
return within( this.container ).getByRole( 'button', { name: 'Open panel' } );
}

get markAsSharedToggle() {
return queryByRole( this.container, 'checkbox', { name: 'Mark the connection as shared' } );
return within( this.container ).queryByRole( 'checkbox', {
name: 'Mark the connection as shared',
} );
}

isOpen() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Button, useGlobalNotices } from '@automattic/jetpack-components';
import { getRedirectUrl } from '@automattic/jetpack-components';
import { Button, useGlobalNotices, getRedirectUrl } from '@automattic/jetpack-components';
import {
BaseControl,
FlexBlock,
__experimentalHStack as HStack, // eslint-disable-line @wordpress/no-unsafe-wp-apis
ExternalLink,
} from '@wordpress/components';
import { ExternalLink } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { useCallback, useMemo } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SocialServiceIcon, Button, Text } from '@automattic/jetpack-components';
import { CopyToClipboard } from '@automattic/jetpack-components';
import { SocialServiceIcon, Button, Text, CopyToClipboard } from '@automattic/jetpack-components';
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
import { useCallback } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
import { TabPanel } from '@wordpress/components';
import { ToggleControl } from '@wordpress/components';
import { TabPanel, ToggleControl } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { __, _x } from '@wordpress/i18n';
import { useCallback } from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jsx-a11y/media-has-caption */
import { useCallback, useRef, useState, useEffect } from '@wordpress/element';
import styles from './styles.module.scss';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ export class DataSync< Schema extends z.ZodSchema, Value extends z.infer< Schema
try {
data = JSON.parse( text );
} catch ( error ) {
// eslint-disable-next-line no-console
throw new DataSyncError( 'Failed to JSON.parse() the response from the server.', {
...this.describeSelf(),
location: url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
useMutation,
QueryClientProvider,
} from '@tanstack/react-query';
import React from 'react';
import { useRef, useEffect } from 'react';
import React, { useRef, useEffect } from 'react';
import { z } from 'zod';
import { DataSync } from './DataSync';
import { DataSyncError } from './DataSyncError';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require( 'path' );
const coverageConfig = require( 'jetpack-js-tools/jest/config.coverage.js' );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require( 'path' );
// eslint-disable-next-line @typescript-eslint/no-var-requires
const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' );

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function* updateJetpackModuleStatus( settings ) {
const data = yield fetchJetpackModules();
yield setJetpackModules( { data } );
return true;
} catch ( e ) {
} catch {
const oldSettings = select( JETPACK_MODULES_STORE_ID ).getJetpackModules();
yield setJetpackModules( oldSettings );
return false;
Expand All @@ -49,7 +49,7 @@ export function* fetchModules() {
const data = yield fetchJetpackModules();
yield setJetpackModules( { data } );
return true;
} catch ( e ) {
} catch {
const oldSettings = select( JETPACK_MODULES_STORE_ID ).getJetpackModules();
yield setJetpackModules( oldSettings );
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function registerJetpackPlugin( name, settings ) {
const unavailable = ! available;

if ( unavailable ) {
// eslint-disable-next-line no-undef -- webpack defines it
if ( 'production' !== process.env.NODE_ENV ) {
// eslint-disable-next-line no-console
console.warn(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react/react-in-jsx-scope */

import { createHigherOrderComponent } from '@wordpress/compose';

import './style.scss';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix some JS lints ahead of eslint 9 upgrade.


2 changes: 0 additions & 2 deletions projects/js-packages/storybook/storybook/preview.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ThemeProvider } from '@automattic/jetpack-components';
import React from 'react';

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

import './style.scss';

Expand Down
Loading

0 comments on commit 8c69a5e

Please sign in to comment.