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-2112 Required props lint: respect @Props(ignoreRequiredProps: ...) #873

Merged
merged 17 commits into from
Jan 25, 2024

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented Jan 22, 2024

Dependent PR

These changes are dependent on two different PRs:

For review, I've set the base as a branch that merges the two together.

Motivation

Part of adding ignoreRequiredProps functionality is supporting it in the analyzer plugin, by making the required props lint not treat those props as required.

Changes

  • Update getAllRequiredProps logic to mark props specified within @Props(ignoreRequiredProps: ...) as ignored
    • Add unit tests
    • Add diagnostic integration tests
    • Add playground example
  • Add ignore for invalid_use_of_visible_for_overriding_member to generated code, since it was causing analyzer plugin test setups to fail when verifying that there are no analysis errors in generated parts
    • Update generated code and golds
  • Update boilerplate parsing to not throw when failing to instantiate an annotation, and instead severe-log.
    • That way, analyzer plugin functionality that relies on boilerplate parsing doesn't emit an IDE error notification when typing an annotation (I noticed this while QAing this change):
      ide-error-screenshot
    • Add regression test

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
    • Steps from PR author:
      • Verify in playground (tools/analyzer_plugin/playground/web/missing_required_props.dart) that:
        • the added IgnoresSomeRequired example doesn't warn for props that are ignored
        • adding/removing the ignoreRequiredProps argument doesn't cause IDE error notifications as you're typing
    • Anything falling under manual testing criteria outlined in CONTRIBUTING.md

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

…2' into analyzer-plugin-opt-out-required-props
@greglittlefield-wf greglittlefield-wf marked this pull request as ready for review January 22, 2024 23:57
@aviary3-wk
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.

'unnecessary_null_in_if_null_operators',
'prefer_null_aware_operators',
// Needed to ignore the `requiredPropNamesToSkipValidation` checks.
'invalid_use_of_visible_for_overriding_member',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this ignore to fix my test setup, which validated there were no warnings in generated code

@greglittlefield-wf greglittlefield-wf force-pushed the analyzer-plugin-opt-out-required-props branch from 7510775 to cbec88a Compare January 23, 2024 16:33
@greglittlefield-wf greglittlefield-wf force-pushed the analyzer-plugin-opt-out-required-props branch from cbec88a to 8a2e187 Compare January 23, 2024 20:44
@@ -50,32 +50,54 @@ class _PropsStateStringHelpersImpl extends Object with PropsStateStringHelpers {
_PropsStateStringHelpersImpl({required this.isProps});
}

final Expando<String> props_ignoreRequiredProps_source = Expando();

/// Uses [InstantiatedMeta] to analyze [node] and determine the proper annotation.
annotations.TypedMap getPropsOrStateAnnotation(bool isProps, AnnotatedNode node) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whitespace-agnostic diff here is helpful

@@ -102,31 +105,38 @@ class InstantiatedComponentMeta<TMeta> extends InstantiatedMeta<TMeta> {
final Identifier? subtypeOfValue;

InstantiatedComponentMeta._(
Annotation? metaNode, TMeta meta, List<Expression> unsupportedArguments, this.subtypeOfValue)
Annotation metaNode, TMeta meta, List<Expression> unsupportedArguments, this.subtypeOfValue)
: super._(metaNode, meta, unsupportedArguments);

static InstantiatedComponentMeta<T>? fromNode<T>(AnnotatedNode node) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whitespace-agnostic diff here is helpful

@greglittlefield-wf greglittlefield-wf force-pushed the analyzer-plugin-opt-out-required-props branch from 1d33d19 to 14d6c32 Compare January 23, 2024 21:31
Copy link
Contributor

@sydneyjodon-wk sydneyjodon-wk left a comment

Choose a reason for hiding this comment

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

+10

  • smoke tested in playground

@greglittlefield-wf greglittlefield-wf changed the base branch from analyzer-plugin-opt-out-required-props--clean-base to v5_wip January 25, 2024 20:54
Copy link
Contributor

@sydneyjodon-wk sydneyjodon-wk left a comment

Choose a reason for hiding this comment

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

+10 refresh

@greglittlefield-wf greglittlefield-wf merged commit a677009 into v5_wip Jan 25, 2024
8 checks passed
@greglittlefield-wf greglittlefield-wf deleted the analyzer-plugin-opt-out-required-props branch January 25, 2024 23:54
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.

4 participants