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

FED-2994 Update class component defaults codemod to take public-ness into account #297

Merged
merged 5 commits into from
Oct 16, 2024

Conversation

sydneyjodon-wk
Copy link
Contributor

@sydneyjodon-wk sydneyjodon-wk commented Oct 15, 2024

Motivation

Right now, the class component codemod always makes defaulted props required, but that goes against our guidance (see here) in cases where those props are public.

This codemod should only make those props required when classes are private.

Changes

  • Move class defaulted props codemod into prop requiredness codemod to use public api info to only make defaulted props required if they are not public

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Frontend Frameworks Design member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary2-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

Just two comments!

exitCode = await runInteractiveCodemodSequence(
dartPaths,
[
ClassComponentRequiredDefaultPropsMigrator(null, recommender),
Copy link
Contributor

Choose a reason for hiding this comment

The 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 --yes-to-all) didn't have to do so twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It combines the patches when I put them together 😢

'mixin TestPrivatePropsMixin on UiProps {\n'
              '  String/*?*/ notDefaultedOptional;\n'
              '  /*late*/ String notDefaultedAlwaysSet;\n'
              '  /*late/*?*/*/ String/*?*/ defaultedN/*?*/ullable;\n'
              '  /*late*/ num/*!*/ defaultedNonNullable;\n'
              '}\n'

https://github.com/Workiva/over_react_codemod/actions/runs/11372701838/job/31637614201?pr=299

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

+10

@greglittlefield-wf
Copy link
Contributor

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

@rmconsole3-wf rmconsole3-wf merged commit 6cf5552 into master Oct 16, 2024
6 checks passed
@rmconsole3-wf rmconsole3-wf deleted the public-defaulted-props branch October 16, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants