Socket
Socket
Sign inDemoInstall

stylelint

Package Overview
Dependencies
Maintainers
7
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylelint - npm Package Compare versions

Comparing version 14.12.0 to 14.12.1

42

lib/rules/font-weight-notation/index.js

@@ -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 @@ /**

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