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

Upgrade: levn@0.4.1 (fixes #9366) #13140

Merged
merged 4 commits into from Apr 7, 2020
Merged

Upgrade: levn@0.4.1 (fixes #9366) #13140

merged 4 commits into from Apr 7, 2020

Conversation

kaicataldo
Copy link
Member

@kaicataldo kaicataldo commented Apr 4, 2020

Prerequisites checklist

  • I have read the contributing guidelines.
  • The team has reached consensus on the changes proposed in this pull request. If not, I understand that the evaluation process will begin with this pull request and won't be merged until the team has reached consensus.

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 to 0.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.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Apr 4, 2020
@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features and removed triage An ESLint team member will look at this issue soon labels Apr 4, 2020
tests/lib/linter/linter.js Outdated Show resolved Hide resolved
@gkz
Copy link
Contributor

gkz commented Apr 4, 2020

You should also update optionator to 0.9.1 - it uses levn internally (and 0.9.1 has the updated levn 0.4.1). Updating optionator will keep the versions of levn used by your option parsing and comment parsing in sync

});

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";';
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member Author

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).

Copy link
Contributor

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

Copy link
Member Author

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.

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

aladdin-add added a commit that referenced this pull request Apr 7, 2020
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)
aladdin-add added a commit that referenced this pull request Apr 7, 2020
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)
@aladdin-add aladdin-add mentioned this pull request Apr 7, 2020
2 tasks
aladdin-add added a commit that referenced this pull request Apr 7, 2020
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)
@kaicataldo kaicataldo merged commit 95e1c70 into master Apr 7, 2020
@kaicataldo kaicataldo deleted the upgrade-levn branch April 7, 2020 22:08
aladdin-add added a commit that referenced this pull request Apr 8, 2020
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)
aladdin-add added a commit that referenced this pull request Apr 24, 2020
* 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
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Oct 5, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Oct 5, 2020
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.

Escape characters are handled incorrectly in inline config comments
4 participants