You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
737 B
38 lines
737 B
'use strict'; |
|
|
|
const hasInterpolation = require('../utils/hasInterpolation'); |
|
|
|
/** |
|
* Check whether a selector is standard |
|
* |
|
* @param {string} selector |
|
* @returns {boolean} |
|
*/ |
|
module.exports = function (selector) { |
|
// SCSS or Less interpolation |
|
if (hasInterpolation(selector)) { |
|
return false; |
|
} |
|
|
|
// SCSS placeholder selectors |
|
if (selector.startsWith('%')) { |
|
return false; |
|
} |
|
|
|
// Less :extend() |
|
if (/:extend(\(.*?\))?/.test(selector)) { |
|
return false; |
|
} |
|
|
|
// Less mixin with resolved nested selectors (e.g. .foo().bar or .foo(@a, @b)[bar]) |
|
if (/\.[\w-]+\(.*\).+/i.test(selector)) { |
|
return false; |
|
} |
|
|
|
// ERB template tags |
|
if (selector.includes('<%') || selector.includes('%>')) { |
|
return false; |
|
} |
|
|
|
return true; |
|
};
|
|
|