Skip to content

Commit

Permalink
ESLint Plugin: Remove all rules targeting test files from recommended…
Browse files Browse the repository at this point in the history
… presets
  • Loading branch information
gziolo committed Aug 16, 2022
1 parent 44b9b59 commit d5bd0e4
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 53 deletions.
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/duotone/components.js
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
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
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
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
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
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
@@ -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;
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
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
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
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

0 comments on commit d5bd0e4

Please sign in to comment.