当前位置: 首页>>代码示例>>TypeScript>>正文


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

本文整理汇总了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;未经允许,请勿转载。