Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false positives for namespaced variables in property-no-unknown (#…
- Loading branch information
Showing
7 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
const isScssVariable = require('../isScssVariable'); | ||
|
||
describe('isScssVariable', () => { | ||
it('sass variable', () => { | ||
expect(isScssVariable('$sass-variable')).toBeTruthy(); | ||
}); | ||
it('sass variable within namespace', () => { | ||
expect(isScssVariable('namespace.$sass-variable')).toBeTruthy(); | ||
}); | ||
it('sass interpolation', () => { | ||
expect(isScssVariable('#{$Attr}-color')).toBeFalsy(); | ||
}); | ||
it('single word property', () => { | ||
expect(isScssVariable('top')).toBeFalsy(); | ||
}); | ||
it('hyphenated property', () => { | ||
expect(isScssVariable('border-top-left-radius')).toBeFalsy(); | ||
}); | ||
it('property with vendor prefix', () => { | ||
expect(isScssVariable('-webkit-appearance')).toBeFalsy(); | ||
}); | ||
it('custom property', () => { | ||
expect(isScssVariable('--custom-property')).toBeFalsy(); | ||
}); | ||
it('less variable', () => { | ||
expect(isScssVariable('@var')).toBeFalsy(); | ||
}); | ||
it('less append property value with comma', () => { | ||
expect(isScssVariable('transform+')).toBeFalsy(); | ||
}); | ||
it('less append property value with space', () => { | ||
expect(isScssVariable('transform+_')).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Check whether a property is SCSS variable | ||
* | ||
* @param {string} property | ||
* @returns {boolean} | ||
*/ | ||
module.exports = function (property) { | ||
// SCSS var (e.g. $var: x), list (e.g. $list: (x)) or map (e.g. $map: (key:value)) | ||
if (property.startsWith('$')) { | ||
return true; | ||
} | ||
|
||
// SCSS var within a namespace (e.g. namespace.$var: x) | ||
if (property.includes('.$')) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters