-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use bem decl for merge, subtract and intersect #232
Conversation
The `node.getLevelNamingScheme` and the `node.setLevelNamingScheme` methods will be removed in `enb@2.0.0`.
Got rid of scheme builders
Redundant code of deps
Remove deprecated techs
Remove deprecated options
The `mock-fs` does not support `require` for Node.js 4. Because of this test failed with error: ``` Cannot find module 'path/to/file.js ```
Support Node.js 4
**Example of new format:** ``` { button__text: [ { entity: { block: ‘button’, elem: ‘text’ }, tech: ‘css’, path: ‘path/to/file.ext’, level: ‘path/to/level’ }, /* ... */ ], /* ... */ } ``` With this introspection format to easily get a list of files named entity. **What has been done?** * Use `bem-walk` to scan levels. * Use `bem-naming` to get id of BEM entity. * Add `BundleIntrospection` class to work with introspection of levels for one bundle. * Rewrite `levels` tech with `build-flow`. * Use promises with `node.buildState` to avoid scanning the same levels multiple times. * Don't read files for directories (example i18n), it should do `files` tech.
Now the `bem-walk` is used to scan.
Exactly the same benchmarks in `bem-walk` repository
API moved to bottom of list
Remove 'docs/bem-project.md' file
Used the `files` field in `package.json`
Replaced *.bemhtml with *.bemhtml.js [issue 404]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -1,3 +1,4 @@ | |||
const decl = require('bem-decl'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it safe to use ES6 here?
/** | ||
* Coverts declaration modName and modVal to mod and val | ||
* | ||
* @param {Array} deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it can be an Object as well
* @param {Array} deps | ||
* @return {Array} | ||
*/ | ||
_convertFromMod: function (deps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's possible to get rid of copy/paste like this (never tested so be careful):
function _switchModsFormat(conditionKey, modsMap, deps) {
Array.isArray(deps) || (deps = [deps]);
return deps.map(function (item) {
if (!item[conditionKey]) return item;
return Object.keys(item).reduce(function (acc, key) {
acc[map[key] || key] = item[key];
return acc;
}, {});
}
}
_convertFromMod: function (deps) {
return _switchModsFormat('mod', {
mod: modName,
val: modVal
}, deps);
}
_convertToMod: function (deps) {
return _switchModsFormat('modName', {
modName: mod,
modVal: val
}, deps);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return _switchModsFormat('mod', { | ||
mod: 'modName', | ||
val: 'modVal' | ||
}, deps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blond whyyyy!?
* @param {Array|Object} deps | ||
* @return {Array} | ||
*/ | ||
_convertToMod: function (deps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему не вынести эти функции отдельно? Им же не нужен контекст this
@skad0 какая связь между депсами и операциями над декларациями в разных форматах? |
@skad0 можешь переоткрыть PR в |
Will work when bem-naming mod field support will be enabled