New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@markuplint/file-resolver

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/file-resolver - npm Package Compare versions

Comparing version 3.0.0-dev.96 to 3.0.0-dev.176

4

lib/auto-load-rules.d.ts

@@ -6,4 +6,4 @@ import type { Ruleset, AnyMLRule } from '@markuplint/ml-core';

export declare function autoLoadRules(ruleset: Ruleset): Promise<{
rules: AnyMLRule[];
errors: unknown[];
rules: AnyMLRule[];
errors: unknown[];
}>;

@@ -25,3 +25,2 @@ "use strict";

};
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -45,3 +44,3 @@ exports.autoLoadRules = void 0;

try {
const _module = await (_a = `@markuplint/rule-${ruleName}`, Promise.resolve().then(() => __importStar(require(_a))));
const _module = await Promise.resolve(`${`@markuplint/rule-${ruleName}`}`).then(s => __importStar(require(s)));
seed = _module.default;

@@ -65,3 +64,3 @@ if (!(seed && 'defaultValue' in seed && 'defaultOptions' in seed && 'verify' in seed)) {

try {
const _module = await (_b = `markuplint-rule-${ruleName}`, Promise.resolve().then(() => __importStar(require(_b))));
const _module = await Promise.resolve(`${`markuplint-rule-${ruleName}`}`).then(s => __importStar(require(s)));
seed = _module.default;

@@ -68,0 +67,0 @@ if (!(seed && 'defaultValue' in seed && 'defaultOptions' in seed && 'verify' in seed)) {

import type { MLFile } from './ml-file';
import type { ConfigSet, Nullable } from './types';
import type { ConfigSet } from './types';
import type { Config } from '@markuplint/ml-config';
import type { Nullable } from '@markuplint/shared';
export declare class ConfigProvider {
#private;
resolve(targetFile: MLFile, names: Nullable<string>[], cache?: boolean): Promise<ConfigSet>;
search(targetFile: MLFile): Promise<string | null>;
set(config: Config, key?: string): string;
private _load;
private _mergeConfigs;
private _pathResolve;
private _recursiveLoad;
#private;
resolve(targetFile: Readonly<MLFile>, names: readonly Nullable<string>[], cache?: boolean): Promise<ConfigSet>;
search(targetFile: Readonly<MLFile>): Promise<string | null>;
set(config: Config, key?: string): string;
private _load;
private _mergeConfigs;
private _pathResolve;
private _recursiveLoad;
}

@@ -9,2 +9,3 @@ "use strict";

const ml_core_1 = require("@markuplint/ml-core");
const shared_1 = require("@markuplint/shared");
const cosmiconfig_1 = require("./cosmiconfig");

@@ -22,3 +23,3 @@ const resolve_plugins_1 = require("./resolve-plugins");

async resolve(targetFile, names, cache = true) {
var _a;
var _a, _b;
if (!cache) {

@@ -29,3 +30,3 @@ tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").clear();

}
const keys = names.filter(utils_1.nonNullableFilter);
const keys = names.filter(shared_1.nonNullableFilter);
const key = keys.join(KEY_SEPARATOR);

@@ -38,10 +39,10 @@ const currentConfig = tslib_1.__classPrivateFieldGet(this, _ConfigProvider_cache, "f").get(key);

const plugins = await (0, resolve_plugins_1.resolvePlugins)(configSet.config.plugins);
if (tslib_1.__classPrivateFieldGet(this, _ConfigProvider_held, "f").size) {
if (tslib_1.__classPrivateFieldGet(this, _ConfigProvider_held, "f").size > 0) {
const extendHelds = Array.from(tslib_1.__classPrivateFieldGet(this, _ConfigProvider_held, "f").values());
for (const held of extendHelds) {
const [, prefix, namespace, name] = held.match(/^([a-z]+:)([^/]+)(?:\/(.+))?$/) || [];
const [, prefix, namespace, name] = (_a = held.match(/^([a-z]+:)([^/]+)(?:\/(.+))?$/)) !== null && _a !== void 0 ? _a : [];
switch (prefix) {
case 'plugin:': {
const plugin = plugins.find(plugin => plugin.name === namespace);
const config = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.configs) === null || _a === void 0 ? void 0 : _a[name];
const config = (_b = plugin === null || plugin === void 0 ? void 0 : plugin.configs) === null || _b === void 0 ? void 0 : _b[name !== null && name !== void 0 ? name : ''];
if (config) {

@@ -63,5 +64,6 @@ this.set(config, held);

const isMatched = targetFile.matches(glob);
if (isMatched) {
const config = overrides[glob];
if (isMatched && config) {
// Note: Original config disappears
configSet.config = overrides[glob];
configSet.config = config;
}

@@ -91,3 +93,3 @@ }

set(config, key) {
key = key || (0, utils_1.uuid)();
key = key !== null && key !== void 0 ? key : (0, utils_1.uuid)();
tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").set(key, config);

@@ -97,2 +99,3 @@ return key;

async _load(filePath, cache) {
var _a;
const entity = tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").get(filePath);

@@ -103,4 +106,4 @@ if (entity) {

if (isPreset(filePath)) {
const [, name] = filePath.match(/^markuplint:(.+)$/i) || [];
const config = await (0, ml_core_1.getPreset)(name);
const [, name] = (_a = filePath.match(/^markuplint:(.+)$/i)) !== null && _a !== void 0 ? _a : [];
const config = await (0, ml_core_1.getPreset)(name !== null && name !== void 0 ? name : filePath);
const pathResolvedConfig = this._pathResolve(config, filePath);

@@ -140,3 +143,3 @@ tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").set(filePath, pathResolvedConfig);

.map(name => tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").get(name))
.filter(utils_1.nonNullableFilter);
.filter(shared_1.nonNullableFilter);
let resultConfig = {};

@@ -165,2 +168,3 @@ for (const config of configs) {

async _recursiveLoad(key, cache, depth = 1) {
var _a;
const stack = new Set();

@@ -176,3 +180,3 @@ const errs = [];

tslib_1.__classPrivateFieldGet(this, _ConfigProvider_recursiveLoadKeyAndDepth, "f").set(key, depth);
let config = tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").get(key) || null;
let config = (_a = tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").get(key)) !== null && _a !== void 0 ? _a : null;
if (!config) {

@@ -184,3 +188,3 @@ config = await this._load(key, cache);

}
const depKeys = config.extends ? (Array.isArray(config.extends) ? config.extends : [config.extends]) : null;
const depKeys = config.extends !== null ? (0, shared_1.toNoEmptyStringArrayFromStringOrArray)(config.extends) : null;
if (depKeys) {

@@ -206,4 +210,4 @@ for (const depKey of depKeys) {

if (!(0, utils_1.fileExists)(filePath) && moduleExists(filePath)) {
const mod = await (_a = filePath, Promise.resolve().then(() => tslib_1.__importStar(require(_a))));
const config = (mod === null || mod === void 0 ? void 0 : mod.default) || null;
const mod = await Promise.resolve(`${filePath}`).then(s => tslib_1.__importStar(require(s)));
const config = (_a = mod === null || mod === void 0 ? void 0 : mod.default) !== null && _a !== void 0 ? _a : null;
return config;

@@ -210,0 +214,0 @@ }

import type { LoaderSync } from 'cosmiconfig';
type CosmiConfig = ReturnType<LoaderSync>;
export declare function search<T = CosmiConfig>(dir: string, cacheClear: boolean): Promise<{
filePath: string;
config: T;
export declare function search<T = CosmiConfig>(
dir: string,
cacheClear: boolean,
): Promise<{
filePath: string;
config: T;
} | null>;
export declare function load<T = CosmiConfig>(filePath: string, cacheClear: boolean): Promise<{
filePath: string;
config: T;
export declare function load<T = CosmiConfig>(
filePath: string,
cacheClear: boolean,
): Promise<{
filePath: string;
config: T;
} | null>;
export {};

@@ -7,5 +7,7 @@ "use strict";

const cosmiconfig_1 = require("cosmiconfig");
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
const jsonc_1 = require("jsonc");
const explorer = (0, cosmiconfig_1.cosmiconfig)('markuplint', {
loaders: {
'.ts': (0, cosmiconfig_typescript_loader_1.TypeScriptLoader)(),
noExt: ((path, content) => {

@@ -12,0 +14,0 @@ try {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFiles = void 0;
const tslib_1 = require("tslib");
const glob_1 = tslib_1.__importDefault(require("glob"));
const glob_1 = require("glob");
const get_file_1 = require("./get-file");

@@ -15,12 +14,5 @@ /**

async function getFiles(filePathOrGlob) {
const fileList = await new Promise((resolve, reject) => {
(0, glob_1.default)(filePathOrGlob, {}, (err, matches) => {
if (err) {
reject(err);
}
resolve(matches);
});
}).catch(() => []);
const fileList = await (0, glob_1.glob)(filePathOrGlob, {}).catch(() => []);
return fileList.map(fileName => (0, get_file_1.getFile)(fileName));
}
exports.getFiles = getFiles;
import type { Target } from '../types';
export declare class MLFile {
#private;
constructor(target: Target);
get dirname(): string;
/**
* Normalized `MLFile.dirname`
*/
get nDirname(): string;
/**
* Normalized `MLFile.path`
*/
get nPath(): string;
get path(): string;
dirExists(): Promise<boolean>;
getCode(): Promise<string>;
isExist(): Promise<boolean>;
isFile(): Promise<boolean>;
matches(globPath: string): boolean;
setCode(code: string): void;
private _fetch;
private _stat;
#private;
constructor(target: Target);
get dirname(): string;
/**
* Normalized `MLFile.dirname`
*/
get nDirname(): string;
/**
* Normalized `MLFile.path`
*/
get nPath(): string;
get path(): string;
dirExists(): Promise<boolean>;
getCode(): Promise<string>;
isExist(): Promise<boolean>;
isFile(): Promise<boolean>;
matches(globPath: string): boolean;
setCode(code: string): void;
private _fetch;
private _stat;
}

@@ -8,5 +8,6 @@ "use strict";

const path_1 = tslib_1.__importDefault(require("path"));
const minimatch_1 = tslib_1.__importDefault(require("minimatch"));
const minimatch_1 = require("minimatch");
class MLFile {
constructor(target) {
var _a, _b;
_MLFile_basename.set(this, void 0);

@@ -34,4 +35,4 @@ _MLFile_code.set(this, void 0);

else {
tslib_1.__classPrivateFieldSet(this, _MLFile_basename, target.name || '<AnonymousFile>', "f");
tslib_1.__classPrivateFieldSet(this, _MLFile_dirname, target.workspace || process.cwd(), "f");
tslib_1.__classPrivateFieldSet(this, _MLFile_basename, (_a = target.name) !== null && _a !== void 0 ? _a : '<AnonymousFile>', "f");
tslib_1.__classPrivateFieldSet(this, _MLFile_dirname, (_b = target.workspace) !== null && _b !== void 0 ? _b : process.cwd(), "f");
}

@@ -86,3 +87,3 @@ tslib_1.__classPrivateFieldSet(this, _MLFile_code, target.sourceCode, "f");

matches(globPath) {
return (0, minimatch_1.default)(this.nPath, pathNormalize(globPath));
return (0, minimatch_1.minimatch)(this.nPath, pathNormalize(globPath));
}

@@ -89,0 +90,0 @@ setCode(code) {

import type { MLFile } from './ml-file';
import type { Target } from './types';
export declare function resolveFiles(targetList: Target[]): Promise<MLFile[]>;
export declare function resolveFiles(targetList: readonly Readonly<Target>[]): Promise<MLFile[]>;
import type { MLFile } from './ml-file';
import type { MLMarkupLanguageParser, ParserOptions } from '@markuplint/ml-ast';
import type { ParserConfig } from '@markuplint/ml-config';
export declare function resolveParser(file: MLFile, parserConfig?: ParserConfig, parserOptions?: ParserOptions): Promise<{
parserModName: string;
parser: MLMarkupLanguageParser;
parserOptions: ParserOptions;
matched: boolean;
export declare function resolveParser(
file: Readonly<MLFile>,
parserConfig?: ParserConfig,
parserOptions?: ParserOptions,
): Promise<{
parserModName: string;
parser: MLMarkupLanguageParser;
parserOptions: ParserOptions;
matched: boolean;
}>;

@@ -13,12 +13,14 @@ "use strict";

};
parserOptions = parserOptions || {};
parserOptions = parserOptions !== null && parserOptions !== void 0 ? parserOptions : {};
let parserModName = '@markuplint/html-parser';
let matched = false;
if (parserConfig) {
for (const pattern of Object.keys(parserConfig)) {
if (path_1.default.basename(file.path).match((0, utils_1.toRegexp)(pattern))) {
parserModName = parserConfig[pattern];
matched = true;
break;
for (const pattern of Object.keys(parserConfig)) {
if (path_1.default.basename(file.path).match((0, utils_1.toRegexp)(pattern))) {
const modName = parserConfig[pattern];
if (!modName) {
continue;
}
parserModName = modName;
matched = true;
break;
}

@@ -36,3 +38,2 @@ }

async function importParser(parserModName) {
var _a;
const entity = parsers.get(parserModName);

@@ -42,4 +43,4 @@ if (entity) {

}
const parser = await (_a = parserModName, Promise.resolve().then(() => tslib_1.__importStar(require(_a))));
const parser = await Promise.resolve(`${parserModName}`).then(s => tslib_1.__importStar(require(s)));
return parser;
}
import type { PluginConfig } from '@markuplint/ml-config';
import type { Plugin } from '@markuplint/ml-core';
export declare function resolvePlugins(pluginPaths?: (string | PluginConfig)[]): Promise<Plugin[]>;
export declare function resolvePlugins(pluginPaths?: readonly (string | PluginConfig)[]): Promise<Plugin[]>;
export declare function cacheClear(): void;

@@ -58,4 +58,5 @@ "use strict";

cache.set(plugin.name, plugin);
if (!plugin.name) {
plugin.name = config.name
let name = plugin.name;
if (!name) {
name = config.name
.toLowerCase()

@@ -65,5 +66,8 @@ .replace(/^(?:markuplint-rule-|@markuplint\/rule-)/i, '')

// eslint-disable-next-line no-console
console.info(`The plugin name became "${plugin.name}"`);
console.info(`The plugin name became "${name}"`);
}
return plugin;
return {
...plugin,
name,
};
}

@@ -77,4 +81,3 @@ function getPluginConfig(pluginPath) {

async function failSafeImport(name) {
var _a;
const res = await (_a = name, Promise.resolve().then(() => __importStar(require(_a)))).catch(e => e);
const res = await Promise.resolve(`${name}`).then(s => __importStar(require(s))).catch(e => e);
if ('code' in res && res === 'MODULE_NOT_FOUND') {

@@ -81,0 +84,0 @@ return null;

import type { AnyMLRule, Ruleset, Plugin } from '@markuplint/ml-core';
import { MLRule } from '@markuplint/ml-core';
export declare function resolveRules(plugins: Plugin[], ruleset: Ruleset, importPreset: boolean,
/**
* @deprecated
*/
autoLoad: boolean): Promise<AnyMLRule[] | MLRule<any, any>[]>;
export declare function resolveRules(
plugins: readonly Plugin[],
ruleset: Ruleset,
importPreset: boolean,
/**
* @deprecated
*/
autoLoad: boolean,
): Promise<Readonly<AnyMLRule>[]>;

@@ -59,3 +59,2 @@ "use strict";

async function importPresetRules() {
var _a;
if (cachedPresetRules) {

@@ -65,3 +64,3 @@ return cachedPresetRules.slice();

const modName = '@markuplint/rules';
const presetRules = (await (_a = modName, Promise.resolve().then(() => __importStar(require(_a))))).default;
const presetRules = (await Promise.resolve(`${modName}`).then(s => __importStar(require(s)))).default;
const ruleList = Object.entries(presetRules).map(([name, seed]) => {

@@ -68,0 +67,0 @@ const rule = new ml_core_1.MLRule({

@@ -33,4 +33,7 @@ import type { SpecConfig } from '@markuplint/ml-config';

*/
export declare function resolveSpecs(filePath: string, specConfig?: SpecConfig): Promise<{
schemas: readonly [MLMLSpec, ...ExtendedSpec[]];
export declare function resolveSpecs(
filePath: string,
specConfig?: SpecConfig,
): Promise<{
schemas: readonly [MLMLSpec, ...ExtendedSpec[]];
}>;

@@ -46,8 +46,2 @@ "use strict";

}
else if (Array.isArray(specConfig)) {
for (const specModName of specConfig) {
const spec = await importSpecs(specModName);
extendedSpecs.push(spec);
}
}
else {

@@ -57,2 +51,5 @@ for (const pattern of Object.keys(specConfig)) {

const specModName = specConfig[pattern];
if (!specModName) {
continue;
}
const spec = await importSpecs(specModName);

@@ -71,3 +68,2 @@ extendedSpecs.push(spec);

async function importSpecs(specModName) {
var _a;
{

@@ -80,3 +76,3 @@ // @ts-ignore

}
const spec = (await (_a = specModName, Promise.resolve().then(() => tslib_1.__importStar(require(_a))))).default;
const spec = (await Promise.resolve(`${specModName}`).then(s => tslib_1.__importStar(require(s)))).default;
// @ts-ignore

@@ -83,0 +79,0 @@ caches.set(specModName, spec);

import type { Config } from '@markuplint/ml-config';
import type { Plugin } from '@markuplint/ml-core';
export type Nullable<T> = T | null | undefined;
export interface ConfigSet {
config: Config;
plugins: Plugin[];
files: Set<string>;
errs: Error[];
readonly config: Config;
readonly plugins: readonly Plugin[];
readonly files: ReadonlySet<string>;
readonly errs: readonly Readonly<Error>[];
}
export type Target = string | {
/**
* Target source code of evaluation
*/
sourceCode: string;
/**
* File names when `sourceCodes`
*/
name?: string;
/**
* Workspace path when `sourceCodes`
*/
workspace?: string;
};
export type Target =
| string
| {
/**
* Target source code of evaluation
*/
readonly sourceCode: string;
/**
* File names when `sourceCodes`
*/
readonly name?: string;
/**
* Workspace path when `sourceCodes`
*/
readonly workspace?: string;
};

@@ -1,5 +0,3 @@

import type { Nullable } from './types';
export declare function nonNullableFilter<T>(item: Nullable<T>): item is T;
export declare function uuid(): string;
export declare function fileExists(filePath: string): boolean;
export declare function toRegexp(pattern: string): string | RegExp;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toRegexp = exports.fileExists = exports.uuid = exports.nonNullableFilter = void 0;
exports.toRegexp = exports.fileExists = exports.uuid = void 0;
const tslib_1 = require("tslib");
const fs_1 = tslib_1.__importDefault(require("fs"));
function nonNullableFilter(item) {
return !!item;
}
exports.nonNullableFilter = nonNullableFilter;
let uuidNum = 0;

@@ -23,3 +19,3 @@ function uuid() {

const matched = pattern.match(/^\/(.+)\/([ig]*)$/i);
if (matched) {
if (matched && matched[1]) {
return new RegExp(matched[1], matched[2]);

@@ -26,0 +22,0 @@ }

{
"name": "@markuplint/file-resolver",
"version": "3.0.0-dev.96+3b9f1720",
"version": "3.0.0-dev.176+f6ad62e9",
"description": "The file resolver of markuplint",

@@ -22,19 +22,21 @@ "repository": "git@github.com:markuplint/markuplint.git",

"devDependencies": {
"@types/node": "18.16.3"
},
"dependencies": {
"@markuplint/html-parser": "3.0.0-dev.176+f6ad62e9",
"@markuplint/ml-ast": "3.0.0-dev.176+f6ad62e9",
"@markuplint/ml-config": "3.0.0-dev.176+f6ad62e9",
"@markuplint/ml-core": "3.0.0-dev.176+f6ad62e9",
"@markuplint/ml-spec": "3.0.0-dev.176+f6ad62e9",
"@markuplint/shared": "3.5.1-dev.3129+f6ad62e9",
"@types/cosmiconfig": "^6.0.0",
"@types/glob": "^8.0.0",
"@types/node": "latest"
},
"dependencies": {
"@markuplint/html-parser": "3.0.0-dev.96+3b9f1720",
"@markuplint/ml-ast": "3.0.0-dev.96+3b9f1720",
"@markuplint/ml-config": "3.0.0-dev.96+3b9f1720",
"@markuplint/ml-core": "3.0.0-dev.96+3b9f1720",
"@markuplint/ml-spec": "3.0.0-dev.96+3b9f1720",
"cosmiconfig": "^8.0.0",
"glob": "^8.0.3",
"cosmiconfig-typescript-loader": "^4.3.0",
"glob": "^10.2.2",
"jsonc": "^2.0.0",
"minimatch": "^5.1.1",
"minimatch": "^9.0.0",
"tslib": "^2.4.1"
},
"gitHead": "3b9f17205d7754b29edf790bdbbf5e4931ba27a2"
"gitHead": "f6ad62e992e1569be4067f1e90d2d6017a658f57"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc