-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[code-infra] Ensure material-ui/disallow-react-api-in-server-components
ESLint rule is applied
#18570
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
[code-infra] Ensure material-ui/disallow-react-api-in-server-components
ESLint rule is applied
#18570
Conversation
…nts` ESLint rule is applied
Deploy preview: https://deploy-preview-18570--material-ui-x.netlify.app/ Bundle size reportTotal Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%) Show details for 100 more bundles (22 more not shown)@mui/x-charts parsed: 0B(0.00%) gzip: 0B(0.00%) |
what is happening exactly? Isn't eslint merging all rule objects from overrides that apply for a file? |
Core defines it like this:
And I suspect that the following rule overrides the above: Lines 265 to 270 in 782eaa3
|
🤔 As far as I understand all rules objects in all overrides that apply to a certain file are merged together. So I don't see how the |
Are you referring to the flat config, or the old one? 🤔 |
The old one.
Are you saying that if I do {
"rules": {
"quotes": ["error", "double"],
"indent": ["error", 2]
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"quotes": ["error", "single"]
}
},
{
"files": ["*.js"],
"rules": {
"indent": ["error", 4]
}
}
]
} the resolved rules for a js file wouldn't be {
"quotes": ["error", "single"],
"indent": ["error", 4]
} but {
"quotes": ["error", "double"],
"indent": ["error", 4]
} as the first override would be completely ignored? |
Checked it with
and I get // ...
"rules": {
"indent": [
"error",
4
],
"quotes": [
"error",
"single"
]
},
"settings": {},
// ... |
I assumed that it works as in this comment (#18570 (comment)), but I didn't check the resolved config. 🤔 |
Ah, I see what's going on. The core rule {
files: ['packages/*/src/*/*.?(c|m)[jt]s?(x)'],
excludedFiles: ['*.spec.*', '*.test.*', '**/mui-joy/**/*', '**/mui-docs/**/*'],
rules: {
'material-ui/disallow-react-api-in-server-components': 'error',
},
}, is deliberately only targeting one level deep in the src folder as it's meant for entrypoints only (notice the single |
Good observation! 🙌 |
Discovered this "can-of-worms" while checking #18562.
Due to legacy ESLint config overriding rules applied on the same
files
, this rule was being overridden and didn't take effect. 🙈Previously, we had a
build:rsc
script taking care of addinguse client;
at the top of the file, but #16273 removed it in favor of this ESLint rule... 🙈cc @brijeshb42