deps-formatter
v0.5.2
Published
deps auto formatting
Downloads
5
Readme
DEPS-FORMATTER
Formatting deps.js
files, for maintain consistency.
Install
npm install --save-dev deps-formatter
Run
Run in your bem-project directory:
deps-formatter
Or to format only one file:
deps-formatter path/to/file.deps.js
Config
Initialization of config file:
deps-formatter --init
This option will create .deps-formatterrc
config file.
.deps-formatterrc
is plain JSON.
Example of config:
cat .deps-formatterrc
{
"rules": {
"format": "arrayexpression",
"depsObjIsArray": true,
"elemsIsArray": true,
"blockNameShortcut": false
},
"levels": {
"common.blocks": {},
"desktop.blocks": {}
}
}
Rules section is described below: rules
Levels
Levels section is directories that contain blocks with deps.js
files.
To learn more about levels traversal check out: bem-walk
If you don't provide levels section deps-formatter will try to find .bemrc
Rules:
Format
Response for root format of deps.js file, could be different for one and many depObjects.
Values:
"expression" -
({...})
or[{...}, {...}]
"arrayExpression" -
[{...}]
or[{...}, {...}]
"objectExpression" -
({...})
or([{...}, {...}])
"commonJS" -
module.exports = {...}
ormodule.exports = [...]
depsObjIsArray
Response for type of mustDeps/shouldDeps value. Works for value that could be recorded as arrays with one value.
Values:
true -
mustDeps: {...} -> mustDeps: [{...}]
false -
mustDeps: [{...}] -> mustDeps: {...}
elemsIsArray
Response for type of elems or elem value. Values:
true -
elems: {...} -> elems: [{...}]
false -
elems: [{...}] -> elems: {...}
blockNameShortcut
Response for allowing {block: 'name'} -> 'name' shortcut
Values:
true -
mustDeps: 'name' -> mustDeps: {block: 'name'}
false -
mustDeps: {block: 'name'} -> mustDeps: 'name'
Reporters:
Different variants of reporter:
console
- defaultcheckstyle