Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom properties in declarations #1122

Merged
merged 1 commit into from
Aug 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/rules/no-misspelled-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var buildPartialProperty = function (valBlock, currentProperty) {
var value = node.first('value');
skipProps++;

if (prop.first().is('ident')) {
if (prop && prop.first().is('ident')) {
if (value.contains('block')) {
propList = propList.concat(
buildPartialProperty(value.first('block'),
Expand Down Expand Up @@ -77,7 +77,10 @@ module.exports = {

ast.traverseByType('declaration', function (node) {
var prop = node.first('property');
var containsInterp = prop.contains('interpolation');
// declaration may include custom properties etc, check that prop is defined here
if (!prop) {
return false;
}
// If we've already checked declarations in a multiline we can skip those decs here
if (skipProps) {
skipProps -= 1;
Expand Down Expand Up @@ -123,7 +126,7 @@ module.exports = {
* If our property name contains interpolation we need to make a best guess by using a
* partial string match as we can't be 100% on the context
*/
if (containsInterp) {
if (prop.contains('interpolation')) {
if (!helpers.isPartialStringMatch(curProperty, propertyList)) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
Expand Down
3 changes: 3 additions & 0 deletions tests/sass/no-misspelled-properties.sass
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ $red: #ff0000
color: red
background-colr: blue
font-size: 12rem

.element
--main-bg-color: brown
4 changes: 4 additions & 0 deletions tests/sass/no-misspelled-properties.scss
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ $red: #ff0000;
background-colr: blue; // 14
font-size: 12rem;
}

.element {
--main-bg-color: brown;
}