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: Add new rules #616

Merged
merged 1 commit into from
May 6, 2024
Merged

ESLint: Add new rules #616

merged 1 commit into from
May 6, 2024

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented May 4, 2024

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

  • Enter a code that does not follow the rules above.
  • ESLint should give you a warning.
  • If you have the eslint extension installed in your code editor, it will automatically format your code according to these rules.

Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These rules look correct based on the ones in Gutenberg here, and the code changes all look good to me 👍

@t-hamano
Copy link
Contributor Author

t-hamano commented May 6, 2024

@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.

@t-hamano t-hamano merged commit 59c3aac into trunk May 6, 2024
2 checks passed
@t-hamano t-hamano deleted the eslint/add-new-rules branch May 6, 2024 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants