當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。