Détail du package

js-beautify-ejsx

beautify-web10.3kMIT1.6.12

jsbeautifier.org for node

beautify, beautifier, code-quality

readme

Important

The following fork was created to be able to fix: https://github.com/royriojas/esformatter-jsx/issues/105 it adds the option voidElements: [], that can be used to specify which elements should be considered void elements as explained here: http://w3c.github.io/html/syntax.html#void-elements

JS Beautifier

Build Status Build status CDNJS version NPM version Download stats Join the chat at https://gitter.im/beautify-web/js-beautify

NPM stats

This little beautifier will reformat and reindent bookmarklets, ugly JavaScript, unpack scripts packed by Dean Edward’s popular packer, as well as deobfuscate scripts processed by javascriptobfuscator.com.

Usage

You can beautify javascript using JS Beautifier in your web browser, or on the command-line using node.js or python.

JS Beautifier is hosted on two CDN services: cdnjs and rawgit.

To pull from one of these services include one set of the script tags below in your document:

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.12/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.12/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.12/beautify-html.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.12/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.12/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.12/beautify-html.min.js"></script>

<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.6.12/js/lib/beautify.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.6.12/js/lib/beautify-css.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.6.12/js/lib/beautify-html.js"></script>

Disclaimer: These are free services, so there are no uptime or support guarantees.

Web Browser

Open jsbeautifier.org. Options are available via the UI.

Python

To beautify using python:

$ pip install jsbeautifier
$ js-beautify file.js

Beautified output goes to stdout.

To use jsbeautifier as a library is simple:

import jsbeautifier
res = jsbeautifier.beautify('your javascript string')
res = jsbeautifier.beautify_file('some_file.js')

...or, to specify some options:

opts = jsbeautifier.default_options()
opts.indent_size = 2
res = jsbeautifier.beautify('some javascript', opts)

JavaScript

As an alternative to the Python script, you may install the NPM package js-beautify. When installed globally, it provides an executable js-beautify script. As with the Python script, the beautified result is sent to stdout unless otherwise configured.

$ npm -g install js-beautify
$ js-beautify foo.js

You can also use js-beautify as a node library (install locally, the npm default):

$ npm install js-beautify
var beautify = require('js-beautify').js_beautify,
    fs = require('fs');

fs.readFile('foo.js', 'utf8', function (err, data) {
    if (err) {
        throw err;
    }
    console.log(beautify(data, { indent_size: 2 }));
});

Options

These are the command-line flags for both Python and JS scripts:

CLI Options:
  -f, --file       Input file(s) (Pass '-' for stdin)
  -r, --replace    Write output in-place, replacing input
  -o, --outfile    Write output to file (default stdout)
  --config         Path to config file
  --type           [js|css|html] ["js"]
  -q, --quiet      Suppress logging to stdout
  -h, --help       Show this help
  -v, --version    Show the version

