-
Notifications
You must be signed in to change notification settings - Fork 7
FED-2994 Update class component defaults codemod to take public-ness into account #297
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
Changes from 4 commits
72be3dd
3f56e0c
fe4c05b
06399a3
99d10cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import 'package:over_react_codemod/src/util/args.dart'; | |
| import 'package:over_react_codemod/src/util/command_runner.dart'; | ||
| import 'package:over_react_codemod/src/util/package_util.dart'; | ||
|
|
||
| import '../../null_safety_prep/class_component_required_default_props.dart'; | ||
| import '../codemod/recommender.dart'; | ||
| import '../collect/aggregated_data.sg.dart'; | ||
|
|
||
|
|
@@ -148,6 +149,16 @@ class CodemodCommand extends Command { | |
| parsedArgs.argValueAsNumber(_Options.publicMaxAllowedSkipRate), | ||
| ); | ||
|
|
||
| exitCode = await runInteractiveCodemodSequence( | ||
| dartPaths, | ||
| [ | ||
| ClassComponentRequiredDefaultPropsMigrator(null, recommender), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this not work when added to the sequence below, like so? exitCode = await runInteractiveCodemodSequence(
dartPaths,
[
+ ClassComponentRequiredDefaultPropsMigrator(null, recommender),
RequiredPropsSuggestor(
recommender,
trustRequiredAnnotations:
parsedArgs[_Flags.trustRequiredAnnotations] as bool,
),
],
defaultYes: true,
args: codemodArgs,
additionalHelpOutput: argParser.usage,
);Not a huge deal, but it would be nice if consumers who wanted to apply all patches via the prompt (like if they didn't think to pass
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It combines the patches when I put them together 😢
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm okay, thanks for trying! There's probably a bug in dart_codemod, then, possibly due to reusing FileContext/AnalysisContextCollection between suggestors. |
||
| ], | ||
| defaultYes: true, | ||
| args: codemodArgs, | ||
| additionalHelpOutput: argParser.usage, | ||
| ); | ||
|
|
||
| exitCode = await runInteractiveCodemodSequence( | ||
| dartPaths, | ||
| [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import 'package:over_react/over_react.dart'; | ||
|
|
||
| part 'test_class_component_defaults.over_react.g.dart'; | ||
|
|
||
| mixin TestPrivatePropsMixin on UiProps { | ||
| String notDefaultedOptional; | ||
| String notDefaultedAlwaysSet; | ||
| String defaultedNullable; | ||
| num defaultedNonNullable; | ||
| } | ||
|
|
||
| mixin SomeOtherPropsMixin on UiProps { | ||
| num anotherDefaultedNonNullable; | ||
| } | ||
|
|
||
| class TestPrivateProps = UiProps | ||
| with TestPrivatePropsMixin, SomeOtherPropsMixin; | ||
|
|
||
| UiFactory<TestPrivateProps> TestPrivate = | ||
| castUiFactory(_$TestPrivate); // ignore: undefined_identifier | ||
|
|
||
| class TestPrivateComponent extends UiComponent2<TestPrivateProps> { | ||
| @override | ||
| get defaultProps => (newProps() | ||
| ..defaultedNullable = null | ||
| ..defaultedNonNullable = 2.1 | ||
| ..anotherDefaultedNonNullable = 1.1 | ||
| ); | ||
|
|
||
| @override | ||
| render() {} | ||
| } | ||
|
|
||
| mixin TestPublic2PropsMixin on UiProps { | ||
| String notDefaultedOptional; | ||
| String notDefaultedAlwaysSet; | ||
| String defaultedNullable; | ||
| num defaultedNonNullable; | ||
| } | ||
|
|
||
| class TestPublic2Props = UiProps | ||
| with TestPublic2PropsMixin, SomeOtherPropsMixin; | ||
|
|
||
| UiFactory<TestPublic2Props> TestPublic2 = | ||
| castUiFactory(_$TestPublic2); // ignore: undefined_identifier | ||
|
|
||
| class TestPublic2Component extends UiComponent2<TestPublic2Props> { | ||
| @override | ||
| get defaultProps => (newProps() | ||
| ..defaultedNullable = null | ||
| ..defaultedNonNullable = 2.1 | ||
| ..anotherDefaultedNonNullable = 1.1 | ||
| ); | ||
|
|
||
| @override | ||
| render() {} | ||
| } | ||
|
|
||
| usages() { | ||
| (TestPrivate()..notDefaultedAlwaysSet = 'abc')(); | ||
| (TestPrivate() | ||
| ..notDefaultedOptional = 'abc' | ||
| ..notDefaultedAlwaysSet = 'abc' | ||
| ..defaultedNullable = 'abc' | ||
| ..defaultedNonNullable = 1 | ||
| ..anotherDefaultedNonNullable = 2 | ||
| )(); | ||
| (TestPublic2()..notDefaultedAlwaysSet = 'abc')(); | ||
| (TestPublic2() | ||
| ..notDefaultedAlwaysSet = 'abc' | ||
| ..notDefaultedOptional = 'abc' | ||
| ..defaultedNullable = 'abc' | ||
| ..defaultedNonNullable = 1 | ||
| ..anotherDefaultedNonNullable = 2 | ||
| )(); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.