Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3dde528
Add system props to sx migrator
greglittlefield-wf Feb 24, 2026
80471e8
Take forwarded props location into account
greglittlefield-wf Feb 24, 2026
f06bcd6
Wrap longer 2-item sx
greglittlefield-wf Feb 24, 2026
f4a24a2
Fix addUnconsumedProps case
greglittlefield-wf Feb 24, 2026
cede441
Tweak trailing commas and multiline
greglittlefield-wf Feb 24, 2026
8ce804d
Add/update tests
greglittlefield-wf Feb 24, 2026
4f2de69
Remove incorrect cases
greglittlefield-wf Feb 24, 2026
4f6b56f
Add language injection comments
greglittlefield-wf Feb 24, 2026
bd3c646
Use fat arrow functions to save on lines
greglittlefield-wf Feb 24, 2026
b86169b
Condense further
greglittlefield-wf Feb 24, 2026
bfa1c3a
Add fixme for potential behavior change
greglittlefield-wf Feb 24, 2026
4938322
Improve comment
greglittlefield-wf Feb 24, 2026
d50bae4
Handle comments
greglittlefield-wf Feb 24, 2026
1215a8b
Simplify multiline logic
greglittlefield-wf Feb 24, 2026
0cecc49
Update sx order to preserve behavior, clean up
greglittlefield-wf Feb 24, 2026
34738b5
Add fixmes in all cases where behavior changes
greglittlefield-wf Feb 24, 2026
b69b2d7
Remove language comments since interpolation messes them up
greglittlefield-wf Feb 24, 2026
32aef9d
Format
greglittlefield-wf Feb 24, 2026
b0225be
Use consts for FIXMEs
greglittlefield-wf Feb 24, 2026
9a47c13
Fix tests, remove extra newline
greglittlefield-wf Feb 24, 2026
c6e1052
Format
greglittlefield-wf Feb 24, 2026
43228a2
Clean up old code, simplify
greglittlefield-wf Feb 24, 2026
bdd35a4
Only apply precedence fixme when needed, update verbiage
greglittlefield-wf Feb 24, 2026
07558e6
Clean up names, system prop detection logic
greglittlefield-wf Feb 24, 2026
78caea2
Improve verbiage
greglittlefield-wf Feb 24, 2026
9e1abc4
Clean up, add comments
greglittlefield-wf Feb 24, 2026
f38ea61
Update doc comment
greglittlefield-wf Feb 24, 2026
392a251
Clean up executable
greglittlefield-wf Feb 24, 2026
d9c49a6
Add tags for tests using private package
greglittlefield-wf Feb 24, 2026
eedbe7a
Add MUI stub test fixture for sx migrator codemod
greglittlefield-wf Feb 25, 2026
63bc7ec
Update migrator and test to not rely on unify_ui
greglittlefield-wf Feb 25, 2026
3c14ba3
Format
greglittlefield-wf Feb 25, 2026
e7072d1
Update changelog
greglittlefield-wf Feb 25, 2026
b67d7d3
Revert wsd_project changes
greglittlefield-wf Feb 25, 2026
65d1d4d
Set up MUI stubs in test file
greglittlefield-wf Feb 25, 2026
cee78d4
Set up MUI stubs in test file
greglittlefield-wf Feb 25, 2026
2f81b79
Revert "Add MUI stub test fixture for sx migrator codemod"
greglittlefield-wf Feb 25, 2026
9802799
Switch from component name list to duck-typing system props
greglittlefield-wf Feb 25, 2026
7e9d28e
Update test util name
greglittlefield-wf Feb 25, 2026
e084694
Cleanup
greglittlefield-wf Feb 25, 2026
a905740
Reorganize system props code, improve doc comments
greglittlefield-wf Feb 26, 2026
def2266
Address CR feedback
greglittlefield-wf Feb 26, 2026
a0f8498
Format
greglittlefield-wf Feb 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Unreleased
- Add mui_system_props_migration codemod to migrate from system props to sx

## 2.37.1
- Use gha-dart-oss

Expand Down
15 changes: 15 additions & 0 deletions bin/mui_system_props_migration.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2026 Workiva Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export 'package:over_react_codemod/src/executables/mui_system_props_migration.dart';
35 changes: 35 additions & 0 deletions lib/src/executables/mui_system_props_migration.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2026 Workiva Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:io';

import 'package:codemod/codemod.dart';
import 'package:over_react_codemod/src/ignoreable.dart';
import 'package:over_react_codemod/src/mui_suggestors/system_props_to_sx_migrator.dart';
import 'package:over_react_codemod/src/util.dart';

void main(List<String> args) async {
const description = 'Migrates deprecated MUI system props to the `sx` prop,'
'\nensuring that existing `sx` prop values are preserved and merged correctly.';

exitCode = await runInteractiveCodemod(
allDartPathsExceptHidden(),
aggregate([
SystemPropsToSxMigrator(),
].map((s) => ignoreable(s))),
defaultYes: true,
args: args,
additionalHelpOutput: description,
);
}
139 changes: 139 additions & 0 deletions lib/src/mui_suggestors/system_props.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Copyright 2026 Workiva Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:analyzer/dart/element/element.dart';

/// Duck-types a component props class as a MUI-system-props-supporting props
/// class by checking for the presence of an `sx` prop and at least one system prop.
bool hasSxAndSomeSystemProps(InterfaceElement propsElement) {
const propsToCheck = [
'sx',
// The following items are arbitrary; we don't need to check for all system props,
// just a few to help prevent false positives where components have a prop or two
// that happens to match a system prop.
'bgcolor',
'm',
'letterSpacing',
];

return propsToCheck.every((propName) =>
propsElement.lookUpGetter(propName, propsElement.library) != null);
}

/// The names of all the MUI system props.
const systemPropNames = {
'm',
'mt',
'mr',
'mb',
'ml',
'mx',
'my',
'p',
'pt',
'pr',
'pb',
'pl',
'px',
'py',
'width',
'maxWidth',
'minWidth',
'height',
'maxHeight',
'minHeight',
'boxSizing',
'display',
'displayPrint',
'overflow',
'textOverflow',
'visibility',
'whiteSpace',
'flexBasis',
'flexDirection',
'flexWrap',
'justifyContent',
'alignItems',
'alignContent',
'order',
'flex',
'flexGrow',
'flexShrink',
'alignSelf',
'justifyItems',
'justifySelf',
'gap',
'columnGap',
'rowGap',
'gridColumn',
'gridRow',
'gridAutoFlow',
'gridAutoColumns',
'gridAutoRows',
'gridTemplateColumns',
'gridTemplateRows',
'gridTemplateAreas',
'gridArea',
'bgcolor',
'color',
'zIndex',
'position',
'top',
'right',
'bottom',
'left',
'boxShadow',
'border',
'borderTop',
'borderRight',
'borderBottom',
'borderLeft',
'borderColor',
'borderRadius',
'fontFamily',
'fontSize',
'fontStyle',
'fontWeight',
'letterSpacing',
'lineHeight',
'textAlign',
'textTransform',
'margin',
'marginTop',
'marginRight',
'marginBottom',
'marginLeft',
'marginX',
'marginY',
'marginInline',
'marginInlineStart',
'marginInlineEnd',
'marginBlock',
'marginBlockStart',
'marginBlockEnd',
'padding',
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
'paddingX',
'paddingY',
'paddingInline',
'paddingInlineStart',
'paddingInlineEnd',
'paddingBlock',
'paddingBlockStart',
'paddingBlockEnd',
'typography',
};
Loading