-
Notifications
You must be signed in to change notification settings - Fork 342
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
Handle preexisting disable rule comments #1261
Handle preexisting disable rule comments #1261
Conversation
…preexisting-disable-rule-comment
…-preexisting-disable-rule-comment
…-preexisting-disable-rule-comment
@dbaeumer can you have a look into it? |
Will have a look this month. |
…-preexisting-disable-rule-comment
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.
Can you please exclude the package-lock changes from the PR. Otherwise very hard to merge.
server/src/eslintServer.ts
Outdated
if ( editInfo.line - 1 > 0) { | ||
|
||
// check previous line if there is a eslint-disable-next-line comment already present | ||
const prevLine = textDocument?.getText(Range.create(Position.create(editInfo.line - 2, 0), Position.create(editInfo.line - 2, Number.MAX_VALUE))); |
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.
We should use uinteger.MAX_VALUE which is defined in the latest LSP protocol and used in ESLint.
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.
changed to uinteger.MAX_VALUE
server/src/eslintServer.ts
Outdated
return TextEdit.insert(Position.create(editInfo.line - 1, 0), `${indentationText}// eslint-disable-next-line ${editInfo.ruleId}${EOL}`); | ||
} | ||
|
||
function createDisableSameLineTextEdit(editInfo: Problem): TextEdit { | ||
// Todo@dbaeumer Use uinteger.MAX_VALUE instead. | ||
return TextEdit.insert(Position.create(editInfo.line - 1, 2147483647), ` // eslint-disable-line ${editInfo.ruleId}`); | ||
const currentLine = textDocument?.getText(Range.create(Position.create(editInfo.line - 1, 0), Position.create(editInfo.line -1, Number.MAX_VALUE))); |
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.
Same here
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.
changed to uinteger.MAX_VALUE
server/src/eslintServer.ts
Outdated
@@ -1933,8 +1947,7 @@ messageQueue.registerRequest(CodeActionRequest.type, (params) => { | |||
if (settings.codeAction.disableRuleComment.location === 'sameLine') { | |||
workspaceChange.getTextEditChange({ uri, version: documentVersion }).add(createDisableSameLineTextEdit(editInfo)); | |||
} else { | |||
// Todo@dbaeumer Use uinteger.MAX_VALUE instead. | |||
const lineText = textDocument.getText(Range.create(Position.create(editInfo.line - 1, 0), Position.create(editInfo.line - 1, 2147483647))); | |||
const lineText = textDocument.getText(Range.create(Position.create(editInfo.line - 1, 0), Position.create(editInfo.line - 1, Number.MAX_VALUE))); |
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.
Same here
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.
changed to uinteger.MAX_VALUE
Reverted the change in all |
Hi @dbaeumer, the changes you had recommended are done. Please go through this PR. |
…-preexisting-disable-rule-comment
@dbaeumer resolved the merge conflicts |
@asingh04 sorry slipped through the cracks. When reviewing I noticed that the code has a lot of Thanks |
…-preexisting-disable-rule-comment
Oh yes, it is my mistake for not noting that |
Thanks for doing the changes. |
Referencing the issue #1248