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

[New] forbid-component-props: add allowedForPatterns and disallowedForPatterns options #3805

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Efimenko
Copy link

@Efimenko Efimenko commented Aug 22, 2024

Initially, issue was described here, but it was closed by another PR (although this PR implements different case).
So, this PR just reimplements Regex implementation with globs as was suggested in one of the comments.

@Efimenko
Copy link
Author

@ljharb what do you think?

Comment on lines 145 to 147
allowPatternList: typeof value === 'string' ? [] : value.allowedForPatterns || [],
disallowList: typeof value === 'string' ? [] : (value.disallowedFor || []),
disallowPatternList: typeof value === 'string' ? [] : value.disallowedForPatterns || [],
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
allowPatternList: typeof value === 'string' ? [] : value.allowedForPatterns || [],
disallowList: typeof value === 'string' ? [] : (value.disallowedFor || []),
disallowPatternList: typeof value === 'string' ? [] : value.disallowedForPatterns || [],
allowPatternList: [].concat(value.allowedForPatterns || []),
disallowList: [].concat(value.disallowedFor || []),
disallowPatternList: [].concat(value.disallowedForPatterns || []),

altho i'm not sure why any of these would be able to be strings - doesn't the schema prevent that?

Copy link
Author

@Efimenko Efimenko Sep 19, 2024

Choose a reason for hiding this comment

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

Yeah, you're right about schema partially. There is also a string option there. Also, this rule has the default also for this rule, so that's why this code supports strings also.

lib/rules/forbid-component-props.js Outdated Show resolved Hide resolved
lib/rules/forbid-component-props.js Outdated Show resolved Hide resolved
lib/rules/forbid-component-props.js Outdated Show resolved Hide resolved
@ljharb ljharb marked this pull request as draft September 11, 2024 19:42
@Efimenko
Copy link
Author

Thanks a lot for the feedback, I will apply the changes.

@Efimenko
Copy link
Author

Honestly, not sure what to do with the "Automatic Rebase" action, didn't find any info in CONTRIBUTING.md

@Efimenko Efimenko marked this pull request as ready for review September 20, 2024 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants