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
Upgrade: levn@0.4.1 (fixes #9366) #13140
Conversation
You should also update |
tests/lib/linter/linter.js
Outdated
}); | ||
|
||
describe("when evaluating code with comments that contain escape sequences", () => { | ||
const code = '/* eslint max-len: ["error", 1, { ignoreComments: true, ignorePattern: "console\\.log\\\\(" }] */\nconsole.log("test");\nvar a = "test2";'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the "...console\\.log..."
does anything, since this is console\.log
, when when passed through levn
is just console.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you switch to using String.raw
this will become more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the issue this PR fixes. Since this string is evaluated at runtime and then used to generate a RegExp, we need to ensure that the .
is escaped (so that it's evaluated as a literal .
character in the RegExp).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a test case like consoleXlog("test");
and make sure it does not fire if it's anything but a dot.
I'm saying is that what you actually want is an escaped backslash \
, so you want \\
(under String.raw
conditions). In JS console type "console\.log"
, you will see that the output is console.log
. You get this right later on when you ensure there is an escaped backlash before the (
by doing \\(
, so that it is escaped in the regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OH, I understand now - thanks! Updating now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1. after upgrading eslint-plugin-jsdoc, it reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names" it was fixed by added setting.jsdoc.mode: typescript (refs:https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names) 2. the following deps were not upgraded: * levn (was upgraded in #13140 * ignore (it has a few breaking change)
1. after upgrading eslint-plugin-jsdoc, it reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names" it was fixed by added setting.jsdoc.mode: typescript (refs:https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names) 2. the following deps were not upgraded: * levn (was upgraded in #13140) * ignore (it has a few breaking change)
1. after upgrading eslint-plugin-jsdoc, it reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names" it was fixed by added setting.jsdoc.mode: typescript (refs:https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names) 2. the following deps were not upgraded: * levn (was upgraded in #13140) * ignore (it has a few breaking change)
1. after upgrading eslint-plugin-jsdoc, it reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names" it was fixed by added setting.jsdoc.mode: typescript (refs:https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names) 2. the following deps were not upgraded: * levn (was upgraded in #13140) * ignore (it has a few breaking change)
* Upgrade: some (dev) deps 1. after upgrading eslint-plugin-jsdoc, it reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names" it was fixed by added setting.jsdoc.mode: typescript (refs:https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names) 2. the following deps were not upgraded: * levn (was upgraded in #13140) * ignore (it has a few breaking change) * Chore: update eslint-config-eslint peer deps * fix conflicts * Chore: review suggestions * Chore: add a comment
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 autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
fixes #9366
What changes did you make? (Give an overview)
This PR upgrades
levn
to0.4.1
to fix the issue of backslashes in strings not being escaped correctly in inline directive comments.Is there anything you'd like reviewers to focus on?
Am I missing anything? Apologies - I know the tests are difficult to read.