Change logic to prevent eol feature override setting value
New logic + document (only insertion)
This commit is contained in:
parent
fa266a2e26
commit
77da64f4f0
315
docs/options.md
315
docs/options.md
|
@ -766,6 +766,7 @@ Automatically beautify Clojure files on save
|
|||
| `beautify_on_save` | :white_check_mark: | :white_check_mark: |
|
||||
| `brace_style` | :white_check_mark: | :x: |
|
||||
| `break_chained_methods` | :white_check_mark: | :x: |
|
||||
| `end_of_line` | :white_check_mark: | :x: |
|
||||
| `end_with_comma` | :white_check_mark: | :x: |
|
||||
| `end_with_newline` | :white_check_mark: | :x: |
|
||||
| `eval_code` | :white_check_mark: | :x: |
|
||||
|
@ -895,6 +896,34 @@ Break chained method calls across subsequent lines (Supported by Coffee Formatte
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`Coffee Formatter`](#coffee-formatter)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by Coffee Formatter)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [End with comma](#end-with-comma)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
@ -2179,6 +2208,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
|
|||
| `beautify_on_save` | :white_check_mark: | :white_check_mark: |
|
||||
| `brace_style` | :white_check_mark: | :x: |
|
||||
| `break_chained_methods` | :white_check_mark: | :white_check_mark: |
|
||||
| `end_of_line` | :white_check_mark: | :x: |
|
||||
| `end_with_comma` | :white_check_mark: | :white_check_mark: |
|
||||
| `end_with_newline` | :white_check_mark: | :x: |
|
||||
| `eval_code` | :white_check_mark: | :x: |
|
||||
|
@ -2314,6 +2344,34 @@ Break chained method calls across subsequent lines (Supported by JS Beautify, Pr
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by JS Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [End with comma](#end-with-comma)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
@ -4972,6 +5030,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
|
|||
| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| `brace_style` | :white_check_mark: | :x: | :x: |
|
||||
| `break_chained_methods` | :white_check_mark: | :x: | :white_check_mark: |
|
||||
| `end_of_line` | :white_check_mark: | :x: | :x: |
|
||||
| `end_with_comma` | :white_check_mark: | :x: | :white_check_mark: |
|
||||
| `end_with_newline` | :white_check_mark: | :x: | :x: |
|
||||
| `eval_code` | :white_check_mark: | :x: | :x: |
|
||||
|
@ -5101,6 +5160,34 @@ Break chained method calls across subsequent lines (Supported by JS Beautify, Pr
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by JS Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [End with comma](#end-with-comma)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
@ -5530,6 +5617,7 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre
|
|||
| `beautify_on_save` | :white_check_mark: | :white_check_mark: |
|
||||
| `brace_style` | :white_check_mark: | :x: |
|
||||
| `break_chained_methods` | :white_check_mark: | :white_check_mark: |
|
||||
| `end_of_line` | :white_check_mark: | :x: |
|
||||
| `end_with_comma` | :white_check_mark: | :white_check_mark: |
|
||||
| `end_with_newline` | :white_check_mark: | :x: |
|
||||
| `eval_code` | :white_check_mark: | :x: |
|
||||
|
@ -5659,6 +5747,34 @@ Break chained method calls across subsequent lines (Supported by JS Beautify, Pr
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by JS Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [End with comma](#end-with-comma)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
@ -6088,6 +6204,7 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre
|
|||
| `beautify_on_save` | :white_check_mark: | :white_check_mark: |
|
||||
| `brace_style` | :white_check_mark: | :x: |
|
||||
| `break_chained_methods` | :white_check_mark: | :white_check_mark: |
|
||||
| `end_of_line` | :white_check_mark: | :x: |
|
||||
| `end_with_comma` | :white_check_mark: | :white_check_mark: |
|
||||
| `end_with_newline` | :white_check_mark: | :x: |
|
||||
| `eval_code` | :white_check_mark: | :x: |
|
||||
|
@ -6217,6 +6334,34 @@ Break chained method calls across subsequent lines (Supported by JS Beautify, Pr
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by JS Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [End with comma](#end-with-comma)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
@ -11779,6 +11924,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
|
|||
| `beautify_on_save` | :white_check_mark: |
|
||||
| `brace_style` | :white_check_mark: |
|
||||
| `break_chained_methods` | :white_check_mark: |
|
||||
| `end_of_line` | :white_check_mark: |
|
||||
| `end_with_comma` | :white_check_mark: |
|
||||
| `end_with_newline` | :white_check_mark: |
|
||||
| `eval_code` | :white_check_mark: |
|
||||
|
@ -11908,6 +12054,34 @@ Break chained method calls across subsequent lines (Supported by TypeScript Form
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`TypeScript Formatter`](#typescript-formatter)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by TypeScript Formatter)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [End with comma](#end-with-comma)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
@ -12785,6 +12959,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
|
|||
| `beautify_on_save` | :white_check_mark: |
|
||||
| `brace_style` | :white_check_mark: |
|
||||
| `break_chained_methods` | :white_check_mark: |
|
||||
| `end_of_line` | :white_check_mark: |
|
||||
| `end_with_comma` | :white_check_mark: |
|
||||
| `end_with_newline` | :white_check_mark: |
|
||||
| `eval_code` | :white_check_mark: |
|
||||
|
@ -12920,6 +13095,34 @@ Break chained method calls across subsequent lines (Supported by Vue Beautifier)
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`Vue Beautifier`](#vue-beautifier)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by Vue Beautifier)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [End with comma](#end-with-comma)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
@ -14777,6 +14980,34 @@ If a terminating comma should be inserted into arrays, object literals, and dest
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`Coffee Formatter`](#coffee-formatter)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by Coffee Formatter)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Fortran Beautifier
|
||||
|
||||
|
@ -15437,6 +15668,34 @@ If a terminating comma should be inserted into arrays, object literals, and dest
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by JS Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [Indent inner html](#indent-inner-html)
|
||||
|
||||
**Namespace**: `html`
|
||||
|
@ -17569,6 +17828,34 @@ If a terminating comma should be inserted into arrays, object literals, and dest
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`TypeScript Formatter`](#typescript-formatter)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by TypeScript Formatter)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Uncrustify
|
||||
|
||||
|
@ -18071,6 +18358,34 @@ If a terminating comma should be inserted into arrays, object literals, and dest
|
|||
}
|
||||
```
|
||||
|
||||
##### [End of line](#end-of-line)
|
||||
|
||||
**Namespace**: `js`
|
||||
|
||||
**Key**: `end_of_line`
|
||||
|
||||
**Default**: `System Default`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `CRLF` `LF` `System Default`
|
||||
|
||||
**Supported Beautifiers**: [`Vue Beautifier`](#vue-beautifier)
|
||||
|
||||
**Description**:
|
||||
|
||||
Override EOL from line-ending-selector (Supported by Vue Beautifier)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"js": {
|
||||
"end_of_line": "System Default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### [Indent inner html](#indent-inner-html)
|
||||
|
||||
**Namespace**: `html`
|
||||
|
|
|
@ -97,7 +97,7 @@ module.exports = class Beautifier
|
|||
startDir.pop()
|
||||
return null
|
||||
|
||||
# Retrieves the default line ending based upon the Atom configuration
|
||||
# Retrieves the default line ending based upon the Atom configuration
|
||||
# `line-ending-selector.defaultLineEnding`. If the Atom configuration
|
||||
# indicates "OS Default", the `process.platform` is queried, returning
|
||||
# CRLF for Windows systems and LF for all other systems.
|
||||
|
@ -106,8 +106,10 @@ module.exports = class Beautifier
|
|||
# configuration, or `null` if the Atom line ending configuration was not
|
||||
# recognized.
|
||||
# see: https://github.com/atom/line-ending-selector/blob/master/lib/main.js
|
||||
getDefaultLineEnding: (crlf,lf) ->
|
||||
switch atom.config.get('line-ending-selector.defaultLineEnding')
|
||||
getDefaultLineEnding: (crlf,lf,optionEol) ->
|
||||
if (!optionEol || optionEol == 'System Default')
|
||||
optionEol = atom.config.get('line-ending-selector.defaultLineEnding')
|
||||
switch optionEol
|
||||
when 'LF'
|
||||
return lf
|
||||
when 'CRLF'
|
||||
|
@ -116,6 +118,7 @@ module.exports = class Beautifier
|
|||
return if process.platform is 'win32' then crlf else lf
|
||||
else
|
||||
return lf
|
||||
|
||||
###
|
||||
If platform is Windows
|
||||
###
|
||||
|
|
|
@ -6,15 +6,6 @@ module.exports = class JSBeautify extends Beautifier
|
|||
link: "https://github.com/beautify-web/js-beautify"
|
||||
|
||||
options: {
|
||||
_:
|
||||
eol: ['end_of_line', (end_of_line) ->
|
||||
if (end_of_line == 'CRLF')
|
||||
'\r\n'
|
||||
else if (end_of_line == 'LF')
|
||||
'\n'
|
||||
else
|
||||
null
|
||||
]
|
||||
HTML: true
|
||||
XML: true
|
||||
Handlebars: true
|
||||
|
@ -36,7 +27,7 @@ module.exports = class JSBeautify extends Beautifier
|
|||
beautify: (text, language, options) ->
|
||||
@verbose("JS Beautify language #{language}")
|
||||
@info("JS Beautify Options: #{JSON.stringify(options, null, 4)}")
|
||||
options.eol = options.eol ? @getDefaultLineEnding('\r\n','\n')
|
||||
options.eol = @getDefaultLineEnding('\r\n','\n',options.end_of_line)
|
||||
return new @Promise((resolve, reject) =>
|
||||
try
|
||||
switch language
|
||||
|
|
|
@ -42,14 +42,6 @@ module.exports = class PrettyDiff extends Beautifier
|
|||
]
|
||||
ternaryline: "preserve_ternary_lines"
|
||||
bracepadding: "space_in_paren"
|
||||
crlf: ['end_of_line', (end_of_line) ->
|
||||
if (end_of_line == 'CRLF')
|
||||
true
|
||||
else if (end_of_line == 'LF')
|
||||
false
|
||||
else
|
||||
null
|
||||
]
|
||||
# Apply language-specific options
|
||||
CSV: true
|
||||
Coldfusion: true
|
||||
|
@ -77,8 +69,7 @@ module.exports = class PrettyDiff extends Beautifier
|
|||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
|
||||
options.crlf = options.crlf ? @getDefaultLineEnding(true,false)
|
||||
options.crlf = @getDefaultLineEnding(true,false,options.end_of_line)
|
||||
return new @Promise((resolve, reject) =>
|
||||
prettydiff = require("prettydiff")
|
||||
_ = require('lodash')
|
||||
|
|
Loading…
Reference in New Issue