beautifier/js-beautify

Add `defaultOptions` method to main beautifier

开放

#1,584 创建于 2018年11月1日

 (3 条评论) (3 个反应) (0 位负责人)JavaScript (1,460 个派生)batch import
good first issueimplementation: javascripttype: enhancement

仓库指标

星标
 (8,342 个星标)
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"
  }
}

贡献者指南