Permalink
Browse files

Merge hirse/brackets-beautify

  • Loading branch information...
1 parent fbc4398 commit 18d12275a19901a4a48108a27ec838755a425d9b @Hirse Hirse committed Nov 7, 2015
View
@@ -1,3 +0,0 @@
-[submodule "thirdparty/js-beautify"]
@drewhamlett
drewhamlett Nov 7, 2015 Member

So we're doing away with the git submodule?

@Hirse
Hirse Nov 7, 2015 Member

Well, it reduces the size from about 5mb to 200kb so I felt this was a good idea.
What do you think?

@drewhamlett
drewhamlett Nov 7, 2015 Member

Ok cool, that makes sense. Thanks

- path = thirdparty/js-beautify
- url = git://github.com/beautify-web/js-beautify.git
View
@@ -1,86 +1,35 @@
{
- // JSHint Default Configuration File (as on JSHint website)
- // See http://jshint.com/docs/ for more details
+ "bitwise": true,
+ "camelcase": false,
+ "curly": true,
+ "eqeqeq": false,
+ "es3": false,
+ "forin": false,
+ "freeze": true,
+ "globalstrict": false,
+ "immed": true,
+ "indent": 4,
+ "latedef": true,
+ "maxlen": 200,
+ "newcap": true,
+ "noarg": true,
+ "nocomma": false,
+ "noempty": true,
+ "nonbsp": true,
+ "nonew": false,
+ "notypeof": false,
+ "quotmark": true,
+ "singleGroups": false,
+ "undef": true,
+ "unused": true,
- "maxerr": 50, // {int} Maximum error before stopping
+ "browser": true,
+ "jquery": true,
- // Enforcing
- "bitwise": true, // true: Prohibit bitwise operators (&, |, ^, etc.)
- "camelcase": false, // true: Identifiers must be in camelCase
- "curly": false, // true: Require {} for every new block or scope
- "eqeqeq": true, // true: Require triple equals (===) for comparison
- "forin": true, // true: Require filtering for..in loops with obj.hasOwnProperty()
- "immed": false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
- "indent": 4, // {int} Number of spaces to use for indentation
- "latedef": false, // true: Require variables/functions to be defined before being used
- "newcap": false, // true: Require capitalization of all constructor functions e.g. `new F()`
- "noarg": true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
- "noempty": true, // true: Prohibit use of empty blocks
- "nonew": false, // true: Prohibit use of constructors for side-effects (without assignment)
- "plusplus": true, // true: Prohibit use of `++` & `--`
- "quotmark": false, // Quotation mark consistency:
- // false : do nothing (default)
- // true : ensure whatever is used is consistent
- // "single" : require single quotes
- // "double" : require double quotes
- "undef": true, // true: Require all non-global variables to be declared (prevents global leaks)
- "unused": false, // true: Require all defined variables be used
- "strict": false, // true: Requires all functions run in ES5 Strict Mode
- "trailing": false, // true: Prohibit trailing whitespaces
- "maxparams": false, // {int} Max number of formal params allowed per function
- "maxdepth": false, // {int} Max depth of nested blocks (within functions)
- "maxstatements": false, // {int} Max number statements per function
- "maxcomplexity": false, // {int} Max cyclomatic complexity per function
- "maxlen": false, // {int} Max number of characters per line
-
- // Relaxing
- "asi": false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
- "boss": false, // true: Tolerate assignments where comparisons would be expected
- "debug": false, // true: Allow debugger statements e.g. browser breakpoints.
- "eqnull": false, // true: Tolerate use of `== null`
- "es5": false, // true: Allow ES5 syntax (ex: getters and setters)
- "esnext": true, // true: Allow ES.next (ES6) syntax (ex: `const`)
- "moz": false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
- // (ex: `for each`, multiple try/catch, function expression…)
- "evil": false, // true: Tolerate use of `eval` and `new Function()`
- "expr": false, // true: Tolerate `ExpressionStatement` as Programs
- "funcscope": false, // true: Tolerate defining variables inside control statements"
- "globalstrict": true, // true: Allow global "use strict" (also enables 'strict')
- "iterator": false, // true: Tolerate using the `__iterator__` property
- "lastsemic": false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
- "laxbreak": false, // true: Tolerate possibly unsafe line breakings
- "laxcomma": false, // true: Tolerate comma-first style coding
- "loopfunc": false, // true: Tolerate functions being defined in loops
- "multistr": true, // true: Tolerate multi-line strings
- "proto": false, // true: Tolerate using the `__proto__` property
- "scripturl": false, // true: Tolerate script-targeted URLs
- "smarttabs": false, // true: Tolerate mixed tabs/spaces when used for alignment
- "shadow": false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
- "sub": true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
- "supernew": false, // true: Tolerate `new function () { ... };` and `new Object;`
- "validthis": false, // true: Tolerate using this in a non-constructor function
-
- // Environments
- "browser": true, // Web Browser (window, document, etc)
- "couch": false, // CouchDB
- "devel": true, // Development/debugging (alert, confirm, etc)
- "dojo": false, // Dojo Toolkit
- "jquery": false, // jQuery
- "mootools": false, // MooTools
- "node": true, // Node.js
- "nonstandard": false, // Widely adopted globals (escape, unescape, etc)
- "prototypejs": false, // Prototype and Scriptaculous
- "rhino": false, // Rhino
- "worker": false, // Web Workers
- "wsh": false, // Windows Scripting Host
- "yui": false, // Yahoo User Interface
-
- // Legacy
- "nomen": false, // true: Prohibit dangling `_` in variables
- "onevar": false, // true: Allow only one `var` statement per function
- "passfail": false, // true: Stop on first error
- "white": false, // true: Check against strict whitespace and indentation rules
-
- // Custom Globals
- "globals": ["$", "io", "moment", "angular", "it", "describe", "socket", "_", "toastr"] // additional predefined global variables
+ "globals": {
+ "require": false,
+ "define": false,
+ "brackets": false,
+ "console": false
+ }
}
View
@@ -1,6 +1,27 @@
# Change Log
+All notable changes to this project will be documented in this file.
+This project tries to adhere to [Semantic Versioning](http://semver.org/).
+
+## Unreleased
+### Added
+- Use Brackets Preferences language and path layer to configure `Beautify on save`
+- Enable use of nested settings from `.jsbeautifyrc`
+- Provide settings to *css_beautify*
+- Format SVG as HTML
-## 1.2.0 - 2015-08-11
### Changed
+- Only change document if beautified text looks different
+- Turned on `end_with_newline` option by default
+
+### Removed
+- Fake French translation
+- `git_happy` option as it is identical to `end_with_newline`
+
+## Fixed
+- LivePreview duplication (see [#14](https://github.com/Hirse/brackets-beautify/issues/14))
+- Key Binding on Linux
-Updated js-beautify to version 1.5.10
+
+## 1.2.0 - 2015-08-11
+### Changed
+- Updated js-beautify to version 1.5.10
View
@@ -0,0 +1,10 @@
+# Contributing
+
+## Issues
+Brackets Beautify uses [js-beautify](https://github.com/beautify-web/js-beautify) to beautify files and is therefore limited to its capabilities.
+
+If you have any issue concerning the formatting, please test it on the website of the library first:
+```
+http://jsbeautifier.org/
+```
+If the issue persists, please refer to the [js-beautify issues](https://github.com/beautify-web/js-beautify/issues).
View
@@ -1,9 +1,22 @@
The MIT License (MIT)
-Copyright (c) 2007-2014 Drew Hamlett, Einar Lielmanis and contributors.
+Copyright (c) 2007-2015 Drew Hamlett
+ 2015 brackets-beautify
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
View
@@ -1,80 +1,136 @@
-brackets-beautify
-=================
+# Brackets Beautify
+[Brackets][Brackets] Extension that formats open HTML, CSS, and JavaScript files using [js-beautify][js-beautify] version [1.5.10][js-beautify version].
-Looking for maintainers for this project. If you're interested please message me. Thanks!
-===
+## Installation
+### Latest Release
+To install the latest _release_ of this extension use the built-in Brackets [Extension Manager][Brackets Extension Manager] which downloads the extension from the [extension registry][Brackets Extension Registry].
-[Brackets](http://brackets.io/) Extension that formats open HTML, CSS, and JavaScript files using [js-beautify](https://github.com/einars/js-beautify).
-
-Compatible with Sprint 22 and above.
-
-Installation
----
-Search for "Beautify" in [Extension Manager](https://github.com/adobe/brackets/wiki/Brackets-Extensions), then click on `Install` for Beautify by Drew Hamlett.
-
-### Alternative Install
-
-Download zip and extract into arbitrary directory (or clone source files), then move the folder to the extensions folder (you can open this folder by clicking "Help > Show Extensions Folder" menu).
-
-Usage
----
-
-`Edit > Beautify` menu or `Cmd-Shift-L(Mac) / Ctrl-Shift-L(Win)` key.
-
-SASS Formatting
----
-
-You need to supply an absolute path to the sass-convert executble for SASS formatting to work.
-
-+ Install [SASS Installation website](http://sass-lang.com/install)
-+ Get absolute path to executable
+### Latest Commit
+To install the latest _commit_ of this extension use the built-in Brackets [Extension Manager][Brackets Extension Manager] which has a function to `Install from URL...` using this link:
+```
+https://github.com/brackets-beautify/brackets-beautify/archive/master.zip
+```
-On MacOSX you can go into terminal and type `which sass-convert`
+## Usage
+Brackets Beautify can be run manually on the whole file or on a selection.
+Use the menu entry `Edit > Beautify`, the context-menu entry `Beautify`, or one of the keyboard shortcuts `Ctrl-Alt-B` (Windows/Linux), `Ctrl-Shift-L` (Windows), `Cmd-Shift-L` (Mac), or [define your own][Beautify User Key Map].
-Since I use rbenv for manageing Ruby versions it gave me this.
-`/Users/drewh/.rbenv/shims/sass-convert`
-If you use system Ruby, when you do `sudo gem install sass` your path will be something like `/usr/bin/sass-convert`
+Alternatively it can be enabled to run automatically on save.
+Use the menu entry `Edit > Beautify on Save` or the more [advanced settings][Beautify Beautify on Save] to activate.
-On Windows your path will be something similiar to this.
-`C:\\Ruby193\\bin\\sass-convert.bat`
+### Configuration
+#### Beautifier Options
+Brackets Beautify supports the same [options][js-beautify options] as [js-beautify][js-beautify] with the exception of indentation-based options (`indent_size`, `indent_char`, and `indent_with_tabs`) which are taken from the current settings in Brackets.
+The options can be specified in a `.jsbeautifyrc` file on project level.
+The default is defined in `default.jsbeautifyrc` and looks like this:
+```json
+{
+ "js": {
+ "eol": "\n",
+ "indent_level": 0,
+ "preserve_newlines": true,
+ "max_preserve_newlines": 10,
+ "jslint_happy": true,
+ "space_after_anon_function": true,
+ "brace_style": "collapse",
+ "keep_array_indentation": true,
+ "keep_function_indentation": false,
+ "space_before_conditional": true,
+ "break_chained_methods": false,
+ "eval_code": false,
+ "unescape_strings": false,
+ "wrap_line_length": 0,
+ "wrap_attributes": "auto",
+ "end_with_newline": true
+ },
+ "css": {
+ "eol": "\n",
+ "end_with_newline": true,
+ "selector_separator_newline": true,
+ "newline_between_rules": true
+ },
+ "html": {
+ "eol": "\n",
+ "end_with_newline": true,
+ "preserve_newlines": true,
+ "max_preserve_newlines": 10,
+ "indent_inner_html": false,
+ "brace_style": "collapse",
+ "indent_scripts": "normal",
+ "wrap_line_length": 0,
+ "wrap_attributes": "auto"
+ }
+}
+```
-+ Now go open Brackets and go to `Debug > Open Preferences File`
+#### File Options for Beautify on Save
+Brackets Beautify leverages [Brackets preferences][Brackets preferences], which means that you can specify per project settings by defining a `.brackets.json` in the root directory of your project. With Brackets preferences you can even define per file settings, which is really handy when dealing with third party libraries or minified resources.
+Brackets Beautify also support per language settings, which enables you to enable/disabled `Beautify on save` for your documents using the Brackets language layer.
-It will look something like this.
+The sample `.brackets.json` below generally enables `Beautify on save` and disables it for any JavaScript file in `thirdparty`, any JavaScript file whose filename contains `min` and any PHP file.
+```json
+{
+ "bb.beautify.onSave": true,
+ "path": {
+ "thirdparty/**.js": {
+ "bb.beautify.onSave": false
+ },
+ "**min**.js": {
+ "bb.beautify.onSave": false
+ }
+ },
+ "language": {
+ "php": {
+ "bb.beautify.onSave": false
+ }
+ }
+}
+```
+#### User Key Map for Beautify
+Open the `keymap.json` with the menu entry `Debug > Open User Key Map` and add an _overrides_ entry.
+For example:
```js
{
- "useTabChar": false,
- "tabSize": 2,
- "spaceUnits": 2,
- "closeBrackets": true,
- "showLineNumbers": true,
- "styleActiveLine": false,
- "wordWrap": false,
- "linting.enabled": true,
- "linting.collapsed": false,
- "quickview.enabled": true
+ "documentation": "https://github.com/adobe/brackets/wiki/User-Key-Bindings",
+ "overrides": {
+ "Ctrl-Alt-F": "bb.beautify.beautify"
+ }
}
```
-
-Now add ```"beautify.sassConvertPath": "/Users/drewh/.rbenv/shims/sass-convert"``` at the bottom. Change the path name to the path all the way to executable. The upcoming version will use ```me.drewh.jsbeautify.sassConvertPath``` as the key.
-
-You will now be able to format scss files.
-
-For windows add `"beautify.sassConvertPath": "C:\\Ruby193\\bin\\sass-convert.bat"`
-
-Contributing
----
-
-For any pull requesets dealing with the actual formatting or the source in beautify-css.js, beautify.js and beautify-html.js, please send to:
-
-https://github.com/einars/js-beautify/issues
-
-
-
-
-
-
+## External formatters
+### SASS
+You need to supply an absolute path to the `sass-convert` executable for SASS formatting to work.
+
+- Install [SASS][SASS Install]
+- Get the absolute path to the executable
+ Some example paths:
+ - On MacOSX
+ Using *rbenv*: `/Users/<USER>/.rbenv/shims/sass-convert`
+ Using system Ruby (`sudo gem install sass`): `/usr/bin/sass-convert`
+ - On Windows: `C:\\Ruby193\\bin\\sass-convert.bat`
+- Open the Brackets settings file and set the entry `bb.beautify.external.sass` to the path value.
+
+
+## Issues
+Brackets Beautify uses [js-beautify][js-beautify] to beautify files and is therefore limited to its capabilities.
+For any issues concerning the actual formatting please refer to the [js-beautify issues][js-beautify issues].
+
+## License
+Brackets Beautify is licensed under the [MIT license][MIT]. [js-beautify][js-beautify] is also licensed under the MIT license.
+
+[Brackets]: http://brackets.io
+[Brackets Extension Manager]: https://github.com/adobe/brackets/wiki/Brackets-Extensions
+[Brackets Extension Registry]: https://brackets-registry.aboutweb.com
+[Brackets preferences]: https://github.com/adobe/brackets/wiki/How-to-Use-Brackets#preferences
+[Beautify User Key Map]: https://github.com/brackets-beautify/brackets-beautify#user-key-map-for-beautify
+[Beautify Beautify on Save]: https://github.com/brackets-beautify/brackets-beautify#file-options-for-beautify-on-save
+[js-beautify]: https://github.com/beautify-web/js-beautify
+[js-beautify version]: https://github.com/beautify-web/js-beautify/blob/master/CHANGELOG.md#v1510
+[js-beautify issues]: https://github.com/beautify-web/js-beautify/issues
+[js-beautify options]: https://github.com/beautify-web/js-beautify#options
+[SASS Install]: http://sass-lang.com/install
+[MIT]: http://opensource.org/licenses/MIT
Oops, something went wrong.

0 comments on commit 18d1227

Please sign in to comment.