-
-
Notifications
You must be signed in to change notification settings - Fork 37
fix: fix comments removal in includeIgnoreFile() #333
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
base: main
Are you sure you want to change the base?
Conversation
|
Hi @hyperz111!, thanks for the Pull Request The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.
To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page. Read more about contributing to ESLint here |
|
Hi @hyperz111, thanks for the PR! Can you please update the original post with details about the bug this PR aims to fix, and an example where the bug is reproducible? |
You can run this code to check: const example = `
# Node.js
node_modules
!/fixtures/node_modules
/dist
# Logs
*.log # End with .log
# Gatsby files
.cache/
# vuepress build output
.vuepress/dist
# other
*/foo.js
dir/**
`.trim();
// Same function
function getIgnoresBefore(content) {
return content
.split(/\r?\n/g)
.map(line => line.trim())
.filter(line => line && !line.startsWith("#"));
}
console.log(getIgnoresBefore(example));
// Same function (in PR)
function getIgnoresAfter(content) {
return content
.split(/\r?\n/g)
.map(line =>
line
.trim()
.replace(/\s?[^\\]?#.*/gu, "")
.trim(),
)
.filter(Boolean);
}
console.log(getIgnoresAfter(example)); |
|
I think he wants to support lines with a comment after a pattern: lib/* # handle this also as a commentCurrently we only support comments at the start of the line which is also what the specification says. |
Yes |
I can't reproduce this behavior with my Git (git version 2.42.0.windows.2), and it isn't in the spec. Is it maybe some recent addition? |
|
Google search (AI overview) for
|
|
I tried it on version 2.52.0 on linux. I could not find any further information about its introduction, so I would be -1 for this change but maybe add a documentation notice. |
|
I'm also -1 for this change as this seems to be a non-standard feature, and I'm fine with adding a note in the docs that this isn't supported. Just to doublecheck in case we missed it. @hyperz111, since you linked the gitignore documentation, can you share the part of the documentation where this is described as allowed? |
|
@mdjermanovic @DMartens just a reminder -- please move items on the Triage board when you're triaging. |
Prerequisites checklist
What is the purpose of this pull request?
Fix comment removal removal in
includeIgnoreFile(). Following.gitignoredocumentation.What changes did you make? (Give an overview)
In
.map, I use regex for removing the valid comment.Related Issues
N/A
Is there anything you'd like reviewers to focus on?
N/A