Skip to content

Commit

Permalink
ESLint v8 (#35576) (#36283)
Browse files Browse the repository at this point in the history
* Update @typescript-eslint/eslint-plugin to ^5.3.0

* Update @typescript-eslint/parser to ^5.3.0

* Update eslint-plugin-jest to ^25.2.3

Changelog: https://github.com/jest-community/eslint-plugin-jest/blob/1cfded5a2744656227d7bf616d65ec12b7ddb287/CHANGELOG.md#2500-2021-10-10

* Update eslint-config-prettier to ^8.3.0

I have removed prettier/react from the config since all configs were merged into each other.
See changelog: https://github.com/prettier/eslint-config-prettier/blob/5a2f0e24382a8e1322784bc836d47706cccd2f1e/CHANGELOG.md#version-800-2021-02-21

* Update eslint-plugin-jsdoc to ^37.0.3

Changelog: https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v37.0.0

* Update globals to ^13.12.0

Changelog: https://github.com/sindresorhus/globals/releases/tag/v13.0.0

* scripts: Update eslint to ^8.2.0

Changelog: https://eslint.org/docs/user-guide/migrating-to-8.0.0

* Document dependency updates in changelogs

* eslint-plugin: Update eslint-plugin-react-hooks to ^4.3.0

* eslint-plugin: Update eslint-plugin-react to ^7.27.0

* eslint-plugin: Update eslint-plugin-jsx-a11y to ^6.5.1

* Update package-lock.json

* scripts: Update eslint to ^8.3.0

* Add moduleNameMapper entry for @eslint/eslintrc

* eslint-plugin: Update eslint peer dependency constraint

* jest-preset-default: Add moduleNameMapper for ESLint

* Update packages/eslint-plugin/package.json

Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>

* Update package-lock.json

* Update CHANGELOG.md

Co-authored-by: Simon Hammes <simonhammes@users.noreply.github.com>
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
  • Loading branch information
3 people committed Dec 3, 2021
1 parent 18214af commit abec4ed
Show file tree
Hide file tree
Showing 17 changed files with 1,207 additions and 711 deletions.
1,849 changes: 1,161 additions & 688 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/api-fetch/src/test/index.js
Expand Up @@ -127,6 +127,7 @@ describe( 'apiFetch', () => {
);

return apiFetch( { path: '/random' } ).catch( ( body ) => {
// eslint-disable-next-line jest/no-conditional-expect
expect( body ).toEqual( {
code: 'bad_request',
message: 'Bad Request',
Expand All @@ -142,6 +143,7 @@ describe( 'apiFetch', () => {
);

return apiFetch( { path: '/random' } ).catch( ( body ) => {
// eslint-disable-next-line jest/no-conditional-expect
expect( body ).toEqual( {
code: 'invalid_json',
message: 'The response is not a valid JSON response.',
Expand All @@ -160,6 +162,7 @@ describe( 'apiFetch', () => {
);

return apiFetch( { path: '/random' } ).catch( ( body ) => {
// eslint-disable-next-line jest/no-conditional-expect
expect( body ).toEqual( {
code: 'invalid_json',
message: 'The response is not a valid JSON response.',
Expand All @@ -171,6 +174,7 @@ describe( 'apiFetch', () => {
window.fetch.mockReturnValue( Promise.reject() );

return apiFetch( { path: '/random' } ).catch( ( body ) => {
// eslint-disable-next-line jest/no-conditional-expect
expect( body ).toEqual( {
code: 'fetch_error',
message: 'You are probably offline.',
Expand Down Expand Up @@ -213,6 +217,7 @@ describe( 'apiFetch', () => {
);

return apiFetch( { path: '/random' } ).catch( ( body ) => {
// eslint-disable-next-line jest/no-conditional-expect
expect( body ).toEqual( null );
} );
} );
Expand Down Expand Up @@ -242,6 +247,7 @@ describe( 'apiFetch', () => {

return apiFetch( { path: '/random', parse: false } ).catch(
( response ) => {
// eslint-disable-next-line jest/no-conditional-expect
expect( response ).toEqual( {
status: 400,
} );
Expand Down
Expand Up @@ -1634,6 +1634,7 @@ describe( 'Selecting links', () => {
);

// We should have highlighted the first item using the keyboard
// eslint-disable-next-line jest/no-conditional-expect
expect( selectedSearchResultElement ).toEqual(
secondSearchSuggestion
);
Expand All @@ -1648,6 +1649,7 @@ describe( 'Selecting links', () => {
);

// We should be back to highlighting the first search result again
// eslint-disable-next-line jest/no-conditional-expect
expect( selectedSearchResultElement ).toEqual(
firstSearchSuggestion
);
Expand Down
Expand Up @@ -148,14 +148,15 @@ function menuItemToBlockAttributes( {
classes.join( ' ' ).trim() && {
className: classes.join( ' ' ).trim(),
} ),
/* eslint-disable camelcase */
...( attr_title?.length && {
title: attr_title,
} ),
// eslint-disable-next-line camelcase
...( object_id &&
'custom' !== object && {
id: object_id,
} ),
/* eslint-enable camelcase */
...( description?.length && {
description,
} ),
Expand Down
2 changes: 1 addition & 1 deletion packages/block-serialization-default-parser/test/index.js
Expand Up @@ -17,7 +17,7 @@ import {
*/
import { parse } from '../src';

describe( 'block-serialization-default-parser-js', jsTester( parse ) ); // eslint-disable-line jest/valid-describe
describe( 'block-serialization-default-parser-js', jsTester( parse ) ); // eslint-disable-line jest/valid-describe-callback

phpTester(
'block-serialization-default-parser-php',
Expand Down
4 changes: 2 additions & 2 deletions packages/block-serialization-spec-parser/shared-tests.js
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, jest/valid-title
? // eslint-disable-next-line jest/valid-describe-callback, jest/valid-title
( ...args ) => describe( ...args )
: // eslint-disable-next-line jest/no-disabled-tests, jest/valid-describe, jest/valid-title
: // eslint-disable-next-line jest/no-disabled-tests, jest/valid-describe-callback, jest/valid-title
( ...args ) => describe.skip( ...args );

export const phpTester = ( name, filename ) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/block-serialization-spec-parser/test/index.js
Expand Up @@ -9,7 +9,7 @@ import path from 'path';
import { parse } from '../';
import { jsTester, phpTester } from '../shared-tests';

describe( 'block-serialization-spec-parser-js', jsTester( parse ) ); // eslint-disable-line jest/valid-describe
describe( 'block-serialization-spec-parser-js', jsTester( parse ) ); // eslint-disable-line jest/valid-describe-callback

phpTester(
'block-serialization-spec-parser-php',
Expand Down
4 changes: 2 additions & 2 deletions packages/env/lib/config/test/config.js
@@ -1,4 +1,4 @@
/* eslint-disable jest/no-try-expect, jest/no-conditional-expect */
/* eslint-disable jest/no-conditional-expect */
/**
* External dependencies
*/
Expand Down Expand Up @@ -1128,4 +1128,4 @@ async function testPortNumberValidation( portName, value, envText = '' ) {
}
jest.clearAllMocks();
}
/* eslint-enable jest/no-try-expect, jest/no-conditional-expect */
/* eslint-enable jest/no-conditional-expect */
10 changes: 10 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Expand Up @@ -2,6 +2,16 @@

## Unreleased

### Breaking Changes

- The peer dependency constraint for ESLint has been updated from `^6 || ^7` to `^8`.
- The bundled `@typescript-eslint/eslint-plugin` dependency has been updated from requiring `^4.31.0` to requiring `^5.3.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- The bundled `@typescript-eslint/parser` dependency has been updated from requiring `^4.31.0` to requiring `^5.3.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- The bundled `eslint-config-prettier` dependency has been updated from requiring `^7.1.0` to requiring `^8.3.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- The bundled `eslint-plugin-jest` dependency has been updated from requiring `^24.1.3` to requiring `^25.2.3` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- The bundled `eslint-plugin-jsdoc` dependency has been updated from requiring `^36.0.8` to requiring `^37.0.3` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- The bundled `globals` dependency has been updated from requiring `^12.0.0` to requiring `^13.12.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).

## 9.3.0 (2021-11-15)

### Enhancements
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/configs/recommended.js
Expand Up @@ -21,7 +21,6 @@ const config = {
extends: [
require.resolve( './recommended-with-formatting.js' ),
'plugin:prettier/recommended',
'prettier/react',
],
rules: {
'prettier/prettier': [ 'error', prettierConfig ],
Expand Down
20 changes: 10 additions & 10 deletions packages/eslint-plugin/package.json
Expand Up @@ -32,24 +32,24 @@
"main": "index.js",
"dependencies": {
"@babel/eslint-parser": "^7.16.0",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"@wordpress/prettier-config": "file:../prettier-config",
"cosmiconfig": "^7.0.0",
"eslint-config-prettier": "^7.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jsdoc": "^36.0.8",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-jest": "^25.2.3",
"eslint-plugin-jsdoc": "^37.0.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"globals": "^12.0.0",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0",
"globals": "^13.12.0",
"prettier": "npm:wp-prettier@2.2.1-beta-1",
"requireindex": "^1.2.0"
},
"peerDependencies": {
"eslint": "^6 || ^7",
"eslint": "^8",
"typescript": "^4"
},
"peerDependenciesMeta": {
Expand Down
Expand Up @@ -198,6 +198,7 @@ function getFixes( fixer, context, callNode ) {
module.exports = {
meta: {
type: 'problem',
hasSuggestions: true,
schema: [],
messages: {
doNotUseStringLiteral: `Do not use string literals ( '{{ argument }}' ) for accessing @wordpress/data stores. Pass the store definition instead`,
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-preset-default/CHANGELOG.md
Expand Up @@ -2,8 +2,9 @@

## Unreleased

### Bug Fix
### Bug Fixes

- Allow ESLint to be imported from within Jest (e.g. when using `ruleTester`) ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- Improve support for test files with `.jsx` and `.tsx` extensions ([#36260](https://github.com/WordPress/gutenberg/pull/36260)).

## 7.1.2 (2021-10-22)
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-preset-default/jest-preset.js
Expand Up @@ -3,6 +3,8 @@ module.exports = {
'\\.(scss|css)$': require.resolve(
'@wordpress/jest-preset-default/scripts/style-mock.js'
),
// See https://github.com/facebook/jest/issues/11100#issuecomment-967161978
'@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs',
},
modulePaths: [ '<rootDir>' ],
setupFiles: [
Expand Down
6 changes: 3 additions & 3 deletions packages/redux-routine/src/test/index.js
Expand Up @@ -60,7 +60,7 @@ describe( 'createMiddleware', () => {
try {
yield { type: 'WAIT_FAIL' };
} catch ( error ) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
// eslint-disable-next-line jest/no-conditional-expect
expect( error ).toBe( 'Message' );
}
}
Expand All @@ -81,7 +81,7 @@ describe( 'createMiddleware', () => {
try {
yield { type: 'WAIT_FAIL' };
} catch ( error ) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
// eslint-disable-next-line jest/no-conditional-expect
expect( error.message ).toBe( 'Message' );
}
}
Expand All @@ -108,7 +108,7 @@ describe( 'createMiddleware', () => {
try {
yield { type: 'WAIT_FAIL' };
} catch ( error ) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
// eslint-disable-next-line jest/no-conditional-expect
expect( error.message ).toBe( 'Message' );
return null;
}
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

### Breaking Changes

- The bundled `eslint` dependency has been updated from requiring `^7.17.0` to requiring `^8.3.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
- The `puppeteer-core` dependency has been updated from requiring `^10.1.0` to requiring `^11.0.0` (see [Breaking Changes](https://github.com/puppeteer/puppeteer/releases/tag/v11.0.0), [#36040](https://github.com/WordPress/gutenberg/pull/36040)).

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Expand Up @@ -53,7 +53,7 @@
"cssnano": "^5.0.7",
"cwd": "^0.10.0",
"dir-glob": "^3.0.1",
"eslint": "^7.17.0",
"eslint": "^8.3.0",
"eslint-plugin-markdown": "^2.2.0",
"expect-puppeteer": "^4.4.0",
"fast-glob": "^3.2.7",
Expand Down

0 comments on commit abec4ed

Please sign in to comment.