csslint: fix bugs in 'box-model' and 'ids'

This commit is contained in:
tophf 2021-08-26 20:49:39 +03:00
parent 12764baacb
commit a5a8d97767

View File

@ -513,7 +513,7 @@ CSSLint.addRule['box-model'] = [{
if (!properties[size]) continue; if (!properties[size]) continue;
for (const prop of sizeProps[size]) { for (const prop of sizeProps[size]) {
if (prop !== 'padding' || !properties[prop]) continue; if (prop !== 'padding' || !properties[prop]) continue;
const {value: {parts}, line, col} = properties[prop].value; const {value: {parts}, line, col} = properties[prop];
if (parts.length !== 2 || Number(parts[0].value) !== 0) { if (parts.length !== 2 || Number(parts[0].value) !== 0) {
reporter.report( reporter.report(
`Using ${size} with ${prop} can sometimes make elements larger than you expect.`, `Using ${size} with ${prop} can sometimes make elements larger than you expect.`,
@ -1071,8 +1071,8 @@ CSSLint.addRule['ids'] = [{
const cnt = const cnt =
sel.parts.reduce((sum = 0, {type, modifiers}) => sel.parts.reduce((sum = 0, {type, modifiers}) =>
type === parser.SELECTOR_PART_TYPE type === parser.SELECTOR_PART_TYPE
? modifiers.reduce(sum, mod => sum + (mod.type === 'id')) ? modifiers.reduce((sum, mod) => sum + (mod.type === 'id'), 0)
: sum); : sum, 0);
if (cnt) { if (cnt) {
reporter.report(`Id in selector${cnt > 1 ? '!'.repeat(cnt) : '.'}`, sel, rule); reporter.report(`Id in selector${cnt > 1 ? '!'.repeat(cnt) : '.'}`, sel, rule);
} }