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

fix: validate ignorePatterns constructor option in FlatESLint class #17139

Merged
merged 2 commits into from May 9, 2023

Conversation

mdjermanovic
Copy link
Member

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Adds missing validation for ignorePatterns constructor option of the FlatESLint class.

What changes did you make? (Give an overview)

Updated function processOptions to throw a readable message when ignorePatterns is not a non-empty string, an array of non-empty strings, or null.

Is there anything you'd like reviewers to focus on?

I'm not sure if this option should be accepting string value as that could be misleading. ignorePatterns: string might be interpreted as if the string can contain multiple patterns (e.g., a newline-delimited list).

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion labels Apr 30, 2023
@mdjermanovic mdjermanovic requested a review from a team as a code owner April 30, 2023 22:18
@netlify
Copy link

netlify bot commented Apr 30, 2023

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 04ee542
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/6453896374951700086a999a
😎 Deploy Preview https://deploy-preview-17139--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Contributor

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

LGTM. I'll leave it open for others to review.

I'm not sure if this option should be accepting string value as that could be misleading. ignorePatterns: string might be interpreted as if the string can contain multiple patterns (e.g., a newline-delimited list).

I believe the string type comes when using CLI --ignore-pattern '!.build'. Or does this also evaluates to ignorePatterns: ['!.build']?

@mdjermanovic
Copy link
Member Author

I'm not sure if this option should be accepting string value as that could be misleading. ignorePatterns: string might be interpreted as if the string can contain multiple patterns (e.g., a newline-delimited list).

I believe the string type comes when using CLI --ignore-pattern '!.build'. Or does this also evaluates to ignorePatterns: ['!.build']?

This evaluates to ignorePatterns: ["!.build"]. CLI passes either undefined or an array.

nzakas
nzakas previously approved these changes May 3, 2023
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Didn't realize we weren't validating this option.

@nzakas
Copy link
Member

nzakas commented May 3, 2023

I'm not sure if this option should be accepting string value as that could be misleading. ignorePatterns: string might be interpreted as if the string can contain multiple patterns (e.g., a newline-delimited list).

Oops, missed this. I think we can enforce that this option must take an array of strings and not a single string. Since the option is passed an array from the CLI, and ESLint also allows arrays in ignorePatterns, I think we're safe to limit to arrays.

@nzakas nzakas dismissed their stale review May 3, 2023 21:07

IgnorePatterns type update

@mdjermanovic
Copy link
Member Author

Updated to disallow ignorePatterns: string.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Just waiting until after we're cleared of a patch release to merge.

Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

@fasttime fasttime merged commit 0c415cd into main May 9, 2023
22 checks passed
@fasttime fasttime deleted the validate-ignorepatterns branch May 9, 2023 07:44
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Nov 6, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants