From 276fdd82c5481961372ab3c9b8e3e759d9b17fef Mon Sep 17 00:00:00 2001 From: yarastqt Date: Thu, 14 Mar 2019 23:07:59 +0300 Subject: [PATCH 1/2] wip --- packages/naming.cell.match/cell-match.test.js | 1 + packages/naming.presets/origin-react.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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.presets/origin-react.js b/packages/naming.presets/origin-react.js index 761ff2cf..d7ff3d52 100644 --- a/packages/naming.presets/origin-react.js +++ b/packages/naming.presets/origin-react.js @@ -9,5 +9,5 @@ module.exports = Object.assign({}, origin, { fs: Object.assign({}, origin.fs, { delims: { elem: '' } }), - wordPattern: '[a-zA-Z0-9]+' + wordPattern: '[a-zA-Z0-9-]+' }); From e81f422ba2938206cd0342ff7fbd4015b9a69569 Mon Sep 17 00:00:00 2001 From: yarastqt Date: Thu, 14 Mar 2019 23:47:45 +0300 Subject: [PATCH 2/2] wip --- packages/naming.entity.parse/index.js | 7 ++++--- packages/naming.presets/origin-react.js | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) 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 d7ff3d52..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]+', });