Skip to content

Commit

Permalink
Scripts: ESLint minor version upgrade to 7.17.0 (#27965)
Browse files Browse the repository at this point in the history
* Scripts: Upgrade ESLint and its configuration to version 7.17

* Autofix errors detected in unit tests

* Disable more linting errors used in the existing code

* Fix more reported warnings

* Add changelog entries for ESLint upgrade

* Update the package lock file

* Update test snapshots to align with test name changes
  • Loading branch information
gziolo authored Jan 4, 2021
1 parent e073409 commit 53291fe
Show file tree
Hide file tree
Showing 53 changed files with 1,101 additions and 565 deletions.
1,317 changes: 877 additions & 440 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions packages/api-fetch/src/middlewares/test/fetch-all-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ describe( 'Fetch All Middleware', () => {
const originalOptions = { url: '/posts?per_page=-1' };
let counter = 1;
jest.doMock( '../../index.js', () => ( options ) => {
if ( counter === 1 ) {
expect( options.url ).toBe( '/posts?per_page=100' );
} else {
expect( options.url ).toBe( '/posts?per_page=100&page=2' );
}
const expectedUrl =
counter === 1
? '/posts?per_page=100'
: '/posts?per_page=100&page=2';
expect( options.url ).toBe( expectedUrl );

const response = Promise.resolve( {
status: 200,
headers: {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-directory/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ describe( 'selectors', () => {
},
};

it( 'it should reflect that the block is installing', () => {
it( 'should reflect that the block is installing', () => {
expect( isInstalling( state, BLOCK_1_ID ) ).toBeTruthy();
} );

it( 'it should reflect that the block is not installing', () => {
it( 'should reflect that the block is not installing', () => {
expect( isInstalling( state, 'not-in-state' ) ).toBeFalsy();
expect( isInstalling( state, BLOCK_2_ID ) ).toBeFalsy();
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ describe( 'Default and Responsive modes', () => {
expect( responsiveControlGroup ).toBeNull();
} );

it( 'should render custom responsive controls when renderResponsiveControls prop is provided and in responsive mode ', () => {
it( 'should render custom responsive controls when renderResponsiveControls prop is provided and in responsive mode', () => {
const spyRenderDefaultControl = jest.fn();

const mockRenderResponsiveControls = jest.fn( ( viewports ) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,7 @@ describe( 'selectors', () => {
expect( getTemplateLock( state ) ).toBe( 'all' );
} );

it( 'should return null if the specified clientId was not found ', () => {
it( 'should return null if the specified clientId was not found', () => {
const state = {
settings: { templateLock: 'all' },
blockListSettings: {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-serialization-spec-parser/shared-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ const hasPHP =
// skipping preserves snapshots while commenting out or simply
// not injecting the tests prompts `jest` to remove "obsolete snapshots"
const makeTest = hasPHP
? // eslint-disable-next-line jest/valid-describe
? // eslint-disable-next-line jest/valid-describe, jest/valid-title
( ...args ) => describe( ...args )
: // eslint-disable-next-line jest/no-disabled-tests, jest/valid-describe
: // eslint-disable-next-line jest/no-disabled-tests, jest/valid-describe, jest/valid-title
( ...args ) => describe.skip( ...args );

export const phpTester = ( name, filename ) =>
Expand Down
1 change: 1 addition & 0 deletions packages/blocks/src/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ describe( 'blocks', () => {
// Verify that for deprecations, the filter is called with a merge of pre-filter
// settings with deprecation keys omitted and the deprecation entry.
if ( i > 0 ) {
// eslint-disable-next-line jest/no-conditional-expect
expect( settings ).toEqual( {
...omit(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/color-picker/test/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DOWN, ENTER, SPACE, UP } from '@wordpress/keycodes';
*/
import { Input } from '../inputs';

describe( 'Input ', () => {
describe( 'Input', () => {
describe( 'calls onChange prop with commit state', () => {
test( 'onKeyDown = ENTER', () => {
const onChange = jest.fn();
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/external-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export function ExternalLink(
).join( ' ' );
const classes = classnames( 'components-external-link', className );
return (
/* eslint-disable react/jsx-no-target-blank */
<a
{ ...additionalProps }
className={ classes }
href={ href }
// eslint-disable-next-line react/jsx-no-target-blank
target="_blank"
rel={ rel }
ref={ ref }
Expand All @@ -47,6 +47,7 @@ export function ExternalLink(
className="components-external-link__icon"
/>
</a>
/* eslint-enable react/jsx-no-target-blank */
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/form-token-field/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe( 'FormTokenField', () => {

// before sending a hover event, we need to wait for
// SuggestionList#_scrollingIntoView to become false
jest.runTimersToTime( 100 );
jest.advanceTimersByTime( 100 );

TestUtils.Simulate.mouseEnter( hoverSuggestion );
expect( getSelectedSuggestion() ).toEqual( [ 'wi', 'th' ] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe( 'createHigherOrderComponent', () => {
expect( TestComponent.displayName ).toBe( 'WithTest(Component)' );
} );

it( 'should use camel case starting with upper for wrapper prefix ', () => {
it( 'should use camel case starting with upper for wrapper prefix', () => {
const TestComponent = createHigherOrderComponent(
( OriginalComponent ) => OriginalComponent,
'with-one-two_threeFOUR'
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/test/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe( 'getAutosaves', () => {
);
} );

it( ' yields undefined if no autosaves exist for the post', async () => {
it( 'yields undefined if no autosaves exist for the post', async () => {
const postType = 'post';
const postId = 1;
const restBase = 'posts';
Expand Down
1 change: 1 addition & 0 deletions packages/data/src/redux-store/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe( 'controls', () => {
.hasFinishedResolution( 'getItems' );
if ( isFinished ) {
const items = registry.select( 'store' ).getItems();
// eslint-disable-next-line jest/no-conditional-expect
expect( items ).toEqual( [ 1, 2, 3 ] );
}
resolve();
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/config/setup-debug-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if ( ! fs.existsSync( ARTIFACTS_PATH ) ) {
* Kudos to Tom Esterez (@testerez) for sharing this idea in https://github.com/smooth-code/jest-puppeteer/issues/131#issuecomment-424073620
*/
let artifactsPromise;
// eslint-disable-next-line jest/no-jasmine-globals
// eslint-disable-next-line jest/no-jasmine-globals, no-undef
jasmine.getEnv().addReporter( {
specDone: ( result ) => {
if ( result.status === 'failed' ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ exports[`Heading can be created by prefixing number sign and a space 1`] = `
<!-- /wp:heading -->"
`;

exports[`Heading it should correctly apply custom colors 1`] = `
exports[`Heading should correctly apply custom colors 1`] = `
"<!-- wp:heading {\\"level\\":3,\\"style\\":{\\"color\\":{\\"text\\":\\"#7700ff\\"}}} -->
<h3 class=\\"has-text-color\\" style=\\"color:#7700ff\\">Heading</h3>
<!-- /wp:heading -->"
`;
exports[`Heading it should correctly apply named colors 1`] = `
exports[`Heading should correctly apply named colors 1`] = `
"<!-- wp:heading {\\"textColor\\":\\"luminous-vivid-orange\\"} -->
<h2 class=\\"has-luminous-vivid-orange-color has-text-color\\">Heading</h2>
<!-- /wp:heading -->"
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/specs/editor/blocks/heading.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe( 'Heading', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'it should correctly apply custom colors', async () => {
it( 'should correctly apply custom colors', async () => {
await clickBlockAppender();
await page.keyboard.type( '### Heading' );
const colorPanelToggle = await page.waitForXPath(
Expand All @@ -91,7 +91,7 @@ describe( 'Heading', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'it should correctly apply named colors', async () => {
it( 'should correctly apply named colors', async () => {
await clickBlockAppender();
await page.keyboard.type( '## Heading' );
const [ colorPanelToggle ] = await page.$x(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`InnerBlocks Template Sync Ensure inner block writing flow works as expe
<!-- /wp:test/test-inner-blocks-paragraph-placeholder -->"
`;
exports[`InnerBlocks Template Sync Ensures blocks without locking are kept intact even if they do not match the template 1`] = `
exports[`InnerBlocks Template Sync Ensures blocks without locking are kept intact even if they do not match the template 1`] = `
"<!-- wp:test/test-inner-blocks-no-locking -->
<!-- wp:paragraph {\\"fontSize\\":\\"large\\"} -->
<p class=\\"has-large-font-size\\">Content…</p>
Expand All @@ -28,7 +28,7 @@ exports[`InnerBlocks Template Sync Ensures blocks without locking are kept intac
<!-- /wp:test/test-inner-blocks-no-locking -->"
`;
exports[`InnerBlocks Template Sync Removes blocks that are not expected by the template if a lock all exists 1`] = `
exports[`InnerBlocks Template Sync Removes blocks that are not expected by the template if a lock all exists 1`] = `
"<!-- wp:test/test-inner-blocks-locking-all -->
<!-- wp:paragraph {\\"fontSize\\":\\"large\\"} -->
<p class=\\"has-large-font-size\\">Content…</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`RenderAppender prop of InnerBlocks Users can customize the appender and can still insert blocks using exposed components 1`] = `
exports[`RenderAppender prop of InnerBlocks Users can customize the appender and can still insert blocks using exposed components 1`] = `
"<!-- wp:test/inner-blocks-render-appender -->
<div style=\\"outline:1px solid gray;padding:5px\\" class=\\"wp-block-test-inner-blocks-render-appender\\"><!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><p></p></blockquote>
<!-- /wp:quote --></div>
<!-- /wp:test/inner-blocks-render-appender -->"
`;
exports[`RenderAppender prop of InnerBlocks Users can dynamically customize the appender 1`] = `
exports[`RenderAppender prop of InnerBlocks Users can dynamically customize the appender 1`] = `
"<!-- wp:test/inner-blocks-render-appender-dynamic -->
<div style=\\"outline:1px solid gray;padding:5px\\" class=\\"wp-block-test-inner-blocks-render-appender-dynamic\\"><!-- wp:quote -->
<blockquote class=\\"wp-block-quote\\"><p></p></blockquote>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ describe( 'InnerBlocks Template Sync', () => {
await switchEditorModeTo( 'Visual' );
};

it( 'Ensures blocks without locking are kept intact even if they do not match the template ', async () => {
it( 'Ensures blocks without locking are kept intact even if they do not match the template', async () => {
await insertBlockAndAddParagraphInside(
'Test Inner Blocks no locking',
'test/test-inner-blocks-no-locking'
);
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'Removes blocks that are not expected by the template if a lock all exists ', async () => {
it( 'Removes blocks that are not expected by the template if a lock all exists', async () => {
await insertBlockAndAddParagraphInside(
'Test InnerBlocks locking all',
'test/test-inner-blocks-locking-all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe( 'Test Custom Post Types', () => {
await deactivatePlugin( 'gutenberg-test-custom-post-types' );
} );

it( 'It should be able to create an hierarchical post without title support', async () => {
it( 'should be able to create an hierarchical post without title support', async () => {
const PARENT_PAGE_INPUT =
'.editor-page-attributes__parent input:not([disabled])';
const SUGGESTION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
closeGlobalBlockInserter,
} from '@wordpress/e2e-test-utils';

describe( 'Allowed Blocks Setting on InnerBlocks ', () => {
describe( 'Allowed Blocks Setting on InnerBlocks', () => {
const paragraphSelector =
'.block-editor-rich-text__editable[data-type="core/paragraph"]';
beforeAll( async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const QUOTE_INSERT_BUTTON_SELECTOR = '//button[.="Quote"]';
const APPENDER_SELECTOR = '.my-custom-awesome-appender';
const DYNAMIC_APPENDER_SELECTOR = 'my-dynamic-blocks-appender';

describe( 'RenderAppender prop of InnerBlocks ', () => {
describe( 'RenderAppender prop of InnerBlocks', () => {
beforeAll( async () => {
await activatePlugin( 'gutenberg-test-innerblocks-render-appender' );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ exports[`Navigating the block hierarchy should navigate using the block hierarch
<!-- /wp:columns -->"
`;
exports[`Navigating the block hierarchy should select the wrapper div for a group 1`] = `
exports[`Navigating the block hierarchy should select the wrapper div for a group 1`] = `
"<!-- wp:group -->
<div class=\\"wp-block-group\\"><div class=\\"wp-block-group__inner-container\\"><!-- wp:paragraph -->
<p>just a paragraph</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe( 'Block Grouping', () => {
expect( availableTransforms ).not.toContain( 'Group' );
} );

it( 'does not show group option in the options toolbar if Grouping block is disabled ', async () => {
it( 'does not show group option in the options toolbar if Grouping block is disabled', async () => {
await clickBlockToolbarButton( 'More options' );

const blockOptionsDropdownHTML = await page.evaluate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe( 'Navigating the block hierarchy', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should select the wrapper div for a group ', async () => {
it( 'should select the wrapper div for a group', async () => {
// Insert a group block
await insertBlock( 'Group' );

Expand Down
Loading

0 comments on commit 53291fe

Please sign in to comment.