stylelint
Advanced tools
Comparing version 15.10.2 to 15.10.3
'use strict'; | ||
const { EOL } = require('os'); | ||
const assignDisabledRanges = require('./assignDisabledRanges'); | ||
const getOsEol = require('./utils/getOsEol'); | ||
const reportUnknownRuleNames = require('./reportUnknownRuleNames'); | ||
@@ -40,3 +41,3 @@ const rules = require('./rules'); | ||
newline = newlineMatch ? newlineMatch[0] : getOsEol(); | ||
newline = newlineMatch ? newlineMatch[0] : EOL; | ||
@@ -43,0 +44,0 @@ assignDisabledRanges(postcssDoc, postcssResult); |
'use strict'; | ||
const { isPlainObject } = require('is-plain-object'); | ||
const { fork, parse, find } = require('css-tree'); | ||
const { fork, parse, find, string } = require('css-tree'); | ||
@@ -16,3 +16,3 @@ const declarationValueIndex = require('../../utils/declarationValueIndex'); | ||
const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration'); | ||
const { isAtRule } = require('../../utils/typeGuards'); | ||
const { isAtRule, isDeclaration } = require('../../utils/typeGuards'); | ||
const { isRegExp, isString } = require('../../utils/validateTypes'); | ||
@@ -33,2 +33,4 @@ const { nestingSupportedAtKeywords } = require('../../reference/atKeywords'); | ||
const SYNTAX_PROPERTY = /^syntax$/i; | ||
/** @type {import('stylelint').Rule} */ | ||
@@ -56,5 +58,3 @@ const rule = (primary, secondaryOptions) => { | ||
const ignoreProperties = Array.from( | ||
Object.entries((secondaryOptions && secondaryOptions.ignoreProperties) || {}), | ||
); | ||
const ignoreProperties = Array.from(Object.entries(secondaryOptions?.ignoreProperties ?? {})); | ||
@@ -69,5 +69,44 @@ /** @type {(name: string, propValue: string) => boolean} */ | ||
const propertiesSyntax = (secondaryOptions && secondaryOptions.propertiesSyntax) || {}; | ||
const typesSyntax = (secondaryOptions && secondaryOptions.typesSyntax) || {}; | ||
const propertiesSyntax = { | ||
// Take a shallow clone as this object will be appended to. | ||
...(secondaryOptions?.propertiesSyntax ?? {}), | ||
}; | ||
const typesSyntax = secondaryOptions?.typesSyntax ?? {}; | ||
/** @type {Map<string, string>} */ | ||
const typedCustomPropertyNames = new Map(); | ||
root.walkAtRules(/^property$/i, (atRule) => { | ||
const propName = atRule.params.trim(); | ||
if (!propName || !atRule.nodes || !isCustomProperty(propName)) return; | ||
for (const node of atRule.nodes) { | ||
if (isDeclaration(node) && SYNTAX_PROPERTY.test(node.prop)) { | ||
const value = node.value.trim(); | ||
const unquoted = string.decode(value); | ||
// Only string values are valid. | ||
// We can not check the syntax of this property. | ||
if (unquoted === value) continue; | ||
// Any value is allowed in this custom property. | ||
// We don't need to check this property. | ||
if (unquoted === '*') continue; | ||
// https://github.com/csstree/csstree/pull/256 | ||
// We can circumvent this issue by prefixing the property name, | ||
// making it a vendor-prefixed property instead of a custom property. | ||
// No one should be using `-stylelint--` as a property prefix. | ||
// | ||
// When this is resolved `typedCustomPropertyNames` can become a `Set<string>` | ||
// and the prefix can be removed. | ||
const prefixedPropName = `-stylelint${propName}`; | ||
typedCustomPropertyNames.set(propName, prefixedPropName); | ||
propertiesSyntax[prefixedPropName] = unquoted; | ||
} | ||
} | ||
}); | ||
const forkedLexer = fork({ | ||
@@ -91,6 +130,18 @@ properties: propertiesSyntax, | ||
if (isCustomProperty(prop)) return; | ||
if (isCustomProperty(prop) && !typedCustomPropertyNames.has(prop)) return; | ||
if (isPropIgnored(prop, value)) return; | ||
// https://github.com/mdn/data/pull/674 | ||
// `initial-value` has an incorrect syntax definition. | ||
// In reality everything is valid. | ||
if ( | ||
/^initial-value$/i.test(prop) && | ||
decl.parent && | ||
isAtRule(decl.parent) && | ||
/^property$/i.test(decl.parent.name) | ||
) { | ||
return; | ||
} | ||
/** @type {import('css-tree').CssNode} */ | ||
@@ -122,3 +173,3 @@ let cssTreeValueNode; | ||
? forkedLexer.matchAtruleDescriptor(parent.name, prop, cssTreeValueNode) | ||
: forkedLexer.matchProperty(prop, cssTreeValueNode); | ||
: forkedLexer.matchProperty(typedCustomPropertyNames.get(prop) ?? prop, cssTreeValueNode); | ||
@@ -125,0 +176,0 @@ if (!error) return; |
{ | ||
"name": "stylelint", | ||
"version": "15.10.2", | ||
"version": "15.10.3", | ||
"description": "A mighty CSS linter that helps you avoid errors and enforce conventions.", | ||
@@ -55,4 +55,3 @@ "keywords": [ | ||
"postversion": "git restore package.json", | ||
"watch": "npm test --ignore-scripts -- --watch", | ||
"changelog-to-github-release": "remark --quiet --use ./scripts/remark-changelog-to-github-release.mjs CHANGELOG.md" | ||
"watch": "npm test --ignore-scripts -- --watch" | ||
}, | ||
@@ -89,3 +88,4 @@ "lint-staged": { | ||
"require": true, | ||
"testRule": true | ||
"testRule": true, | ||
"testRuleConfigs": true | ||
}, | ||
@@ -121,4 +121,3 @@ "root": true | ||
"moduleNameMapper": { | ||
"^stylelint$": "<rootDir>/lib/index.js", | ||
"stylelint/lib/utils/getOsEol": "<rootDir>/lib/utils/getOsEol.js" | ||
"^stylelint$": "<rootDir>/lib/index.js" | ||
}, | ||
@@ -138,5 +137,5 @@ "preset": "jest-preset-stylelint", | ||
"dependencies": { | ||
"@csstools/css-parser-algorithms": "^2.3.0", | ||
"@csstools/css-tokenizer": "^2.1.1", | ||
"@csstools/media-query-list-parser": "^2.1.2", | ||
"@csstools/css-parser-algorithms": "^2.3.1", | ||
"@csstools/css-tokenizer": "^2.2.0", | ||
"@csstools/media-query-list-parser": "^2.1.4", | ||
"@csstools/selector-specificity": "^3.0.0", | ||
@@ -149,3 +148,3 @@ "balanced-match": "^2.0.0", | ||
"debug": "^4.3.4", | ||
"fast-glob": "^3.3.0", | ||
"fast-glob": "^3.3.1", | ||
"fastest-levenshtein": "^1.0.16", | ||
@@ -161,3 +160,3 @@ "file-entry-cache": "^6.0.1", | ||
"is-plain-object": "^5.0.0", | ||
"known-css-properties": "^0.27.0", | ||
"known-css-properties": "^0.28.0", | ||
"mathml-tag-names": "^2.1.3", | ||
@@ -168,3 +167,3 @@ "meow": "^10.1.5", | ||
"picocolors": "^1.0.0", | ||
"postcss": "^8.4.25", | ||
"postcss": "^8.4.27", | ||
"postcss-resolve-nested-selector": "^0.1.1", | ||
@@ -186,6 +185,6 @@ "postcss-safe-parser": "^6.0.0", | ||
"@changesets/get-github-info": "^0.5.2", | ||
"@jest/globals": "^29.6.1", | ||
"@jest/globals": "^29.6.2", | ||
"@stylelint/prettier-config": "^3.0.0", | ||
"@stylelint/remark-preset": "^4.0.0", | ||
"@types/balanced-match": "^1.0.2", | ||
"@types/balanced-match": "^1.0.3", | ||
"@types/css-tree": "^2.3.1", | ||
@@ -208,14 +207,14 @@ "@types/debug": "^4.1.8", | ||
"deepmerge": "^4.3.1", | ||
"eslint": "^8.45.0", | ||
"eslint-config-stylelint": "^19.0.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint": "^8.47.0", | ||
"eslint-config-stylelint": "^19.1.0", | ||
"eslint-plugin-import": "^2.28.0", | ||
"eslint-plugin-jest": "^27.2.3", | ||
"husky": "^8.0.3", | ||
"jest": "^29.6.1", | ||
"jest-preset-stylelint": "^6.1.0", | ||
"jest": "^29.6.2", | ||
"jest-preset-stylelint": "^6.2.0", | ||
"jest-watch-typeahead": "^2.2.2", | ||
"lint-staged": "^13.2.3", | ||
"lint-staged": "^14.0.0", | ||
"np": "^8.0.4", | ||
"npm-run-all": "^4.1.5", | ||
"patch-package": "^7.0.2", | ||
"patch-package": "^8.0.0", | ||
"postcss-html": "^1.5.0", | ||
@@ -222,0 +221,0 @@ "postcss-import": "^15.1.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
1326701
30099
594
+ Addedknown-css-properties@0.28.0(transitive)
- Removedknown-css-properties@0.27.0(transitive)
Updatedfast-glob@^3.3.1
Updatedknown-css-properties@^0.28.0
Updatedpostcss@^8.4.27