0.5.2 • Published 7 years ago

deps-formatter v0.5.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

DEPS-FORMATTER

NPM version Build Status Coverage Status Dependency Status

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 = {...} or module.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 - default
  • checkstyle