Skip to content

chore: add @eslint-react/eslint-plugin #6145

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

Merged
merged 6 commits into from
Jun 2, 2025
Merged

Conversation

joshblack
Copy link
Member

Now that we're on eslint v9, we can use https://eslint-react.xyz/ 🥳 This PR adds the package to the project along with some quick refactors for some rules.

Changelog

New

Changed

Removed

@Copilot Copilot AI review requested due to automatic review settings May 29, 2025 20:41
@joshblack joshblack requested a review from a team as a code owner May 29, 2025 20:41
@joshblack joshblack requested a review from TylerJDev May 29, 2025 20:41
Copy link

changeset-bot bot commented May 29, 2025

⚠️ No Changeset found

Latest commit: 9e59adc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the staff Author is a staff member label May 29, 2025
@joshblack joshblack added skip changeset This change does not need a changelog and removed staff Author is a staff member labels May 29, 2025
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label May 29, 2025
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates the new @eslint-react/eslint-plugin at version 9 and applies autofixes and refactors to satisfy the newly enabled lint rules.

  • Adds the ESLint plugin to package.json and updates eslint.config.mjs
  • Introduces shared default constants (e.g. defaultRenderAnchor, defaultSxProp, etc.) to replace inline object defaults
  • Applies automatic React lint fixes and refactors across multiple components

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/deprecated/ActionMenu.tsx Extract inline renderAnchor default into defaultRenderAnchor
packages/react/src/tests/hooks/useMnemonics.test.tsx Removed fallback onSelect default in test fixture
packages/react/src/SelectPanel/SelectPanel.tsx Moved inline renderAnchor to defaultRendorAnchor constant
packages/react/src/PageLayout/PageLayout.tsx Replaced sx = {} defaults with imported defaultSxProp
packages/react/src/PageHeader/PageHeader.tsx Replaced sx = {} default with defaultSxProp
packages/react/src/Overlay/Overlay.tsx Removed default empty object for styleFromProps
packages/react/src/DialogV1/Dialog.tsx Removed unused Box import and propTypes on DialogHeader
packages/react/src/Dialog/Dialog.tsx Added defaultFooterButtons constant for footerButtons default
packages/react/src/DataTable/Pagination.tsx Introduced defaultShowPages constant for showPages default
packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Introduced defaultVariant constant for variant default
package.json Added @eslint-react/eslint-plugin dependency
eslint.config.mjs Enabled eslint-react configs and rule overrides
Comments suppressed due to low confidence (5)

packages/react/src/SelectPanel/SelectPanel.tsx:137

  • The constant name defaultRendorAnchor appears to have a typo (Rendor vs. Render). Consider renaming it to defaultRenderAnchor for clarity.
const defaultRendorAnchor: SelectPanelProps['renderAnchor'] = props => {

packages/react/src/tests/hooks/useMnemonics.test.tsx:6

  • Removing the default onSelect = () => null means onSelect may be undefined in tests that don’t pass it explicitly, leading to runtime errors. Restore a safe default or mark it as required.
onSelect,

packages/react/src/Overlay/Overlay.tsx:105

  • By removing the default (= {}), styleFromProps can be undefined and may cause errors when spread into another object. Consider reintroducing a default empty object.
style: styleFromProps,

packages/react/src/Dialog/Dialog.tsx:231

  • [nitpick] Using a shared array constant as a default prop can lead to unexpected mutations if the array is modified at runtime. Consider using a factory function or inline default to ensure a new array per instance.
const defaultFooterButtons: Array<DialogButtonProps> = []

packages/react/src/DataTable/Pagination.tsx:175

  • [nitpick] Similar to defaultFooterButtons, this shared object may be mutated unintentionally. Consider returning a fresh object per invocation or documenting that it should be treated as immutable.
const defaultShowPages = {

Copy link
Contributor

github-actions bot commented Jun 2, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 94.51 KB (-0.03% 🔽)
packages/react/dist/browser.umd.js 94.64 KB (+0.02% 🔺)

@joshblack joshblack enabled auto-merge June 2, 2025 15:24
@joshblack joshblack added this pull request to the merge queue Jun 2, 2025
Merged via the queue into main with commit 1493ce9 Jun 2, 2025
35 checks passed
@joshblack joshblack deleted the chore/add-eslint-react branch June 2, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants