@markuplint/ml-config
Advanced tools
Comparing version 2.1.0 to 3.0.0-alpha.0
@@ -14,7 +14,3 @@ "use strict"; | ||
parserOptions: mergeObject(a.parserOptions, b.parserOptions), | ||
specs: | ||
// v3 | ||
// mergeObject(a.specs, b.specs), | ||
// v2 | ||
mergeSpecs(a.specs, b.specs), | ||
specs: mergeObject(a.specs, b.specs), | ||
excludeFiles: concatArray(a.excludeFiles, b.excludeFiles, true), | ||
@@ -176,50 +172,1 @@ rules: mergeRules( | ||
} | ||
/** | ||
* @deprecated | ||
* @param a | ||
* @param b | ||
* @returns | ||
*/ | ||
function mergeSpecs(a, b) { | ||
return mergeObject(convertSpec_v1_to_v2(a), convertSpec_v1_to_v2(b)); | ||
} | ||
/** | ||
* @deprecated | ||
* @param spec | ||
* @returns | ||
*/ | ||
function convertSpec_v1_to_v2(spec) { | ||
if (spec == null) { | ||
return; | ||
} | ||
if (typeof spec === 'string') { | ||
return { '/.+/': spec }; | ||
} | ||
if (Array.isArray(spec)) { | ||
if (spec.length === 0) { | ||
return {}; | ||
} | ||
else if (spec.length === 1) { | ||
return { '/.+/': spec[0] }; | ||
} | ||
const res = {}; | ||
for (const item of spec) { | ||
switch (item) { | ||
case '@markuplint/vue-spec': { | ||
res['/\\.vue$/i'] = item; | ||
break; | ||
} | ||
case '@markuplint/react-spec': { | ||
res['/\\.[jt]sx?$/i'] = item; | ||
break; | ||
} | ||
default: { | ||
res['/.+/'] = item; | ||
} | ||
} | ||
} | ||
deleteUndefProp(res); | ||
return res; | ||
} | ||
return spec; | ||
} |
@@ -0,1 +1,3 @@ | ||
import type { RegexSelector } from '@markuplint/selector'; | ||
export type { RegexSelector } from '@markuplint/selector'; | ||
export interface Config { | ||
@@ -7,3 +9,3 @@ $schema?: string; | ||
parserOptions?: ParserOptions; | ||
specs?: SpecConfig | SpecConfig_v1; | ||
specs?: SpecConfig; | ||
excludeFiles?: string[]; | ||
@@ -28,6 +30,2 @@ rules?: Rules; | ||
}; | ||
/** | ||
* @deprecated | ||
*/ | ||
export declare type SpecConfig_v1 = string | string[]; | ||
export declare type Rule<T extends RuleConfigValue, O = void> = RuleConfig<T, O> | T | boolean; | ||
@@ -47,6 +45,2 @@ export declare type AnyRule = Rule<RuleConfigValue, unknown>; | ||
export interface NodeRule { | ||
/** | ||
* @deprecated | ||
*/ | ||
tagName?: string; | ||
selector?: string; | ||
@@ -60,6 +54,2 @@ regexSelector?: RegexSelector; | ||
export interface ChildNodeRule { | ||
/** | ||
* @deprecated | ||
*/ | ||
tagName?: string; | ||
selector?: string; | ||
@@ -70,13 +60,2 @@ regexSelector?: RegexSelector; | ||
} | ||
export declare type RegexSelector = RegexSelectorWithoutCompination & { | ||
combination?: { | ||
combinator: RegexSelectorCombinator; | ||
} & RegexSelector; | ||
}; | ||
export declare type RegexSelectorCombinator = ' ' | '>' | '+' | '~' | ':has(+)' | ':has(~)'; | ||
export declare type RegexSelectorWithoutCompination = { | ||
nodeName?: string; | ||
attrName?: string; | ||
attrValue?: string; | ||
}; | ||
export declare type Report<T extends RuleConfigValue, O = null> = Report1<T, O> | Report2 | (Report1<T, O> & Report2); | ||
@@ -83,0 +62,0 @@ export declare type Report1<T extends RuleConfigValue, O = null> = { |
import type { AnyRule } from './types'; | ||
export declare function toRegxp(pattern: string): string | RegExp; | ||
export declare function regexSelectorMatches(reg: string, raw: string): { | ||
[x: string]: string; | ||
} | null; | ||
/** | ||
@@ -7,0 +3,0 @@ * Return undefined if the template doesn't include the variable that is set as a property in data. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.exchangeValueOnRule = exports.provideValue = exports.regexSelectorMatches = exports.toRegxp = void 0; | ||
exports.exchangeValueOnRule = exports.provideValue = void 0; | ||
const tslib_1 = require("tslib"); | ||
const mustache_1 = tslib_1.__importDefault(require("mustache")); | ||
function toRegxp(pattern) { | ||
const matched = pattern.match(/^\/(.+)\/([ig]*)$/i); | ||
if (matched) { | ||
return new RegExp(matched[1], matched[2]); | ||
} | ||
return pattern; | ||
} | ||
exports.toRegxp = toRegxp; | ||
function regexSelectorMatches(reg, raw) { | ||
const res = {}; | ||
const pattern = toRegxp(reg); | ||
const regex = pattern instanceof RegExp ? pattern : new RegExp(`^${pattern.trim()}$`); | ||
const matched = regex.exec(raw); | ||
if (!matched) { | ||
return null; | ||
} | ||
matched.forEach((val, i) => (res[`$${i}`] = val)); | ||
return { | ||
...res, | ||
...matched.groups, | ||
}; | ||
} | ||
exports.regexSelectorMatches = regexSelectorMatches; | ||
/** | ||
@@ -30,0 +7,0 @@ * Return undefined if the template doesn't include the variable that is set as a property in data. |
{ | ||
"name": "@markuplint/ml-config", | ||
"version": "2.1.0", | ||
"version": "3.0.0-alpha.0", | ||
"description": "JSON Schema and TypeScript types of markuplint configure JSON", | ||
@@ -22,2 +22,3 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
"dependencies": { | ||
"@markuplint/selector": "3.0.0-alpha.0", | ||
"deepmerge": "^4.2.2", | ||
@@ -27,3 +28,3 @@ "is-plain-object": "^5.0.0", | ||
}, | ||
"gitHead": "373c916d5ebbba463f5e088696666a383ee96492" | ||
"gitHead": "d32c522e016888e20bcbb5f09352c006b964f193" | ||
} |
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
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
69834
4
391
2
+ Added@markuplint/selector@3.0.0-alpha.0(transitive)
+ Addedcssesc@3.0.0(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedpostcss-selector-parser@6.1.2(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)