csslint: expand referenced rules when describing errors
This commit is contained in:
parent
5bdaacc049
commit
f3be825d25
|
@ -6022,12 +6022,19 @@ copy(ValidationTypes, {
|
||||||
},
|
},
|
||||||
|
|
||||||
describe: function(type) {
|
describe: function(type) {
|
||||||
if (this.complex[type] instanceof Matcher) {
|
const complex = this.complex[type];
|
||||||
return this.complex[type].toString(0);
|
const text = complex instanceof Matcher ? complex.toString(0) : type;
|
||||||
}
|
return this.explode(text);
|
||||||
return type;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
explode(text) {
|
||||||
|
return !text.includes('<') ? text :
|
||||||
|
text.replace(/(<.*?>)([{#?])?/g, (_, rule, mod) => {
|
||||||
|
const ref = this.simple[rule] || this.complex[rule];
|
||||||
|
return !ref || !ref.originalText ? rule :
|
||||||
|
(mod ? '[' : '') + this.explode(ref.originalText) + (mod ? ']' : '');
|
||||||
|
});
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Determines if the next part(s) of the given expression
|
* Determines if the next part(s) of the given expression
|
||||||
* are any of the given types.
|
* are any of the given types.
|
||||||
|
@ -6466,16 +6473,16 @@ copy(ValidationTypes, {
|
||||||
Object.keys(ValidationTypes.simple).forEach(function(nt) {
|
Object.keys(ValidationTypes.simple).forEach(function(nt) {
|
||||||
var rule = ValidationTypes.simple[nt];
|
var rule = ValidationTypes.simple[nt];
|
||||||
if (typeof rule === "string") {
|
if (typeof rule === "string") {
|
||||||
ValidationTypes.simple[nt] = function(part) {
|
ValidationTypes.simple[nt] = Object.defineProperty(function(part) {
|
||||||
return ValidationTypes.isLiteral(part, rule);
|
return ValidationTypes.isLiteral(part, rule);
|
||||||
};
|
}, 'originalText', {value: rule});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(ValidationTypes.complex).forEach(function(nt) {
|
Object.keys(ValidationTypes.complex).forEach(function(nt) {
|
||||||
var rule = ValidationTypes.complex[nt];
|
var rule = ValidationTypes.complex[nt];
|
||||||
if (typeof rule === "string") {
|
if (typeof rule === "string") {
|
||||||
ValidationTypes.complex[nt] = Matcher.parse(rule);
|
ValidationTypes.complex[nt] = Object.defineProperty(Matcher.parse(rule), 'originalText', {value: rule});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user