mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-30 08:00:55 +00:00
Merge branch 'main' into json-invalid-wrap-with-line-length-and-signed-number
This commit is contained in:
commit
9b61173b07
13
.github/workflows/main.yml
vendored
13
.github/workflows/main.yml
vendored
@ -17,19 +17,14 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu, windows, macos ]
|
||||
python-version: [3.7, 3.8, 3.9, '3.10']
|
||||
python-version: [3.8, '3.10', 3.11]
|
||||
include:
|
||||
- python-version: 3.7
|
||||
node-version: 12
|
||||
- python-version: 3.8
|
||||
node-version: 14
|
||||
- python-version: 3.9
|
||||
node-version: 16
|
||||
- python-version: '3.10'
|
||||
node-version: 16
|
||||
exclude:
|
||||
- os: windows
|
||||
python-version: 2.7
|
||||
node-version: 18
|
||||
- python-version: 3.11
|
||||
node-version: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Node ${{ matrix.node-version }}
|
||||
|
@ -141,7 +141,7 @@ To use `js-beautify` as a `node` library (after install locally), import and cal
|
||||
The configuration option names are the same as the CLI names but with underscores instead of dashes. For example, `--indent-size 2 --space-in-empty-paren` would be `{ indent_size: 2, space_in_empty_paren: true }`.
|
||||
|
||||
```js
|
||||
var beautify = require('js-beautify').js,
|
||||
var beautify = require('js-beautify/js').js,
|
||||
fs = require('fs');
|
||||
|
||||
fs.readFile('foo.js', 'utf8', function (err, data) {
|
||||
|
3001
package-lock.json
generated
3001
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -51,22 +51,22 @@
|
||||
"dependencies": {
|
||||
"config-chain": "^1.1.13",
|
||||
"editorconfig": "^0.15.3",
|
||||
"glob": "^8.0.3",
|
||||
"glob": "^8.1.0",
|
||||
"nopt": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-regex": "^6.0.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"codemirror": "^5.65.2",
|
||||
"jquery": "^3.6.0",
|
||||
"jshint": "^2.13.4",
|
||||
"minimist": "^1.2.6",
|
||||
"mocha": "^10.0.0",
|
||||
"codemirror": "^5.65.13",
|
||||
"jquery": "^3.6.4",
|
||||
"jshint": "^2.13.6",
|
||||
"minimist": "^1.2.8",
|
||||
"mocha": "^10.2.0",
|
||||
"mustache": "^4.2.0",
|
||||
"requirejs": "^2.3.6",
|
||||
"serve": "^14.0.1",
|
||||
"serve": "^14.2.0",
|
||||
"strip-ansi": "^7.0.1",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack": "^5.81.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ def beautify(string, opts=None):
|
||||
|
||||
def beautify_file(file_name, opts=None):
|
||||
_main = __import__("cssbeautifier", globals(), locals(), ["_main"])._main
|
||||
return _main.beautify_file(file, opts)
|
||||
return _main.beautify_file(file_name, opts)
|
||||
|
||||
|
||||
def usage(stream=sys.stdout):
|
||||
|
@ -52,7 +52,6 @@ def beautify_file(file_name, opts=None):
|
||||
|
||||
|
||||
def usage(stream=sys.stdout):
|
||||
|
||||
print(
|
||||
"cssbeautifier.py@"
|
||||
+ __version__
|
||||
@ -102,7 +101,6 @@ Rarely needed options:
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
argv = sys.argv[1:]
|
||||
|
||||
try:
|
||||
|
@ -67,7 +67,6 @@ def beautify_file(file_name, opts=default_options()):
|
||||
|
||||
|
||||
def usage(stream=sys.stdout):
|
||||
|
||||
print(
|
||||
"cssbeautifier.py@"
|
||||
+ __version__
|
||||
@ -384,7 +383,6 @@ class Beautifier:
|
||||
if self._options.brace_style == "expand":
|
||||
self._output.add_new_line(True)
|
||||
elif self._ch == ":":
|
||||
|
||||
for i in range(0, len(self.NON_SEMICOLON_NEWLINE_PROPERTY)):
|
||||
if self._input.lookBack(self.NON_SEMICOLON_NEWLINE_PROPERTY[i]):
|
||||
insideNonSemiColonValues = True
|
||||
|
@ -87,7 +87,6 @@ def beautify_file(file_name, opts=default_options()):
|
||||
|
||||
|
||||
def usage(stream=sys.stdout):
|
||||
|
||||
print(
|
||||
"jsbeautifier.py@"
|
||||
+ __version__
|
||||
@ -156,7 +155,6 @@ Rarely needed options:
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
argv = sys.argv[1:]
|
||||
|
||||
try:
|
||||
|
@ -27,7 +27,6 @@ import re
|
||||
|
||||
class Directives:
|
||||
def __init__(self, start_block_pattern, end_block_pattern):
|
||||
|
||||
self.__directives_block_pattern = re.compile(
|
||||
start_block_pattern + r" beautify( \w+[:]\w+)+ " + end_block_pattern
|
||||
)
|
||||
|
@ -204,7 +204,6 @@ class IndentStringCache:
|
||||
|
||||
class Output:
|
||||
def __init__(self, options, baseIndentString=""):
|
||||
|
||||
self.__indent_cache = IndentStringCache(options, baseIndentString)
|
||||
self.raw = False
|
||||
self._end_with_newline = options.end_with_newline
|
||||
|
@ -171,7 +171,6 @@ class TemplatablePattern(Pattern):
|
||||
resulting_string or self.__patterns.django_value.read()
|
||||
)
|
||||
if not self._excluded.django:
|
||||
|
||||
resulting_string = (
|
||||
resulting_string or self.__patterns.django_comment.read()
|
||||
)
|
||||
|
@ -1213,7 +1213,7 @@ class Beautifier:
|
||||
or current_token.previous.text == ")"
|
||||
)
|
||||
):
|
||||
# This conditionial checks backtick strings and makes no changes
|
||||
# This conditional checks backtick strings and makes no changes
|
||||
pass
|
||||
elif self.start_of_statement(current_token):
|
||||
# The conditional starts the statement if appropriate.
|
||||
@ -1379,7 +1379,6 @@ class Beautifier:
|
||||
and self._options.preserve_newlines
|
||||
and current_token.text in Tokenizer.positionable_operators
|
||||
):
|
||||
|
||||
isColon = current_token.text == ":"
|
||||
isTernaryColon = isColon and in_ternary
|
||||
isOtherColon = isColon and not in_ternary
|
||||
|
@ -342,7 +342,6 @@ class Tokenizer(BaseTokenizer):
|
||||
return None
|
||||
|
||||
def _read_regexp(self, c, previous_token):
|
||||
|
||||
if c == "/" and self.allowRegExOrXML(previous_token):
|
||||
# handle regexp
|
||||
resulting_string = self._input.next()
|
||||
@ -425,7 +424,6 @@ class Tokenizer(BaseTokenizer):
|
||||
resulting_string = ""
|
||||
|
||||
if c == "#":
|
||||
|
||||
# she-bang
|
||||
if self._is_first_token():
|
||||
resulting_string = self._patterns.shebang.read()
|
||||
@ -471,7 +469,6 @@ class Tokenizer(BaseTokenizer):
|
||||
self._input.back()
|
||||
|
||||
elif c == "<" and self._is_first_token():
|
||||
|
||||
if self._patterns.html_comment_start.read():
|
||||
c = "<!--"
|
||||
while self._input.hasNext() and not self._input.testChar(
|
||||
|
@ -59,7 +59,7 @@
|
||||
} }
|
||||
|
||||
space_after_anon_function (default false) - should the space before an anonymous function's parens be added, "function()" vs "function ()",
|
||||
NOTE: This option is overriden by jslint_happy (i.e. if jslint_happy is true, space_after_anon_function is true by design)
|
||||
NOTE: This option is overridden by jslint_happy (i.e. if jslint_happy is true, space_after_anon_function is true by design)
|
||||
|
||||
brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none" | any of the former + ",preserve-inline"
|
||||
put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are.
|
||||
|
@ -16,7 +16,7 @@ $(function() {
|
||||
the.editor = CodeMirror.fromTextArea(textArea, {
|
||||
lineNumbers: true
|
||||
});
|
||||
setPreferredColorScheme();
|
||||
|
||||
set_editor_mode();
|
||||
the.editor.focus();
|
||||
|
||||
@ -37,6 +37,7 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
setPreferredColorScheme();
|
||||
|
||||
$(window).bind('keydown', function(e) {
|
||||
if ((e.ctrlKey || e.metaKey) && e.keyCode === 13) {
|
||||
|
Loading…
Reference in New Issue
Block a user