@textlint/config-loader
Advanced tools
Comparing version 12.6.1 to 13.0.0
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -20,3 +11,3 @@ exports.loadRawConfig = exports.loadConfig = exports.loadPackagesFromRawConfig = void 0; | ||
*/ | ||
const loadPackagesFromRawConfig = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const loadPackagesFromRawConfig = async (options) => { | ||
var _a, _b, _c, _d, _e, _f; | ||
@@ -29,3 +20,3 @@ // TODO: validation | ||
// rules | ||
const { rules, rulesError } = yield (0, loader_1.loadRules)({ | ||
const { rules, rulesError } = await (0, loader_1.loadRules)({ | ||
rulesObject: (_a = options.rawConfig.rules) !== null && _a !== void 0 ? _a : {}, | ||
@@ -36,3 +27,3 @@ moduleResolver, | ||
// filterRules | ||
const { filterRules, filterRulesError } = yield (0, loader_1.loadFilterRules)({ | ||
const { filterRules, filterRulesError } = await (0, loader_1.loadFilterRules)({ | ||
rulesObject: (_c = options.rawConfig.filters) !== null && _c !== void 0 ? _c : {}, | ||
@@ -43,3 +34,3 @@ moduleResolver, | ||
// plugins | ||
const { plugins, pluginsError } = yield (0, loader_1.loadPlugins)({ | ||
const { plugins, pluginsError } = await (0, loader_1.loadPlugins)({ | ||
pluginsObject: (_e = options.rawConfig.plugins) !== null && _e !== void 0 ? _e : {}, | ||
@@ -77,3 +68,3 @@ moduleResolver, | ||
}; | ||
}); | ||
}; | ||
exports.loadPackagesFromRawConfig = loadPackagesFromRawConfig; | ||
@@ -84,4 +75,4 @@ /** | ||
*/ | ||
const loadConfig = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const rawResult = yield (0, exports.loadRawConfig)(options); | ||
const loadConfig = async (options) => { | ||
const rawResult = await (0, exports.loadRawConfig)(options); | ||
if (!rawResult.ok) { | ||
@@ -98,3 +89,3 @@ return { | ||
}; | ||
const result = yield (0, exports.loadPackagesFromRawConfig)(options.preLoadingPackage ? options.preLoadingPackage(packageOptions) : packageOptions); | ||
const result = await (0, exports.loadPackagesFromRawConfig)(options.preLoadingPackage ? options.preLoadingPackage(packageOptions) : packageOptions); | ||
if (!result.ok) { | ||
@@ -113,3 +104,3 @@ return { | ||
}; | ||
}); | ||
}; | ||
exports.loadConfig = loadConfig; | ||
@@ -121,3 +112,3 @@ /** | ||
*/ | ||
const loadRawConfig = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const loadRawConfig = async (options) => { | ||
try { | ||
@@ -161,4 +152,4 @@ const results = (0, rc_config_loader_1.rcFile)("textlint", { | ||
} | ||
}); | ||
}; | ||
exports.loadRawConfig = loadRawConfig; | ||
//# sourceMappingURL=config-loader.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,9 +8,7 @@ exports.dynamicImport = void 0; | ||
// https://github.com/nodejs/node/issues/31710 | ||
function dynamicImport(targetPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fileUrl = (0, node_url_1.pathToFileURL)(targetPath).href; | ||
return import(fileUrl); | ||
}); | ||
async function dynamicImport(targetPath) { | ||
const fileUrl = (0, node_url_1.pathToFileURL)(targetPath).href; | ||
return import(fileUrl); | ||
} | ||
exports.dynamicImport = dynamicImport; | ||
//# sourceMappingURL=import.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,3 +12,3 @@ exports.loadRules = exports.loadFilterRules = exports.loadPlugins = void 0; | ||
}; | ||
const loadPlugins = ({ pluginsObject, moduleResolver, testReplaceDefinitions }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const loadPlugins = async ({ pluginsObject, moduleResolver, testReplaceDefinitions }) => { | ||
const plugins = []; | ||
@@ -27,5 +18,5 @@ const pluginErrors = []; | ||
// { plugins: ["a", "b"] } | ||
yield Promise.all(pluginsObject.map((pluginId) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(pluginsObject.map(async (pluginId) => { | ||
const resolvedModule = moduleResolver.resolvePluginPackageName(pluginId); | ||
const mod = yield (0, import_1.dynamicImport)(resolvedModule.filePath); | ||
const mod = await (0, import_1.dynamicImport)(resolvedModule.filePath); | ||
const plugin = (0, module_interop_1.moduleInterop)(mod.default); | ||
@@ -47,7 +38,7 @@ if (!isPluginCreator(plugin)) { | ||
}); | ||
}))); | ||
})); | ||
} | ||
else { | ||
// { plugins: { "a": true, "b": options } } | ||
yield Promise.all(Object.entries(pluginsObject).map(([pluginId, pluginOptions]) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(Object.entries(pluginsObject).map(async ([pluginId, pluginOptions]) => { | ||
try { | ||
@@ -65,3 +56,3 @@ // Test Replace logic | ||
const resolvedPlugin = moduleResolver.resolvePluginPackageName(pluginId); | ||
const mod = yield (0, import_1.dynamicImport)(resolvedPlugin.filePath); | ||
const mod = await (0, import_1.dynamicImport)(resolvedPlugin.filePath); | ||
const plugin = (0, module_interop_1.moduleInterop)(mod.default); | ||
@@ -90,3 +81,3 @@ if (!isPluginCreator(plugin)) { | ||
} | ||
}))); | ||
})); | ||
} | ||
@@ -102,9 +93,9 @@ return { | ||
}; | ||
}); | ||
}; | ||
exports.loadPlugins = loadPlugins; | ||
const loadFilterRules = ({ rulesObject, moduleResolver, testReplaceDefinitions }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const loadFilterRules = async ({ rulesObject, moduleResolver, testReplaceDefinitions }) => { | ||
// rules | ||
const rules = []; | ||
const ruleErrors = []; | ||
yield Promise.all(Object.entries(rulesObject).map(([ruleId, ruleOptions]) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(Object.entries(rulesObject).map(async ([ruleId, ruleOptions]) => { | ||
try { | ||
@@ -122,3 +113,3 @@ // Test Replace logic | ||
const resolvePackage = moduleResolver.resolveFilterRulePackageName(ruleId); | ||
const mod = yield (0, import_1.dynamicImport)(resolvePackage.filePath); | ||
const mod = await (0, import_1.dynamicImport)(resolvePackage.filePath); | ||
const ruleModule = (0, module_interop_1.moduleInterop)(mod.default); | ||
@@ -142,3 +133,3 @@ if (!(0, is_1.isTextlintFilterRuleReporter)(ruleModule)) { | ||
} | ||
}))); | ||
})); | ||
return { | ||
@@ -153,9 +144,9 @@ filterRules: rules, | ||
}; | ||
}); | ||
}; | ||
exports.loadFilterRules = loadFilterRules; | ||
const loadRules = ({ rulesObject, moduleResolver, testReplaceDefinitions }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const loadRules = async ({ rulesObject, moduleResolver, testReplaceDefinitions }) => { | ||
// rules | ||
const rules = []; | ||
const ruleErrors = []; | ||
yield Promise.all(Object.entries(rulesObject).map(([ruleId, ruleOptions]) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(Object.entries(rulesObject).map(async ([ruleId, ruleOptions]) => { | ||
try { | ||
@@ -179,3 +170,3 @@ // Test Replace logic | ||
const presetRulesOptions = typeof ruleOptions === "boolean" ? {} : ruleOptions; | ||
const rulesInPreset = yield (0, preset_loader_1.loadPreset)({ | ||
const rulesInPreset = await (0, preset_loader_1.loadPreset)({ | ||
presetName: ruleId, | ||
@@ -190,3 +181,3 @@ presetRulesOptions, | ||
const resolvePackage = moduleResolver.resolveRulePackageName(ruleId); | ||
const mod = yield (0, import_1.dynamicImport)(resolvePackage.filePath); | ||
const mod = await (0, import_1.dynamicImport)(resolvePackage.filePath); | ||
const ruleModule = (0, module_interop_1.moduleInterop)(mod.default); | ||
@@ -217,3 +208,3 @@ if (!(0, is_1.isTextlintRuleModule)(ruleModule)) { | ||
} | ||
}))); | ||
})); | ||
return { | ||
@@ -228,4 +219,4 @@ rules, | ||
}; | ||
}); | ||
}; | ||
exports.loadRules = loadRules; | ||
//# sourceMappingURL=loader.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,22 +9,20 @@ exports.loadPreset = void 0; | ||
const import_1 = require("./import"); | ||
function loadPreset({ presetName, presetRulesOptions, moduleResolver }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const presetPackageName = moduleResolver.resolvePresetPackageName(presetName); | ||
const mod = yield (0, import_1.dynamicImport)(presetPackageName.filePath); | ||
const preset = (0, module_interop_1.moduleInterop)(mod.default); | ||
if (!(0, is_1.isPresetCreator)(preset)) { | ||
throw new Error(`preset should have rules and rulesConfig: ${presetName}`); | ||
} | ||
// we should use preset.rules → some preset use different name actual rule | ||
return Object.keys(preset.rules).map((ruleId) => { | ||
var _a; | ||
const normalizedKey = (0, utils_1.normalizeTextlintPresetSubRuleKey)({ preset: presetName, rule: ruleId }); | ||
return { | ||
ruleId: normalizedKey, | ||
rule: preset.rules[ruleId], | ||
options: (_a = presetRulesOptions[ruleId]) !== null && _a !== void 0 ? _a : preset.rulesConfig[ruleId], | ||
filePath: presetPackageName.filePath, | ||
moduleName: presetPackageName.moduleName | ||
}; | ||
}); | ||
async function loadPreset({ presetName, presetRulesOptions, moduleResolver }) { | ||
const presetPackageName = moduleResolver.resolvePresetPackageName(presetName); | ||
const mod = await (0, import_1.dynamicImport)(presetPackageName.filePath); | ||
const preset = (0, module_interop_1.moduleInterop)(mod.default); | ||
if (!(0, is_1.isPresetCreator)(preset)) { | ||
throw new Error(`preset should have rules and rulesConfig: ${presetName}`); | ||
} | ||
// we should use preset.rules → some preset use different name actual rule | ||
return Object.keys(preset.rules).map((ruleId) => { | ||
var _a; | ||
const normalizedKey = (0, utils_1.normalizeTextlintPresetSubRuleKey)({ preset: presetName, rule: ruleId }); | ||
return { | ||
ruleId: normalizedKey, | ||
rule: preset.rules[ruleId], | ||
options: (_a = presetRulesOptions[ruleId]) !== null && _a !== void 0 ? _a : preset.rulesConfig[ruleId], | ||
filePath: presetPackageName.filePath, | ||
moduleName: presetPackageName.moduleName | ||
}; | ||
}); | ||
@@ -40,0 +29,0 @@ } |
@@ -1,10 +0,1 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import { rcFile } from "rc-config-loader"; | ||
@@ -17,3 +8,3 @@ import { TextLintModuleResolver } from "./textlint-module-resolver"; | ||
*/ | ||
export const loadPackagesFromRawConfig = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
export const loadPackagesFromRawConfig = async (options) => { | ||
var _a, _b, _c, _d, _e, _f; | ||
@@ -26,3 +17,3 @@ // TODO: validation | ||
// rules | ||
const { rules, rulesError } = yield loadRules({ | ||
const { rules, rulesError } = await loadRules({ | ||
rulesObject: (_a = options.rawConfig.rules) !== null && _a !== void 0 ? _a : {}, | ||
@@ -33,3 +24,3 @@ moduleResolver, | ||
// filterRules | ||
const { filterRules, filterRulesError } = yield loadFilterRules({ | ||
const { filterRules, filterRulesError } = await loadFilterRules({ | ||
rulesObject: (_c = options.rawConfig.filters) !== null && _c !== void 0 ? _c : {}, | ||
@@ -40,3 +31,3 @@ moduleResolver, | ||
// plugins | ||
const { plugins, pluginsError } = yield loadPlugins({ | ||
const { plugins, pluginsError } = await loadPlugins({ | ||
pluginsObject: (_e = options.rawConfig.plugins) !== null && _e !== void 0 ? _e : {}, | ||
@@ -74,3 +65,3 @@ moduleResolver, | ||
}; | ||
}); | ||
}; | ||
/** | ||
@@ -80,4 +71,4 @@ * Load config file and return config object that is loaded rule instance. | ||
*/ | ||
export const loadConfig = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const rawResult = yield loadRawConfig(options); | ||
export const loadConfig = async (options) => { | ||
const rawResult = await loadRawConfig(options); | ||
if (!rawResult.ok) { | ||
@@ -94,3 +85,3 @@ return { | ||
}; | ||
const result = yield loadPackagesFromRawConfig(options.preLoadingPackage ? options.preLoadingPackage(packageOptions) : packageOptions); | ||
const result = await loadPackagesFromRawConfig(options.preLoadingPackage ? options.preLoadingPackage(packageOptions) : packageOptions); | ||
if (!result.ok) { | ||
@@ -109,3 +100,3 @@ return { | ||
}; | ||
}); | ||
}; | ||
/** | ||
@@ -116,3 +107,3 @@ * Load config file and return parsed config object that is not loaded rule instance | ||
*/ | ||
export const loadRawConfig = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
export const loadRawConfig = async (options) => { | ||
try { | ||
@@ -156,3 +147,3 @@ const results = rcFile("textlint", { | ||
} | ||
}); | ||
}; | ||
//# sourceMappingURL=config-loader.js.map |
@@ -1,10 +0,1 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import { pathToFileURL } from "node:url"; | ||
@@ -14,8 +5,6 @@ // import() can not load Window file path | ||
// https://github.com/nodejs/node/issues/31710 | ||
export function dynamicImport(targetPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fileUrl = pathToFileURL(targetPath).href; | ||
return import(fileUrl); | ||
}); | ||
export async function dynamicImport(targetPath) { | ||
const fileUrl = pathToFileURL(targetPath).href; | ||
return import(fileUrl); | ||
} | ||
//# sourceMappingURL=import.js.map |
@@ -1,10 +0,1 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import { isPresetRuleKey } from "./config-util"; | ||
@@ -18,3 +9,3 @@ import { moduleInterop } from "@textlint/module-interop"; | ||
}; | ||
export const loadPlugins = ({ pluginsObject, moduleResolver, testReplaceDefinitions }) => __awaiter(void 0, void 0, void 0, function* () { | ||
export const loadPlugins = async ({ pluginsObject, moduleResolver, testReplaceDefinitions }) => { | ||
const plugins = []; | ||
@@ -24,5 +15,5 @@ const pluginErrors = []; | ||
// { plugins: ["a", "b"] } | ||
yield Promise.all(pluginsObject.map((pluginId) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(pluginsObject.map(async (pluginId) => { | ||
const resolvedModule = moduleResolver.resolvePluginPackageName(pluginId); | ||
const mod = yield dynamicImport(resolvedModule.filePath); | ||
const mod = await dynamicImport(resolvedModule.filePath); | ||
const plugin = moduleInterop(mod.default); | ||
@@ -44,7 +35,7 @@ if (!isPluginCreator(plugin)) { | ||
}); | ||
}))); | ||
})); | ||
} | ||
else { | ||
// { plugins: { "a": true, "b": options } } | ||
yield Promise.all(Object.entries(pluginsObject).map(([pluginId, pluginOptions]) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(Object.entries(pluginsObject).map(async ([pluginId, pluginOptions]) => { | ||
try { | ||
@@ -62,3 +53,3 @@ // Test Replace logic | ||
const resolvedPlugin = moduleResolver.resolvePluginPackageName(pluginId); | ||
const mod = yield dynamicImport(resolvedPlugin.filePath); | ||
const mod = await dynamicImport(resolvedPlugin.filePath); | ||
const plugin = moduleInterop(mod.default); | ||
@@ -87,3 +78,3 @@ if (!isPluginCreator(plugin)) { | ||
} | ||
}))); | ||
})); | ||
} | ||
@@ -99,8 +90,8 @@ return { | ||
}; | ||
}); | ||
export const loadFilterRules = ({ rulesObject, moduleResolver, testReplaceDefinitions }) => __awaiter(void 0, void 0, void 0, function* () { | ||
}; | ||
export const loadFilterRules = async ({ rulesObject, moduleResolver, testReplaceDefinitions }) => { | ||
// rules | ||
const rules = []; | ||
const ruleErrors = []; | ||
yield Promise.all(Object.entries(rulesObject).map(([ruleId, ruleOptions]) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(Object.entries(rulesObject).map(async ([ruleId, ruleOptions]) => { | ||
try { | ||
@@ -118,3 +109,3 @@ // Test Replace logic | ||
const resolvePackage = moduleResolver.resolveFilterRulePackageName(ruleId); | ||
const mod = yield dynamicImport(resolvePackage.filePath); | ||
const mod = await dynamicImport(resolvePackage.filePath); | ||
const ruleModule = moduleInterop(mod.default); | ||
@@ -138,3 +129,3 @@ if (!isTextlintFilterRuleReporter(ruleModule)) { | ||
} | ||
}))); | ||
})); | ||
return { | ||
@@ -149,8 +140,8 @@ filterRules: rules, | ||
}; | ||
}); | ||
export const loadRules = ({ rulesObject, moduleResolver, testReplaceDefinitions }) => __awaiter(void 0, void 0, void 0, function* () { | ||
}; | ||
export const loadRules = async ({ rulesObject, moduleResolver, testReplaceDefinitions }) => { | ||
// rules | ||
const rules = []; | ||
const ruleErrors = []; | ||
yield Promise.all(Object.entries(rulesObject).map(([ruleId, ruleOptions]) => __awaiter(void 0, void 0, void 0, function* () { | ||
await Promise.all(Object.entries(rulesObject).map(async ([ruleId, ruleOptions]) => { | ||
try { | ||
@@ -174,3 +165,3 @@ // Test Replace logic | ||
const presetRulesOptions = typeof ruleOptions === "boolean" ? {} : ruleOptions; | ||
const rulesInPreset = yield loadPreset({ | ||
const rulesInPreset = await loadPreset({ | ||
presetName: ruleId, | ||
@@ -185,3 +176,3 @@ presetRulesOptions, | ||
const resolvePackage = moduleResolver.resolveRulePackageName(ruleId); | ||
const mod = yield dynamicImport(resolvePackage.filePath); | ||
const mod = await dynamicImport(resolvePackage.filePath); | ||
const ruleModule = moduleInterop(mod.default); | ||
@@ -212,3 +203,3 @@ if (!isTextlintRuleModule(ruleModule)) { | ||
} | ||
}))); | ||
})); | ||
return { | ||
@@ -223,3 +214,3 @@ rules, | ||
}; | ||
}); | ||
}; | ||
//# sourceMappingURL=loader.js.map |
@@ -1,10 +0,1 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
// LICENSE : MIT | ||
@@ -15,24 +6,22 @@ import { moduleInterop } from "@textlint/module-interop"; | ||
import { dynamicImport } from "./import"; | ||
export function loadPreset({ presetName, presetRulesOptions, moduleResolver }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const presetPackageName = moduleResolver.resolvePresetPackageName(presetName); | ||
const mod = yield dynamicImport(presetPackageName.filePath); | ||
const preset = moduleInterop(mod.default); | ||
if (!isPresetCreator(preset)) { | ||
throw new Error(`preset should have rules and rulesConfig: ${presetName}`); | ||
} | ||
// we should use preset.rules → some preset use different name actual rule | ||
return Object.keys(preset.rules).map((ruleId) => { | ||
var _a; | ||
const normalizedKey = normalizeTextlintPresetSubRuleKey({ preset: presetName, rule: ruleId }); | ||
return { | ||
ruleId: normalizedKey, | ||
rule: preset.rules[ruleId], | ||
options: (_a = presetRulesOptions[ruleId]) !== null && _a !== void 0 ? _a : preset.rulesConfig[ruleId], | ||
filePath: presetPackageName.filePath, | ||
moduleName: presetPackageName.moduleName | ||
}; | ||
}); | ||
export async function loadPreset({ presetName, presetRulesOptions, moduleResolver }) { | ||
const presetPackageName = moduleResolver.resolvePresetPackageName(presetName); | ||
const mod = await dynamicImport(presetPackageName.filePath); | ||
const preset = moduleInterop(mod.default); | ||
if (!isPresetCreator(preset)) { | ||
throw new Error(`preset should have rules and rulesConfig: ${presetName}`); | ||
} | ||
// we should use preset.rules → some preset use different name actual rule | ||
return Object.keys(preset.rules).map((ruleId) => { | ||
var _a; | ||
const normalizedKey = normalizeTextlintPresetSubRuleKey({ preset: presetName, rule: ruleId }); | ||
return { | ||
ruleId: normalizedKey, | ||
rule: preset.rules[ruleId], | ||
options: (_a = presetRulesOptions[ruleId]) !== null && _a !== void 0 ? _a : preset.rulesConfig[ruleId], | ||
filePath: presetPackageName.filePath, | ||
moduleName: presetPackageName.moduleName | ||
}; | ||
}); | ||
} | ||
//# sourceMappingURL=preset-loader.js.map |
{ | ||
"name": "@textlint/config-loader", | ||
"version": "12.6.1", | ||
"version": "13.0.0", | ||
"description": "Config loader for textlint. .textlintrc loader", | ||
@@ -47,6 +47,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@textlint/kernel": "^12.6.1", | ||
"@textlint/module-interop": "^12.6.1", | ||
"@textlint/types": "^12.6.1", | ||
"@textlint/utils": "^12.6.1", | ||
"@textlint/kernel": "^13.0.0", | ||
"@textlint/module-interop": "^13.0.0", | ||
"@textlint/types": "^13.0.0", | ||
"@textlint/utils": "^13.0.0", | ||
"debug": "^4.3.4", | ||
@@ -69,3 +69,3 @@ "rc-config-loader": "^4.1.2", | ||
}, | ||
"gitHead": "d2b1ea21b70dd86190f530ba3c1ecad697c8f39d" | ||
"gitHead": "5ab6892e6c3f100751542f2c84bc91e78c584f7f" | ||
} |
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
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
217587
2066
+ Added@textlint/ast-node-types@13.4.1(transitive)
+ Added@textlint/ast-tester@13.4.1(transitive)
+ Added@textlint/ast-traverse@13.4.1(transitive)
+ Added@textlint/feature-flag@13.4.1(transitive)
+ Added@textlint/kernel@13.4.1(transitive)
+ Added@textlint/module-interop@13.4.1(transitive)
+ Added@textlint/source-code-fixer@13.4.1(transitive)
+ Added@textlint/types@13.4.1(transitive)
+ Added@textlint/utils@13.4.1(transitive)
+ Addedfast-equals@4.0.3(transitive)
- Removed@textlint/ast-node-types@12.6.1(transitive)
- Removed@textlint/ast-tester@12.6.1(transitive)
- Removed@textlint/ast-traverse@12.6.1(transitive)
- Removed@textlint/feature-flag@12.6.1(transitive)
- Removed@textlint/kernel@12.6.1(transitive)
- Removed@textlint/module-interop@12.6.1(transitive)
- Removed@textlint/source-code-fixer@12.6.1(transitive)
- Removed@textlint/types@12.6.1(transitive)
- Removed@textlint/utils@12.6.1(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removeddeep-equal@1.1.2(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-date-object@1.0.5(transitive)
- Removedis-regex@1.1.4(transitive)
- Removedobject-is@1.1.6(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
Updated@textlint/kernel@^13.0.0
Updated@textlint/types@^13.0.0
Updated@textlint/utils@^13.0.0