Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint Plugin: Remove all rules targeting test files from recommended presets #43272

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/duotone/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { __unstableGetValuesFromColors as getValuesFromColors } from './index';
/**
* SVG and stylesheet needed for rendering the duotone filter.
*
* @param {Object} props Duotone props.
* @param {string} props.selector Selector to apply the filter to.
* @param {string} props.id Unique id for this duotone filter.
* @param {Object} props Duotone props.
* @param {string} props.selector Selector to apply the filter to.
* @param {string} props.id Unique id for this duotone filter.
*
* @return {WPElement} Duotone element.
*/
Expand All @@ -29,8 +29,8 @@ ${ selector } {
/**
* Stylesheet for disabling a global styles duotone filter.
*
* @param {Object} props Duotone props.
* @param {string} props.selector Selector to disable the filter for.
* @param {Object} props Duotone props.
* @param {string} props.selector Selector to disable the filter for.
*
* @return {WPElement} Filter none style element.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/block-editor/src/hooks/duotone.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ extend( [ namesPlugin ] );
/**
* SVG and stylesheet needed for rendering the duotone filter.
*
* @param {Object} props Duotone props.
* @param {string} props.selector Selector to apply the filter to.
* @param {string} props.id Unique id for this duotone filter.
* @param {string[]|"unset"} props.colors Array of RGB color strings ordered from dark to light.
* @param {Object} props Duotone props.
* @param {string} props.selector Selector to apply the filter to.
* @param {string} props.id Unique id for this duotone filter.
* @param {string[]|"unset"} props.colors Array of RGB color strings ordered from dark to light.
*
* @return {WPElement} Duotone element.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/docgen/lib/get-type-annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ function getTypeAnnotation( typeAnnotation ) {
*
* @param {ASTNode} token Contains either a function or a call to a function-wrapper.
*
* TODO: Remove the special-casing here once we're able to infer the types from TypeScript itself.
* TODO: Remove the special-casing here once we're able to infer the types from TypeScript itself.
*/
function unwrapWrappedSelectors( token ) {
if ( babelTypes.isFunctionDeclaration( token ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function flattenTree( input = {}, prefix, token ) {
*
* @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
*
* @param {Object} tree A theme.json tree containing layout definitions.
* @param {Object} tree A theme.json tree containing layout definitions.
*
* @return {Array} An array of style declarations.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Breaking Change

- Increase the minimum Node.js version to 14 and minimum npm version to 6.14.4 ([#43141](https://github.com/WordPress/gutenberg/pull/43141)).
- Remove all rules targeting test files from the `recommended` and `recommended-with-formatting` presets when Jest package is installed ([#43272](https://github.com/WordPress/gutenberg/pull/43272)).

## 12.8.0 (2022-07-27)

Expand Down
18 changes: 9 additions & 9 deletions packages/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ There is also `recommended-with-formatting` ruleset for projects that want to en

Alternatively, you can opt-in to only the more granular rulesets offered by the plugin. These include:

- `custom`
- `es5`
- `esnext`
- `jsdoc`
- `jsx-a11y`
- `react`
- `i18n`
- `test-e2e`
- `test-unit`
- `custom` – custom rules for WordPress development.
- `es5` – rules for legacy ES5 environments.
- `esnext` – rules for ES2015+ environments.
- `i18n` – rules for internationalization.
- `jsdoc` – rules for JSDoc comments.
- `jsx-a11y` – rules for accessibility in JSX.
- `react` – rules for React components.
- `test-e2e` – rules for end-to-end tests written in Puppeteer.
- `test-unit`– rules for unit tests written in Jest.

For example, if your project does not use React, you could consider extending including only the ESNext rules in your project using the following `extends` definition:

Expand Down
26 changes: 1 addition & 25 deletions packages/eslint-plugin/configs/recommended-with-formatting.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
/**
* Internal dependencies
*/
const { isPackageInstalled } = require( '../utils' );

// Exclude bundled WordPress packages from the list.
const wpPackagesRegExp = '^@wordpress/(?!(icons|interface))';
const wpPackagesRegExp = '^@wordpress/(?!(icons|interface|style-engine))';

const config = {
extends: [
Expand Down Expand Up @@ -45,23 +40,4 @@ const config = {
},
};

// Don't apply Jest config if Playwright is installed.
if (
isPackageInstalled( 'jest' ) &&
! isPackageInstalled( '@playwright/test' )
) {
config.overrides = [
{
// Unit test files and their helpers only.
files: [ '**/@(test|__tests__)/**/*.js', '**/?(*.)test.js' ],
extends: [ require.resolve( './test-unit.js' ) ],
},
{
// End-to-end test files and their helpers only.
files: [ '**/specs/**/*.js', '**/?(*.)spec.js' ],
extends: [ require.resolve( './test-e2e.js' ) ],
},
];
}

module.exports = config;
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ const waitForMediaLibrary = async ( driver ) => {
/**
* @param {string} driver
* @param {string} elementLocator
* @param {number} maxIteration - Default value is 25
* @param {number} maxIteration - Default value is 25
* @param {string} elementToReturn - Options are allElements, lastElement, firstElement. Defaults to "firstElement"
* @param {number} iteration - Default value is 0
* @param {number} iteration - Default value is 0
* @return {string} - Returns the first element found, empty string if not found
*/
const waitForVisible = async (
Expand Down Expand Up @@ -567,7 +567,7 @@ const waitForVisible = async (
/**
* @param {string} driver
* @param {string} elementLocator
* @param {number} maxIteration - Default value is 25, can be adjusted to be less to wait for element to not be visible
* @param {number} maxIteration - Default value is 25, can be adjusted to be less to wait for element to not be visible
* @param {string} elementToReturn - Options are allElements, lastElement, firstElement. Defaults to "firstElement"
* @return {boolean} - Returns true if element is found, false otherwise
*/
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Breaking Change

- Increase the minimum Node.js version to 14 and minimum npm version to 6.14.4 ([#43141](https://github.com/WordPress/gutenberg/pull/43141)).
- The bundled `@wordpress/eslint-plugin` package got updated to the new major version and the default linting for Jest unit tests is now handled in the default config in this package ([#43272](https://github.com/WordPress/gutenberg/pull/43272)).

## 23.7.1 (2022-08-12)

Expand Down
7 changes: 7 additions & 0 deletions packages/scripts/config/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ const { hasBabelConfig } = require( '../utils' );
const eslintConfig = {
root: true,
extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ],
overrides: [
{
// Unit test files and their helpers only.
files: [ '**/@(test|__tests__)/**/*.js', '**/?(*.)test.js' ],
extends: [ 'plugin:@wordpress/eslint-plugin/test-unit' ],
},
],
};

if ( ! hasBabelConfig() ) {
Expand Down
10 changes: 5 additions & 5 deletions packages/style-engine/src/styles/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export function generateRule(
/**
* Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.
*
* @param style Style object.
* @param options Options object with settings to adjust how the styles are generated.
* @param path An array of strings representing the path to the style value in the style object.
* @param ruleKeys An array of CSS property keys and patterns.
* @param individualProperties The "sides" or individual properties for which to generate rules.
* @param style Style object.
* @param options Options object with settings to adjust how the styles are generated.
* @param path An array of strings representing the path to the style value in the style object.
* @param ruleKeys An array of CSS property keys and patterns.
* @param individualProperties The "sides" or individual properties for which to generate rules.
*
* @return GeneratedCSSRule[] CSS rules.
*/
Expand Down