• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript feature-flag.throwIfTesting函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@textlint/feature-flag.throwIfTesting函数的典型用法代码示例。如果您正苦于以下问题:TypeScript throwIfTesting函数的具体用法?TypeScript throwIfTesting怎么用?TypeScript throwIfTesting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了throwIfTesting函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: addProcessor

 /**
  * Use setupPlugins insteadof it.
  *
  * ````
  * textlint.setupPlugins({
  *   yourPluginName: yourPlugin
  * });
  * ````
  *
  * @param {*} Processor
  * @deprecated
  *
  * It will be removed until textlint@10
  */
 addProcessor(Processor: TextlintPluginProcessorConstructor) {
     throwIfTesting(
         "Use setupPlugins insteadof addProcessor method.`addProcessor` will be removed in the future." +
             "For more details, See https://github.com/textlint/textlint/issues/293"
     );
     this.pluginCreatorSet = new PluginCreatorSet(
         ObjectAssign({}, this.defaultPlugins, {
             [`${Processor.name}@deprecated`]: {
                 Processor
             }
         })
     );
 }
开发者ID:,项目名称:,代码行数:27,代码来源:


示例2: addProcessor

 /**
  * Use setupPlugins insteadof it.
  *
  * ````
  * textlint.setupPlugins({
  *   yourPluginName: yourPlugin
  * });
  * ````
  *
  * @param {*} Processor
  * @deprecated
  *
  * It will be removed until textlint@10
  */
 addProcessor(Processor: TextlintPluginProcessorConstructor) {
     throwIfTesting(
         "Use setupPlugins insteadof addProcessor method.`addProcessor` will be removed in the future." +
             "For more details, See https://github.com/textlint/textlint/issues/293"
     );
     this.textlintKernelDescriptor = this.textlintKernelDescriptor.shallowMerge({
         plugins: [
             {
                 pluginId: "`${Processor.name}@deprecated`",
                 plugin: { Processor }
             }
         ].concat(this.defaultPlugins)
     });
 }
开发者ID:textlint,项目名称:textlint,代码行数:28,代码来源:textlint-core.ts


示例3: adjust

    /**
     * adjust node's location with error's padding location.
     * @param {ReportMessage} reportArgs
     * @returns {{line: number, column: number, fix?: FixCommand}}
     */
    adjust(reportArgs: ReportArgs): { line: number; column: number; fix?: TextlintFixCommand } {
        const { node, ruleError, ruleId } = reportArgs;
        const errorPrefix = `[${ruleId}]` || "";
        const padding = ruleError;
        /*
         FIXME: It is old and un-document way
         new RuleError("message", index);
         */
        let _backwardCompatibleIndexValue;
        if (typeof padding === "number") {
            _backwardCompatibleIndexValue = padding;
            throwIfTesting(`${errorPrefix} This is un-document way:
report(node, new RuleError("message", index);

Please use { index }: 

report(node, new RuleError("message", {
    index: paddingLineColumn
});
`);
        }
        // when running from textlint-tester, assert
        if (padding.line === undefined && padding.column !== undefined) {
            // FIXME: Backward compatible <= textlint.5.5
            throwIfTesting(`${errorPrefix} Have to use a sets with "line" and "column".
See FAQ: https://github.com/textlint/textlint/blob/master/docs/faq/line-column-or-index.md            

report(node, new RuleError("message", {
    line: paddingLineNumber,
    column: paddingLineColumn
});

OR use "index" property insteadof only "column".

report(node, new RuleError("message", {
    index: paddingLineColumn
});
`);
        }

        // When either one of {column, line} or {index} is not used, throw error
        if ((padding.line !== undefined || padding.column !== undefined) && padding.index !== undefined) {
            // Introduced textlint 5.6
            // https://github.com/textlint/textlint/releases/tag/5.6.0
            // Always throw Error
            throw new Error(`${errorPrefix} Have to use {line, column} or index.
=> use either one of the two

report(node, new RuleError("message", {
    line: paddingLineNumber,
    column: paddingLineColumn
});

OR use "index" property

report(node, new RuleError("message", {
    index: paddingIndexValue
});
`);
        }

        const adjustedLoc = this._adjustLoc(node, padding, _backwardCompatibleIndexValue);
        const adjustedFix = this._adjustFix(node, padding);
        /*
         {
         line,
         column
         fix?
         }
         */
        return ObjectAssign({}, adjustedLoc, adjustedFix);
    }
开发者ID:jamesjnadeau,项目名称:jamesjnadeau.com,代码行数:77,代码来源:source-location.ts



注:本文中的@textlint/feature-flag.throwIfTesting函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript kernel.TextlintKernel类代码示例发布时间:2022-05-28
下一篇:
TypeScript dot-test-bed.DOTTestBed类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap