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

[core] Fix eslint no-restricted-imports rule application #13401

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Jun 6, 2024

I think the recent changes broke the linting because no-restricted-imports does not work well when applied several time (the last one tends to override the previous ones).

  • Prevent imports from the root of all the X packages except the grid ones in all our packages / doc / test files
  • Prevent imports from @mui/utils root in all our packages / doc / test files
  • Prevent imports from @mui/material root in all our packages / doc / test files
  • Prevent imports of depth 2 (e.g.: import { DateRange } from '@mui/x-date-pickers/internals/models') in all our packages / doc files (the test files can do it to avoid exporting stuff just because some test uses it

@LukasTy if you see any weird behavior I'm of course interested, I tested a few imports and it seems to be consistent

@flaviendelangle flaviendelangle added the core Infrastructure work going on behind the scenes label Jun 6, 2024
@mui-bot
Copy link

mui-bot commented Jun 6, 2024

Deploy preview: https://deploy-preview-13401--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against f2b634e

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 10, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 10, 2024
@@ -1,7 +1,7 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Rating from '@mui/material/Rating';
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
Copy link
Member

Choose a reason for hiding this comment

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

This modification looks weird, because nothing indicates that this hook is unstable.

Not an issue in the package code, but it the docs, I'm not sure

Copy link
Member Author

Choose a reason for hiding this comment

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

One could say that we should not even use @mui/utils in the doc since it's meant to be an internal package, but we are doing it extensively 😬

Copy link
Member

Choose a reason for hiding this comment

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

Problem solved? 😁

Suggested change
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
import unstable_useEnhancedEffect from '@mui/utils/useEnhancedEffect';

Otherwise, https://github.com/mui/material-ui/blob/a59ee1a371f488349dda6d4fd4993538aa0e1c77/docs/data/joy/customization/theme-colors/BootstrapVariantTokens.js#L108-L109

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 11, 2024

// Rules only impacting bundled files and doc files
{
files: ['packages/*/src/**/*{.ts,.tsx,.js}', 'docs/data/**/*{.ts,.tsx,.js}'],
Copy link
Member

Choose a reason for hiding this comment

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

I suspect that we don't need this. This should be coming from the monorepo root eslint configuration since there doesn't seem to be anything specific about MUI X.

Suggested change
files: ['packages/*/src/**/*{.ts,.tsx,.js}', 'docs/data/**/*{.ts,.tsx,.js}'],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants