-
Notifications
You must be signed in to change notification settings - Fork 167
[WIP] feat(diagnostics): ability to ignore some codes #172
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,6 +184,31 @@ describe('diagnostics', () => { | |
await new Promise(resolve => setTimeout(resolve, 200)); | ||
assert.equal(diagnosticsForThisTest.length, 2, JSON.stringify(diagnostics)); | ||
}).timeout(10000); | ||
|
||
it('code 6133 (ununsed variable) is ignored', async () => { | ||
const doc = { | ||
uri: uri('diagnosticsBar2.ts'), | ||
languageId: 'typescript', | ||
version: 1, | ||
text: ` | ||
function foo() { | ||
const x = 42; | ||
return 1; | ||
} | ||
` | ||
} | ||
server.didOpenTextDocument({ | ||
textDocument: doc | ||
}) | ||
|
||
server.requestDiagnostics(); | ||
await server.requestDiagnostics(); | ||
await new Promise(resolve => setTimeout(resolve, 200)); | ||
const diagnosticsForThisFile = diagnostics.filter(d => d!.uri === doc.uri); | ||
assert.equal(diagnosticsForThisFile.length, 1, JSON.stringify(diagnostics)); | ||
const fileDiagnostics = diagnosticsForThisFile[0]!.diagnostics; | ||
assert.equal(fileDiagnostics.length, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test passes but only because the sample TS code does not generate a diagnostic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hrm, I'm not getting the same diagnostic error. I wonder what's up But, switching the code to
Does give me a diagnostic error:
Which I can ignore by setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll edit the test for this then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it has to do with the typescript version in use, or the target; I'm unclear as to which settings are used in the tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pushed the test change on this fixup commit |
||
}).timeout(10000); | ||
}); | ||
|
||
describe('document symbol', () => { | ||
|
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.
[].includes()
instead ofindexOf
maybe?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 used
Array.every
in my first version but that's why it wasn't working in neovim.I'm not sure what's going on there, maybe an older nodeJS runtime; but I figured I'd do away with the headache and just stick to es5.
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.
Array.includes is supported since node 6 though so it won't be a problem.
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 project currently targets es6 (or 2015), and it looks like
Array.includes
is only available for es7 (2016) compilation targets.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 see. Then never mind me although that target should probably be updated in a separate PR. That target is very old.
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 guess targeting an older standard has the added benefit of maximizing compatibility, if for some reason you're stuck with an older node version.
Uh oh!
There was an error while loading. Please reload this page.
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.
But ES7 is supported from Node7 (or Node 8 if you prefer "stable" release). It would be reasonable to require at least Node 8 as that is already 3 or 4 years old.
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.
Agreed that targeting the current LTS version would be better.
Uh oh!
There was an error while loading. Please reload this page.
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'd lean toward getting the target bumped prior to this PR if either of you are interested. Based on https://nodejs.org/en/about/releases/ we should probably support Node v10 and up
Edit: Created #173 to keep track of it
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 agree bumping deps and updating the target JS version is high priority, but it's unrelated to the changes in this PR and shouldn't be a blocker for merging this imo.