Revert "Added Overrided EOL option for JS , JSX"

This reverts commit c48eaf967e.
This commit is contained in:
Deforder 2017-01-14 14:47:27 +07:00
parent c48eaf967e
commit 97d62680e4
5 changed files with 2979 additions and 459 deletions

File diff suppressed because it is too large Load Diff

View File

@ -97,26 +97,6 @@ module.exports = class Beautifier
startDir.pop()
return null
# 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.
# Code modified from atom/line-ending-selector
# returns: The correct line-ending character sequence based upon the Atom
# 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')
when 'LF'
return lf
when 'CRLF'
return crlf
when 'OS Default'
return if process.platform is 'win32' then crlf else lf
else
return lf
###
If platform is Windows
###

View File

@ -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
@ -34,10 +25,11 @@ 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')
#TODO reconsider handling of EOL once js-beautify adds EOL detection
#see https://github.com/beautify-web/js-beautify/issues/899
options.eol = getDefaultLineEnding() ? options.eol #fixes issue #707
return new @Promise((resolve, reject) =>
try
switch language
@ -66,3 +58,23 @@ module.exports = class JSBeautify extends Beautifier
reject(err)
)
# 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.
# Code modified from atom/line-ending-selector
# returns: The correct line-ending character sequence based upon the Atom
# 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= ->
switch atom.config.get('line-ending-selector.defaultLineEnding')
when 'LF'
return '\n'
when 'CRLF'
return '\r\n'
when 'OS Default'
return if process.platform is 'win32' then '\r\n' else '\n'
else
return null

View File

@ -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
@ -78,7 +70,6 @@ module.exports = class PrettyDiff extends Beautifier
beautify: (text, language, options) ->
options.crlf = options.crlf ? @getDefaultLineEnding(true,false)
return new @Promise((resolve, reject) =>
prettydiff = require("prettydiff")
_ = require('lodash')

View File

@ -111,10 +111,5 @@ module.exports = {
default: false
description: "If a terminating comma should be inserted into \
arrays, object literals, and destructured objects."
end_of_line:
type: 'string'
default: "System Default"
enum: ["CRLF","LF","System Default"]
description: "Override EOL from line-ending-selector"
}