@textlint/config-loader
Advanced tools
Comparing version 13.4.1 to 13.4.2-next.0
@@ -9,3 +9,3 @@ import type { TextlintRuleModule } from "@textlint/types"; | ||
export declare function hasLinter(ruleCreator: any): boolean; | ||
export declare const isTextlintRuleModule: (mod: unknown) => mod is TextlintRuleModule<{}>; | ||
export declare const isTextlintRuleModule: (mod: unknown) => mod is TextlintRuleModule; | ||
/** | ||
@@ -17,3 +17,3 @@ * Check if the given value is a preset object | ||
rules: { | ||
[index: string]: TextlintRuleModule<{}>; | ||
[index: string]: TextlintRuleModule; | ||
}; | ||
@@ -20,0 +20,0 @@ rulesConfig: { |
@@ -31,6 +31,8 @@ "use strict"; | ||
plugins.push({ | ||
type: "Plugin", | ||
pluginId, | ||
plugin, | ||
filePath: resolvedModule.filePath, | ||
moduleName: resolvedModule.moduleName | ||
moduleName: resolvedModule.moduleName, | ||
inputModuleName: resolvedModule.inputModuleName | ||
}); | ||
@@ -67,2 +69,3 @@ })); | ||
plugins.push({ | ||
type: "Plugin", | ||
pluginId, | ||
@@ -72,3 +75,4 @@ plugin, | ||
filePath: resolvedPlugin.filePath, | ||
moduleName: resolvedPlugin.moduleName | ||
moduleName: resolvedPlugin.moduleName, | ||
inputModuleName: resolvedPlugin.inputModuleName | ||
}); | ||
@@ -122,3 +126,4 @@ } | ||
filePath: resolvePackage.filePath, | ||
moduleName: resolvePackage.moduleName | ||
moduleName: resolvePackage.moduleName, | ||
inputModuleName: resolvePackage.inputModuleName | ||
}); | ||
@@ -194,3 +199,4 @@ } | ||
filePath: resolvePackage.filePath, | ||
moduleName: resolvePackage.moduleName | ||
moduleName: resolvePackage.moduleName, | ||
inputModuleName: resolvePackage.inputModuleName | ||
}); | ||
@@ -241,2 +247,3 @@ } | ||
- ruleKey: "a", | ||
- inputModuleName: "preset-example" | ||
@@ -254,3 +261,6 @@ */ | ||
filePath: presetPackageName.filePath, | ||
// preset package name | ||
moduleName: presetPackageName.moduleName, | ||
inputModuleName: presetPackageName.inputModuleName, | ||
// rule key in preset | ||
ruleKey | ||
@@ -257,0 +267,0 @@ }; |
@@ -8,2 +8,7 @@ export interface ConfigModulePrefix { | ||
} | ||
export type TextLintModuleResolverResolveResult = { | ||
inputModuleName: string; | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
/** | ||
@@ -30,6 +35,3 @@ * This class aim to resolve textlint's package name and get the module path. | ||
}); | ||
tryResolveModuleName: (moduleName: string) => { | ||
moduleName: string; | ||
filePath: string; | ||
} | null; | ||
tryResolvePackagePath: (modulePath: string) => string | null; | ||
/** | ||
@@ -40,6 +42,3 @@ * Take package name, and return path to module. | ||
*/ | ||
resolveRulePackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolveRulePackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -50,6 +49,3 @@ * Take package name, and return path to module. | ||
*/ | ||
resolveFilterRulePackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolveFilterRulePackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -60,6 +56,3 @@ * Take package name, and return path to module. | ||
*/ | ||
resolvePluginPackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolvePluginPackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -69,8 +62,4 @@ * Take package name, and return path to module. | ||
* The user must specify preset- prefix to these `packageName`. | ||
* @returns {string} return path to module | ||
*/ | ||
resolvePresetPackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolvePresetPackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -77,0 +66,0 @@ * Take Config package name, and return path to module. |
@@ -53,17 +53,11 @@ "use strict"; | ||
this.moduleCache = new Map(); | ||
this.tryResolveModuleName = (moduleName) => { | ||
const cachedFilePath = this.moduleCache.get(moduleName); | ||
this.tryResolvePackagePath = (modulePath) => { | ||
const cachedFilePath = this.moduleCache.get(modulePath); | ||
if (cachedFilePath) { | ||
return { | ||
moduleName, | ||
filePath: cachedFilePath | ||
}; | ||
return cachedFilePath; | ||
} | ||
const ret = (0, try_resolve_1.default)(moduleName); | ||
const ret = (0, try_resolve_1.default)(modulePath); | ||
if (ret) { | ||
this.moduleCache.set(moduleName, ret); | ||
return { | ||
moduleName, | ||
filePath: ret | ||
}; | ||
this.moduleCache.set(modulePath, ret); | ||
return ret; | ||
} | ||
@@ -86,9 +80,17 @@ return null; | ||
// <rule-name> or textlint-rule-<rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -108,9 +110,17 @@ throw new ReferenceError(`Failed to load textlint's rule module: "${packageName}" is not found. | ||
// <rule-name> or textlint-filter-rule-<rule-name> or @scope/<rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -130,9 +140,17 @@ throw new ReferenceError(`Failed to load textlint's filter rule module: "${packageName}" is not found. | ||
// <plugin-name> or textlint-plugin-<rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -147,3 +165,2 @@ throw new ReferenceError(`Failed to load textlint's plugin module: "${packageName}" is not found. | ||
* The user must specify preset- prefix to these `packageName`. | ||
* @returns {string} return path to module | ||
*/ | ||
@@ -174,20 +191,36 @@ resolvePresetPackageName(packageName) { | ||
// textlint-rule-preset-<preset-name> or @scope/textlint-rule-preset-<preset-name> | ||
const resultFullPresetPackageName = this.tryResolveModuleName(path.join(baseDir, fullFullPackageName)); | ||
if (resultFullPresetPackageName) { | ||
return resultFullPresetPackageName; | ||
const resultFullPresetPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullFullPackageName)); | ||
if (resultFullPresetPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullFullPackageName, | ||
filePath: resultFullPresetPackagePath | ||
}; | ||
} | ||
// <preset-name> | ||
const resultPresetPackageName = this.tryResolveModuleName(path.join(baseDir, packageNameWithoutPreset)); | ||
if (resultPresetPackageName) { | ||
return resultPresetPackageName; | ||
const resultPresetPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageNameWithoutPreset)); | ||
if (resultPresetPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageNameWithoutPreset, | ||
filePath: resultPresetPackagePath | ||
}; | ||
} | ||
// <rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
// <package-name> | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -194,0 +227,0 @@ throw new ReferenceError(`Failed to load textlint's preset module: "${packageName}" is not found. |
import type { TextlintKernelFilterRule, TextlintKernelPlugin, TextlintKernelRule } from "@textlint/kernel"; | ||
import type { TextlintRuleModule, TextlintRuleOptions } from "@textlint/types"; | ||
export type TextlintConfigPlugin = TextlintKernelPlugin & { | ||
type: "Plugin"; | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* plugin module name | ||
*/ | ||
moduleName: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
export type TextlintConfigSingleRule = TextlintKernelRule & { | ||
type: "Rule"; | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* rule module name | ||
* @example "textlint-rule-example" | ||
*/ | ||
moduleName: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
export type TextlintConfigRuleInPreset = TextlintKernelRule & { | ||
type: "RuleInPreset"; | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* preset module name | ||
* @example "textlint-rule-preset-example" | ||
*/ | ||
moduleName: string; | ||
/** | ||
* rule key in preset | ||
* @example In "{moduleName}/{ruleKey}", the ruleKey is "ruleKey" | ||
*/ | ||
ruleKey: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
* | ||
* Difference with `ruleId` is that `ruleId` is rule identifier and includes `preset-name`. | ||
* For example, `ruleId` is `preset-name/rule-key`. | ||
* But, `inputModuleName` is `preset-name`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
export type TextlintConfigRule = TextlintConfigSingleRule | TextlintConfigRuleInPreset; | ||
export type TextlintConfigFilterRule = TextlintKernelFilterRule & { | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* filter rule module name | ||
* @example "textlint-filter-rule-example" | ||
*/ | ||
moduleName: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
@@ -23,0 +83,0 @@ export type TextlintConfigRulePreset = { |
@@ -9,3 +9,3 @@ import type { TextlintRuleModule } from "@textlint/types"; | ||
export declare function hasLinter(ruleCreator: any): boolean; | ||
export declare const isTextlintRuleModule: (mod: unknown) => mod is TextlintRuleModule<{}>; | ||
export declare const isTextlintRuleModule: (mod: unknown) => mod is TextlintRuleModule; | ||
/** | ||
@@ -17,3 +17,3 @@ * Check if the given value is a preset object | ||
rules: { | ||
[index: string]: TextlintRuleModule<{}>; | ||
[index: string]: TextlintRuleModule; | ||
}; | ||
@@ -20,0 +20,0 @@ rulesConfig: { |
@@ -28,6 +28,8 @@ import { isPresetRuleKey } from "./config-util"; | ||
plugins.push({ | ||
type: "Plugin", | ||
pluginId, | ||
plugin, | ||
filePath: resolvedModule.filePath, | ||
moduleName: resolvedModule.moduleName | ||
moduleName: resolvedModule.moduleName, | ||
inputModuleName: resolvedModule.inputModuleName | ||
}); | ||
@@ -64,2 +66,3 @@ })); | ||
plugins.push({ | ||
type: "Plugin", | ||
pluginId, | ||
@@ -69,3 +72,4 @@ plugin, | ||
filePath: resolvedPlugin.filePath, | ||
moduleName: resolvedPlugin.moduleName | ||
moduleName: resolvedPlugin.moduleName, | ||
inputModuleName: resolvedPlugin.inputModuleName | ||
}); | ||
@@ -118,3 +122,4 @@ } | ||
filePath: resolvePackage.filePath, | ||
moduleName: resolvePackage.moduleName | ||
moduleName: resolvePackage.moduleName, | ||
inputModuleName: resolvePackage.inputModuleName | ||
}); | ||
@@ -189,3 +194,4 @@ } | ||
filePath: resolvePackage.filePath, | ||
moduleName: resolvePackage.moduleName | ||
moduleName: resolvePackage.moduleName, | ||
inputModuleName: resolvePackage.inputModuleName | ||
}); | ||
@@ -235,2 +241,3 @@ } | ||
- ruleKey: "a", | ||
- inputModuleName: "preset-example" | ||
@@ -248,3 +255,6 @@ */ | ||
filePath: presetPackageName.filePath, | ||
// preset package name | ||
moduleName: presetPackageName.moduleName, | ||
inputModuleName: presetPackageName.inputModuleName, | ||
// rule key in preset | ||
ruleKey | ||
@@ -251,0 +261,0 @@ }; |
@@ -8,2 +8,7 @@ export interface ConfigModulePrefix { | ||
} | ||
export type TextLintModuleResolverResolveResult = { | ||
inputModuleName: string; | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
/** | ||
@@ -30,6 +35,3 @@ * This class aim to resolve textlint's package name and get the module path. | ||
}); | ||
tryResolveModuleName: (moduleName: string) => { | ||
moduleName: string; | ||
filePath: string; | ||
} | null; | ||
tryResolvePackagePath: (modulePath: string) => string | null; | ||
/** | ||
@@ -40,6 +42,3 @@ * Take package name, and return path to module. | ||
*/ | ||
resolveRulePackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolveRulePackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -50,6 +49,3 @@ * Take package name, and return path to module. | ||
*/ | ||
resolveFilterRulePackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolveFilterRulePackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -60,6 +56,3 @@ * Take package name, and return path to module. | ||
*/ | ||
resolvePluginPackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolvePluginPackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -69,8 +62,4 @@ * Take package name, and return path to module. | ||
* The user must specify preset- prefix to these `packageName`. | ||
* @returns {string} return path to module | ||
*/ | ||
resolvePresetPackageName(packageName: string): { | ||
moduleName: string; | ||
filePath: string; | ||
}; | ||
resolvePresetPackageName(packageName: string): TextLintModuleResolverResolveResult; | ||
/** | ||
@@ -77,0 +66,0 @@ * Take Config package name, and return path to module. |
@@ -24,17 +24,11 @@ import * as path from "path"; | ||
this.moduleCache = new Map(); | ||
this.tryResolveModuleName = (moduleName) => { | ||
const cachedFilePath = this.moduleCache.get(moduleName); | ||
this.tryResolvePackagePath = (modulePath) => { | ||
const cachedFilePath = this.moduleCache.get(modulePath); | ||
if (cachedFilePath) { | ||
return { | ||
moduleName, | ||
filePath: cachedFilePath | ||
}; | ||
return cachedFilePath; | ||
} | ||
const ret = tryResolve(moduleName); | ||
const ret = tryResolve(modulePath); | ||
if (ret) { | ||
this.moduleCache.set(moduleName, ret); | ||
return { | ||
moduleName, | ||
filePath: ret | ||
}; | ||
this.moduleCache.set(modulePath, ret); | ||
return ret; | ||
} | ||
@@ -57,9 +51,17 @@ return null; | ||
// <rule-name> or textlint-rule-<rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -79,9 +81,17 @@ throw new ReferenceError(`Failed to load textlint's rule module: "${packageName}" is not found. | ||
// <rule-name> or textlint-filter-rule-<rule-name> or @scope/<rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -101,9 +111,17 @@ throw new ReferenceError(`Failed to load textlint's filter rule module: "${packageName}" is not found. | ||
// <plugin-name> or textlint-plugin-<rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -118,3 +136,2 @@ throw new ReferenceError(`Failed to load textlint's plugin module: "${packageName}" is not found. | ||
* The user must specify preset- prefix to these `packageName`. | ||
* @returns {string} return path to module | ||
*/ | ||
@@ -145,20 +162,36 @@ resolvePresetPackageName(packageName) { | ||
// textlint-rule-preset-<preset-name> or @scope/textlint-rule-preset-<preset-name> | ||
const resultFullPresetPackageName = this.tryResolveModuleName(path.join(baseDir, fullFullPackageName)); | ||
if (resultFullPresetPackageName) { | ||
return resultFullPresetPackageName; | ||
const resultFullPresetPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullFullPackageName)); | ||
if (resultFullPresetPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullFullPackageName, | ||
filePath: resultFullPresetPackagePath | ||
}; | ||
} | ||
// <preset-name> | ||
const resultPresetPackageName = this.tryResolveModuleName(path.join(baseDir, packageNameWithoutPreset)); | ||
if (resultPresetPackageName) { | ||
return resultPresetPackageName; | ||
const resultPresetPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageNameWithoutPreset)); | ||
if (resultPresetPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageNameWithoutPreset, | ||
filePath: resultPresetPackagePath | ||
}; | ||
} | ||
// <rule-name> | ||
const resultFullPackageName = this.tryResolveModuleName(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackageName) { | ||
return resultFullPackageName; | ||
const resultFullPackagePath = this.tryResolvePackagePath(path.join(baseDir, fullPackageName)); | ||
if (resultFullPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: fullPackageName, | ||
filePath: resultFullPackagePath | ||
}; | ||
} | ||
// <package-name> | ||
const resultPackageName = this.tryResolveModuleName(path.join(baseDir, packageName)); | ||
if (resultPackageName) { | ||
return resultPackageName; | ||
const resultPackagePath = this.tryResolvePackagePath(path.join(baseDir, packageName)); | ||
if (resultPackagePath) { | ||
return { | ||
inputModuleName: packageName, | ||
moduleName: packageName, | ||
filePath: resultPackagePath | ||
}; | ||
} | ||
@@ -165,0 +198,0 @@ throw new ReferenceError(`Failed to load textlint's preset module: "${packageName}" is not found. |
import type { TextlintKernelFilterRule, TextlintKernelPlugin, TextlintKernelRule } from "@textlint/kernel"; | ||
import type { TextlintRuleModule, TextlintRuleOptions } from "@textlint/types"; | ||
export type TextlintConfigPlugin = TextlintKernelPlugin & { | ||
type: "Plugin"; | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* plugin module name | ||
*/ | ||
moduleName: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
export type TextlintConfigSingleRule = TextlintKernelRule & { | ||
type: "Rule"; | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* rule module name | ||
* @example "textlint-rule-example" | ||
*/ | ||
moduleName: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
export type TextlintConfigRuleInPreset = TextlintKernelRule & { | ||
type: "RuleInPreset"; | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* preset module name | ||
* @example "textlint-rule-preset-example" | ||
*/ | ||
moduleName: string; | ||
/** | ||
* rule key in preset | ||
* @example In "{moduleName}/{ruleKey}", the ruleKey is "ruleKey" | ||
*/ | ||
ruleKey: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
* | ||
* Difference with `ruleId` is that `ruleId` is rule identifier and includes `preset-name`. | ||
* For example, `ruleId` is `preset-name/rule-key`. | ||
* But, `inputModuleName` is `preset-name`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
export type TextlintConfigRule = TextlintConfigSingleRule | TextlintConfigRuleInPreset; | ||
export type TextlintConfigFilterRule = TextlintKernelFilterRule & { | ||
/** | ||
* Absolute file path to the rule module | ||
*/ | ||
filePath: string; | ||
/** | ||
* filter rule module name | ||
* @example "textlint-filter-rule-example" | ||
*/ | ||
moduleName: string; | ||
/** | ||
* Inputted module name | ||
* This module name is resolved by config-loader | ||
* The resolved module name will be `moduleName`. | ||
*/ | ||
inputModuleName: string; | ||
}; | ||
@@ -23,0 +83,0 @@ export type TextlintConfigRulePreset = { |
{ | ||
"name": "@textlint/config-loader", | ||
"version": "13.4.1", | ||
"version": "13.4.2-next.0+e1284f9", | ||
"description": "Config loader for textlint. .textlintrc loader", | ||
@@ -47,6 +47,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@textlint/kernel": "^13.4.1", | ||
"@textlint/module-interop": "^13.4.1", | ||
"@textlint/types": "^13.4.1", | ||
"@textlint/utils": "^13.4.1", | ||
"@textlint/kernel": "^13.4.2-next.0+e1284f9", | ||
"@textlint/module-interop": "^13.4.2-next.0+e1284f9", | ||
"@textlint/types": "^13.4.2-next.0+e1284f9", | ||
"@textlint/utils": "^13.4.2-next.0+e1284f9", | ||
"debug": "^4.3.4", | ||
@@ -58,8 +58,8 @@ "rc-config-loader": "^4.1.3", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^18.18.9", | ||
"@types/node": "^18.19.9", | ||
"mocha": "^10.2.0", | ||
"prettier": "^2.3.0", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "~4.9.4" | ||
"ts-node": "^10.9.2", | ||
"typescript": "~5.3.3" | ||
}, | ||
@@ -69,3 +69,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "12529a831ab27256c0a322b439420f741ad22029" | ||
"gitHead": "e1284f942abd8eae21f4bdf029a185c9036ac0d6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238837
2289
1
1
+ Added@textlint/ast-node-types@13.4.2-next.0(transitive)
+ Added@textlint/ast-tester@13.4.2-next.0(transitive)
+ Added@textlint/ast-traverse@13.4.2-next.0(transitive)
+ Added@textlint/feature-flag@13.4.2-next.0(transitive)
+ Added@textlint/kernel@13.4.2-next.0(transitive)
+ Added@textlint/module-interop@13.4.2-next.0(transitive)
+ Added@textlint/source-code-fixer@13.4.2-next.0(transitive)
+ Added@textlint/types@13.4.2-next.0(transitive)
+ Added@textlint/utils@13.4.2-next.0(transitive)
- Removed@textlint/ast-node-types@13.4.1(transitive)
- Removed@textlint/ast-tester@13.4.1(transitive)
- Removed@textlint/ast-traverse@13.4.1(transitive)
- Removed@textlint/feature-flag@13.4.1(transitive)
- Removed@textlint/kernel@13.4.1(transitive)
- Removed@textlint/module-interop@13.4.1(transitive)
- Removed@textlint/source-code-fixer@13.4.1(transitive)
- Removed@textlint/types@13.4.1(transitive)
- Removed@textlint/utils@13.4.1(transitive)