Skip to content

chore: import/no-extraneous-dependencies off for stories and test files #5481

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

Closed
wants to merge 3 commits into from

Conversation

Rajdeepc
Copy link
Contributor

@Rajdeepc Rajdeepc commented May 19, 2025

Description

This PR modifies the ESLint configuration to disable the import/no-extraneous-dependencies rule for test and storybook files, allowing these files to import development dependencies without triggering linting errors.

Changes

  • Updated .eslintrc.json to turn off import/no-extraneous-dependencies rule for:
    • Test files (**/test/**/*.test.{js,ts,jsx,tsx})
    • Storybook files (**/stories/**/*.{js,ts,jsx,tsx})
  • Simplified the file patterns in the override configuration
  • Maintained the rule for all other source files

Impact

This change:

  • Reduces noise in the linting output for test and storybook files
  • Allows test and storybook files to freely import development dependencies
  • Maintains strict dependency checking for the main source code

Motivation and context

Related issue(s)

  • N/A

Screenshots (if appropriate)


Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Create a test commit in your local branch or in this branch

    1. Update any file in your code and try to add any test or storybook file to your commit
    2. Try to push this commit
    3. Commit passes without any errors stating missing dependencies

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

@Rajdeepc Rajdeepc self-assigned this May 19, 2025
@Rajdeepc Rajdeepc requested a review from a team as a code owner May 19, 2025 06:45
Copy link

changeset-bot bot commented May 19, 2025

⚠️ No Changeset found

Latest commit: 5af5279

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

Copy link

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

Tachometer results

Currently, no packages are changed by this PR...

@Rajdeepc Rajdeepc requested a review from castastrophe May 19, 2025 07:24
Comment on lines 88 to 89
"**/test/**/*.test.{js,ts,jsx,tsx}",
"**/stories/**/*.{js,ts,jsx,tsx}"
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks great but do we want to scope these a little more?

Suggested change
"**/test/**/*.test.{js,ts,jsx,tsx}",
"**/stories/**/*.{js,ts,jsx,tsx}"
"{packages,tools}/*/test/*.test.ts",
"{packages,tools}/*/stories/*.ts"

To make sure we're not ignoring assets we want to validate?

Copy link
Contributor

@castastrophe castastrophe left a comment

Choose a reason for hiding this comment

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

Approved with a suggestion about making the selectors more specific.

@@ -83,6 +83,15 @@
]
},
"overrides": [
{
"files": [
"{packages,tools}/*/test/*.test.ts",
Copy link
Contributor

@caseyisonit caseyisonit May 19, 2025

Choose a reason for hiding this comment

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

nit: what if we made these agnostic so we don't miss any rogue files in the repo?

Suggested change
"{packages,tools}/*/test/*.test.ts",
"**/test/*.test.ts",
"**/stories/*.ts"

Copy link
Contributor

@caseyisonit caseyisonit May 19, 2025

Choose a reason for hiding this comment

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

@Rajdeepc reopened this as tools has no context inside of packages. I recommend keeping the stars and adding the same rule to tools.

cc @castastrophe

Copy link
Contributor Author

@Rajdeepc Rajdeepc May 21, 2025

Choose a reason for hiding this comment

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

To avoid confusion, I have added the check to switch off it under

"files": [
      "*.test.ts",
      "*.stories.ts",
      "**/benchmark/*.ts",
      "**/test/*.ts"
  ],

@caseyisonit caseyisonit added the ready-for-merge Will auto-update until merged label May 21, 2025
@caseyisonit
Copy link
Contributor

@Rajdeepc I think during cutover I needed to add this rule in to get around linter errors in script testing. Can you confirm that's correct in main (that's what I see in the conflict). If it is correct and included in main, we can close this with a comment calling out the cutover PR resolved this.

@caseyisonit
Copy link
Contributor

Confirmed with @Rajdeepc that this is covered in main now and we can close this PR. Resolved in #5472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Will auto-update until merged ready-for-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants