stylelint
Advanced tools
Comparing version 14.12.0 to 14.12.1
@@ -11,3 +11,2 @@ 'use strict'; | ||
const { | ||
fontWeightKeywords, | ||
fontWeightNonNumericKeywords, | ||
@@ -21,2 +20,3 @@ fontWeightRelativeKeywords, | ||
const validateOptions = require('../../utils/validateOptions'); | ||
const { assertString } = require('../../utils/validateTypes'); | ||
@@ -27,3 +27,3 @@ const ruleName = 'font-weight-notation'; | ||
expected: (type) => `Expected ${type} font-weight notation`, | ||
invalidNamed: (name) => `Unexpected invalid font-weight name "${name}"`, | ||
expectedWithActual: (actual, expected) => `Expected "${actual}" to be "${expected}"`, | ||
}); | ||
@@ -38,7 +38,7 @@ | ||
const KEYWORD_TO_NUMERIC = new Map([ | ||
const NAMED_TO_NUMERIC = new Map([ | ||
['normal', '400'], | ||
['bold', '700'], | ||
]); | ||
const NUMERIC_TO_KEYWORD = new Map([ | ||
const NUMERIC_TO_NAMED = new Map([ | ||
['400', 'normal'], | ||
@@ -131,5 +131,5 @@ ['700', 'bold'], | ||
if (!isNumbery(lowerWeightValue) && fontWeightNonNumericKeywords.has(lowerWeightValue)) { | ||
const numericValue = NAMED_TO_NUMERIC.get(lowerWeightValue); | ||
if (context.fix) { | ||
const numericValue = KEYWORD_TO_NUMERIC.get(lowerWeightValue); | ||
if (numericValue) { | ||
@@ -142,4 +142,8 @@ weightValueNode.value = numericValue; | ||
complain(messages.expected('numeric'), weightValueNode); | ||
const msg = numericValue | ||
? messages.expectedWithActual(weightValue, numericValue) | ||
: messages.expected('numeric'); | ||
complain(msg, weightValueNode); | ||
return true; | ||
@@ -150,27 +154,17 @@ } | ||
if (primary === 'named-where-possible') { | ||
if (isNumbery(lowerWeightValue) && NUMERIC_TO_KEYWORD.has(lowerWeightValue)) { | ||
if (isNumbery(lowerWeightValue) && NUMERIC_TO_NAMED.has(lowerWeightValue)) { | ||
const namedValue = NUMERIC_TO_NAMED.get(lowerWeightValue); | ||
assertString(namedValue); | ||
if (context.fix) { | ||
const keyword = NUMERIC_TO_KEYWORD.get(lowerWeightValue); | ||
weightValueNode.value = namedValue; | ||
if (keyword) { | ||
weightValueNode.value = keyword; | ||
} | ||
return true; | ||
} | ||
complain(messages.expected('named'), weightValueNode); | ||
complain(messages.expectedWithActual(weightValue, namedValue), weightValueNode); | ||
return true; | ||
} | ||
if ( | ||
decl.prop.toLowerCase() === 'font-weight' && | ||
!fontWeightKeywords.has(lowerWeightValue) && | ||
lowerWeightValue !== NORMAL_KEYWORD | ||
) { | ||
complain(messages.invalidNamed(weightValue), weightValueNode); | ||
return true; | ||
} | ||
} | ||
@@ -177,0 +171,0 @@ |
{ | ||
"name": "stylelint", | ||
"version": "14.12.0", | ||
"version": "14.12.1", | ||
"description": "A mighty, modern CSS linter.", | ||
@@ -188,3 +188,3 @@ "keywords": [ | ||
"postcss-sass": "^0.5.0", | ||
"postcss-scss": "^4.0.4", | ||
"postcss-scss": "^4.0.5", | ||
"remark-cli": "^11.0.0", | ||
@@ -191,0 +191,0 @@ "sugarss": "^4.0.1", |
@@ -356,3 +356,3 @@ declare module 'stylelint' { | ||
message: RuleMessage; | ||
messageArgs?: Parameters<RuleMessage> | undefined; | ||
messageArgs?: Parameters<RuleMessageFunc> | undefined; | ||
node: PostCSS.Node; | ||
@@ -359,0 +359,0 @@ /** |
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
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
882249
27791