Closed jitendravyas closed 5 years ago
I set my own componentSelectors
function bemSelectors(block, presetOptions) {
const ns = (presetOptions && presetOptions.namespace) ? presetOptions.namespace + '-' : '';
const WORD = '[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*';
const element = '(?:__' + WORD + ')?';
const modifier = '(?:--' + WORD + '){0,2}';
const attribute = '(?:\\[.+\\])?';
return new RegExp('^\\.' + ns + block + element + modifier + attribute + '$');
}
Original preset-patterns.js looks like
function bemSelector(block, presetOptions) {
const ns = (presetOptions && presetOptions.namespace) ? `${presetOptions.namespace}-` : '';
const WORD = '[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*';
const element = `(?:__${WORD})?`;
const modifier = `(?:_${WORD}){0,2}`;
const attribute = '(?:\\[.+\\])?';
return new RegExp(`^\\.${ns}${block}${element}${modifier}${attribute}$`);
}
for function bemSelector but this should as suggested from gunnx like:
function bemSelector(block, presetOptions) {
const ns = (presetOptions && presetOptions.namespace) ? `${presetOptions.namespace}-` : '';
const WORD = '[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*';
const element = `(?:__${WORD})?`;
const modifier = `(?:--${WORD}){0,2}`;
const attribute = '(?:\\[.+\\])?';
return new RegExp(`^\\.${ns}${block}${element}${modifier}${attribute}$`);
}
You can look at http://getbem.com/naming/
i made a fix here: https://github.com/postcss/postcss-bem-linter/pull/136
Closing as fixed
Please add Harry robert's style BEM as a Preset.
https://github.com/postcss/postcss-bem-linter/blob/master/lib/preset-patterns.js