WordPress / create-block-theme

A WordPress plugin to create block themes
https://wordpress.org/plugins/create-block-theme/
GNU General Public License v2.0
310 stars 44 forks source link

ESLint: Add new rules #616

Closed t-hamano closed 2 months ago

t-hamano commented 2 months ago

This PR adds three new rules to ESLint that are also introduced in the Gutenberg project.

I believe these rules will improve code quality, prevent unintended problems, and make it easier for contributors.

Rules

@wordpress/dependency-group

Force import statements to add External, WordPress, and Internal as comments to indicate what they depend on.

import CodeMirror from '@uiw/react-codemirror';
import { __, sprintf } from '@wordpress/i18n';
import { fetchThemeJson } from '../resolvers';

/**
 * External dependencies
 */
import CodeMirror from '@uiw/react-codemirror';

/**
 * WordPress dependencies
 */
import { __, sprintf } from '@wordpress/i18n';

/**
 * Internal dependencies
 */
import { fetchThemeJson } from '../resolvers';

@wordpress/i18n-text-domain

Forces the text domain called create-block-theme in the translation function.

__( 'Hello World' )
__( 'Hello World', 'create-block' )

__( 'Hello World', 'create-block-theme' )

react/jsx-boolean-value

Forces the value to be omitted if the value of props is true.

<TextControl
    disabled={ true }
/>

<TextControl
    disabled
/>

Testing Instructions

t-hamano commented 2 months ago

@mikachan Thanks for the review!

P.S. Since I have been invited as a member of this repository, I would like to merge only the approved PRs myself.