Beautifier Options:
  -s, --indent-size                 Indentation size [4]
  -c, --indent-char                 Indentation character [" "]
  -t, --indent-with-tabs            Indent with tabs, overrides -s and -c
  -e, --eol                         Character(s) to use as line terminators.
                                    [first newline in file, otherwise "\n]
  -n, --end-with-newline            End output with newline
  --editorconfig                    Use EditorConfig to set up the options
  -l, --indent-level                Initial indentation level [0]
  -p, --preserve-newlines           Preserve line-breaks (--no-preserve-newlines disables)
  -m, --max-preserve-newlines       Number of line-breaks to be preserved in one chunk [10]
  -P, --space-in-paren              Add padding spaces within paren, ie. f( a, b )
  -E, --space-in-empty-paren        Add a single space inside empty paren, ie. f( )
  -j, --jslint-happy                Enable jslint-stricter mode
  -a, --space-after-anon-function   Add a space before an anonymous function's parens, ie. function ()
  -b, --brace-style                 [collapse|expand|end-expand|none][,preserve-inline] [collapse,preserve-inline]
  -B, --break-chained-methods       Break chained method calls across subsequent lines
  -k, --keep-array-indentation      Preserve array indentation
  -x, --unescape-strings            Decode printable characters encoded in xNN notation
  -w, --wrap-line-length            Wrap lines at next opportunity after N characters [0]
  -X, --e4x                         Pass E4X xml literals through untouched
  --good-stuff                      Warm the cockles of Crockford's heart
  -C, --comma-first                 Put commas at the beginning of new line instead of end
  -O, --operator-position           Set operator position (before-newline|after-newline|preserve-newline) [before-newline]

Which correspond to the underscored option keys for both library interfaces

defaults per CLI options

{
    "indent_size": 4,
    "indent_char": " ",
    "indent_with_tabs": false,
    "eol": "\n",
    "end_with_newline": false,
    "indent_level": 0,
    "preserve_newlines": true,
    "max_preserve_newlines": 10,
    "space_in_paren": false,
    "space_in_empty_paren": false,
    "jslint_happy": false,
    "space_after_anon_function": false,
    "brace_style": "collapse",
    "break_chained_methods": false,
    "keep_array_indentation": false,
    "unescape_strings": false,
    "wrap_line_length": 0,
    "e4x": false,
    "comma_first": false,
    "operator_position": "before-newline"
}

defaults not exposed in the cli

{
  "eval_code": false,
  "space_before_conditional": true
}

Notice not all defaults are exposed via the CLI. Historically, the Python and JS APIs have not been 100% identical. For example, space_before_conditional is currently JS-only, and not addressable from the CLI script. There are still a few other additional cases keeping us from 100% API-compatibility.

Loading settings from environment or .jsbeautifyrc (JavaScript-Only)

In addition to CLI arguments, you may pass config to the JS executable via:

  • any jsbeautify_-prefixed environment variables
  • a JSON-formatted file indicated by the --config parameter
  • a .jsbeautifyrc file containing JSON data at any level of the filesystem above $PWD

Configuration sources provided earlier in this stack will override later ones.

Setting inheritance and Language-specific overrides

The settings are a shallow tree whose values are inherited for all languages, but can be overridden. This works for settings passed directly to the API in either implementation. In the Javascript implementation, settings loaded from a config file, such as .jsbeautifyrc, can also use inheritance/overriding.

Below is an example configuration tree showing all the supported locations for language override nodes. We'll use indent_size to discuss how this configuration would behave, but any number of settings can be inherited or overridden:

{
    "indent_size": 4,
    "html": {
        "end_with_newline": true,
        "js": {
            "indent_size": 2
        },
        "css": {
            "indent_size": 2
        }
    },
    "css": {
        "indent_size": 1
    },
    "js": {
       "preserve-newlines": true
    }
}

Using the above example would have the following result:

  • HTML files
    • Inherit indent_size of 4 spaces from the top-level setting.
    • The files would also end with a newline.
    • JavaScript and CSS inside HTML
      • Inherit the HTML end_with_newline setting
      • Override their indentation to 2 spaces
  • CSS files
    • Override the top-level setting to an indent_size of 1 space.
  • JavaScript files
    • Inherit indent_size of 4 spaces from the top-level setting
    • Set preserve-newlines to true

CSS & HTML

In addition to the js-beautify executable, css-beautify and html-beautify are also provided as an easy interface into those scripts. Alternatively, js-beautify --css or js-beautify --html will accomplish the same thing, respectively.

// Programmatic access
var beautify_js = require('js-beautify'); // also available under "js" export
var beautify_css = require('js-beautify').css;
var beautify_html = require('js-beautify').html;

// All methods accept two arguments, the string to be beautified, and an options object.

The CSS & HTML beautifiers are much simpler in scope, and possess far fewer options.

CSS Beautifier Options:
  -s, --indent-size                  Indentation size [4]
  -c, --indent-char                  Indentation character [" "]
  -t, --indent-with-tabs             Indent with tabs, overrides -s and -c
  -e, --eol                          Character(s) to use as line terminators. (default newline - "\\n")
  -n, --end-with-newline             End output with newline
  -L, --selector-separator-newline   Add a newline between multiple selectors
  -N, --newline-between-rules        Add a newline between CSS rules

HTML Beautifier Options:
  -s, --indent-size                  Indentation size [4]
  -c, --indent-char                  Indentation character [" "]
  -t, --indent-with-tabs             Indent with tabs, overrides -s and -c
  -e, --eol                          Character(s) to use as line terminators. (default newline - "\\n")
  -n, --end-with-newline             End output with newline
  -p, --preserve-newlines            Preserve existing line-breaks (--no-preserve-newlines disables)
  -m, --max-preserve-newlines        Maximum number of line-breaks to be preserved in one chunk [10]
  -I, --indent-inner-html            Indent <head> and <body> sections. Default is false.
  -b, --brace-style                  [collapse-preserve-inline|collapse|expand|end-expand|none] ["collapse"]
  -S, --indent-scripts               [keep|separate|normal] ["normal"]
  -w, --wrap-line-length             Maximum characters per line (0 disables) [250]
  -A, --wrap-attributes              Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline] ["auto"]
  -i, --wrap-attributes-indent-size  Indent wrapped attributes to after N characters [indent-size] (ignored if wrap-attributes is "force-aligned")
  -U, --unformatted                  List of tags (defaults to inline) that should not be reformatted
  -T, --content_unformatted          List of tags (defaults to pre) that its content should not be reformatted
  -E, --extra_liners                 List of tags (defaults to [head,body,/html] that should have an extra newline before them.
  --editorconfig                     Use EditorConfig to set up the options

Directives to Ignore or Preserve sections (Javascript only)

Beautifier for supports directives in comments inside the file. This allows you to tell the beautifier to preserve the formatting of or completely ignore part of a file. The example input below will remain changed after beautification

// Use preserve when the content is not javascript, but you don't want it reformatted.
/* beautify preserve:start */
{
    browserName: 'internet explorer',
    platform:    'Windows 7',
    version:     '8'
}
/* beautify preserve:end */

// Use ignore when the content is not parsable as javascript.
var a =  1;
/* beautify ignore:start */
 {This is some strange{template language{using open-braces?
/* beautify ignore:end */

License

You are free to use this in any way you want, in case you find this useful or working for you but you must keep the copyright notice and license. (MIT)

Credits

Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, Dave Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull, Mathias Bynens, Vittorio Gambaletta and others.

(README.md: js-beautify@1.6.12)

changelog

Changelog

v1.6.12

Description

Closed Issues

  • CSS: Preserve Newlines (#537)

v1.6.11

Description

Reverted #1117 - Preserve newlines broken

Closed Issues

  • On beautify, new line before next CSS selector (#1142)

v1.6.10

Description

Added preserver_newlines to css beautifier

Closed Issues

v1.6.9

Description

  • Fixed html formatting issue with attribute wrap (Thanks, @HookyQR!)
  • Fixed python package publishing

Closed Issues

  • Wrong HTML beautification starting with v1.6.5 (#1115)
  • Ignore linebreak when meet handlebar (#1104)
  • Lines are not un-indented correctly when attributes are wrapped (#1103)
  • force-aligned is not aligned when indenting with tabs (#1102)
  • Python package fails to publish (#1101)
  • Explaination of 'operator_position' is absent from README.md (#1047)

v1.6.8

Description

  • Fixed a batch of comment and semicolon-less code bugs

Closed Issues

  • Incorrect indentation after loop with comment (#1090)
  • Extra newline is inserted after beautifying code with anonymous function (#1085)
  • end brace with next comment line make bad indent (#1043)
  • Javascript comment in last line doesn't beautify well (#964)
  • indent doesn't work with comment (jsdoc) (#913)
  • Wrong indentation, when new line between chained methods (#892)
  • Comments in a non-semicolon style have extra indent (#815)
  • [bug] Incorrect indentation due to commented line(s) following a function call with a function argument. (#713)
  • Wrong indent formatting (#569)

v1.6.7

Description

Added content_unformatted option (Thanks @arai-a)

Closed Issues

  • HTML pre code indentation (#928)
  • Beautify script/style tags but ignore their inner JS/CSS content (#906)

v1.6.6

Description

  • Added support for editorconfig from stdin
  • Added js-beautify to cdnjs
  • Fixed CRLF to LF for HTML and CSS on windows
  • Added inheritance/overriding to config format (Thanks @DaniGuardiola and @HookyQR)
  • Added force-align to wrap-attributes (Thanks @Lukinos)
  • Added force-expand-multiline to wrap-attributes (Thanks @tobias-zucali)
  • Added preserve-inline as independent brace setting (Thanks @Coburn37)
  • Fixed handlebars with angle-braces (Thanks @mmsqe)

Closed Issues

  • Wrong indentation for comment after nested unbraced control constructs (#1079)
  • Should prefer breaking the line after operator ? instead of before operator < (#1073)
  • New option "force-expand-multiline" for "wrap_attributes" (#1070)
  • Breaks if html file starts with comment (#1068)
  • collapse-preserve-inline restricts users to collapse brace_style (#1057)
  • Parsing failure on numbers with "e" (#1054)
  • Issue with Browser Instructions (#1053)
  • Add preserve inline function for expand style braces (#1052)
  • Update years in LICENSE (#1038)
  • JS. Switch with template literals. Unexpected indentation. (#1030)
  • The object with spread object formatted not correctly (#1023)
  • Bad output generator function in class (#1013)
  • Support editorconfig for stdin (#1012)
  • Publish to cdnjs (#992)
  • breaks if handlebars comments contain handlebars tags (#930)
  • Using jsbeautifyrc is broken (#929)
  • Option to put HTML attributes on their own lines, aligned (#916)
  • Erroneously changes CRLF to LF on Windows in HTML and CSS (#899)
  • Weird space in {get } vs { normal } (#888)
  • Bad for-of formatting with constant Array (#875)
  • Problems with filter property in css and scss (#755)
  • Add "collapse-one-line" option for non-collapse brace styles (#487)

v1.6.4

Description

  • Fixed JSX multi-line root element handling
  • Fixed CSS Combinator spacing (NOTE: use space_around_combinator option)
  • Fixed (more) CSS pseudo-class and pseudo-element selectors (Thanks @Konamiman!)
  • Fixed Shorthand generator functions and yield* (Thanks @jgeurts!)
  • Added EditorConfig support (Thanks @ethanluoyc!)
  • Added indent_body_inner_html and indent_head_inner_html (Thanks @spontaliku-softaria!)
  • Added js-beautify to https://cdn.rawgit.com (Thanks @zxqfox)

Closed Issues

  • css-beautify sibling combinator space issue (#1001)
  • Bug: Breaks when the source code it found an unclosed multiline comment. (#996)
  • CSS: Preserve white space before pseudo-class and pseudo-element selectors (#985)
  • Spelling error in token definition (#984)
  • collapse-preserve-inline does not preserve simple, single line ("return") statements (#982)
  • Publish the library via cdn (#971)
  • Bug with css calc() function (#957)
  • &:first-of-type:not(:last-child) when prettified insert erroneous white character (#952)
  • Shorthand generator functions are formatting strangely (#941)
  • Add handlebars support on cli for html (#935)
  • Do not put a space within yield* generator functions. (#920)
  • Possible to add an indent_inner_inner_html option? (Prevent indenting second-level tags) (#917)
  • Messing up jsx formatting (#914)
  • Bug report: Closing 'body' tag isn't formatted correctly (#900)
  • { throw … } not working with collapse-preserve-inline (#898)
  • ES6 concise method not propely indented (#889)
  • CSS beautify changing symantics (#883)
  • Dojo unsupported script types. (#874)
  • Readme version comment (#868)
  • Extra space after pseudo-elements within :not() (#618)
  • space in media queries after colon &: selectors (#565)
  • Integrating editor config (#551)
  • Preserve short expressions/statements on single line (#338)

v1.6.3

Description

Bug fixes

Closed Issues

  • CLI broken when output path is not set (#933)
  • huge memory leak (#909)
  • don't print unpacking errors on stdout (python) (#884)
  • Fix incomplete list of non-positionable operators (python lib) (#878)
  • Fix Issue #844 (#873)
  • assignment exponentiation operator (#864)
  • Bug in Less mixins (#844)
  • Can't Nest Conditionals (#680)
  • ternary operations (#670)
  • Support newline before logical or ternary operator (#605)
  • Provide config files for format and linting (#336)

v1.6.2

Description

Closed Issues

  • Add missing 'collapse-preserve-inline' option to js module (#861)

v1.6.1

Description

Fixes for regressions found in 1.6.0

Closed Issues

  • Inconsistent formatting for arrays of objects (#860)
  • Publish v1.6.1 (#859)
  • Space added to "from++" due to ES6 keyword (#858)
  • Changelog generator doesn't sort versions above 9 right (#778)
  • space-after-anon-function not applied to object properties (#761)
  • Separating 'input' elements adds whitespace (#580)
  • Inline Format (#572)
  • Preserve attributes line break in HTML (#455)
  • Multiline Array (#406)

v1.6.0

Description

  • Inline/short object and json preservation (all rejoice!)
  • ES6 annotations, module import/export, arrow functions, concise methods, and more
  • JSX spread attributes
  • HTML wrap attributes, inline element fixes, doctype and php fixes
  • Test framework hardening
  • Windows build fixed and covered by appveyor continuous integration

Closed Issues

  • Individual tests pollute options object (#855)
  • Object attribute assigned fat arrow function with implicit return of a ternary causes next line to indent (#854)
  • Treat php tags as single in html (#850)
  • Read piped input by default (#849)
  • Replace makefile dependency with bash script (#848)
  • list of HTML inline elements incomplete; wraps inappropriately (#840)
  • Beautifying bracket-less if/elses (#838)
  • elements within a are getting indented incorrectly (#836)
  • single attribute breaks jsx beautification (#834)
  • Improve Python packaging (#831)
  • Erroneously changes CRLF to LF on Windows. (#829)
  • Can't deal with XHTML5 (#828)
  • HTML after PHP is indented (#826)
  • exponentiation operator (#825)
  • Add support for script type "application/ld+json" (#821)
  • package.json: Remove "preferGlobal" option (#820)
  • Don't use array.indexOf() to support legacy browsers (#816)
  • ES6 Object Shortand Indenting Weirdly Sometimes (#810)
  • Implicit Return Function on New Line not Preserved (#806)
  • Misformating "0b" Binary Strings (#803)
  • Beautifier breaks ES6 nested template strings (#797)
  • Misformating "0o" Octal Strings (#792)
  • Do not use hardcoded directory for tests (#788)
  • Handlebars {{else}} tag not given a newline (#784)
  • Wrong indentation for XML header (<?xml version="1.0"?>) (#783)
  • is_whitespace for loop incrementing wrong variable (#777)
  • Newline is inserted after comment with comma_first (#775)
  • Cannot copy more than 1000 characters out of CodeMirror buffer (#768)
  • Missing 'var' in beautify-html.js; breaks strict mode (#763)
  • Fix typo in the example javascript code of index.html (#753)

v1.5.10

Description

Hotfix for directives Version jump due to release script tweaks

Closed Issues

  • Preserve directive doesn't work as intended (#723)

v1.5.7

Description

  • Beautifier does not break PHP and Underscore.js templates
  • Fix for SCSS pseudo classes and intperpolation/mixins
  • Alternative Newline Characters in CSS and HTML
  • Preserve formatting or completely ignore section of javascript using comments

Closed Issues

  • Support for legacy JavaScript versions (e.g. WSH+JScript & Co) (#720)
  • Is \n hard coded into CSS Beautifier logic? (#715)
  • Spaces and linebreaks after # and around { } messing up interpolation/mixins (SASS/SCSS) (#689)
  • Calls to functions get completely messed up in Sass (*.scss) (#675)
  • No new line after selector in scss files (#666)
  • using html-beautify on handlebars template deletes unclosed tag if on second line (#623)
  • more Extra space after scss pseudo classes (#557)
  • Unnecessary spaces in PHP code (#490)
  • Some underscore.js template tags are broken (#417)
  • Selective ignore using comments (feature request) (#384)

v1.5.6

Description

  • JSX support!
  • Alternative Newline Characters
  • CSS and JS comment formatting fixes
  • General bug fixing

Closed Issues

  • Fix tokenizer's bracket pairs' open stack (#693)
  • Indentation is incorrect for HTML5 void tag <source> (#692)
  • Line wrapping breaks at the wrong place when the line is indented. (#691)
  • Publish v1.5.6 (#687)
  • Replace existing file fails using python beautifier (#686)
  • Pseudo-classes formatted incorrectly and inconsistently with @page (#661)
  • doc: add end_with_newline option (#650)
  • Improve support for xml parts of jsx (React) => spaces, spread attributes and nested objects break the process (#646)
  • html-beautify formats handlebars comments but does not format html comments (#635)
  • Support for ES7 async (#630)
  • css beautify adding an extra newline after a comment line in a css block (#609)
  • No option to "Indent with tabs" for HTML files (#587)
  • Function body is indented when followed by a comment (#583)
  • JSX support (#425)
  • Alternative Newline Characters (#260)

v1.5.5

Description

  • Initial implementation of comma-first formatting - Diff-friendly literals!
  • CSS: Add newline between rules
  • LESS: improved function parameter formatting
  • HTML: options for wrapping attributes
  • General bug fixing

Closed Issues

  • Add GUI support for --indent-inner-html. (#633)
  • Publish v1.5.5 (#629)
  • CSS: Updating the documentation for the 'newline_between_rules' (#615)
  • Equal Sign Removed from Filter Properties Alpha Opacity Assignment (#599)
  • Keep trailing spaces on comments (#598)
  • only print the file names of changed files (#597)
  • CSS: support add newline between rules (#574)
  • elem[array]++ changes to elem[array] ++ inserting unnecessary gap (#570)
  • add support to less functions paramters braces (#568)
  • selector_separator_newline: true for Sass doesn't work (#563)
  • yield statements are being beautified to their own newlines since 1.5.2 (#560)
  • HTML beautifier inserts extra newline into <li>s ending with <code> (#524)
  • Add wrap_attributes option (#476)
  • Add or preserve empty line between CSS rules (#467)
  • Support comma first style of variable declaration (#245)

v1.5.4

Description

  • Fix for LESS/CSS pseudo/classes
  • Fix for HTML img tag spaces

https://github.com/beautify-web/js-beautify/compare/v1.5.3...v1.5.4

Closed Issues

  • TypeScript oddly formatted with 1.5.3 (#552)
  • HTML beautifier inserts double spaces between adjacent tags (#525)
  • Keep space in font rule (#491)
  • [Brackets plug in] Space after disappears (#454)
  • Support nested pseudo-classes and parent reference (LESS) (#427)
  • Alternate approach: preserve single spacing and treat img as inline element (#415)

v1.5.3

Description

  • High priority bug fixes
  • Major fixes to css-beautifier to not blow up LESS/SCSS
  • Lower priority bug fixes that were very ugly

https://github.com/beautify-web/js-beautify/compare/v1.5.2...v1.5.3

Closed Issues

  • [TypeError: Cannot read property 'type' of undefined] (#548)
  • Bug with RegExp (#547)
  • Odd behaviour on less (#520)
  • css beauitify (#506)
  • Extra space after scss pseudo classes. (#500)
  • Generates invalid scss when formatting ampersand selectors (#498)
  • bad formatting of .less files using @variable or &:hover syntax (#489)
  • Incorrect beautifying of CSS comment including an url. (#466)
  • Handle SASS parent reference &: (#414)
  • Js-beautify breaking selectors in less code. (#410)
  • Problem with "content" (#364)
  • Space gets inserted between function and paren for function in Define (#313)
  • beautify-html returns null on broken html (#301)
  • Indentation of functions inside conditionals not passing jslint (#298)

v1.5.2

Description

  • Improved indenting for statements, array, variable declaration, "Starless" block-comments
  • Support for bitwise-not, yield, get, set, let, const, generator functions
  • Reserved words can be used as object property names
  • Added options: space_after_anon_function, end-with-newline
  • Properly tokenize Numbers (including decimals and exponents)
  • Do not break "x++ + y"
  • function declaration inside array behaves the same as in expression
  • Close String literals at newline
  • Support handlebar syntax
  • Check <script> "type"-attribute
  • Allow <style> and <script> tags to be unformatted
  • Port css nesting fix to python
  • Fix python six dependency
  • Initial very cursory support for ES6 module, export, and import

https://github.com/beautify-web/js-beautify/compare/v1.5.1...v1.5.2

Closed Issues

  • Allow custom elements to be unformatted (#540)
  • Need option to ignore brace style (#538)
  • Refactor to Output and OutputLine classes (#536)
  • Recognize ObjectLiteral on open brace (#535)
  • Refactor to fully tokenize before formatting (#530)
  • Cleanup checked in six.py file (#527)
  • Changelog.md? (#526)
  • New line added between each css declaration (#523)
  • Kendo Template scripts get messed up! (#516)
  • SyntaxError: Unexpected token ++ (#514)
  • space appears before open square bracket when the object name is "set" (#508)
  • Unclosed string problem (#505)
  • "--n" and "++n" are not indented like "n--" and "n++" are... (#495)
  • Allow <style> and <script> tags to be unformatted (#494)
  • Preserve new line at end of file (#492)
  • Line wraps breaking numbers (causes syntax error) (#488)
  • jsBeautify acts differently when handling different kinds of function expressions (#485)
  • AttributeError: 'NoneType' object has no attribute 'groups' (#479)
  • installation doco for python need update -- pip install six? (#478)
  • Move einars/js-beautify to beautify-web/js-beautify (#475)
  • Bring back space_after_anon_function (#474)
  • fix for #453, Incompatible handlebar syntax (#468)
  • Python: missing explicit dependency on "six" package (#465)
  • function declaration inside array, adds extra line. (#464)
  • [es6] yield a array (#458)
  • Publish v1.5.2 (#452)
  • Port css colon character fix to python (#446)
  • Cannot declare object literal properties with unquoted reserved words (#440)
  • Do not put a space within function* generator functions. (#428)
  • beautification of "nth-child" css fails csslint (#418)

v1.5.1

Description

Highlights:

  • Fixes var declaration of objects and arrays to indent correctly (#256, #430)
  • Support keywords as IdentifierNames such as foo.catch() (#309, #351,#368, #378)
  • Improved indenting for statements (#289)
  • Improved ES6 support - let, const, template strings, and "fat arrow"
  • Support for non-ASCII characters in variable names (#305)
  • Multiple fixes to requirejs support and added tests to protect in future
  • Improved LESS support (still plenty of room for improvement in this area)
  • Do not add space after !!

https://github.com/einars/js-beautify/compare/v1.4.2...v1.5.1

Closed Issues

  • Nested if statements not displayed correctly (#450)
  • preserve_newlines always true (#449)
  • line wrapping breaks in weird places (#438)
  • Update dependencies to current versions (#437)
  • Add support for ES6 template strings (#434)
  • Fix #402: support ES6 fat arrow (#433)
  • Ending brace missaligned when part of first definition in var line (#430)
  • fixing disabled line wrapping for HTML (#429)
  • Missing semi colon (#420)
  • Fixed require.js support (#416)
  • should not split the es6 operator '=>' (#402)
  • fixed relative paths for require.js (#387)
  • Support reserved words as property names (#378)
  • Make the AMD API match the rest of the APIs (#376)
  • Preserve newlines in html related to issue #307 (#375)
  • Multi-line statements (#374)
  • Reserved words used as property/function/variable identifiers are formatted incorrectly (#368)
  • fixed problems with colon character (#363)
  • require.JS paths are hardcoded in beautify-html.js (#359)
  • Regression in p.a.c.ked file detection (#357)
  • Fix Issue #339 (#354)
  • Added single line comment support in less/sass for javascript parser (#353)
  • Function named 'in' not formatting correctly (#351)
  • CSS Pseudo element (#346)
  • array closing brace error for return statements with keep_array_indentation (#340)
  • CSS Beautifier: breaks :before and :after (regression) (#339)
  • Publish v1.5.0 (#335)
  • "keep array indentation" not working (#333)
  • CSS Beautifier: support LESS/SASS line comments (#326)
  • Incorrect formating with semicolon-less code (#323)

v1.4.2

Description

Release quick fix for python errno error that has started being more heavily reported Initial release of css beautifier ported to python Additional minor fixes and enhancements

Closed Issues

  • global name 'errno' is not defined (#352)
  • import errno for errno.EEXIST (#349)
  • Added bower.json (#343)
  • HTML wrap-line-length: 0 doesn't work (#342)
  • Make beautify.js, beautify-html.js, beautify-css.js available in bower (#341)
  • Making .jsbeautifyrc resolve work (in general and for Windows re home dir) (#334)
  • windows 8 error: path.js:204 throw new TypeError('Arguments to path.join must be strings'); (#300)
  • Port beautify-css to python (#204)

v1.4.1

Description

Incremental fixes and improvements

Closed Issues

  • Tests borked when running from web (#332)
  • wrap_line_length isn't enforced for property values (#331)
  • Have no empty line between comment and function (#329)
  • Add new line at the end of the file (html-beautify) (#325)
  • Space in empty parentheses (#322)
  • Handlebars (#321)
  • Space in empty parentheses (#320)
  • The indent_with_tabs option did not work when required in node, only CLI. (#319)
  • add option to indent "inner HTML"... (#312)
  • Wrong format of HTML textnode containing multipe words (#306)
  • Repair to work in windows (#304)
  • make export object the same with common and amd methods (#303)
  • jshint cleanup and make require.js optimizable (#302)
  • E4X xml-literal allowed xml-characters (#294)
  • Publish 1.4.1 (#292)
  • Blank line inserted between function and preceding comment (#291)
  • Add tests for beautify-html.js (#211)

v1.4.0

Description

Given the breadth of the changes in the code and api, bump to 1.4.0 for the next release.

https://github.com/einars/js-beautify/compare/v1.3.4...v1.4.0

Closed Issues

  • Fix major performance degradation from minimal indenting (#288)
  • Minimal indenting (#286)
  • Empty lines are removed in HTML and CSS, and also adds trailing spaces (#285)
  • npmjs cli options incomplete (#283)
  • Publish 1.4.0 (#282)
  • Blocks, arrays, and expressions over indented (#281)
  • Keeping New lines inside markup (#280)
  • E4X xml-literal small fixes (#279)
  • Add support for Asynchronous Module Definition (AMD) API (#274)
  • fixed broken run tests script (#255)
  • Ending parenthesis in function call (#239)
  • Preventing line breaks around Unformatted tags (#105)
  • IE conditional HTML comments don't play well with the rest of the document (#91)