【问题标题】:tslint error: Asterik in jsdoc must be alignedtslint 错误:jsdoc 中的 Asterik 必须对齐
【发布时间】:2017-02-20 15:09:11
【问题描述】:

我不断收到此 tslint 错误,但看不出代码有什么问题。有没有人看到下面的 jsdoc 星号没有正确对齐的问题:

/**
 * @ngdoc directive
 * @module ers.components.button
 * @scope
 * @transclude
 * @data
 * @binding
 * @name ersButton
 * @restrict E
 * @constructor
 * 
 * @description
 * 
 * A button performs the defined action when the user clicks it.
 * 
 * - Buttons can only consist of text and/or an icon.
 * - Buttons must contain either a click event, an href, an ui-sref, or a type (for form actions).
 * - Buttons labels should be clear. Limit the button text (less is more).
 * 
 * ### Usage
 * 
 * - Use <b>Primary Buttons</b> for primary actions (for example, "Submit", "Login", or "Save"). 
 * Avoid having multiple primary buttons on the same screen.
 * - Use <b>Secondary Buttons</b> for secondary actions that accompany the primary call-to-action (for example, "Reset" or "Cancel").
 * - Use <b>Icon Buttons</b> only for special use cases where standard label buttons are too large to use (for example, Tool Bars).
 *   
 * ### Examples
 * 
 * #### Standard Buttons
 * 
 * Primary and secondary buttons.
 *
 * <code-editor identifier="example1" data-title="Basic Buttons" html-content-url="demos/ersButton/basic/index.html" 
 * js-content-url="demos/ersButton/basic/script.js" css-content-url="demos/ersButton/basic/styles.css" 
 * content-mode="html"></code-editor>
 */

几乎下面的每一行都给了我同样的错误。

【问题讨论】:

  • 您的降价包含制表符和空格的混合,并且星号不会在降价中对齐。 jsdoc-format 规则强制执行的内容描述为 here,
  • 是的,一定有一些间距问题导致它失败。我最终只是删除了所有内容并再次输入它并通过了 linter。谢谢

标签: angularjs typescript jsdoc tslint


【解决方案1】:

来自jsdoc-format规则说明:

以下规则对 JSDoc cmets 强制执行(cmets 开始 与 /**):

  • 每行包含一个星号,星号必须对齐
  • 每个星号后面必须跟一个空格或换行符(第一个和最后一个除外)
  • 每行星号前的唯一字符必须是空白字符
  • 一行 cmets 必须以 /** 开头并以 */ 结尾

我从您的 comment 看到您有间距问题。

【讨论】:

  • 那么问题是什么?
【解决方案2】:

尽管看起来对齐星星不是您的问题,但我只是制作了这个小脚本来修复您所有的打字稿文件:https://github.com/Marr11317/starAligner。

希望对某些人有所帮助...

【讨论】:

    【解决方案3】:

    在我的 Angular 9 项目中,我得到了 lint 错误

    filename.ts:13:1 - asterisks in jsdoc must be aligned

    来自

    /**
     *
     */
    

    固定

    /*
    *
    */
    

    不知道为什么,因为多行 cmets 的 js-doc rule 说它需要两个星号。

    【讨论】:

      【解决方案4】:

      我遇到了同样的问题:

      错误:

      /**
      *
      *
      * 
      */
      

      修复:

      /**
       *
       *
       * 
       */
      

      【讨论】:

        猜你喜欢
        • 2020-02-06
        • 2019-08-21
        • 2020-05-25
        • 2017-04-07
        • 2015-02-13
        • 1970-01-01
        • 1970-01-01
        • 2017-11-20
        • 2021-07-01
        相关资源
        最近更新 更多