Skip to content

Commit

Permalink
feature: ember-template-lint documentation link
Browse files Browse the repository at this point in the history
* rule link

* parse uri

* feature: code description for template-lint-diagnostics

* update tests

* fix linting
  • Loading branch information
lifeart authored Feb 2, 2021
1 parent 8f26a2f commit eb475bf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,13 @@ export default class Server {
}
// this.setStatusText('Initialized');

const info = JSON.parse(fs.readFileSync(path.join(__dirname, './../package.json'), 'utf8'));

return {
serverInfo: {
name: info.name,
version: info.version,
},
capabilities: {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: TextDocumentSyncKind.Full,
Expand Down
Empty file removed src/utils/debug.log
Empty file.
12 changes: 10 additions & 2 deletions src/utils/diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ export function toHbsSource(templateNode: ITemplateNode): string {
}

export function toDiagnostic(source: string, error: TemplateLinterError): Diagnostic {
return {
const result = {
severity: DiagnosticSeverity.Error,
range: toRange(source, error),
message: toMessage(error),
code: error.rule,
code: error.rule || 'syntax',
source: error.rule ? 'ember-template-lint' : 'glimmer-engine',
};

if (result.source === 'ember-template-lint') {
(result as any).codeDescription = {
href: `https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/${result.code}.md`,
};
}

return result as Diagnostic;
}

function toLineRange(source: string, idx: number): [number, number] {
Expand Down
3 changes: 3 additions & 0 deletions test/__snapshots__/integration-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,9 @@ Object {
},
},
},
"serverInfo": Object {
"name": "@lifeart/ember-language-server",
},
}
`;
Expand Down
2 changes: 2 additions & 0 deletions test/integration-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ describe('integration', function () {
jest.setTimeout(15000);
const response = await initServer(connection);

expect(response.serverInfo.version.split('.').length).toEqual(3);
delete response.serverInfo.version;
expect(response).toMatchSnapshot();
});
});
Expand Down

0 comments on commit eb475bf

Please # to comment.