Skip to content

Commit 052a63c

Browse files
committed
Bring over some fixes that were missed from Brian's original prototype
1 parent 181f762 commit 052a63c

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

eslint-plugin/src/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface IPlugin {
1414
rules: {[x: string]: eslint.Rule.RuleModule};
1515
}
1616

17-
export const plugin: IPlugin = {
17+
const plugin: IPlugin = {
1818
rules: {
1919
"syntax": {
2020
meta: {
@@ -31,16 +31,13 @@ export const plugin: IPlugin = {
3131
const tsDocParser: TSDocParser = new TSDocParser();
3232
const sourceCode: eslint.SourceCode = context.getSourceCode();
3333
const checkCommentBlocks: (node: ESTree.Node) => void = function (node: ESTree.Node) {
34-
const commentBlocks: ESTree.Comment[] = sourceCode.getCommentsBefore(node).filter(function (comment: ESTree.Comment) {
35-
return comment.type === "Block";
36-
});
37-
if (commentBlocks.length > 0) {
38-
const commentBlock: ESTree.Comment = commentBlocks[0];
39-
const commentString: string = "/*" + commentBlock.value + "*/";
34+
const commentToken: eslint.AST.Token | null = sourceCode.getJSDocComment(node);
35+
if (commentToken) {
36+
const commentString: string = "/*" + commentToken.value + "*/";
4037
const results: ParserMessageLog = tsDocParser.parseString(commentString).log;
4138
for (const message of results.messages) {
4239
context.report({
43-
node: node,
40+
loc: commentToken.loc,
4441
messageId: message.messageId,
4542
data: {
4643
unformattedText: message.unformattedText
@@ -58,3 +55,5 @@ export const plugin: IPlugin = {
5855
}
5956
}
6057
}
58+
59+
export = plugin;

eslint-plugin/src/tests/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { RuleTester } from "eslint";
3-
import { plugin } from "../index";
3+
import * as plugin from "../index";
44

55
const ruleTester: RuleTester = new RuleTester({
66
env: {

0 commit comments

Comments
 (0)