Skip to content

refactor(project): update to eslint v9 #5972

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

joshblack
Copy link
Member

Closes https://github.com/github/primer/issues/4155

Update the project from eslint v7 to eslint v9, including a transformation to the new flat config.

Changelog

New

Changed

  • Update eslint configuration to use the new flat config
  • Update plugins in order to work with new flat config
  • Update files with changes rules or remove rules that no longer apply

Removed

Rollout strategy

  • None; if selected, include a brief description as to why

This is a change to our internal eslint config

@Copilot Copilot AI review requested due to automatic review settings April 25, 2025 18:12
@joshblack joshblack requested a review from a team as a code owner April 25, 2025 18:12
@joshblack joshblack requested a review from francinelucca April 25, 2025 18:12
Copy link

changeset-bot bot commented Apr 25, 2025

⚠️ No Changeset found

Latest commit: ea4d28f

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 staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Apr 25, 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 updates the project to ESLint v9 by migrating to the new flat config while ensuring code consistency with updated linting rules. Key changes include:

  • Replacing legacy ESLint configuration (.eslintrc.js) with a comprehensive flat config (eslint.config.mjs).
  • Updating event handlers in various ActionList and ActionMenu components from onClick to onSelect per new guidelines.
  • Transforming React import statements and ESLint ignore comments (e.g. switching from @ts-ignore to @ts-expect-error) to adhere to updated best practices.

Reviewed Changes

Copilot reviewed 122 out of 124 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Updated React import to "import type React" for improved type usage.
packages/react/src/ActionMenu/ActionMenu.examples.stories.tsx Replaced onClick with onSelect for action items.
packages/react/src/ActionList/Item.tsx Revised the function type suppression comment to reflect the updated rule and event handling changes.
packages/react/src/ActionBar/ActionBar.tsx Changed onClick to onSelect for overflow menu actions in the ActionBar.
packages/react/.storybook/src/accessibility-tool.tsx Removed optional chaining for window.localStorage for consistency with browser environments.
packages/postcss-preset-primer/src/index.js Modified ESLint suppression comments to use @ts-expect-error with explanatory messages.
eslint.config.mjs Introduced the new flat ESLint configuration aligning with ESLint v9 requirements.
.eslintrc.js Removed the legacy ESLint configuration in favor of the new setup.
examples/theming/src/app/registry.tsx & examples/nextjs/src/app/registry.tsx Updated React imports to separate type and value imports.
Files not reviewed (2)
  • .eslintignore: Language not supported
  • package.json: Language not supported
Comments suppressed due to low confidence (4)

packages/postcss-preset-primer/src/index.js:9

  • The switch from '@ts-ignore' to '@ts-expect-error' is good for clarity; verify that similar updates are applied consistently across other parts of the code.
import customPropertiesFallback from 'postcss-custom-properties-fallback'

.eslintrc.js:1

  • The removal of the legacy .eslintrc.js is expected with the migration to ESLint v9; ensure that any custom overrides are fully ported into the new flat config.
module.exports = { ... }

packages/react/.storybook/src/accessibility-tool.tsx:14

  • Since window.localStorage is guaranteed in browser environments, this explicit removal of optional chaining is appropriate; ensure the environment consistently supports localStorage.
const currentValue = showSurroundingElements ?? window.localStorage.getItem('showSurroundingElements') === 'true'

eslint.config.mjs:29

  • Review that the new flat config accurately reflects all necessary overrides and custom rules from the previous configuration to prevent unexpected linting behavior.
const config = defineConfig([

@joshblack joshblack added the skip changeset This change does not need a changelog label Apr 25, 2025
@github-actions github-actions bot requested a deployment to storybook-preview-5972 April 25, 2025 18:14 Abandoned
@joshblack joshblack changed the title Refactor/update to eslint v9 refactor(project): update to eslint v9 Apr 25, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-5972 April 25, 2025 18:29 Inactive
Copy link
Contributor

github-actions bot commented Apr 25, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 99.68 KB (-0.09% 🔽)
packages/react/dist/browser.umd.js 100.07 KB (+0.15% 🔺)

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 staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant