beautifier/js-beautify

Add `defaultOptions` method to main beautifier

Open

#1,584 建立於 2018年11月1日

在 GitHub 查看
 (2 留言) (3 反應) (0 負責人)JavaScript (1,460 fork)batch import
good first issueimplementation: javascripttype: enhancement

倉庫指標

Star
 (8,342 star)
PR 合併指標
 (平均合併 51天 1小時) (30 天內合併 16 個 PR)

描述

Description

Related to #1364. #1568 added a basic implementation for this.

We need to add beautify.defaultOptions() that:

  1. calls core Options constructor
  2. calls each of the child defaultOptions()
  3. removes the inherited settings and also the raw_options field

It should return something like what is shown below.

Finally, we should consider calling this method during the build to generate the .jsbeautifyrc file.

There should be one source of truth the settings for the project.

{
  "disabled": false,
  "eol": "auto",
  "end_with_newline": false,
  "indent_size": 4,
  "indent_char": " ",
  "indent_level": 0,
  "preserve_newlines": true,
  "max_preserve_newlines": 32786,
  "indent_with_tabs": false,
  "wrap_line_length": 0,
  "js": {
    "brace_preserve_inline": false,
    "brace_style": "collapse",
    "unindent_chained_methods": false,
    "break_chained_methods": false,
    "space_in_paren": false,
    "space_in_empty_paren": false,
    "jslint_happy": false,
    "space_after_anon_function": false,
    "space_after_named_function": false,
    "keep_array_indentation": false,
    "space_before_conditional": true,
    "unescape_strings": false,
    "e4x": false,
    "comma_first": false,
    "operator_position": "before-newline",
    "test_output_raw": false
  },
  "css": {
    "selector_separator_newline": true,
    "newline_between_rules": true,
    "space_around_combinator": false
  },
  "html": {
    "js": {},
    "css": {},
    "indent_inner_html": false,
    "indent_body_inner_html": true,
    "indent_head_inner_html": true,
    "indent_handlebars": true,
    "wrap_attributes": "auto",
    "wrap_attributes_indent_size": 4,
    "extra_liners": [
        "head",
        "body",
        "/html"
    ],
    "inline": [
      "a", "abbr", "area", "audio", "b", "bdi", "bdo", "br", "button", "canvas", "cite", "code", "data", "datalist", "del", "dfn", "em", "embed", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "map", "mark", "math", "meter", "noscript", "object", "output", "progress", "q", "ruby", "s", "samp", "select", "small", "span", "strong", "sub", "sup", "svg", "template", "textarea", "time", "u", "var", "video", "wbr", "text", "acronym", "address", "big", "dt", "ins", "strike", "tt"
    ],
    "void_elements": [
      "area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr", "!doctype", "?xml", "?php", "?=", "basefont", "isindex"
    ],
    "unformatted": [],
    "content_unformatted": [
        "pre",
        "textarea"
    ],
    "indent_scripts": "normal"
  }
}

貢獻者指南