@blumintinc/eslint-plugin-blumint 1.20.142 → 1.20.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -146,20 +146,37 @@ const DEFAULT_MUI_COMPONENTS = new Set([
|
|
|
146
146
|
'Toolbar',
|
|
147
147
|
]);
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
150
|
-
* (
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
149
|
+
* Props a component declares as its own first-class API, keyed by the
|
|
150
|
+
* (component, prop) pair. Each name below collides with a system prop, but the
|
|
151
|
+
* component *consumes* it — feeding `ownerState`, selecting a theme value and
|
|
152
|
+
* MUI's internal `.Mui*-*` class selectors — instead of forwarding it as CSS.
|
|
153
|
+
* The system-prop reading is therefore wrong for the pair whatever value is
|
|
154
|
+
* written, and moving the prop into `sx` emits a declaration whose value is not
|
|
155
|
+
* a CSS value for that property: the browser drops it, so the fix type-checks
|
|
156
|
+
* (`SxProps` accepts `string | number`), lints clean, and silently loses the
|
|
157
|
+
* styling.
|
|
158
|
+
*
|
|
159
|
+
* The keying has to be per pair, not per prop name: the same name is a genuine
|
|
160
|
+
* system prop elsewhere (`color` on `Typography`, `maxWidth` on `Box`), so
|
|
161
|
+
* exempting the bare name would blind the rule on every other component.
|
|
156
162
|
*/
|
|
157
|
-
const
|
|
158
|
-
'
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
'
|
|
163
|
+
const COMPONENT_OWN_PROPS = new Map([
|
|
164
|
+
// `color` is a closed palette/variant selector (`'primary' | 'error' | …`)
|
|
165
|
+
// on these — never a CSS color (#1273). On `AppBar` it picks the *background*
|
|
166
|
+
// shade, so the system-prop reading also targets the wrong CSS property.
|
|
167
|
+
['Button', new Set(['color'])],
|
|
168
|
+
['IconButton', new Set(['color'])],
|
|
169
|
+
['Chip', new Set(['color'])],
|
|
170
|
+
['Badge', new Set(['color'])],
|
|
171
|
+
['AppBar', new Set(['color'])],
|
|
172
|
+
// `maxWidth` is a breakpoint KEY (`'xs' | … | 'xl' | false`) that selects a
|
|
173
|
+
// width from `theme.breakpoints.values` and drives the `maxWidth*` class
|
|
174
|
+
// (#1966). As CSS, `max-width: xl` is invalid and the element unbounds.
|
|
175
|
+
['Container', new Set(['maxWidth'])],
|
|
176
|
+
['Dialog', new Set(['maxWidth'])],
|
|
162
177
|
]);
|
|
178
|
+
/** True when `propName` belongs to `componentName`'s own prop API. */
|
|
179
|
+
const componentOwnsProp = (componentName, propName) => COMPONENT_OWN_PROPS.get(componentName)?.has(propName) === true;
|
|
163
180
|
/**
|
|
164
181
|
* Props that must never be moved to `sx` because they are genuine component
|
|
165
182
|
* API props, not MUI system styling shorthands. `direction` and `spacing` are
|
|
@@ -782,10 +799,10 @@ exports.preferSxPropOverSystemProps = (0, createRule_1.createRule)({
|
|
|
782
799
|
return false;
|
|
783
800
|
}
|
|
784
801
|
function isSystemProp(name, componentName) {
|
|
785
|
-
//
|
|
786
|
-
//
|
|
787
|
-
//
|
|
788
|
-
if (
|
|
802
|
+
// A prop the component owns is never the system prop of the same name, so
|
|
803
|
+
// the autofix must not rewrite it into a CSS declaration the browser
|
|
804
|
+
// discards.
|
|
805
|
+
if (componentOwnsProp(componentName, name)) {
|
|
789
806
|
return false;
|
|
790
807
|
}
|
|
791
808
|
return MUI_SYSTEM_PROPS.has(name) && !isAllowedProp(name);
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.20.143",
|
|
4
|
+
"date": "2026-08-12T07:48:25.970Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "prefer-sx-prop-over-system-props",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1966
|
|
11
|
+
],
|
|
12
|
+
"summary": "key the exemption on (component, prop) (closes #1966)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.20.142",
|
|
4
18
|
"date": "2026-08-12T07:04:58.677Z",
|