stylelint-scss
Advanced tools
Comparing version 6.0.0 to 6.1.0
{ | ||
"name": "stylelint-scss", | ||
"description": "A collection of SCSS-specific rules for Stylelint", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"author": "Krister Kari", | ||
@@ -19,3 +19,3 @@ "repository": "stylelint-scss/stylelint-scss", | ||
"postcss-resolve-nested-selector": "^0.1.1", | ||
"postcss-selector-parser": "^6.0.13", | ||
"postcss-selector-parser": "^6.0.15", | ||
"postcss-value-parser": "^4.2.0" | ||
@@ -25,3 +25,3 @@ }, | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.54.0", | ||
"eslint": "^8.56.0", | ||
"github-contributors-list": "^1.2.5", | ||
@@ -32,8 +32,8 @@ "husky": "^8.0.3", | ||
"lint-staged": "^14.0.1", | ||
"np": "^9.0.0", | ||
"np": "^9.2.0", | ||
"postcss": "^8.4.31", | ||
"postcss-less": "^6.0.0", | ||
"postcss-scss": "^4.0.9", | ||
"prettier": "^3.1.0", | ||
"stylelint": "^16.0.2" | ||
"prettier": "^3.2.4", | ||
"stylelint": "^16.2.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "files": [ |
114
README.md
@@ -192,4 +192,6 @@ # stylelint-scss | ||
- [`no-global-function-names`](./src/rules/no-global-function-names/README.md): Disallows the use of global function names, as these global functions are now located inside built-in Sass modules. | ||
- [`no-unused-private-members`](./src/rules/no-unused-private-members/README.md): Disallow unused private members such as functions, mixins, variables or placeholder selectors. | ||
## Deprecated | ||
These rules are deprecated — we won't fix bugs nor add options, and we will remove them in the next major release. We recommend you use a pretty printer (like Prettier) alongside Stylelint rather than these rules. | ||
@@ -227,4 +229,4 @@ | ||
<th align="center"><a href="https://github.com/XhmikosR"><img alt="XhmikosR" src="https://avatars.githubusercontent.com/u/349621?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/ybiquitous"><img alt="ybiquitous" src="https://avatars.githubusercontent.com/u/473530?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/Eugeno"><img alt="Eugeno" src="https://avatars.githubusercontent.com/u/23382920?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/joseph118"><img alt="joseph118" src="https://avatars.githubusercontent.com/u/6863655?v=4&s=80" width="80"></a></th> | ||
</tr> | ||
@@ -237,4 +239,4 @@ </thead> | ||
<td align="center"><a href="https://github.com/XhmikosR">XhmikosR</a></td> | ||
<td align="center"><a href="https://github.com/ybiquitous">ybiquitous</a></td> | ||
<td align="center"><a href="https://github.com/Eugeno">Eugeno</a></td> | ||
<td align="center"><a href="https://github.com/joseph118">joseph118</a></td> | ||
</tr> | ||
@@ -245,3 +247,3 @@ </tbody></table> | ||
<tr> | ||
<th align="center"><a href="https://github.com/ybiquitous"><img alt="ybiquitous" src="https://avatars.githubusercontent.com/u/473530?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/joseph118"><img alt="joseph118" src="https://avatars.githubusercontent.com/u/6863655?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/pamelalozano16"><img alt="pamelalozano16" src="https://avatars.githubusercontent.com/u/30474787?v=4&s=80" width="80"></a></th> | ||
@@ -255,3 +257,3 @@ <th align="center"><a href="https://github.com/stof"><img alt="stof" src="https://avatars.githubusercontent.com/u/439401?v=4&s=80" width="80"></a></th> | ||
<tbody><tr> | ||
<td align="center"><a href="https://github.com/ybiquitous">ybiquitous</a></td> | ||
<td align="center"><a href="https://github.com/joseph118">joseph118</a></td> | ||
<td align="center"><a href="https://github.com/pamelalozano16">pamelalozano16</a></td> | ||
@@ -290,4 +292,4 @@ <td align="center"><a href="https://github.com/stof">stof</a></td> | ||
<th align="center"><a href="https://github.com/chimurai"><img alt="chimurai" src="https://avatars.githubusercontent.com/u/655241?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/AndyOGo"><img alt="AndyOGo" src="https://avatars.githubusercontent.com/u/914443?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/bjankord"><img alt="bjankord" src="https://avatars.githubusercontent.com/u/633148?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/vseventer"><img alt="vseventer" src="https://avatars.githubusercontent.com/u/638323?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/xboy2012"><img alt="xboy2012" src="https://avatars.githubusercontent.com/u/7540144?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/chalkygames123"><img alt="chalkygames123" src="https://avatars.githubusercontent.com/u/5608239?v=4&s=80" width="80"></a></th> | ||
@@ -300,4 +302,4 @@ </tr> | ||
<td align="center"><a href="https://github.com/chimurai">chimurai</a></td> | ||
<td align="center"><a href="https://github.com/AndyOGo">AndyOGo</a></td> | ||
<td align="center"><a href="https://github.com/bjankord">bjankord</a></td> | ||
<td align="center"><a href="https://github.com/vseventer">vseventer</a></td> | ||
<td align="center"><a href="https://github.com/xboy2012">xboy2012</a></td> | ||
<td align="center"><a href="https://github.com/chalkygames123">chalkygames123</a></td> | ||
@@ -309,17 +311,17 @@ </tr> | ||
<tr> | ||
<th align="center"><a href="https://github.com/xboy2012"><img alt="xboy2012" src="https://avatars.githubusercontent.com/u/7540144?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/vseventer"><img alt="vseventer" src="https://avatars.githubusercontent.com/u/638323?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/SterlingVix"><img alt="SterlingVix" src="https://avatars.githubusercontent.com/u/7531113?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/Calme1709"><img alt="Calme1709" src="https://avatars.githubusercontent.com/u/30140939?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/Deimos"><img alt="Deimos" src="https://avatars.githubusercontent.com/u/9033?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/diego-codes"><img alt="diego-codes" src="https://avatars.githubusercontent.com/u/5973294?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/FloEdelmann"><img alt="FloEdelmann" src="https://avatars.githubusercontent.com/u/202916?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/bjankord"><img alt="bjankord" src="https://avatars.githubusercontent.com/u/633148?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/AndyOGo"><img alt="AndyOGo" src="https://avatars.githubusercontent.com/u/914443?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/qmhc"><img alt="qmhc" src="https://avatars.githubusercontent.com/u/40221744?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/freezy-sk"><img alt="freezy-sk" src="https://avatars.githubusercontent.com/u/661637?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/YodaDaCoda"><img alt="YodaDaCoda" src="https://avatars.githubusercontent.com/u/365349?v=4&s=80" width="80"></a></th> | ||
</tr> | ||
</thead> | ||
<tbody><tr> | ||
<td align="center"><a href="https://github.com/xboy2012">xboy2012</a></td> | ||
<td align="center"><a href="https://github.com/vseventer">vseventer</a></td> | ||
<td align="center"><a href="https://github.com/SterlingVix">SterlingVix</a></td> | ||
<td align="center"><a href="https://github.com/Calme1709">Calme1709</a></td> | ||
<td align="center"><a href="https://github.com/Deimos">Deimos</a></td> | ||
<td align="center"><a href="https://github.com/diego-codes">diego-codes</a></td> | ||
<td align="center"><a href="https://github.com/FloEdelmann">FloEdelmann</a></td> | ||
<td align="center"><a href="https://github.com/bjankord">bjankord</a></td> | ||
<td align="center"><a href="https://github.com/AndyOGo">AndyOGo</a></td> | ||
<td align="center"><a href="https://github.com/qmhc">qmhc</a></td> | ||
<td align="center"><a href="https://github.com/freezy-sk">freezy-sk</a></td> | ||
<td align="center"><a href="https://github.com/YodaDaCoda">YodaDaCoda</a></td> | ||
</tr> | ||
@@ -330,17 +332,17 @@ </tbody></table> | ||
<tr> | ||
<th align="center"><a href="https://github.com/lithiumlron"><img alt="lithiumlron" src="https://avatars.githubusercontent.com/u/101921280?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/EvanHahn"><img alt="EvanHahn" src="https://avatars.githubusercontent.com/u/777712?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/FloEdelmann"><img alt="FloEdelmann" src="https://avatars.githubusercontent.com/u/202916?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/G-Rath"><img alt="G-Rath" src="https://avatars.githubusercontent.com/u/3151613?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/guoyunhe"><img alt="guoyunhe" src="https://avatars.githubusercontent.com/u/5836790?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/jantimon"><img alt="jantimon" src="https://avatars.githubusercontent.com/u/4113649?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/wlewis-formative"><img alt="wlewis-formative" src="https://avatars.githubusercontent.com/u/91909230?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/kersh"><img alt="kersh" src="https://avatars.githubusercontent.com/u/621330?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/AM-77"><img alt="AM-77" src="https://avatars.githubusercontent.com/u/18232579?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/YozhikM"><img alt="YozhikM" src="https://avatars.githubusercontent.com/u/27273025?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/sajadtorkamani"><img alt="sajadtorkamani" src="https://avatars.githubusercontent.com/u/9380313?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/paulgv"><img alt="paulgv" src="https://avatars.githubusercontent.com/u/4895885?v=4&s=80" width="80"></a></th> | ||
</tr> | ||
</thead> | ||
<tbody><tr> | ||
<td align="center"><a href="https://github.com/lithiumlron">lithiumlron</a></td> | ||
<td align="center"><a href="https://github.com/EvanHahn">EvanHahn</a></td> | ||
<td align="center"><a href="https://github.com/FloEdelmann">FloEdelmann</a></td> | ||
<td align="center"><a href="https://github.com/G-Rath">G-Rath</a></td> | ||
<td align="center"><a href="https://github.com/guoyunhe">guoyunhe</a></td> | ||
<td align="center"><a href="https://github.com/jantimon">jantimon</a></td> | ||
<td align="center"><a href="https://github.com/wlewis-formative">wlewis-formative</a></td> | ||
<td align="center"><a href="https://github.com/kersh">kersh</a></td> | ||
<td align="center"><a href="https://github.com/AM-77">AM-77</a></td> | ||
<td align="center"><a href="https://github.com/YozhikM">YozhikM</a></td> | ||
<td align="center"><a href="https://github.com/sajadtorkamani">sajadtorkamani</a></td> | ||
<td align="center"><a href="https://github.com/paulgv">paulgv</a></td> | ||
</tr> | ||
@@ -351,17 +353,17 @@ </tbody></table> | ||
<tr> | ||
<th align="center"><a href="https://github.com/nlydv"><img alt="nlydv" src="https://avatars.githubusercontent.com/u/39429628?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/manovotny"><img alt="manovotny" src="https://avatars.githubusercontent.com/u/446260?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/keegan-lillo"><img alt="keegan-lillo" src="https://avatars.githubusercontent.com/u/3537963?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/stormwarning"><img alt="stormwarning" src="https://avatars.githubusercontent.com/u/999825?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/keegan-lillo"><img alt="keegan-lillo" src="https://avatars.githubusercontent.com/u/3537963?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/manovotny"><img alt="manovotny" src="https://avatars.githubusercontent.com/u/446260?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/nlydv"><img alt="nlydv" src="https://avatars.githubusercontent.com/u/39429628?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/paulgv"><img alt="paulgv" src="https://avatars.githubusercontent.com/u/4895885?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/sajadtorkamani"><img alt="sajadtorkamani" src="https://avatars.githubusercontent.com/u/9380313?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/jantimon"><img alt="jantimon" src="https://avatars.githubusercontent.com/u/4113649?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/guoyunhe"><img alt="guoyunhe" src="https://avatars.githubusercontent.com/u/5836790?v=4&s=80" width="80"></a></th> | ||
</tr> | ||
</thead> | ||
<tbody><tr> | ||
<td align="center"><a href="https://github.com/nlydv">nlydv</a></td> | ||
<td align="center"><a href="https://github.com/manovotny">manovotny</a></td> | ||
<td align="center"><a href="https://github.com/keegan-lillo">keegan-lillo</a></td> | ||
<td align="center"><a href="https://github.com/stormwarning">stormwarning</a></td> | ||
<td align="center"><a href="https://github.com/keegan-lillo">keegan-lillo</a></td> | ||
<td align="center"><a href="https://github.com/manovotny">manovotny</a></td> | ||
<td align="center"><a href="https://github.com/nlydv">nlydv</a></td> | ||
<td align="center"><a href="https://github.com/paulgv">paulgv</a></td> | ||
<td align="center"><a href="https://github.com/sajadtorkamani">sajadtorkamani</a></td> | ||
<td align="center"><a href="https://github.com/jantimon">jantimon</a></td> | ||
<td align="center"><a href="https://github.com/guoyunhe">guoyunhe</a></td> | ||
</tr> | ||
@@ -372,17 +374,17 @@ </tbody></table> | ||
<tr> | ||
<th align="center"><a href="https://github.com/YozhikM"><img alt="YozhikM" src="https://avatars.githubusercontent.com/u/27273025?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/AM-77"><img alt="AM-77" src="https://avatars.githubusercontent.com/u/18232579?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/kersh"><img alt="kersh" src="https://avatars.githubusercontent.com/u/621330?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/wlewis-formative"><img alt="wlewis-formative" src="https://avatars.githubusercontent.com/u/91909230?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/YodaDaCoda"><img alt="YodaDaCoda" src="https://avatars.githubusercontent.com/u/365349?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/freezy-sk"><img alt="freezy-sk" src="https://avatars.githubusercontent.com/u/661637?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/G-Rath"><img alt="G-Rath" src="https://avatars.githubusercontent.com/u/3151613?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/EvanHahn"><img alt="EvanHahn" src="https://avatars.githubusercontent.com/u/777712?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/lithiumlron"><img alt="lithiumlron" src="https://avatars.githubusercontent.com/u/101921280?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/diego-codes"><img alt="diego-codes" src="https://avatars.githubusercontent.com/u/5973294?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/Deimos"><img alt="Deimos" src="https://avatars.githubusercontent.com/u/9033?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/Calme1709"><img alt="Calme1709" src="https://avatars.githubusercontent.com/u/30140939?v=4&s=80" width="80"></a></th> | ||
</tr> | ||
</thead> | ||
<tbody><tr> | ||
<td align="center"><a href="https://github.com/YozhikM">YozhikM</a></td> | ||
<td align="center"><a href="https://github.com/AM-77">AM-77</a></td> | ||
<td align="center"><a href="https://github.com/kersh">kersh</a></td> | ||
<td align="center"><a href="https://github.com/wlewis-formative">wlewis-formative</a></td> | ||
<td align="center"><a href="https://github.com/YodaDaCoda">YodaDaCoda</a></td> | ||
<td align="center"><a href="https://github.com/freezy-sk">freezy-sk</a></td> | ||
<td align="center"><a href="https://github.com/G-Rath">G-Rath</a></td> | ||
<td align="center"><a href="https://github.com/EvanHahn">EvanHahn</a></td> | ||
<td align="center"><a href="https://github.com/lithiumlron">lithiumlron</a></td> | ||
<td align="center"><a href="https://github.com/diego-codes">diego-codes</a></td> | ||
<td align="center"><a href="https://github.com/Deimos">Deimos</a></td> | ||
<td align="center"><a href="https://github.com/Calme1709">Calme1709</a></td> | ||
</tr> | ||
@@ -393,7 +395,7 @@ </tbody></table> | ||
<tr> | ||
<th align="center"><a href="https://github.com/qmhc"><img alt="qmhc" src="https://avatars.githubusercontent.com/u/40221744?v=4&s=80" width="80"></a></th> | ||
<th align="center"><a href="https://github.com/SterlingVix"><img alt="SterlingVix" src="https://avatars.githubusercontent.com/u/7531113?v=4&s=80" width="80"></a></th> | ||
</tr> | ||
</thead> | ||
<tbody><tr> | ||
<td align="center"><a href="https://github.com/qmhc">qmhc</a></td> | ||
<td align="center"><a href="https://github.com/SterlingVix">SterlingVix</a></td> | ||
</tr> | ||
@@ -400,0 +402,0 @@ </tbody></table> |
@@ -29,7 +29,3 @@ "use strict"; | ||
root.walkAtRules(atrule => { | ||
if (atrule.name !== "else") { | ||
return; | ||
} | ||
root.walkAtRules("else", atrule => { | ||
// Don't need to ignore "the first rule in a stylesheet", etc, cases | ||
@@ -52,3 +48,4 @@ // because @else should always go after @if | ||
result, | ||
ruleName | ||
ruleName, | ||
word: `@${atrule.name}` | ||
}); | ||
@@ -55,0 +52,0 @@ }); |
"use strict"; | ||
const { utils } = require("stylelint"); | ||
const atRuleParamIndex = require("../../utils/atRuleParamIndex"); | ||
const namespace = require("../../utils/namespace"); | ||
@@ -37,5 +38,5 @@ const ruleUrl = require("../../utils/ruleUrl"); | ||
root.walkAtRules("else", decl => { | ||
root.walkAtRules("else", atRule => { | ||
// return early if the else-if statement is not surrounded by parentheses | ||
if (!match.test(decl.params)) { | ||
if (!match.test(atRule.params)) { | ||
return; | ||
@@ -45,9 +46,19 @@ } | ||
if (context.fix) { | ||
decl.params = decl.params.replace(match, replacement); | ||
atRule.params = atRule.params.replace(match, replacement); | ||
} | ||
const index = atRule.params.indexOf("("); | ||
const paramIndex = atRuleParamIndex(atRule); | ||
checker({ | ||
source: decl.params, | ||
index: decl.params.indexOf("("), | ||
err: message => utils.report({ message, node: decl, result, ruleName }) | ||
source: atRule.params, | ||
index, | ||
err: message => | ||
utils.report({ | ||
message, | ||
node: atRule, | ||
result, | ||
ruleName, | ||
index: paramIndex + index | ||
}) | ||
}); | ||
@@ -54,0 +65,0 @@ }); |
@@ -18,2 +18,4 @@ "use strict"; | ||
const INTERPOLATION_PATTERN = /^#{.+}/; | ||
function rule(actual) { | ||
@@ -28,13 +30,16 @@ return (root, result) => { | ||
root.walkAtRules("extend", atrule => { | ||
const isPlaceholder = atrule.params.trim()[0] === "%"; | ||
const isInterpolation = /^#{.+}/.test(atrule.params.trim()); | ||
const param = atrule.params.trim(); | ||
if (!isPlaceholder && !isInterpolation) { | ||
utils.report({ | ||
ruleName, | ||
result, | ||
node: atrule, | ||
message: messages.rejected | ||
}); | ||
} | ||
// Placeholder | ||
if (param.startsWith("%")) return; | ||
if (INTERPOLATION_PATTERN.test(param)) return; | ||
utils.report({ | ||
ruleName, | ||
result, | ||
node: atrule, | ||
message: messages.rejected, | ||
word: param | ||
}); | ||
}); | ||
@@ -41,0 +46,0 @@ }; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const { utils } = require("stylelint"); | ||
const declarationValueIndex = require("../../utils/declarationValueIndex"); | ||
const isNativeCssFunction = require("../../utils/isNativeCssFunction"); | ||
@@ -57,2 +58,4 @@ const { isString } = require("../../utils/validateTypes"); | ||
root.walkDecls(decl => { | ||
const declValueIndex = declarationValueIndex(decl); | ||
valueParser(decl.value).walk(node => { | ||
@@ -93,6 +96,8 @@ if ( | ||
args.forEach(arg => { | ||
const baseIndex = declValueIndex + node.sourceIndex; | ||
args.forEach(({ key, index, endIndex }) => { | ||
switch (expectation) { | ||
case "never": { | ||
if (!arg.key) { | ||
if (!key) { | ||
return; | ||
@@ -105,3 +110,5 @@ } | ||
result, | ||
ruleName | ||
ruleName, | ||
index: baseIndex + index, | ||
endIndex: baseIndex + endIndex | ||
}); | ||
@@ -112,3 +119,3 @@ break; | ||
case "always": { | ||
if (arg.key && isScssVarRegExp.test(arg.key)) { | ||
if (key && isScssVarRegExp.test(key)) { | ||
return; | ||
@@ -121,3 +128,5 @@ } | ||
result, | ||
ruleName | ||
ruleName, | ||
index: baseIndex + index, | ||
endIndex: baseIndex + endIndex | ||
}); | ||
@@ -124,0 +133,0 @@ break; |
"use strict"; | ||
const { utils } = require("stylelint"); | ||
const atRuleParamIndex = require("../../utils/atRuleParamIndex"); | ||
const namespace = require("../../utils/namespace"); | ||
@@ -37,5 +38,5 @@ const ruleUrl = require("../../utils/ruleUrl"); | ||
root.walkAtRules("function", decl => { | ||
root.walkAtRules("function", atRule => { | ||
if (context.fix) { | ||
decl.params = decl.params.replace(match, replacement); | ||
atRule.params = atRule.params.replace(match, replacement); | ||
@@ -45,6 +46,16 @@ return; | ||
const paranIndex = atRule.params.indexOf("("); | ||
const baseIndex = atRuleParamIndex(atRule); | ||
checker({ | ||
source: decl.params, | ||
index: decl.params.indexOf("("), | ||
err: message => utils.report({ message, node: decl, result, ruleName }) | ||
source: atRule.params, | ||
index: paranIndex, | ||
err: message => | ||
utils.report({ | ||
message, | ||
node: atRule, | ||
result, | ||
ruleName, | ||
index: baseIndex + paranIndex | ||
}) | ||
}); | ||
@@ -51,0 +62,0 @@ }); |
@@ -31,9 +31,5 @@ "use strict"; | ||
root.walkAtRules(decl => { | ||
if (decl.name !== "function") { | ||
return; | ||
} | ||
root.walkAtRules("function", atRule => { | ||
// Stripping the function of its arguments | ||
const funcName = decl.params.replace(/(\s*)\([\s\S]*\)/g, ""); | ||
const funcName = atRule.params.replace(/(\s*)\([\s\S]*\)/g, ""); | ||
@@ -44,12 +40,8 @@ if (regexpPattern.test(funcName)) { | ||
const funcTopLine = Object.assign({}, decl.source.start); | ||
funcTopLine.line += 1; | ||
funcTopLine.column = 0; | ||
utils.report({ | ||
message: messages.expected, | ||
node: decl, | ||
node: atRule, | ||
result, | ||
ruleName, | ||
end: funcTopLine | ||
word: funcName | ||
}); | ||
@@ -56,0 +48,0 @@ }); |
@@ -28,14 +28,11 @@ "use strict"; | ||
root.walkAtRules(atrule => { | ||
// Do nothing if it's not an @if | ||
if (atrule.name !== "if") { | ||
return; | ||
} | ||
root.walkAtRules("if", atrule => { | ||
const { params } = atrule; | ||
// If rule != null and (expr), skip | ||
if (atrule.params.match(/.* != null and .*/)) { | ||
if (params.match(/.* != null and .*/)) { | ||
return; | ||
} | ||
if (atrule.params.match(/.* == null[ \t]*\)?/)) { | ||
if (params.match(/.* == null[ \t]*\)?/)) { | ||
utils.report({ | ||
@@ -45,5 +42,6 @@ message: messages.equals_null, | ||
result, | ||
ruleName | ||
ruleName, | ||
word: params | ||
}); | ||
} else if (atrule.params.match(/.* != null[ \t]*\)?/)) { | ||
} else if (params.match(/.* != null[ \t]*\)?/)) { | ||
utils.report({ | ||
@@ -53,3 +51,4 @@ message: messages.not_equals_null, | ||
result, | ||
ruleName | ||
ruleName, | ||
word: params | ||
}); | ||
@@ -56,0 +55,0 @@ } |
@@ -5,2 +5,3 @@ "use strict"; | ||
const { utils } = require("stylelint"); | ||
const atRuleParamIndex = require("../../utils/atRuleParamIndex"); | ||
const namespace = require("../../utils/namespace"); | ||
@@ -50,4 +51,4 @@ const ruleUrl = require("../../utils/ruleUrl"); | ||
root.walkAtRules("import", decl => { | ||
const paths = decl.params | ||
root.walkAtRules("import", atRule => { | ||
const paths = atRule.params | ||
.split(/["']\s*,/) | ||
@@ -75,5 +76,6 @@ .filter(path => !mediaQueryTypesRE.test(path.trim())); | ||
message: messages.expected, | ||
node: decl, | ||
node: atRule, | ||
result, | ||
ruleName | ||
ruleName, | ||
word: pathStripped | ||
}); | ||
@@ -88,3 +90,3 @@ | ||
const extPattern = new RegExp(`\\.${extension}(['" ]*)$`, "g"); | ||
decl.params = decl.params.replace(extPattern, "$1"); | ||
atRule.params = atRule.params.replace(extPattern, "$1"); | ||
@@ -94,6 +96,11 @@ return; | ||
const dotExt = `.${extension}`; | ||
const index = | ||
atRuleParamIndex(atRule) + atRule.params.lastIndexOf(dotExt); | ||
utils.report({ | ||
message: messages.rejected(extension), | ||
node: decl, | ||
word: extension, | ||
node: atRule, | ||
index, | ||
endIndex: index + dotExt.length, | ||
result, | ||
@@ -100,0 +107,0 @@ ruleName |
@@ -58,3 +58,4 @@ "use strict"; | ||
result, | ||
ruleName | ||
ruleName, | ||
word: mixinName | ||
}); | ||
@@ -61,0 +62,0 @@ }); |
"use strict"; | ||
const { utils } = require("stylelint"); | ||
const atRuleParamIndex = require("../../utils/atRuleParamIndex"); | ||
const optionsHaveIgnored = require("../../utils/optionsHaveIgnored"); | ||
const { | ||
parseFunctionArguments | ||
} = require("../../utils/parseFunctionArguments"); | ||
const namespace = require("../../utils/namespace"); | ||
@@ -63,29 +67,13 @@ const ruleUrl = require("../../utils/ruleUrl"); | ||
const args = argsString[1] | ||
// Create array of arguments. | ||
.split(",") | ||
// Create a key-value array for every argument. | ||
.map(argsString => | ||
argsString.split(":").map(argsKeyValuePair => argsKeyValuePair.trim()) | ||
) | ||
.reduce((resultArray, keyValuePair) => { | ||
const pair = { value: keyValuePair[1] || keyValuePair[0] }; | ||
const mixinArgs = parseFunctionArguments(atRule.params); | ||
if (keyValuePair[1]) { | ||
pair.key = keyValuePair[0]; | ||
} | ||
if (mixinArgs.length === 0) return; | ||
if (mixinArgs.length === 1 && shouldIgnoreSingleArgument) return; | ||
return [...resultArray, pair]; | ||
}, []); | ||
const baseIndex = atRuleParamIndex(atRule); | ||
const isSingleArgument = args.length === 1; | ||
if (isSingleArgument && shouldIgnoreSingleArgument) { | ||
return; | ||
} | ||
args.forEach(arg => { | ||
mixinArgs.forEach(({ key, index, endIndex }) => { | ||
switch (expectation) { | ||
case "never": { | ||
if (!arg.key) { | ||
if (!key) { | ||
return; | ||
@@ -98,3 +86,5 @@ } | ||
result, | ||
ruleName | ||
ruleName, | ||
index: baseIndex + index, | ||
endIndex: baseIndex + endIndex | ||
}); | ||
@@ -105,3 +95,3 @@ break; | ||
case "always": { | ||
if (arg.key && isScssVarRegExp.test(arg.key)) { | ||
if (key && isScssVarRegExp.test(key)) { | ||
return; | ||
@@ -114,3 +104,5 @@ } | ||
result, | ||
ruleName | ||
ruleName, | ||
index: baseIndex + index, | ||
endIndex: baseIndex + endIndex | ||
}); | ||
@@ -117,0 +109,0 @@ break; |
"use strict"; | ||
const { utils } = require("stylelint"); | ||
const atRuleParamIndex = require("../../utils/atRuleParamIndex"); | ||
const whitespaceChecker = require("../../utils/whitespaceChecker"); | ||
@@ -37,5 +38,5 @@ const namespace = require("../../utils/namespace"); | ||
root.walkAtRules("mixin", decl => { | ||
root.walkAtRules("mixin", atRule => { | ||
if (context.fix) { | ||
decl.params = decl.params.replace(match, replacement); | ||
atRule.params = atRule.params.replace(match, replacement); | ||
@@ -45,6 +46,16 @@ return; | ||
const parenIndex = atRule.params.indexOf("("); | ||
const baseIndex = atRuleParamIndex(atRule); | ||
checker({ | ||
source: decl.params, | ||
index: decl.params.indexOf("("), | ||
err: message => utils.report({ message, node: decl, result, ruleName }) | ||
source: atRule.params, | ||
index: parenIndex, | ||
err: message => | ||
utils.report({ | ||
message, | ||
node: atRule, | ||
result, | ||
ruleName, | ||
index: baseIndex + parenIndex | ||
}) | ||
}); | ||
@@ -51,0 +62,0 @@ }); |
@@ -31,9 +31,5 @@ "use strict"; | ||
root.walkAtRules(decl => { | ||
if (decl.name !== "mixin") { | ||
return; | ||
} | ||
root.walkAtRules("mixin", atRule => { | ||
// Stripping the mixin of its arguments | ||
const mixinName = decl.params.replace(/(\s*)\([\s\S]*\)/g, ""); | ||
const mixinName = atRule.params.replace(/(\s*)\([\s\S]*\)/g, ""); | ||
@@ -44,12 +40,8 @@ if (regexpPattern.test(mixinName)) { | ||
const mixinTopLine = Object.assign({}, decl.source.start); | ||
mixinTopLine.line += 1; | ||
mixinTopLine.column = 0; | ||
utils.report({ | ||
message: messages.expected, | ||
node: decl, | ||
node: atRule, | ||
result, | ||
ruleName, | ||
end: mixinTopLine | ||
word: mixinName | ||
}); | ||
@@ -56,0 +48,0 @@ }); |
@@ -56,3 +56,4 @@ "use strict"; | ||
result, | ||
ruleName | ||
ruleName, | ||
word: `@${node.name}` | ||
}); | ||
@@ -59,0 +60,0 @@ } |
@@ -25,3 +25,4 @@ "use strict"; | ||
result, | ||
ruleName | ||
ruleName, | ||
word: atrule.params.replace(/\bif\b/, "") // Remove 'if' from '@else if'. | ||
}); | ||
@@ -28,0 +29,0 @@ } |
"use strict"; | ||
const { utils } = require("stylelint"); | ||
const atRuleParamIndex = require("../../utils/atRuleParamIndex"); | ||
const namespace = require("../../utils/namespace"); | ||
@@ -35,16 +36,23 @@ const ruleUrl = require("../../utils/ruleUrl"); | ||
root.walkAtRules("use", decl => { | ||
const parts = separateEachParams(decl.params); | ||
root.walkAtRules("use", atRule => { | ||
const parts = separateEachParams(atRule.params); | ||
if (parts && getDefaultNamespace(parts[0]) === parts[1]) { | ||
if (context.fix) { | ||
decl.after(decl.toString().replace(/\s*as\s* [^\s*]+\s*/, " ")); | ||
decl.next().raws = decl.raws; | ||
decl.remove(); | ||
atRule.after(atRule.toString().replace(/\s*as\s* [^\s*]+\s*/, " ")); | ||
atRule.next().raws = atRule.raws; | ||
atRule.remove(); | ||
return; | ||
} | ||
const matchedAlias = atRule.params.match(/as\s+\S+/); | ||
if (!matchedAlias) return; | ||
const index = atRuleParamIndex(atRule) + matchedAlias.index; | ||
utils.report({ | ||
message: messages.rejected, | ||
node: decl, | ||
node: atRule, | ||
result, | ||
ruleName | ||
ruleName, | ||
index, | ||
endIndex: index + matchedAlias[0].length | ||
}); | ||
@@ -51,0 +59,0 @@ } |
@@ -25,11 +25,13 @@ "use strict"; | ||
root.walkAtRules("use", decl => { | ||
if (/as\s*\*\s*(?:$|with\s*\()/.test(decl.params)) { | ||
utils.report({ | ||
message: messages.rejected, | ||
node: decl, | ||
result, | ||
ruleName | ||
}); | ||
} | ||
root.walkAtRules("use", atRule => { | ||
const matched = atRule.params.match(/(as\s*\*)\s*(?:$|with\s*\()/); | ||
if (!matched) return; | ||
utils.report({ | ||
message: messages.rejected, | ||
node: atRule, | ||
result, | ||
ruleName, | ||
word: matched[1] | ||
}); | ||
}); | ||
@@ -36,0 +38,0 @@ }; |
@@ -57,9 +57,9 @@ "use strict"; | ||
Object.keys(nestedGroups).forEach(namespace => { | ||
Object.entries(nestedGroups).forEach(([namespace, groups]) => { | ||
// Only warn if there are more than one nested groups with equal namespaces | ||
if (nestedGroups[namespace].length === 1) { | ||
if (groups.length === 1) { | ||
return; | ||
} | ||
nestedGroups[namespace].forEach(group => { | ||
groups.forEach(group => { | ||
utils.report({ | ||
@@ -69,3 +69,4 @@ message: messages.expected(namespace), | ||
result, | ||
ruleName | ||
ruleName, | ||
word: namespace | ||
}); | ||
@@ -72,0 +73,0 @@ }); |
@@ -5,3 +5,2 @@ "use strict"; | ||
const { utils } = require("stylelint"); | ||
const declarationValueIndex = require("../../utils/declarationValueIndex"); | ||
const namespace = require("../../utils/namespace"); | ||
@@ -111,4 +110,2 @@ const ruleUrl = require("../../utils/ruleUrl"); | ||
const unit = matchUnit[1]; | ||
const offset = decl.value.indexOf(unit); | ||
utils.report({ | ||
@@ -118,3 +115,3 @@ ruleName, | ||
message: messages.rejected(unit), | ||
index: declarationValueIndex(decl) + offset, | ||
word: matchUnit[0], | ||
node: decl | ||
@@ -121,0 +118,0 @@ }); |
@@ -114,3 +114,4 @@ "use strict"; | ||
node, | ||
message: messages.rejected(nodeName, value) | ||
message: messages.rejected(nodeName, value), | ||
word: value | ||
}); | ||
@@ -117,0 +118,0 @@ } |
@@ -67,3 +67,4 @@ "use strict"; | ||
result, | ||
ruleName | ||
ruleName, | ||
word: prop | ||
}); | ||
@@ -70,0 +71,0 @@ }); |
@@ -85,2 +85,3 @@ "use strict"; | ||
index: comment.source.start, | ||
endIndex: comment.source.end + 1, | ||
result, | ||
@@ -87,0 +88,0 @@ ruleName |
@@ -30,19 +30,21 @@ "use strict"; | ||
valueParser(decl.value).walk(node => { | ||
if (node.type !== "function" || node.value === "") { | ||
return; | ||
} | ||
if ( | ||
calculationFunctions.includes(node.value) && | ||
node.nodes.some( | ||
args => args.type === "word" && /^#{.*|\s*}/.test(args.value) | ||
) | ||
) { | ||
utils.report({ | ||
message: messages.rejected(node.value), | ||
node: decl, | ||
word: decl.name, | ||
result, | ||
ruleName | ||
}); | ||
} | ||
if (node.type !== "function" || node.value === "") return; | ||
if (!calculationFunctions.includes(node.value)) return; | ||
// Interpolation is valid in SassScript. | ||
if (decl.type === "decl" && decl.prop.startsWith("--")) return; | ||
const interpolation = node.nodes.find( | ||
({ type, value }) => type === "word" && /^#{.*|\s*}/.test(value) | ||
); | ||
if (!interpolation) return; | ||
utils.report({ | ||
message: messages.rejected(node.value), | ||
node: decl, | ||
word: interpolation.value, | ||
result, | ||
ruleName | ||
}); | ||
}); | ||
@@ -49,0 +51,0 @@ }); |
@@ -45,2 +45,4 @@ "use strict"; | ||
root.walkDecls(decl => { | ||
const declValueIndex = declarationValueIndex(decl); | ||
valueParser(decl.value).walk(node => { | ||
@@ -60,11 +62,13 @@ // Verify that we're only looking at functions. | ||
if (isSassColorFunction || isDSFilterColorFunction) { | ||
const nodes = isDSFilterColorFunction | ||
const funcNodes = isDSFilterColorFunction | ||
? node.nodes.filter(isColorFunction) | ||
: [node]; | ||
nodes.forEach(node => { | ||
funcNodes.forEach(funcNode => { | ||
const index = declValueIndex + funcNode.sourceIndex; | ||
utils.report({ | ||
message: messages.rejected, | ||
node: decl, | ||
index: declarationValueIndex(decl) + node.sourceIndex, | ||
index, | ||
endIndex: index + funcNode.value.length, | ||
result, | ||
@@ -71,0 +75,0 @@ ruleName |
@@ -54,3 +54,3 @@ "use strict"; | ||
node: decl, | ||
word: decl.name, | ||
word: nameWithoutNamespace, | ||
result, | ||
@@ -57,0 +57,0 @@ ruleName |
@@ -66,6 +66,8 @@ "use strict"; | ||
} else { | ||
const index = declarationValueIndex(decl) + node.sourceIndex; | ||
utils.report({ | ||
message: messages.rejected, | ||
node: decl, | ||
index: declarationValueIndex(decl) + node.sourceIndex, | ||
index, | ||
endIndex: index + node.value.length, | ||
result, | ||
@@ -72,0 +74,0 @@ ruleName |
@@ -70,6 +70,8 @@ "use strict"; | ||
} else { | ||
const index = declarationValueIndex(decl) + node.sourceIndex; | ||
utils.report({ | ||
message: messages.rejected, | ||
node: decl, | ||
index: declarationValueIndex(decl) + node.sourceIndex, | ||
index, | ||
endIndex: index + node.value.length, | ||
result, | ||
@@ -76,0 +78,0 @@ ruleName |
@@ -61,2 +61,3 @@ "use strict"; | ||
"no-global-function-names": require("./no-global-function-names"), | ||
"no-unused-private-members": require("./no-unused-private-members"), | ||
"operator-no-newline-after": require("./operator-no-newline-after"), | ||
@@ -63,0 +64,0 @@ "operator-no-newline-before": require("./operator-no-newline-before"), |
@@ -20,3 +20,2 @@ "use strict"; | ||
const validOptions = utils.validateOptions(result, ruleName, { actual }); | ||
const hasArgumentsRegExp = /\(\s*([^)]+?)\s*\)/; | ||
@@ -27,3 +26,5 @@ if (!validOptions) { | ||
function checkPathForUnderscore(path, decl) { | ||
const hasArgumentsRegExp = /\(\s*([^)]+?)\s*\)/; | ||
function checkPathForUnderscore(path, atrule) { | ||
// Stripping trailing quotes and whitespaces, if any | ||
@@ -51,5 +52,6 @@ const pathStripped = path | ||
message: messages.expected, | ||
node: decl, | ||
node: atrule, | ||
result, | ||
ruleName | ||
ruleName, | ||
word: pathStripped | ||
}); | ||
@@ -75,3 +77,3 @@ } | ||
const arg = args[0].split(","); | ||
checkPathForUnderscore(arg[0].replace(/\(|\)/, ""), atrule); | ||
checkPathForUnderscore(arg[0].replace(/[()]/g, ""), atrule); | ||
} | ||
@@ -78,0 +80,0 @@ } |
@@ -45,8 +45,8 @@ "use strict"; | ||
mapKeys.forEach(map_key => { | ||
if (mathOperators.includes(map_key.value)) { | ||
mapKeys.forEach(mapKey => { | ||
if (mathOperators.includes(mapKey.value)) { | ||
return; | ||
} | ||
if (map_key.type === "word" && isNaN(map_key.value)) { | ||
if (mapKey.type === "word" && isNaN(mapKey.value)) { | ||
utils.report({ | ||
@@ -56,3 +56,4 @@ message: messages.expected, | ||
result, | ||
ruleName | ||
ruleName, | ||
word: mapKey.value | ||
}); | ||
@@ -59,0 +60,0 @@ } |
@@ -36,3 +36,4 @@ "use strict"; | ||
result, | ||
ruleName | ||
ruleName, | ||
word: decl.prop | ||
}); | ||
@@ -39,0 +40,0 @@ }); |
@@ -177,3 +177,4 @@ "use strict"; | ||
result, | ||
ruleName | ||
ruleName, | ||
word: decl.prop | ||
}); | ||
@@ -180,0 +181,0 @@ } |
@@ -30,17 +30,12 @@ "use strict"; | ||
root.walkAtRules(decl => { | ||
const isMixin = decl.name === "mixin"; | ||
root.walkAtRules("mixin", atRule => { | ||
const mixinName = atRuleBaseName(atRule); | ||
if (!isMixin) { | ||
return; | ||
} | ||
const mixinName = atRuleBaseName(decl); | ||
if (mixins[mixinName]) { | ||
utils.report({ | ||
message: messages.rejected(mixinName), | ||
node: decl, | ||
node: atRule, | ||
result, | ||
ruleName | ||
ruleName, | ||
word: mixinName | ||
}); | ||
@@ -47,0 +42,0 @@ } |
@@ -5,3 +5,2 @@ "use strict"; | ||
const { utils } = require("stylelint"); | ||
const declarationValueIndex = require("../../utils/declarationValueIndex"); | ||
const namespace = require("../../utils/namespace"); | ||
@@ -186,7 +185,7 @@ const ruleUrl = require("../../utils/ruleUrl"); | ||
if (Object.keys(rules).includes(cleanValue)) { | ||
if (rules[cleanValue]) { | ||
utils.report({ | ||
message: messages.rejected(cleanValue), | ||
node: decl, | ||
index: declarationValueIndex(decl) + node.sourceIndex, | ||
word: cleanValue, | ||
result, | ||
@@ -193,0 +192,0 @@ ruleName |
@@ -46,2 +46,3 @@ "use strict"; | ||
if (newLineBefore) { | ||
const index = globalIndex + startIndex; | ||
utils.report({ | ||
@@ -52,3 +53,4 @@ ruleName, | ||
message: messages.rejected(symbol), | ||
index: endIndex + globalIndex | ||
index, | ||
endIndex: index + symbol.length | ||
}); | ||
@@ -55,0 +57,0 @@ } |
@@ -46,2 +46,3 @@ "use strict"; | ||
if (newLineBefore) { | ||
const index = globalIndex + startIndex; | ||
utils.report({ | ||
@@ -52,3 +53,4 @@ ruleName, | ||
message: messages.rejected(symbol), | ||
index: endIndex + globalIndex | ||
index, | ||
endIndex: index + symbol.length | ||
}); | ||
@@ -55,0 +57,0 @@ } |
@@ -43,2 +43,3 @@ "use strict"; | ||
if (!beforeOk) { | ||
const index = globalIndex + startIndex; | ||
utils.report({ | ||
@@ -49,3 +50,4 @@ ruleName, | ||
message: messages.expectedBefore(symbol), | ||
index: startIndex + globalIndex | ||
index, | ||
endIndex: index + symbol.length | ||
}); | ||
@@ -60,2 +62,3 @@ } | ||
if (!afterOk) { | ||
const index = globalIndex + startIndex; | ||
utils.report({ | ||
@@ -66,3 +69,4 @@ ruleName, | ||
message: messages.expectedAfter(symbol), | ||
index: endIndex + globalIndex | ||
index, | ||
endIndex: index + symbol.length | ||
}); | ||
@@ -69,0 +73,0 @@ } |
@@ -39,3 +39,3 @@ "use strict"; | ||
function checkImportForCSS(path, decl) { | ||
function checkImportForCSS(path, atRule) { | ||
// Stripping trailing quotes and whitespaces, if any | ||
@@ -59,4 +59,4 @@ const pathStripped = path | ||
message: messages.expected, | ||
node: decl, | ||
index: decl.params.indexOf(path), | ||
node: atRule, | ||
word: pathStripped, | ||
result, | ||
@@ -63,0 +63,0 @@ ruleName |
@@ -73,3 +73,3 @@ "use strict"; | ||
fullSelector.walkTags(compoundSelector => { | ||
const { value, sourceIndex } = compoundSelector; | ||
const { value } = compoundSelector; | ||
@@ -91,3 +91,3 @@ if (value[0] !== "%") { | ||
node: rule, | ||
index: sourceIndex | ||
word: value | ||
}); | ||
@@ -94,0 +94,0 @@ }); |
@@ -100,10 +100,12 @@ "use strict"; | ||
// Nested properties | ||
if ( | ||
parent && | ||
isType(parent, "rule") && | ||
parent.selector && | ||
parent.selector[parent.selector.length - 1] === ":" && | ||
parent.selector.substring(0, 2) !== "--" | ||
let pointer = parent; | ||
while ( | ||
pointer && | ||
isType(pointer, "rule") && | ||
pointer.selector && | ||
pointer.selector[pointer.selector.length - 1] === ":" && | ||
pointer.selector.substring(0, 2) !== "--" | ||
) { | ||
prop = parent.selector.replace(":", "") + "-" + prop; | ||
prop = pointer.selector.replace(":", "") + "-" + prop; | ||
pointer = pointer.parent; | ||
} | ||
@@ -110,0 +112,0 @@ |
@@ -74,4 +74,2 @@ "use strict"; | ||
parseSelector(rule.selector, result, rule, fullSelector => { | ||
let message; | ||
fullSelector.walk(node => { | ||
@@ -134,2 +132,3 @@ if (node.value === "}") { | ||
let message; | ||
if (hasInterpolation) { | ||
@@ -140,2 +139,11 @@ message = messages.expectedInterpolation; | ||
} | ||
utils.report({ | ||
ruleName, | ||
result, | ||
node: rule, | ||
message, | ||
word: node.toString() | ||
}); | ||
return; | ||
} | ||
@@ -148,12 +156,13 @@ | ||
message = messages.rejected; | ||
if (node.type !== "selector") return; | ||
utils.report({ | ||
ruleName, | ||
result, | ||
node: rule, | ||
message: messages.rejected, | ||
word: node.toString() | ||
}); | ||
return; | ||
} | ||
utils.report({ | ||
ruleName, | ||
result, | ||
node: rule, | ||
message, | ||
index: node.sourceIndex | ||
}); | ||
}); | ||
@@ -160,0 +169,0 @@ }); |
@@ -80,3 +80,4 @@ "use strict"; | ||
message: messages.rejected, | ||
index: node.sourceIndex | ||
index: node.sourceIndex, | ||
endIndex: node.sourceIndex + node.value.length | ||
}); | ||
@@ -83,0 +84,0 @@ }); |
@@ -73,3 +73,4 @@ "use strict"; | ||
message: messages.rejected, | ||
index: node.sourceIndex | ||
index: node.sourceIndex, | ||
endIndex: node.sourceIndex + rule.selector.length | ||
}); | ||
@@ -76,0 +77,0 @@ }); |
@@ -35,3 +35,3 @@ "use strict"; | ||
function mapToKeyValue(nodes) { | ||
const keyVal = nodes.reduce((acc, curr, i) => { | ||
const keyVal = nodes.reduce((acc, currentNode, i) => { | ||
if (acc.length === 1) { | ||
@@ -47,4 +47,6 @@ return acc; | ||
acc.push({ | ||
key: valueParser.stringify(nodes[i]), | ||
value: valueParser.stringify(nodes.slice(2)) | ||
key: valueParser.stringify(currentNode), | ||
value: valueParser.stringify(nodes.slice(2)), | ||
index: currentNode.sourceIndex, | ||
endIndex: nodes.at(-1).sourceEndIndex | ||
}); | ||
@@ -56,3 +58,5 @@ | ||
acc.push({ | ||
value: valueParser.stringify(nodes) | ||
value: valueParser.stringify(nodes), | ||
index: currentNode.sourceIndex, | ||
endIndex: nodes.at(-1).sourceEndIndex | ||
}); | ||
@@ -67,11 +71,10 @@ | ||
function parseFunctionArguments(value) { | ||
const parsed = valueParser(value); | ||
const { nodes } = valueParser(value); | ||
const [firstNode] = nodes; | ||
if (!parsed.nodes[0] || parsed.nodes[0].type !== "function") { | ||
if (!firstNode || firstNode.type !== "function") { | ||
return []; | ||
} | ||
return parsed.nodes.map(node => | ||
groupByKeyValue(node.nodes).map(mapToKeyValue) | ||
)[0]; | ||
return nodes.map(node => groupByKeyValue(node.nodes).map(mapToKeyValue))[0]; | ||
} | ||
@@ -78,0 +81,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
285926
117
8276
397