本文整理汇总了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
}
})
);
}
示例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)
});
}
示例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);
}