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

tools: auto fix custom eslint rule for no-unescaped-regexp-dot #16673

Conversation

shobhitchittora
Copy link
Contributor

@shobhitchittora shobhitchittora commented Nov 1, 2017

  1. Added fixer method for resolving lint error.
  2. Added additional valid tests + Output for current and new invalid tests.

Refs: #16636

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

Tools

1. Added fixer method for resolving lint error.
2. Added additional valid tests + Output for current and new invalid tests.

Refs: nodejs#16636
@nodejs-github-bot nodejs-github-bot added the tools Issues and PRs related to the tools directory. label Nov 1, 2017
Fixing some build errors + added correct output for invalid cases

Refs: nodejs#16636
},
{
code: String.raw`/\\./`,
errors: [{ message: 'Unescaped dot character in regular expression' }]
errors: [{ message: 'Unescaped dot character in regular expression' }],
output: String.raw`/\./`
Copy link
Member

Choose a reason for hiding this comment

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

This seems wrong... ? I believe it should be more like:

String.raw`/\\\./`

The \\ is part of the RegExp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the logic and test file.

const dotOffset = expression.indexOf('.');
var correctedExpression = '';

if (expression.charAt(dotOffset - 1) === '\\') {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this code should run unless a fixer is requested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@apapirovski Fixed.

1. Updated test with correct output strings + added additional invalid case.
2. Refractored the fixer method + logic correction.

Refs: nodejs#16636
@BridgeAR
Copy link
Member

BridgeAR commented Nov 23, 2017

Hm, I am somewhat against landing this. The reason is that this is ambiguous. The user might indeed intend to use the dot as is. If a user would just run eslint with the fix flag the user would not notice the change at all and that is somewhat bad. So I would rather keep it as is.

@joyeecheung
Copy link
Member

I am with @BridgeAR on this one.

@shobhitchittora
Copy link
Contributor Author

@apapirovski @joyeecheung @BridgeAR Would you like me to close this PR then ?

@joyeecheung
Copy link
Member

@shobhitchittora Yes...I think so. Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants