ESLint to parse and verify JSDoc












4














Say I have this piece of code:



/** @type {string} */
const foo = '123';
const bar = foo.map((c) => c + 1);


Then I'd like ESLint to tell me I've got an error here: map is not a function of a string type



I use WebStorm as my IDE and it recognizes the issue, but I'd like to be able to recognize these issues using my linter from the command line.










share|improve this question




















  • 1




    This sounds like something you would use a language like Typescript for, and out of scope for a linter.
    – Flimm
    Nov 19 '18 at 15:09






  • 2




    @Flimm A linter or lint refers to tools that analyze source code to flag programming errors, bugs, stylistic errors, and suspicious constructs Wikipedia. I think it is in its scope? :)
    – YardenST
    Nov 19 '18 at 15:12












  • Google closure compiler more or less does just that. Facebook's flow analyzer should also catch that, even without the annotation. It is definitely out of scope for a linter, you just need a different tool.
    – Jared Smith
    Nov 19 '18 at 15:15


















4














Say I have this piece of code:



/** @type {string} */
const foo = '123';
const bar = foo.map((c) => c + 1);


Then I'd like ESLint to tell me I've got an error here: map is not a function of a string type



I use WebStorm as my IDE and it recognizes the issue, but I'd like to be able to recognize these issues using my linter from the command line.










share|improve this question




















  • 1




    This sounds like something you would use a language like Typescript for, and out of scope for a linter.
    – Flimm
    Nov 19 '18 at 15:09






  • 2




    @Flimm A linter or lint refers to tools that analyze source code to flag programming errors, bugs, stylistic errors, and suspicious constructs Wikipedia. I think it is in its scope? :)
    – YardenST
    Nov 19 '18 at 15:12












  • Google closure compiler more or less does just that. Facebook's flow analyzer should also catch that, even without the annotation. It is definitely out of scope for a linter, you just need a different tool.
    – Jared Smith
    Nov 19 '18 at 15:15
















4












4








4







Say I have this piece of code:



/** @type {string} */
const foo = '123';
const bar = foo.map((c) => c + 1);


Then I'd like ESLint to tell me I've got an error here: map is not a function of a string type



I use WebStorm as my IDE and it recognizes the issue, but I'd like to be able to recognize these issues using my linter from the command line.










share|improve this question















Say I have this piece of code:



/** @type {string} */
const foo = '123';
const bar = foo.map((c) => c + 1);


Then I'd like ESLint to tell me I've got an error here: map is not a function of a string type



I use WebStorm as my IDE and it recognizes the issue, but I'd like to be able to recognize these issues using my linter from the command line.







javascript webstorm eslint jsdoc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 19:31









LazyOne

106k21240258




106k21240258










asked Nov 19 '18 at 15:08









YardenST

3,43812338




3,43812338








  • 1




    This sounds like something you would use a language like Typescript for, and out of scope for a linter.
    – Flimm
    Nov 19 '18 at 15:09






  • 2




    @Flimm A linter or lint refers to tools that analyze source code to flag programming errors, bugs, stylistic errors, and suspicious constructs Wikipedia. I think it is in its scope? :)
    – YardenST
    Nov 19 '18 at 15:12












  • Google closure compiler more or less does just that. Facebook's flow analyzer should also catch that, even without the annotation. It is definitely out of scope for a linter, you just need a different tool.
    – Jared Smith
    Nov 19 '18 at 15:15
















  • 1




    This sounds like something you would use a language like Typescript for, and out of scope for a linter.
    – Flimm
    Nov 19 '18 at 15:09






  • 2




    @Flimm A linter or lint refers to tools that analyze source code to flag programming errors, bugs, stylistic errors, and suspicious constructs Wikipedia. I think it is in its scope? :)
    – YardenST
    Nov 19 '18 at 15:12












  • Google closure compiler more or less does just that. Facebook's flow analyzer should also catch that, even without the annotation. It is definitely out of scope for a linter, you just need a different tool.
    – Jared Smith
    Nov 19 '18 at 15:15










1




1




This sounds like something you would use a language like Typescript for, and out of scope for a linter.
– Flimm
Nov 19 '18 at 15:09




This sounds like something you would use a language like Typescript for, and out of scope for a linter.
– Flimm
Nov 19 '18 at 15:09




2




2




@Flimm A linter or lint refers to tools that analyze source code to flag programming errors, bugs, stylistic errors, and suspicious constructs Wikipedia. I think it is in its scope? :)
– YardenST
Nov 19 '18 at 15:12






@Flimm A linter or lint refers to tools that analyze source code to flag programming errors, bugs, stylistic errors, and suspicious constructs Wikipedia. I think it is in its scope? :)
– YardenST
Nov 19 '18 at 15:12














Google closure compiler more or less does just that. Facebook's flow analyzer should also catch that, even without the annotation. It is definitely out of scope for a linter, you just need a different tool.
– Jared Smith
Nov 19 '18 at 15:15






Google closure compiler more or less does just that. Facebook's flow analyzer should also catch that, even without the annotation. It is definitely out of scope for a linter, you just need a different tool.
– Jared Smith
Nov 19 '18 at 15:15














1 Answer
1






active

oldest

votes


















3














ESLint does not do this, but one can check javascript files, not just typescript files, with Typescript: https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files



It supports quite a few JSDoc comments: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript + it infers types when nothing has been explicitly defined.



Here's the Typescript config of an javascript project of mine: https://github.com/voxpelli/node-promised-retry/blob/67512edc4f414d128279f25268d860d9f10d2be0/tsconfig.json






share|improve this answer





















  • Thanks @VoxPelli this is a great solution I'll definitely check that out
    – YardenST
    Nov 30 '18 at 11:03













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377497%2feslint-to-parse-and-verify-jsdoc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














ESLint does not do this, but one can check javascript files, not just typescript files, with Typescript: https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files



It supports quite a few JSDoc comments: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript + it infers types when nothing has been explicitly defined.



Here's the Typescript config of an javascript project of mine: https://github.com/voxpelli/node-promised-retry/blob/67512edc4f414d128279f25268d860d9f10d2be0/tsconfig.json






share|improve this answer





















  • Thanks @VoxPelli this is a great solution I'll definitely check that out
    – YardenST
    Nov 30 '18 at 11:03


















3














ESLint does not do this, but one can check javascript files, not just typescript files, with Typescript: https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files



It supports quite a few JSDoc comments: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript + it infers types when nothing has been explicitly defined.



Here's the Typescript config of an javascript project of mine: https://github.com/voxpelli/node-promised-retry/blob/67512edc4f414d128279f25268d860d9f10d2be0/tsconfig.json






share|improve this answer





















  • Thanks @VoxPelli this is a great solution I'll definitely check that out
    – YardenST
    Nov 30 '18 at 11:03
















3












3








3






ESLint does not do this, but one can check javascript files, not just typescript files, with Typescript: https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files



It supports quite a few JSDoc comments: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript + it infers types when nothing has been explicitly defined.



Here's the Typescript config of an javascript project of mine: https://github.com/voxpelli/node-promised-retry/blob/67512edc4f414d128279f25268d860d9f10d2be0/tsconfig.json






share|improve this answer












ESLint does not do this, but one can check javascript files, not just typescript files, with Typescript: https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files



It supports quite a few JSDoc comments: https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript + it infers types when nothing has been explicitly defined.



Here's the Typescript config of an javascript project of mine: https://github.com/voxpelli/node-promised-retry/blob/67512edc4f414d128279f25268d860d9f10d2be0/tsconfig.json







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 30 '18 at 9:43









VoxPelli

1,561919




1,561919












  • Thanks @VoxPelli this is a great solution I'll definitely check that out
    – YardenST
    Nov 30 '18 at 11:03




















  • Thanks @VoxPelli this is a great solution I'll definitely check that out
    – YardenST
    Nov 30 '18 at 11:03


















Thanks @VoxPelli this is a great solution I'll definitely check that out
– YardenST
Nov 30 '18 at 11:03






Thanks @VoxPelli this is a great solution I'll definitely check that out
– YardenST
Nov 30 '18 at 11:03




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377497%2feslint-to-parse-and-verify-jsdoc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules