[英]ESLint to parse and verify JSDoc
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 然后我想让ESLint告诉我这里有一个错误:map不是字符串类型的函数
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. 我使用WebStorm作为我的IDE,它识别出这个问题,但我希望能够从命令行使用我的linter来识别这些问题。
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 ESLint没有这样做,但是可以使用Typescript检查javascript文件,而不仅仅是打字稿文件: 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. 它支持相当多的JSDoc注释: https : //github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript +它在没有明确定义任何内容时推断出类型。
Here's the Typescript config of an javascript project of mine: https://github.com/voxpelli/node-promised-retry/blob/67512edc4f414d128279f25268d860d9f10d2be0/tsconfig.json 这是我的一个javascript项目的Typescript配置: https : //github.com/voxpelli/node-promised-retry/blob/67512edc4f414d128279f25268d860d9f10d2be0/tsconfig.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.