diff --git a/packages/naming.cell.match/cell-match.test.js b/packages/naming.cell.match/cell-match.test.js index 9051d471..e729cda4 100644 --- a/packages/naming.cell.match/cell-match.test.js +++ b/packages/naming.cell.match/cell-match.test.js @@ -164,6 +164,7 @@ describe('naming.cell.match', () => { parse typical block path → bb/bb.css → { cell: { layer: 'common', block: 'bb', tech: 'css' } } parse typical elem path → bb/ee/bb-ee.css → { cell: { layer: 'common', block: 'bb', elem: 'ee', tech: 'css' } } parse typical block in layer → bb/bb@ios.css → { cell: { layer: 'ios', block: 'bb', tech: 'css' } } + parse typical block in layer → bb/bb@touch-phone.css → { cell: { layer: 'touch-phone', block: 'bb', tech: 'css' } } parse typical mod path → bb/_mod/bb_mod.css → { cell: { layer: 'common', block: 'bb', mod: 'mod', tech: 'css' } } `] })) { diff --git a/packages/naming.entity.parse/index.js b/packages/naming.entity.parse/index.js index 3aee7da4..f36d6717 100644 --- a/packages/naming.entity.parse/index.js +++ b/packages/naming.entity.parse/index.js @@ -7,10 +7,11 @@ const BemEntityName = require('@bem/sdk.entity-name'); * * @param {INamingConventionDelims} delims — separates entity names from each other. * @param {String} wordPattern — defines which symbols can be used for block, element and modifier's names. + * @param {String} blockPattern — WIP * @returns {RegExp} */ -function buildRegex(delims, wordPattern) { - const block = '(' + wordPattern + ')'; +function buildRegex(delims, wordPattern, blockPattern) { + const block = '(' + blockPattern + ')'; const elem = '(?:' + delims.elem + '(' + wordPattern + '))?'; const modName = '(?:' + delims.mod.name + '(' + wordPattern + '))?'; const modVal = '(?:' + delims.mod.val + '(' + wordPattern + '))?'; @@ -50,7 +51,7 @@ function parse(str, regex) { * @returns {Function} */ module.exports = (convention) => { - const regex = buildRegex(convention.delims, convention.wordPattern); + const regex = buildRegex(convention.delims, convention.wordPattern, convention.blockPattern); return (str) => parse(str, regex); }; diff --git a/packages/naming.presets/origin-react.js b/packages/naming.presets/origin-react.js index 761ff2cf..75d999e3 100644 --- a/packages/naming.presets/origin-react.js +++ b/packages/naming.presets/origin-react.js @@ -9,5 +9,6 @@ module.exports = Object.assign({}, origin, { fs: Object.assign({}, origin.fs, { delims: { elem: '' } }), - wordPattern: '[a-zA-Z0-9]+' + wordPattern: '[a-zA-Z0-9-]+', + blockPattern: '[a-zA-Z0-9]+', });