Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@markuplint/ml-config

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/ml-config - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

4

lib/merge-config.js

@@ -52,3 +52,3 @@ "use strict";

}
const value = Array.isArray(oA.value) && Array.isArray(b) ? [...oA.value, oB] : oB;
const value = Array.isArray(oA.value) && Array.isArray(oB) ? [...oA.value, ...oB] : oB;
const res = (0, utils_1.cleanOptions)({ ...oA, value });

@@ -149,3 +149,3 @@ (0, utils_1.deleteUndefProp)(res);

(0, utils_1.deleteUndefProp)(res);
return res;
return Object.freeze(res);
}

@@ -152,0 +152,0 @@ function optimizeRules(rules) {

import type { ParserOptions } from '@markuplint/ml-ast';
import type { RegexSelector } from '@markuplint/selector';
export type { RegexSelector } from '@markuplint/selector';
export interface Config {
$schema?: string;
extends?: string | string[];
plugins?: (PluginConfig | string)[];
parser?: ParserConfig;
parserOptions?: ParserOptions;
specs?: SpecConfig;
excludeFiles?: string[];
pretenders?: Pretender[];
rules?: Rules;
nodeRules?: NodeRule[];
childNodeRules?: ChildNodeRule[];
overrides?: Record<string, Omit<Config, '$schema' | 'extends' | 'overrides'>>;
}
export type Config = {
readonly $schema?: string;
readonly extends?: string | readonly string[];
readonly plugins?: readonly (PluginConfig | string)[];
readonly parser?: ParserConfig;
readonly parserOptions?: ParserOptions;
readonly specs?: SpecConfig;
readonly excludeFiles?: readonly string[];
readonly pretenders?: readonly Pretender[];
readonly rules?: Rules;
readonly nodeRules?: readonly NodeRule[];
readonly childNodeRules?: readonly ChildNodeRule[];
readonly overrides?: Readonly<Record<string, OverrideConfig>>;
};
export type PrimitiveScalar = string | number | boolean;
export type PlainData = Nullable<PrimitiveScalar> | readonly PlainData[] | {
readonly [key: string]: PlainData | any;
};
export type NonNullablePlainData = PrimitiveScalar | readonly NonNullablePlainData[] | {
readonly [key: string]: NonNullablePlainData;
};
export type OverrideConfig = Omit<Config, '$schema' | 'extends' | 'overrides'>;
export type PluginConfig = {
name: string;
settings: Record<string, any>;
readonly name: string;
readonly settings: Readonly<Record<string, NonNullablePlainData>>;
};
export interface ParserConfig {
[extensionPattern: string]: string;
}
export type ParserConfig = {
readonly [extensionPattern: string]: string;
};
export type SpecConfig = {
[extensionPattern: string]: string;
readonly [extensionPattern: string]: string;
};
export type Pretender = {
/**
* Target node selectors
*/
selector: string;
/**
* If it is a string, it is resolved as an element name.
* An element has the same attributes as the pretended custom element
* because attributes are just inherited.
*
* If it is an Object, It creates the element by that.
*/
as: string | OriginalNode;
/**
* Target node selectors
*/
readonly selector: string;
/**
* If it is a string, it is resolved as an element name.
* An element has the same attributes as the pretended custom element
* because attributes are just inherited.
*
* If it is an Object, It creates the element by that.
*/
readonly as: string | OriginalNode;
};
export type OriginalNode = {
/**
* Element name
*/
element: string;
/**
* Namespace
*
* Supports `"svg"` and `undefined` only.
* If it is `undefined`, the namespace is HTML.
*/
namespace?: 'svg';
/**
* Attributes
*/
attrs?: {
/**
* Attribute name
*/
name: string;
/**
* If it omits this property, the attribute is resolved as a boolean.
*/
value?:
| string
| {
fromAttr: string;
};
}[];
/**
* To have attributes the defined element has.
*/
inheritAttrs?: boolean;
/**
* ARIA properties
*/
aria?: PretenderARIA;
/**
* Element name
*/
readonly element: string;
/**
* Namespace
*
* Supports `"svg"` and `undefined` only.
* If it is `undefined`, the namespace is HTML.
*/
readonly namespace?: 'svg';
/**
* Attributes
*/
readonly attrs?: readonly {
/**
* Attribute name
*/
readonly name: string;
/**
* If it omits this property, the attribute is resolved as a boolean.
*/
readonly value?: string | {
readonly fromAttr: string;
};
}[];
/**
* To have attributes the defined element has.
*/
readonly inheritAttrs?: boolean;
/**
* ARIA properties
*/
readonly aria?: PretenderARIA;
};

@@ -84,101 +90,99 @@ /**

export type PretenderARIA = {
/**
* Accessible name
*
* - If it is `true`, it assumes the element has any text on its accessible name.
* - If it specifies `fromAttr` property, it assumes the accessible name refers to the value of the attribute.
*/
name?:
| boolean
| {
fromAttr: string;
};
/**
* Accessible name
*
* - If it is `true`, it assumes the element has any text on its accessible name.
* - If it specifies `fromAttr` property, it assumes the accessible name refers to the value of the attribute.
*/
readonly name?: boolean | {
readonly fromAttr: string;
};
};
export type Rule<T extends RuleConfigValue, O = void> = RuleConfig<T, O> | T | boolean;
export type Rule<T extends RuleConfigValue, O extends PlainData = undefined> = RuleConfig<T, O> | Readonly<T> | boolean;
/**
* @deprecated
*/
export type RuleV2<T extends RuleConfigValue, O = void> = RuleConfigV2<T, O> | T | boolean;
export type AnyRule = Rule<RuleConfigValue, unknown>;
export type RuleV2<T extends RuleConfigValue, O extends PlainData = undefined> = RuleConfigV2<T, O> | Readonly<T> | boolean;
export type AnyRule = Rule<RuleConfigValue, PlainData>;
/**
* @deprecated
*/
export type AnyRuleV2 = RuleV2<RuleConfigValue, unknown>;
export interface Rules {
[ruleName: string]: AnyRule;
}
export type RuleConfig<T extends RuleConfigValue, O = void> = {
severity?: Severity;
value?: T;
options?: O;
reason?: string;
export type AnyRuleV2 = RuleV2<RuleConfigValue, PlainData>;
export type Rules = {
readonly [ruleName: string]: AnyRule;
};
export type RuleConfig<T extends RuleConfigValue, O extends PlainData = undefined> = {
readonly severity?: Severity;
readonly value?: Readonly<T>;
readonly options?: Readonly<O>;
readonly reason?: string;
};
/**
* @deprecated
*/
export type RuleConfigV2<T extends RuleConfigValue, O = void> = {
severity?: Severity;
value?: T;
reason?: string;
/**
* Old property
*
* @deprecated
* @see {this.options}
*/
option?: O;
export type RuleConfigV2<T extends RuleConfigValue, O extends PlainData = undefined> = {
readonly severity?: Severity;
readonly value?: Readonly<T>;
readonly reason?: string;
/**
* Old property
*
* @deprecated
* @see {this.options}
*/
readonly option?: Readonly<O>;
};
export type Severity = 'error' | 'warning' | 'info';
export type RuleConfigValue = string | number | boolean | any[] | null;
export interface NodeRule {
selector?: string;
regexSelector?: RegexSelector;
categories?: string[];
roles?: string[];
obsolete?: boolean;
rules?: Rules;
}
export interface ChildNodeRule {
selector?: string;
regexSelector?: RegexSelector;
inheritance?: boolean;
rules?: Rules;
}
export type Report<T extends RuleConfigValue, O = null> = Report1<T, O> | Report2 | (Report1<T, O> & Report2);
export type Report1<T extends RuleConfigValue, O = null> = {
message: string;
scope: Scope<T, O>;
export type RuleConfigValue = PrimitiveScalar | readonly (PrimitiveScalar | Readonly<Record<string, any>>)[] | null;
export type NodeRule = {
readonly selector?: string;
readonly regexSelector?: RegexSelector;
readonly categories?: readonly string[];
readonly roles?: readonly string[];
readonly obsolete?: boolean;
readonly rules?: Rules;
};
export type ChildNodeRule = {
readonly selector?: string;
readonly regexSelector?: RegexSelector;
readonly inheritance?: boolean;
readonly rules?: Rules;
};
export type Report<T extends RuleConfigValue, O extends PlainData = undefined> = Report1<T, O> | Report2 | (Report1<T, O> & Report2);
export type Report1<T extends RuleConfigValue, O extends PlainData = undefined> = {
readonly message: string;
readonly scope: Scope<T, O>;
};
export type Report2 = {
message: string;
line: number;
col: number;
raw: string;
readonly message: string;
readonly line: number;
readonly col: number;
readonly raw: string;
};
export type Scope<T extends RuleConfigValue, O = null> = {
rule: RuleInfo<T, O>;
startLine: number;
startCol: number;
raw: string;
export type Scope<T extends RuleConfigValue, O extends PlainData = undefined> = {
readonly rule: RuleInfo<T, O>;
readonly startLine: number;
readonly startCol: number;
readonly raw: string;
};
export interface Violation {
ruleId: string;
severity: Severity;
message: string;
reason?: string;
line: number;
col: number;
raw: string;
}
export interface RuleInfo<T extends RuleConfigValue, O = null> {
disabled: boolean;
severity: Severity;
value: T;
options: O;
reason?: string;
}
export type GlobalRuleInfo<T extends RuleConfigValue, O = null> = RuleInfo<T, O> & {
nodeRules: RuleInfo<T, O>[];
childNodeRules: RuleInfo<T, O>[];
export type Violation = {
readonly ruleId: string;
readonly severity: Severity;
readonly message: string;
readonly reason?: string;
readonly line: number;
readonly col: number;
readonly raw: string;
};
export type RuleInfo<T extends RuleConfigValue, O extends PlainData = undefined> = {
readonly disabled: boolean;
readonly severity: Severity;
readonly value: Readonly<T>;
readonly options: Readonly<O>;
readonly reason?: string;
};
export type GlobalRuleInfo<T extends RuleConfigValue, O extends PlainData = undefined> = RuleInfo<T, O> & {
nodeRules: RuleInfo<T, O>[];
childNodeRules: RuleInfo<T, O>[];
};
export type Nullable<T> = T | null | undefined;

@@ -1,2 +0,2 @@

import type { AnyRule, AnyRuleV2, RuleConfig, RuleConfigV2, RuleConfigValue } from './types';
import type { AnyRule, AnyRuleV2, PlainData, RuleConfig, RuleConfigV2, RuleConfigValue } from './types';
/**

@@ -9,10 +9,5 @@ * Return undefined if the template doesn't include the variable that is set as a property in data.

*/
export declare function provideValue(template: string, data: Record<string, string>): string | undefined;
export declare function exchangeValueOnRule(
rule: AnyRule | AnyRuleV2,
data: Record<string, string>,
): AnyRule | undefined;
export declare function cleanOptions(
rule: RuleConfig<RuleConfigValue, unknown> | RuleConfigV2<RuleConfigValue, unknown>,
): RuleConfig<RuleConfigValue, unknown>;
export declare function provideValue(template: string, data: Readonly<Record<string, string>>): string | undefined;
export declare function exchangeValueOnRule(rule: AnyRule | AnyRuleV2, data: Readonly<Record<string, string>>): AnyRule | undefined;
export declare function cleanOptions(rule: RuleConfig<RuleConfigValue, PlainData> | RuleConfigV2<RuleConfigValue, PlainData>): RuleConfig<RuleConfigValue, PlainData>;
export declare function isRuleConfigValue(v: any): v is RuleConfigValue;

@@ -19,0 +14,0 @@ /**

@@ -43,5 +43,10 @@ "use strict";

if (options) {
const newOptions = exchangeOption(options, data);
result = {
...result,
options: exchangeOption(options, data),
...(newOptions == null
? undefined
: {
options: newOptions,
}),
};

@@ -130,3 +135,3 @@ }

})
.filter(item => item !== undefined);
.filter((item) => item !== undefined);
return ruleArray.length ? ruleArray : undefined;

@@ -146,3 +151,3 @@ }

}
if (Array.isArray(optionValue)) {
if (isArray(optionValue)) {
return optionValue.map(v => exchangeOption(v, data));

@@ -156,1 +161,14 @@ }

}
/**
* Array.isArray for ReadonlyArray
*
* > Array.isArray type narrows to any[] for ReadonlyArray<T>
*
* @see https://github.com/microsoft/TypeScript/issues/17002
*
* @param value
* @returns
*/
function isArray(value) {
return Array.isArray(value);
}
{
"name": "@markuplint/ml-config",
"version": "3.4.0",
"version": "3.5.0",
"description": "JSON Schema and TypeScript types of markuplint configure JSON",

@@ -22,12 +22,13 @@ "repository": "git@github.com:markuplint/markuplint.git",

"devDependencies": {
"@markuplint/ml-ast": "3.0.0",
"@markuplint/ml-ast": "3.1.0",
"@types/mustache": "^4.2.2"
},
"dependencies": {
"@markuplint/selector": "3.4.0",
"@markuplint/selector": "3.5.0",
"deepmerge": "^4.2.2",
"is-plain-object": "^5.0.0",
"mustache": "^4.2.0"
"mustache": "^4.2.0",
"type-fest": "^3.6.1"
},
"gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
"gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
}
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