├── .gitignore
├── .travis.yml
├── test
├── index.js
├── failing
│ ├── jsx.js
│ ├── obfuscated.js
│ ├── singleline.js
│ ├── multiline.js
│ └── obfuscated-files
│ │ └── standard-format-torture.js
├── shebang.js
├── testFile.js
├── es6.js
├── jsx.js
├── test-files
│ └── test.js
├── multiline.js
└── singleline.js
├── index.js
├── collaborators.md
├── readme.md
├── package.json
├── bin.js
└── rc
└── esformatter.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '0.12'
4 | - '0.11'
5 | - '0.10'
6 | sudo: false # Enable docker based containers
7 | cache:
8 | directories: # Cache npm install
9 | - node_modules
10 |
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var join = require('path').join
3 | var testFile = require('./testFile')
4 | var TARGET_FILE = join(__dirname, './test-files/test.js')
5 |
6 | test('test.js formatted and linted without error', testFile(TARGET_FILE))
7 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var semi = require('semi')
2 | var transform = require('standard-format').transform
3 | module.exports.transform = function (text) {
4 | text = transform(text)
5 | // handle errors
6 | semi.on('error', function (err) { throw err })
7 |
8 | return semi.add(text)
9 | }
10 |
--------------------------------------------------------------------------------
/test/failing/jsx.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var fmt = require('../../').transform
3 |
4 | var noops = []
5 |
6 | test.skip('JSX noops', function (t) {
7 | t.plan(noops.length)
8 | noops.forEach(function (obj) {
9 | var fmtd = fmt(obj.program)
10 | t.equal(fmtd, obj.program, obj.msg)
11 | console.log('issues:\n' + obj.issues.join('\n'))
12 | })
13 | })
14 |
--------------------------------------------------------------------------------
/test/shebang.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var fmt = require('../').transform
3 |
4 | test('deal with shebang line', function (t) {
5 | t.plan(2)
6 |
7 | var program = "#!/usr/bin/env node\nconsole.log('badaboom');\n"
8 | var formatted
9 |
10 | var msg = 'Expect formatter to not explode with shebang'
11 | t.ok(formatted = fmt(program), msg)
12 |
13 | msg = 'Expect program to be still have shebang'
14 | t.equal(formatted, program, msg)
15 | })
16 |
--------------------------------------------------------------------------------
/test/failing/obfuscated.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var path = require('path')
3 | var testFile = require('../testFile')
4 |
5 | var files = [
6 | {path: path.resolve(path.join(__dirname, '/obfuscated-files/standard-format-torture.js')),
7 | issues: ['https://github.com/maxogden/standard-format/issues/27']}
8 | ]
9 |
10 | files.forEach(function (fileObj) {
11 | var basename = path.basename(fileObj.path)
12 | test('deobfuscate and lint ' + basename, testFile(fileObj.path, 1))
13 | })
14 |
--------------------------------------------------------------------------------
/test/failing/singleline.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var fmt = require('../../').transform
3 |
4 | var transforms = [
5 | {
6 | str: 'var x = {key:123,more:456}\n',
7 | expect: 'var x = {key: 123, more: 456}\n',
8 | msg: 'Space after comma in keys',
9 | issues: ['https://github.com/maxogden/standard-format/issues/54']
10 | }
11 | ]
12 |
13 | test('singleline transforms', function (t) {
14 | t.plan(transforms.length)
15 | transforms.forEach(function (obj) {
16 | t.equal(fmt(obj.str), obj.expect, obj.msg)
17 | console.log('issues:\n' + obj.issues.join('\n'))
18 | })
19 | })
20 |
--------------------------------------------------------------------------------
/collaborators.md:
--------------------------------------------------------------------------------
1 | ## Collaborators
2 |
3 | standard-format is only possible due to the excellent work of the following collaborators:
4 |
5 |
11 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 |
2 | # semistandard-format
3 | This is a fork of [standard-format](https://github.com/maxogden/standard-format) same concept but with semicolons.
4 |
5 | ## Installation
6 |
7 | Install with npm
8 |
9 | $ npm install -g semistandard-format
10 |
11 | ## Example Usage
12 |
13 | Output all formatted javascript in a directory and subdirectories to stdout
14 |
15 | $ semistandard-format
16 |
17 | Format all javascript files, overwriting them into standard format
18 |
19 | $ semistandard-format -w
20 |
21 | Format javascript over stdin
22 |
23 | $ semistandard-format < file.js > formatted-file.js
24 |
25 | Format and overwrite specific files
26 |
27 | $ semistandard-format -w file1.js file2.js
28 |
29 | ### Editor plugins
30 |
31 | - Sublime Text: [sublime-standard-format](https://packagecontrol.io/packages/StandardFormat)
32 | - Atom: [atom-standard-formatter](https://atom.io/packages/standard-formatter)
33 |
34 | ### Science :mortar_board:
35 |
36 | > A new step should be added to the modification cycle: modifying the program to make it readable.
37 |
38 | [Elshoff & Marcotty, 1982](http://dl.acm.org/citation.cfm?id=358596)
--------------------------------------------------------------------------------
/test/testFile.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var fs = require('fs')
3 | var fmt = require('../').transform
4 | var standard = require('semistandard')
5 | var inspect = require('util').inspect
6 |
7 | function testFile (filePath, depth) {
8 | // Reads a file, formats its contents then lints it with standard
9 | // Test fails if there are linting errors or warnings
10 | // Inspect depth is optional
11 | var basename = path.basename(filePath)
12 | function test (t) {
13 | fs.readFile(filePath, {encoding: 'utf8'}, function (err, data) {
14 | t.error(err, 'read ' + basename + ' file without error ')
15 |
16 | var formatted
17 |
18 | try {
19 | formatted = fmt(data)
20 | } catch (e) {
21 | t.error(e, 'format ' + basename + ' without error')
22 | }
23 |
24 | standard.lintText(formatted, function (err, result) {
25 | t.error(err, 'linting ' + basename + ' should be error free')
26 | t.equal(result.errorCount, 0, basename + ' error free after formatting')
27 | t.equal(result.warningCount, 0, basename + ' warning free after formatting')
28 | if (result.errorCount || result.warningCount !== 0) {
29 | // If there is an issue, print the details
30 | console.log(inspect(result, {depth: depth || null}))
31 | }
32 | t.end()
33 | })
34 | })
35 | }
36 | return test
37 | }
38 |
39 | module.exports = testFile
40 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "semistandard-format",
3 | "version": "3.0.0",
4 | "description": "attempts to reformat javascript to comply with feross/standard style but with semicolons",
5 | "main": "index.js",
6 | "bin": "./bin.js",
7 | "scripts": {
8 | "test": "standard && tape test/*.js | tap-spec",
9 | "test-file": " ({',
31 | 'inc: el.val + 1,',
32 | 'dec: el.val - 1',
33 | '}));',
34 | ''
35 | ].join('\n'),
36 |
37 | expected: [
38 | 'array.map(el => ({',
39 | ' inc: el.val + 1,',
40 | ' dec: el.val - 1',
41 | '}));',
42 | ''
43 | ].join('\n'),
44 |
45 | msg: 'arrow functions correctly indent',
46 | issues: [
47 | 'https://github.com/maxogden/standard-format/issues/127'
48 | ]
49 | }
50 | ]
51 |
52 | test('ES6 Classes', function (t) {
53 | t.plan(classes.length)
54 | classes.forEach(function (obj) {
55 | t.equal(fmt(obj.program), obj.expected, obj.msg)
56 | console.log('issues:\n' + obj.issues.join('\n'))
57 | })
58 | })
59 |
--------------------------------------------------------------------------------
/test/failing/multiline.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var fmt = require('../../').transform
3 |
4 | var noops = [
5 | {
6 | program: [
7 | 'var cool =',
8 | ' a +',
9 | ' b +',
10 | ' c',
11 | ''
12 | ].join('\n'),
13 | msg: 'Allow indendation following a newline after assignment operator',
14 | issues: ['https://github.com/maxogden/standard-format/issues/101']
15 | }
16 | ]
17 |
18 | test('multiline noop', function (t) {
19 | t.plan(noops.length)
20 | noops.forEach(function (obj) {
21 | var fmtd = fmt(obj.program)
22 | t.equal(fmtd, obj.program, obj.msg)
23 | console.log('issues:\n' + obj.issues.join('\n'))
24 | })
25 | })
26 |
27 | var transforms = [
28 | {
29 | program: [
30 | 'function x()',
31 | '{',
32 | ' var i=0;',
33 | ' do {',
34 | ' i++',
35 | ' } while(i<10)',
36 | ' console.log(i);',
37 | '}'
38 | ].join('\n'),
39 | expected: [
40 | 'function x () {',
41 | ' var i = 0',
42 | ' do {',
43 | ' i++',
44 | ' } while (i < 10)',
45 | ' console.log(i)',
46 | '}',
47 | ''
48 | ].join('\n'),
49 | msg: 'Indendation following a do-while loop',
50 | issues: [
51 | 'https://github.com/maxogden/standard-format/pull/87',
52 | 'https://github.com/maxogden/standard-format/issues/86'
53 | ]
54 | }
55 | ]
56 |
57 | test('Failing Multiline Transforms', function (t) {
58 | t.plan(transforms.length)
59 | transforms.forEach(function (obj) {
60 | t.equal(fmt(obj.program), obj.expected, obj.msg)
61 | console.log('issues:\n' + obj.issues.join('\n'))
62 | })
63 | })
64 |
--------------------------------------------------------------------------------
/test/jsx.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var fmt = require('../').transform
3 |
4 | var noops = [
5 | {
6 | program: [
7 | 'export default class Foo extends Component {',
8 | ' renderPartial () {',
9 | ' return this.props.bar.map((item) => {',
10 | ' return ;',
11 | ' });',
12 | ' }',
13 | '};',
14 | ''
15 | ].join('\n'),
16 |
17 | msg: 'Keep indentation for multiple return statements with JSX'
18 | },
19 | {
20 | program: [
21 | 'export class Foo extends React.Component {',
22 | ' render () {',
23 | ' return (',
24 | ' ',
25 | ' );',
26 | ' }',
27 | '};',
28 | ''
29 | ].join('\n'),
30 | msg: 'Preserve indendation on JSX blocks',
31 | issues: ['https://github.com/maxogden/standard-format/issues/99']
32 | },
33 | {
34 | program: [
35 | 'export class Foo extends React.Component {',
36 | ' render () {',
37 | ' return (',
38 | ' ',
39 | ' ',
40 | '
',
41 | ' );',
42 | ' }',
43 | '};',
44 | ''
45 | ].join('\n'),
46 | msg: 'Preserve indendation on JSX blocks with parameters',
47 | issues: ['https://github.com/maxogden/standard-format/issues/99']
48 | },
49 | {
50 | program: [
51 | 'export class Foo extends React.Component {',
52 | ' render () {',
53 | ' return (',
54 | ' ',
55 | ' ',
60 | '
',
61 | ' );',
62 | ' }',
63 | '};',
64 | ''
65 | ].join('\n'),
66 | msg: '4+ jsx args are multilined and aligned',
67 | issues: ['https://github.com/maxogden/standard-format/issues/99']
68 | }
69 | ]
70 |
71 | test('jsx noop', function (t) {
72 | t.plan(noops.length)
73 | noops.forEach(function (obj) {
74 | t.equal(fmt(obj.program), obj.program, obj.msg)
75 | })
76 | })
77 |
--------------------------------------------------------------------------------
/bin.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var fmt = require('./')
4 | var load = require('standard-format').load
5 | var fs = require('fs')
6 | var stdin = require('stdin')
7 | var argv = require('minimist')(process.argv.slice(2), {
8 | boolean: ['help', 'stdin', 'version', 'write'],
9 | alias: {
10 | h: 'help',
11 | w: 'write',
12 | v: 'version'
13 | }
14 | })
15 |
16 | // running `semistandard-format -` is equivalent to `semistandard-format --stdin`
17 | if (argv._[0] === '-') {
18 | argv.stdin = true
19 | argv._.shift()
20 | }
21 |
22 | if (argv.help) {
23 | console.log(function () {
24 | /*
25 | semistandard-format - Auto formatter for the easier cases in standard
26 |
27 | Usage:
28 | semistandard-format [FILES...]
29 |
30 | If FILES is omitted, then all JavaScript source files (*.js) in the current
31 | working directory are checked, recursively.
32 |
33 | These paths are automatically excluded:
34 | node_modules/, .git/, *.min.js, bundle.js
35 |
36 | Flags:
37 | -v --version Show current version.
38 | -w --write Directly modify input files.
39 | -h, --help Show usage information.
40 |
41 | Readme: https://github.com/maxogden/semistandard-format
42 |
43 | */
44 | }.toString().split(/\n/).slice(2, -2).join('\n'))
45 | process.exit(0)
46 | }
47 |
48 | if (argv.version) {
49 | console.log(require('./package.json').version)
50 | process.exit(0)
51 | }
52 |
53 | function processFile (transformed) {
54 | if (argv.write && transformed.name !== 'stdin') {
55 | fs.writeFileSync(transformed.name, transformed.data)
56 | } else {
57 | process.stdout.write(transformed.data)
58 | }
59 | }
60 |
61 | function getFiles (done) {
62 | var args = argv._
63 | if (argv.stdin) {
64 | return stdin(function (file) {
65 | return done(null, [{ name: 'stdin', data: file }])
66 | })
67 | } else if (args.length === 0) {
68 | return load(done)
69 | } else {
70 | return done(null, args.map(function (file) {
71 | return { name: file, data: fs.readFileSync(file).toString() }
72 | }))
73 | }
74 | }
75 |
76 | getFiles(function (err, files) {
77 | if (err) return error(err)
78 | files.forEach(function (file) {
79 | try {
80 | file.data = fmt.transform(file.data)
81 | processFile(file)
82 | } catch (e) { error(file.name + ': ' + e) }
83 | })
84 | })
85 |
86 | function error (err) {
87 | console.error(err)
88 | process.exit(1)
89 | }
90 |
--------------------------------------------------------------------------------
/test/test-files/test.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | // This file is automatically ran through standard-format
4 | // and checked by standard. Add test cases for the formatter by adding
5 | // to this file
6 | var noop = require('noop')
7 |
8 | // eol semicolons
9 | var x = 1;
10 |
11 | // eol whitespace
12 | x = 2
13 |
14 | // standard-format has nothing to say about unused vars
15 | // so this is here to prevent invalid test cases
16 | console.log(x)
17 |
18 | //bad comment -- needs a space after slashes
19 | var test = "what";
20 |
21 | if(test) {
22 | ["a","b","c"].forEach(function (x) {
23 | // test: infix commas
24 | console.log(x*2);
25 | })
26 | }
27 |
28 | var obj = {val: 2}
29 | var another = { foo: 'bar' }
30 |
31 | // space after function name and arg paren
32 | ;[1].forEach(function(){})
33 |
34 | // space after argument paren
35 | function f2 (x,y,z){}
36 | function fooz() {}
37 | function foox () {}
38 | function foos () {}
39 |
40 | var anon = function() {}
41 |
42 | f2( obj)
43 | f2(obj )
44 | f2( obj )
45 | f2( obj, obj )
46 | f2( obj,obj )
47 | fooz()
48 | foox()
49 | foos()
50 | anon(another)
51 |
52 | function foo(){}
53 | function bar() {}
54 | function quux() {}
55 |
56 |
57 | foo()
58 | bar()
59 | quux()
60 |
61 |
62 | function food (){}
63 | function foot () {}
64 |
65 |
66 | food()
67 | foot()
68 |
69 |
70 | // test: no block padding
71 | var lessThanThreeNewlines = function () {
72 |
73 | return 2;
74 | }
75 | lessThanThreeNewlines()
76 |
77 | // at most one newline after opening brace
78 | function noExtraNewlines() {
79 |
80 |
81 | return 2;
82 | }
83 | noExtraNewlines()
84 |
85 | // at most one newline after opening brace
86 | function noExtraSingle() { return 2 }
87 | noExtraSingle()
88 |
89 | // at most one newline after opening brace
90 | // at most one newline before closing brace
91 | function noExtraBraces() {
92 |
93 |
94 | if (noExtraBraces != null)
95 |
96 | {
97 |
98 | return 42
99 |
100 | }
101 |
102 | else
103 |
104 | {
105 |
106 | return 42
107 |
108 | }
109 |
110 | switch(noExtraBraces)
111 |
112 | {
113 |
114 | case null:
115 | return 42
116 |
117 | }
118 |
119 | try
120 |
121 | {
122 |
123 | return 42
124 |
125 | }
126 | catch (e)
127 |
128 | {
129 | }
130 |
131 | for (var i in noExtraBraces) {
132 |
133 | return i
134 |
135 | }
136 |
137 | }
138 | noExtraBraces()
139 |
140 |
141 | // weird bug function
142 | for (var i = 0 ; i < 42; i++ ) {
143 | }
144 |
145 | function getRequests (cb) {
146 | foo({
147 | }, function (err, resp, body) {
148 | cb(err, resp, body)
149 | })
150 | }
151 | getRequests()
152 |
153 | // jsx
154 | var React = require('react')
155 |
156 | var testClass = React.createClass({
157 | render: function () {
158 | return (
159 |
160 | )
161 | }
162 | })
163 |
164 | module.exports = testClass
165 |
166 | // spacing around Property names (key-spacing)
167 | void {
168 | testing :123
169 | }
170 |
171 | // Test start of line semicolins
172 | var gloopy = 12
173 | [1,2,3].map(function () {})
174 | console.log(gloopy)
175 |
176 | // Test member accessors
177 | var array = [1,2,3]
178 | var val = array[0]
179 | var val2 = array[1]
180 | noop(val, val2)
181 |
--------------------------------------------------------------------------------
/test/multiline.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var fmt = require('../').transform
3 |
4 | var cr = new RegExp(/\n/g)
5 | var crlf = '\r\n'
6 |
7 | var collapse = [
8 | {
9 | program: [
10 | 'var x = 1',
11 | '',
12 | '',
13 | 'var z = 2',
14 | ''
15 | ].join('\n'),
16 |
17 | expected: [
18 | 'var x = 1;',
19 | '',
20 | 'var z = 2;',
21 | ''
22 | ].join('\n'),
23 |
24 | msg: 'two empty lines should collapse to one'
25 | },
26 | {
27 | program: [
28 | 'var x = 1',
29 | '', '', '', '', '',
30 | '', '', '', '', '',
31 | 'var z = 2', ''
32 | ].join('\n'),
33 |
34 | expected: [
35 | 'var x = 1;',
36 | '',
37 | 'var z = 2;', ''
38 | ].join('\n'),
39 |
40 | msg: 'ten empty lines should collapse to one'
41 | },
42 | {
43 | program: [
44 | 'var foo = function () {',
45 | '',
46 | ' bar()',
47 | '}',
48 | ''
49 | ].join('\n'),
50 |
51 | expected: [
52 | 'var foo = function () {',
53 | ' bar();',
54 | '};',
55 | ''
56 | ].join('\n'),
57 |
58 | msg: 'Remove padding newlines after curly braces'
59 | },
60 | {
61 | program: [
62 | 'var x = 123; /* Useful comment ',
63 | 'that spans two lines */',
64 | ''
65 | ].join('\n'),
66 |
67 | expected: [
68 | 'var x = 123; /* Useful comment ',
69 | 'that spans two lines */',
70 | ''
71 | ].join('\n'),
72 |
73 | msg: 'Don\'t Remove semicolon from multiline comment'
74 | }
75 | ]
76 |
77 | test('multiline collapse', function (t) {
78 | t.plan(collapse.length)
79 | collapse.forEach(function (obj) {
80 | t.equal(fmt(obj.program), obj.expected, obj.msg)
81 | })
82 | })
83 |
84 | test('multiline collapse CRLF', function (t) {
85 | t.plan(collapse.length)
86 | collapse.forEach(function (obj) {
87 | obj.program = obj.program.replace(cr, crlf)
88 | obj.expected = obj.expected.replace(cr, crlf)
89 | t.equal(fmt(obj.program), obj.expected, obj.msg)
90 | })
91 | })
92 |
93 | var noops = [
94 | {
95 | program: [
96 | 'var x = 1;',
97 | '',
98 | 'var z = 2;',
99 | ''
100 | ].join('\n'),
101 |
102 | msg: 'single empty line should be unmodified'
103 | },
104 | {
105 | program: [
106 | 'function getRequests (cb) {',
107 | ' nets({',
108 | " url: binUrl + '/api/v1/bins/' + bin.name + '/requests',",
109 | ' json: true,',
110 | ' headers: headers',
111 | ' }, function (err, resp, body) {',
112 | ' cb(err, resp, body);',
113 | ' });',
114 | '}',
115 | ''
116 | ].join('\n'),
117 |
118 | msg: "Don't mess with function tabbing"
119 |
120 | },
121 | {
122 | program: [
123 | 'var obj = {',
124 | " 'standard': {",
125 | " 'ignore': ['test.js', '**test/failing/**']",
126 | ' }',
127 | '};',
128 | ''
129 | ].join('\n'),
130 |
131 | msg: 'allow single line object arrays'
132 | },
133 | {
134 | program: [
135 | '/*global localStorage*/',
136 | '(function () { // IIFE to ensure no global leakage!',
137 | '}());',
138 | ''
139 | ].join('\n'),
140 |
141 | msg: 'IIFEs are not messed with'
142 | },
143 | {
144 | program: [
145 | "console.log('meh');",
146 | '(function a () {',
147 | " console.log('hiya');",
148 | '}());',
149 | ''
150 | ].join('\n'),
151 |
152 | msg: 'IIFEs are not messed with'
153 | }
154 | ]
155 |
156 | test('multiline noop', function (t) {
157 | t.plan(noops.length)
158 | noops.forEach(function (obj) {
159 | t.equal(fmt(obj.program), obj.program, obj.msg)
160 | })
161 | })
162 |
163 | test('multiline noop CRLF', function (t) {
164 | t.plan(noops.length)
165 | noops.forEach(function (obj) {
166 | obj.program = obj.program.replace(cr, crlf)
167 | t.equal(fmt(obj.program), obj.program, obj.msg)
168 | })
169 | })
170 |
171 | var semicolons = [
172 | {
173 | program: [
174 | 'var x = 2',
175 | '[1, 2, 3].map(function () {})',
176 | '',
177 | 'var y = 8',
178 | '(function () {',
179 | ' bar()',
180 | '}())',
181 | ''
182 | ].join('\n'),
183 |
184 | expected: [
185 | 'var x = 2;',
186 | '[1, 2, 3].map(function () {});',
187 | '',
188 | 'var y = 8;',
189 | '(function () {',
190 | ' bar();',
191 | '}());',
192 | ''
193 | ].join('\n'),
194 |
195 | msg: 'Add semicolon before `[` and `(` if they are the first things on the line'
196 | },
197 | {
198 | program: [
199 | "console.log('meh');",
200 | '(function a() {',
201 | "console.log('hiya');",
202 | '}());',
203 | ''
204 | ].join('\n'),
205 |
206 | expected: [
207 | "console.log('meh');",
208 | '(function a () {',
209 | " console.log('hiya');",
210 | '}());',
211 | ''
212 | ].join('\n'),
213 |
214 | msg: 'IIFEs are not messed with'
215 | }
216 | ]
217 |
218 | test('multiline semicolons', function (t) {
219 | t.plan(semicolons.length)
220 | semicolons.forEach(function (obj) {
221 | t.equal(fmt(obj.program), obj.expected, obj.msg)
222 | })
223 | })
224 |
--------------------------------------------------------------------------------
/test/singleline.js:
--------------------------------------------------------------------------------
1 | var test = require('tape')
2 | var fmt = require('../').transform
3 |
4 | var noops = [
5 | {
6 | str: 'if (!opts) opts = {};\n',
7 | msg: 'Noop on single line conditional assignment'
8 | },
9 |
10 | {
11 | str: 'var g = { name: f, data: fs.readFileSync(f).toString() };\n',
12 | msg: 'Noop on single line object assignment'
13 | },
14 | {
15 | str: "var x = {foo: 'bar'};\n",
16 | msg: 'Dont add padding to object braces'
17 | },
18 | {
19 | str: "var x = ['test.js', '**test/failing/**'];\n",
20 | msg: 'Noop on singleline arrays'
21 | },
22 | {
23 | str: 'function x () {}\n',
24 | msg: 'Noop on named functions correctly spaced'
25 | },
26 | {
27 | str: 'window.wrapFunctionsUntil(1);\n',
28 | msg: 'Noop non-functions with function in the name'
29 | },
30 | {
31 | str: "import * as lib from 'lib';\n",
32 | msg: 'Noop ES2015 import'
33 | },
34 | {
35 | str: 'function * blarg (foo) {yield foo;}\n',
36 | msg: 'Noop ES2015 generator'
37 | },
38 | {
39 | str: 'console.log(1 === 2 ? 3 : 4);\n',
40 | msg: 'Noop infix'
41 | },
42 | {
43 | str: 'test[0];\ntest;\n',
44 | msg: 'allow newline after member accessor',
45 | issues: ['https://github.com/maxogden/standard-format/pull/93']
46 | },
47 | {
48 | str: 'test(test[0]);\n',
49 | msg: "don't force newline on mid-expression member accessor",
50 | issues: ['https://github.com/maxogden/standard-format/pull/93']
51 | },
52 | {
53 | str: '// good comment\n',
54 | msg: 'Expect good comments to be unchanged'
55 | }
56 | ]
57 |
58 | test('singleline noop expressions', function (t) {
59 | t.plan(noops.length)
60 | noops.forEach(function (obj) {
61 | t.equal(fmt(obj.str), obj.str, obj.msg)
62 | })
63 | })
64 |
65 | var transforms = [
66 | {
67 | str: 'var x = function() {};\n',
68 | expect: 'var x = function () {};\n',
69 | msg: 'Anonymous function spacing between keyword and arguments'
70 | },
71 | {
72 | str: 'var x = function (y){};\n',
73 | expect: 'var x = function (y) {};\n',
74 | msg: 'Anonymous function spacing between arguments and opening brace'
75 | },
76 | {
77 | str: 'function xx() {}\n',
78 | expect: 'function xx () {}\n',
79 | msg: 'Named function spacing between keyword and arguments'
80 | },
81 | {
82 | str: 'function xx (y){}\n',
83 | expect: 'function xx (y) {}\n',
84 | msg: 'Named function spacing between arguments and opening brace'
85 | },
86 | {
87 | str: 'var hi = 1\n',
88 | expect: 'var hi = 1;\n',
89 | msg: 'Squash spaces around variable value'
90 | },
91 | {
92 | str: 'var hi = 1;\n',
93 | expect: 'var hi = 1;\n',
94 | msg: 'Space after variable name'
95 | },
96 | {
97 | str: 'var hi;\n hi = 1;\n',
98 | expect: 'var hi;\nhi = 1;\n',
99 | msg: 'Squash spaces around assignment operator'
100 | },
101 | {
102 | str: 'function foo (x,y,z) {}\n',
103 | expect: 'function foo (x, y, z) {}\n',
104 | msg: 'Space after commas in function parameters'
105 | },
106 | {
107 | str: 'var array = [1,2,3];\n',
108 | expect: 'var array = [1, 2, 3];\n',
109 | msg: 'Space after commas in array'
110 | },
111 | {
112 | str: 'var x = 1\n',
113 | expect: 'var x = 1;\n',
114 | msg: 'Add semicolons'
115 | },
116 | {
117 | str: 'var x = {key:123};\n',
118 | expect: 'var x = {key: 123};\n',
119 | msg: 'Space after colon (key-spacing)'
120 | },
121 | {
122 | str: 'var x = {key : 123};\n',
123 | expect: 'var x = {key: 123};\n',
124 | msg: 'No Space before colon (key-spacing)'
125 | },
126 | {
127 | str: 'if(true){}\n',
128 | expect: 'if (true) {}\n',
129 | msg: 'Space after if'
130 | },
131 | {
132 | str: 'if ( true ) {}\n',
133 | expect: 'if (true) {}\n',
134 | msg: 'Remove spaces inside conditional'
135 | },
136 | {
137 | str: 'var condition = ( x === y );\n',
138 | expect: 'var condition = (x === y);\n',
139 | msg: 'Remove spaces inside expression parentheses'
140 | },
141 | {
142 | str: 'function doStuff ( x, y ) {}\n',
143 | expect: 'function doStuff (x, y) {}\n',
144 | msg: 'Remove spaces inside parameter list parentheses'
145 | },
146 | {
147 | str: 'var x = 123 // Useful comment\n',
148 | expect: 'var x = 123; // Useful comment\n',
149 | msg: 'Add trailing semicolons that are followed by a comment'
150 | },
151 | {
152 | str: 'var x = 123 /* Useful comment */\n',
153 | expect: 'var x = 123; /* Useful comment */\n',
154 | msg: 'Add unneeded trailing semicolons that are followed by a multiline comment'
155 | },
156 | {
157 | str: 'console.log(1===2?3:4);\n',
158 | expect: 'console.log(1 === 2 ? 3 : 4);\n',
159 | msg: 'infix'
160 | },
161 | {
162 | str: 'const { message, rollup, line, col, type } = origMessage;\n',
163 | expect: 'const { message, rollup, line, col, type } = origMessage;\n',
164 | msg: 'No space before comma in keys in destructuring assignment'
165 | },
166 | {
167 | str: '//bad comment\n',
168 | expect: '// bad comment\n',
169 | msg: 'Expect space or tab after // in comment'
170 | }
171 | ]
172 |
173 | test('singleline transforms', function (t) {
174 | t.plan(transforms.length)
175 | transforms.forEach(function (obj) {
176 | t.equal(fmt(obj.str), obj.expect, obj.msg)
177 | })
178 | })
179 |
180 | var cr = new RegExp(/\n/g)
181 | var crlf = '\r\n'
182 |
183 | test('singleline transforms CRLF', function (t) {
184 | t.plan(transforms.length)
185 | transforms.forEach(function (obj) {
186 | obj.str = obj.str.replace(cr, crlf)
187 | obj.expect = obj.expect.replace(cr, crlf)
188 | t.equal(fmt(obj.str), obj.expect, obj.msg)
189 | })
190 | })
191 |
--------------------------------------------------------------------------------
/rc/esformatter.json:
--------------------------------------------------------------------------------
1 | {
2 | "indent" : {
3 | "ReturnStatement": ">=1",
4 | "value": " ",
5 | "alignComments": true,
6 | "ArrayExpression": 1,
7 | "ArrayPattern": 1,
8 | "ArrowFunctionExpression": 1,
9 | "AssignmentExpression": 1,
10 | "AssignmentExpression.BinaryExpression": 1,
11 | "AssignmentExpression.LogicalExpression": 1,
12 | "AssignmentExpression.UnaryExpression": 1,
13 | "CallExpression": 1,
14 | "CallExpression.BinaryExpression": 1,
15 | "CallExpression.LogicalExpression": 1,
16 | "CallExpression.UnaryExpression": 1,
17 | "CatchClause": 1,
18 | "ConditionalExpression": 1,
19 | "CommentInsideEmptyBlock": 1,
20 | "ClassDeclaration": 1,
21 | "DoWhileStatement": 1,
22 | "ForInStatement": 1,
23 | "ForOfStatement": 1,
24 | "ForStatement": 1,
25 | "FunctionDeclaration": 1,
26 | "FunctionExpression": 1,
27 | "IfStatement": 1,
28 | "MemberExpression": 1,
29 | "MultipleVariableDeclaration": 1,
30 | "NewExpression": 1,
31 | "ObjectExpression": 1,
32 | "ObjectExpression.BinaryExpression": 1,
33 | "ObjectExpression.LogicalExpression": 1,
34 | "ObjectExpression.UnaryExpression": 1,
35 | "ObjectPattern": 1,
36 | "ParameterList": 1,
37 | "SingleVariableDeclaration": 0,
38 | "SwitchCase": 1,
39 | "SwitchStatement": 1,
40 | "TopLevelFunctionBlock": 1,
41 | "TryStatement": 1,
42 | "VariableDeclaration.BinaryExpression": 1,
43 | "VariableDeclaration.LogicalExpression": 1,
44 | "VariableDeclaration.UnaryExpression": 1,
45 | "WhileStatement": 1
46 | },
47 |
48 | "lineBreak" : {
49 | "value" : "\n",
50 |
51 | "before" : {
52 | "AssignmentExpression" : -1,
53 | "AssignmentOperator": -1,
54 | "AssignmentPattern" : 0,
55 | "ArrayPatternOpening": 0,
56 | "ArrayPatternClosing": 0,
57 | "ArrayPatternComma": 0,
58 | "ArrowFunctionExpressionArrow": 0,
59 | "ArrowFunctionExpressionOpeningBrace": 0,
60 | "ArrowFunctionExpressionClosingBrace": "<=1",
61 | "BlockStatement" : -1,
62 | "BreakKeyword": ">=1",
63 | "CallExpression" : -1,
64 | "CallExpressionOpeningParentheses" : 0,
65 | "CallExpressionClosingParentheses" : -1,
66 | "ClassDeclaration" : ">=1",
67 | "ClassDeclarationOpeningBrace" : 0,
68 | "ClassDeclarationClosingBrace" : "<=1",
69 | "ConditionalExpression" : ">=1",
70 | "CatchOpeningBrace" : 0,
71 | "CatchClosingBrace" : "<=1",
72 | "CatchKeyword": 0,
73 | "DeleteOperator" : -1,
74 | "DoWhileStatement" : -1,
75 | "DoWhileStatementOpeningBrace" : 0,
76 | "DoWhileStatementClosingBrace" : "<=1",
77 | "EndOfFile" : 1,
78 | "EmptyStatement" : -1,
79 | "FinallyKeyword" : -1,
80 | "FinallyOpeningBrace" : 0,
81 | "FinallyClosingBrace" : "<=1",
82 | "ForInStatement" : -1,
83 | "ForInStatementExpressionOpening" : -1,
84 | "ForInStatementExpressionClosing" : -1,
85 | "ForInStatementOpeningBrace" : 0,
86 | "ForInStatementClosingBrace" : "<=1",
87 | "ForOfStatement" : ">=1",
88 | "ForOfStatementExpressionOpening" : 0,
89 | "ForOfStatementExpressionClosing" : 0,
90 | "ForOfStatementOpeningBrace" : 0,
91 | "ForOfStatementClosingBrace" : "<=1",
92 | "ForStatement" : -1,
93 | "ForStatementExpressionOpening" : -1,
94 | "ForStatementExpressionClosing" : -1,
95 | "ForStatementOpeningBrace" : 0,
96 | "ForStatementClosingBrace" : "<=1",
97 | "FunctionExpression" : -1,
98 | "FunctionExpressionOpeningBrace" : 0,
99 | "FunctionExpressionClosingBrace" : "<=1",
100 | "FunctionDeclaration" : -1,
101 | "FunctionDeclarationOpeningBrace" : 0,
102 | "FunctionDeclarationClosingBrace" : "<=1",
103 | "IIFEClosingParentheses" : 0,
104 | "IfStatement" : -1,
105 | "IfStatementOpeningBrace" : 0,
106 | "IfStatementClosingBrace" : "<=1",
107 | "ElseIfStatement" : -1,
108 | "ElseIfStatementOpeningBrace" : 0,
109 | "ElseIfStatementClosingBrace" : "<=1",
110 | "ElseStatement" : 0,
111 | "ElseStatementOpeningBrace" : 0,
112 | "ElseStatementClosingBrace" : "<=1",
113 | "LogicalExpression" : -1,
114 | "MethodDefinition": ">=1",
115 | "MemberExpressionOpening": 0,
116 | "MemberExpressionClosing": 0,
117 | "MemberExpressionPeriod": -1,
118 | "ObjectExpressionClosingBrace" : -1,
119 | "ObjectPatternOpeningBrace": 0,
120 | "ObjectPatternClosingBrace": 0,
121 | "ObjectPatternComma": 0,
122 | "Property" : -1,
123 | "PropertyValue" : 0,
124 | "ReturnStatement" : -1,
125 | "SwitchOpeningBrace" : 0,
126 | "SwitchClosingBrace" : -1,
127 | "ThisExpression" : -1,
128 | "ThrowStatement" : -1,
129 | "TryKeyword": -1,
130 | "TryOpeningBrace" : 0,
131 | "TryClosingBrace" : "<=1",
132 | "VariableName" : -1,
133 | "VariableValue" : -1,
134 | "VariableDeclaration" : -1,
135 | "VariableDeclarationSemiColon": -1,
136 | "VariableDeclarationWithoutInit" : -1,
137 | "WhileStatement" : -1,
138 | "WhileStatementOpeningBrace" : 0,
139 | "WhileStatementClosingBrace" : "<=1"
140 | },
141 |
142 | "after" : {
143 | "AssignmentExpression" : -1,
144 | "AssignmentOperator" : -1,
145 | "AssignmentPattern" : 0,
146 | "ArrayPatternOpening": 0,
147 | "ArrayPatternClosing": 0,
148 | "ArrayPatternComma": 0,
149 | "ArrowFunctionExpressionArrow": 0,
150 | "ArrowFunctionExpressionOpeningBrace": ">=1",
151 | "ArrowFunctionExpressionClosingBrace": -1,
152 | "BlockStatement" : -1,
153 | "BreakKeyword": -1,
154 | "CallExpression" : -1,
155 | "CallExpressionOpeningParentheses" : -1,
156 | "CallExpressionClosingParentheses" : -1,
157 | "ClassDeclaration" : ">=1",
158 | "ClassDeclarationOpeningBrace" : ">=1",
159 | "ClassDeclarationClosingBrace" : ">=1",
160 | "CatchOpeningBrace" : "<=1",
161 | "CatchClosingBrace" : -1,
162 | "CatchKeyword": 0,
163 | "ConditionalExpression" : -1,
164 | "DeleteOperator" : -1,
165 | "DoWhileStatement" : -1,
166 | "DoWhileStatementOpeningBrace" : "<=1",
167 | "DoWhileStatementClosingBrace" : -1,
168 | "EmptyStatement" : 1,
169 | "FinallyKeyword" : -1,
170 | "FinallyOpeningBrace" : "<=2",
171 | "FinallyClosingBrace" : -1,
172 | "ForInStatement" : -1,
173 | "ForInStatementExpressionOpening" : -1,
174 | "ForInStatementExpressionClosing" : -1,
175 | "ForInStatementOpeningBrace" : "<=1",
176 | "ForInStatementClosingBrace" : -1,
177 | "ForOfStatement" : -1,
178 | "ForOfStatementExpressionOpening" : "<2",
179 | "ForOfStatementExpressionClosing" : -1,
180 | "ForOfStatementOpeningBrace" : ">=1",
181 | "ForOfStatementClosingBrace" : ">=1",
182 | "ForStatement" : -1,
183 | "ForStatementExpressionOpening" : -1,
184 | "ForStatementExpressionClosing" : -1,
185 | "ForStatementOpeningBrace" : "<=1",
186 | "ForStatementClosingBrace" : -1,
187 | "FunctionExpression" : -1,
188 | "FunctionExpressionOpeningBrace" : "<=1",
189 | "FunctionExpressionClosingBrace" : -1,
190 | "FunctionDeclaration" : -1,
191 | "FunctionDeclarationOpeningBrace" : "<=1",
192 | "FunctionDeclarationClosingBrace" : -1,
193 | "IIFEOpeningParentheses" : 0,
194 | "IfStatement" : -1,
195 | "IfStatementOpeningBrace" : "<=1",
196 | "IfStatementClosingBrace" : -1,
197 | "ElseIfStatement" : -1,
198 | "ElseIfStatementOpeningBrace" : "<=1",
199 | "ElseIfStatementClosingBrace" : -1,
200 | "ElseStatement" : -1,
201 | "ElseStatementOpeningBrace" : "<=1",
202 | "ElseStatementClosingBrace" : -1,
203 | "LogicalExpression" : -1,
204 | "MethodDefinition": ">=1",
205 | "MemberExpressionOpening": 0,
206 | "MemberExpressionClosing" : ">=0",
207 | "MemberExpressionPeriod": 0,
208 | "ObjectExpressionOpeningBrace" : "<=1",
209 | "ObjectPatternOpeningBrace": 0,
210 | "ObjectPatternClosingBrace": 0,
211 | "ObjectPatternComma": 0,
212 | "Property" : -1,
213 | "PropertyName" : 0,
214 | "ReturnStatement" : -1,
215 | "SwitchOpeningBrace" : "<=1",
216 | "SwitchClosingBrace" : -1,
217 | "SwitchCaseColon": ">=1",
218 | "ThisExpression" : -1,
219 | "ThrowStatement" : -1,
220 | "TryKeyword": -1,
221 | "TryOpeningBrace" : "<=1",
222 | "TryClosingBrace" : -1,
223 | "VariableValue" : -1,
224 | "VariableDeclaration" : -1,
225 | "VariableDeclarationSemiColon" : ">=1",
226 | "WhileStatement" : -1,
227 | "WhileStatementOpeningBrace" : "<=1",
228 | "WhileStatementClosingBrace" : -1
229 | }
230 | },
231 |
232 |
233 | "whiteSpace" : {
234 | "value" : " ",
235 | "removeTrailing" : 1,
236 |
237 | "before" : {
238 | "AssignmentPattern" : 1,
239 | "ArrayExpressionOpening" : -1,
240 | "ArrayExpressionClosing" : -1,
241 | "ArrayExpressionComma" : -1,
242 | "ArrayPatternOpening": 1,
243 | "ArrayPatternClosing": 0,
244 | "ArrayPatternComma": 0,
245 | "ArrowFunctionExpressionArrow": 1,
246 | "ArrowFunctionExpressionOpeningBrace": 1,
247 | "ArrowFunctionExpressionClosingBrace": 0,
248 | "ArgumentComma" : -1,
249 | "ArgumentList" : 0,
250 | "AssignmentOperator" : 1,
251 | "BinaryExpression": -1,
252 | "BinaryExpressionOperator" : 1,
253 | "BlockComment" : 1,
254 | "CallExpression" : -1,
255 | "CallExpressionOpeningParentheses" : 0,
256 | "CallExpressionClosingParentheses" : -1,
257 | "CatchParameterList" : 0,
258 | "CatchOpeningBrace" : 1,
259 | "CatchClosingBrace" : 1,
260 | "CatchKeyword" : 1,
261 | "CommaOperator" : 0,
262 | "ClassDeclarationOpeningBrace" : 1,
263 | "ClassDeclarationClosingBrace" : 1,
264 | "ConditionalExpressionConsequent" : 1,
265 | "ConditionalExpressionAlternate" : 1,
266 | "DoWhileStatementOpeningBrace" : 1,
267 | "DoWhileStatementClosingBrace" : 1,
268 | "DoWhileStatementConditional" : 1,
269 | "EmptyStatement" : 0,
270 | "ExpressionClosingParentheses": 0,
271 | "FinallyKeyword" : -1,
272 | "FinallyOpeningBrace" : 1,
273 | "FinallyClosingBrace" : 1,
274 | "ForInStatement" : 1,
275 | "ForInStatementExpressionOpening" : 1,
276 | "ForInStatementExpressionClosing" : 0,
277 | "ForInStatementOpeningBrace" : 1,
278 | "ForInStatementClosingBrace" : 1,
279 | "ForOfStatement" : 1,
280 | "ForOfStatementExpressionOpening" : 1,
281 | "ForOfStatementExpressionClosing" : 0,
282 | "ForOfStatementOpeningBrace" : 1,
283 | "ForOfStatementClosingBrace" : 1,
284 | "ForStatement" : 1,
285 | "ForStatementExpressionOpening" : 1,
286 | "ForStatementExpressionClosing" : 0,
287 | "ForStatementOpeningBrace" : 1,
288 | "ForStatementClosingBrace" : -1,
289 | "ForStatementSemicolon" : 0,
290 | "FunctionDeclarationOpeningBrace" : 1,
291 | "FunctionDeclarationClosingBrace" : -1,
292 | "FunctionExpressionOpeningBrace" : 1,
293 | "FunctionExpressionClosingBrace" : -1,
294 | "FunctionGeneratorAsterisk": 1,
295 | "FunctionName" : 1,
296 | "IIFEClosingParentheses" : 0,
297 | "IfStatementConditionalOpening" : 1,
298 | "IfStatementConditionalClosing" : 0,
299 | "IfStatementOpeningBrace" : 1,
300 | "IfStatementClosingBrace" : -1,
301 | "ModuleSpecifierClosingBrace": 1,
302 | "ElseStatementOpeningBrace" : 1,
303 | "ElseStatementClosingBrace" : -1,
304 | "ElseIfStatementOpeningBrace" : 1,
305 | "ElseIfStatementClosingBrace" : -1,
306 | "LineComment" : 1,
307 | "LogicalExpressionOperator" : 1,
308 | "MemberExpressionOpening": 0,
309 | "MemberExpressionClosing" : -1,
310 | "MemberExpressionPeriod": 0,
311 | "ObjectExpressionOpeningBrace": -1,
312 | "ObjectExpressionClosingBrace": -1,
313 | "ObjectPatternOpeningBrace": -1,
314 | "ObjectPatternClosingBrace": -1,
315 | "ObjectPatternComma": 0,
316 | "Property" : -1,
317 | "PropertyValue" : 1,
318 | "ParameterComma" : -1,
319 | "ParameterList" : 0,
320 | "SwitchDiscriminantOpening" : 1,
321 | "SwitchDiscriminantClosing" : -1,
322 | "SwitchCaseColon": 0,
323 | "ThrowKeyword": -1,
324 | "TryKeyword": -1,
325 | "TryOpeningBrace" : 1,
326 | "TryClosingBrace" : -1,
327 | "UnaryExpressionOperator": -1,
328 | "VariableName" : -1,
329 | "VariableValue" : 1,
330 | "VariableDeclarationSemiColon" : 0,
331 | "WhileStatementConditionalOpening" : -1,
332 | "WhileStatementConditionalClosing" : -1,
333 | "WhileStatementOpeningBrace" : -1,
334 | "WhileStatementClosingBrace" : -1
335 | },
336 |
337 | "after" : {
338 | "AssignmentPattern" : 1,
339 | "ArrayExpressionOpening" : -1,
340 | "ArrayExpressionClosing" : -1,
341 | "ArrayExpressionComma" : 1,
342 | "ArrayPatternOpening": 0,
343 | "ArrayPatternClosing": 1,
344 | "ArrayPatternComma": 1,
345 | "ArrowFunctionExpressionArrow": 1,
346 | "ArrowFunctionExpressionOpeningBrace": 0,
347 | "ArrowFunctionExpressionClosingBrace": 0,
348 | "ArgumentComma" : 1,
349 | "ArgumentList" : 0,
350 | "AssignmentOperator" : 1,
351 | "BinaryExpression": -1,
352 | "BinaryExpressionOperator" : 1,
353 | "BlockComment" : -1,
354 | "CallExpression" : -1,
355 | "CallExpressionOpeningParentheses" : -1,
356 | "CallExpressionClosingParentheses" : -1,
357 | "CatchParameterList" : -1,
358 | "CatchOpeningBrace" : -1,
359 | "CatchClosingBrace" : -1,
360 | "CatchKeyword" : -1,
361 | "ClassDeclarationOpeningBrace" : 1,
362 | "ClassDeclarationClosingBrace" : 1,
363 | "CommaOperator" : 1,
364 | "ConditionalExpressionConsequent" : 1,
365 | "ConditionalExpressionTest" : 1,
366 | "DoWhileStatementOpeningBrace" : -1,
367 | "DoWhileStatementClosingBrace" : -1,
368 | "DoWhileStatementBody" : -1,
369 | "EmptyStatement" : -1,
370 | "ExpressionOpeningParentheses" : 0,
371 | "FinallyKeyword" : -1,
372 | "FinallyOpeningBrace" : -1,
373 | "FinallyClosingBrace" : -1,
374 | "ForInStatement" : -1,
375 | "ForInStatementExpressionOpening" : -1,
376 | "ForInStatementExpressionClosing" : -1,
377 | "ForInStatementOpeningBrace" : -1,
378 | "ForInStatementClosingBrace" : -1,
379 | "ForStatement" : -1,
380 | "ForStatementExpressionOpening" : -1,
381 | "ForStatementExpressionClosing" : -1,
382 | "ForStatementClosingBrace" : -1,
383 | "ForStatementOpeningBrace" : -1,
384 | "ForStatementSemicolon" : -1,
385 | "FunctionReservedWord": 1,
386 | "FunctionName" : 1,
387 | "FunctionExpressionOpeningBrace" : -1,
388 | "FunctionExpressionClosingBrace" : -1,
389 | "FunctionDeclarationOpeningBrace" : -1,
390 | "FunctionDeclarationClosingBrace" : -1,
391 | "IIFEOpeningParentheses" : 0,
392 | "IfStatementConditionalOpening" : 0,
393 | "IfStatementConditionalClosing" : -1,
394 | "IfStatementOpeningBrace" : -1,
395 | "IfStatementClosingBrace" : -1,
396 | "ModuleSpecifierOpeningBrace": 1,
397 | "ElseStatementOpeningBrace" : -1,
398 | "ElseStatementClosingBrace" : -1,
399 | "ElseIfStatementOpeningBrace" : -1,
400 | "ElseIfStatementClosingBrace" : -1,
401 | "MemberExpressionOpening" : -1,
402 | "MemberExpressionClosing": 0,
403 | "MemberExpressionPeriod": 0,
404 | "MethodDefinitionName" : 1,
405 | "LogicalExpressionOperator" : 1,
406 | "ObjectExpressionOpeningBrace": -1,
407 | "ObjectExpressionClosingBrace": -1,
408 | "ObjectPatternOpeningBrace": -1,
409 | "ObjectPatternClosingBrace": -1,
410 | "ObjectPatternComma": 1,
411 | "PropertyName" : 0,
412 | "PropertyValue" : -1,
413 | "ParameterComma" : 1,
414 | "ParameterList" : 0,
415 | "SwitchDiscriminantOpening" : -1,
416 | "SwitchDiscriminantClosing" : 1,
417 | "ThrowKeyword": -1,
418 | "TryKeyword": -1,
419 | "TryOpeningBrace" : -1,
420 | "TryClosingBrace" : -1,
421 | "UnaryExpressionOperator": -1,
422 | "VariableName" : 1,
423 | "VariableValue" : 0,
424 | "VariableDeclarationSemiColon": -1,
425 | "WhileStatementConditionalOpening" : -1,
426 | "WhileStatementConditionalClosing" : -1,
427 | "WhileStatementOpeningBrace" : -1,
428 | "WhileStatementClosingBrace" : -1
429 | }
430 | },
431 |
432 | "jsx": {
433 | "formatJSX": true,
434 | "attrsOnSameLineAsTag": false,
435 | "maxAttrsOnTag": 3,
436 | "firstAttributeOnSameLine": false,
437 | "alignWithFirstAttribute": false,
438 | "spaceInJSXExpressionContainers": "",
439 | "htmlOptions": {
440 | "brace_style": "collapse",
441 | "indent_char": " ",
442 | "indent_size": 2,
443 | "max_preserve_newlines": 2,
444 | "preserve_newlines": true
445 | }
446 | },
447 |
448 | "plugins": [
449 | "esformatter-quotes",
450 | "esformatter-literal-notation",
451 | "esformatter-spaced-lined-comment",
452 | "esformatter-semicolons",
453 | "esformatter-semicolon-first",
454 | "esformatter-jsx"
455 | ],
456 |
457 | "quotes": {
458 | "type": "single",
459 | "avoidEscape": true
460 | }
461 | }
462 |
--------------------------------------------------------------------------------
/test/failing/obfuscated-files/standard-format-torture.js:
--------------------------------------------------------------------------------
1 | this.gbar_ = this.gbar_ || {};(function(_){var window=this;
2 | try{
3 | _.jb = function(a){var c=_.La;c.d? a(): c.b.push(a)};_.kb = function(){};_.lb = function(a){_.lb[" "](a);return a};_.lb[" "] = _.kb;
4 | } catch( e) {_._DumpException(e) }
5 | try{
6 | var gh;gh = function(a){if(a.classList)return a.classList;a = a.className;return _.t(a) && a.match(/\S+/g) || []};_.Q = function(a,c){return a.classList? a.classList.contains(c): _.ra(gh(a),c)};_.R = function(a,c){a.classList? a.classList.add(c): _.Q(a,c) || (a.className += 0 < a.className.length? " " + c: c)};
7 | _.hh = function(a,c){if(a.classList)(0, _.ma)(c,function(c){_.R(a,c)}); else{var d={};(0, _.ma)(gh(a),function(a){d[a] = !0});(0, _.ma)(c,function(a){d[a] = !0});a.className = ""; for (var e in d)a.className += 0 < a.className.length? " " + e: e}};_.S = function(a,c){a.classList? a.classList.remove(c): _.Q(a,c) && (a.className = (0, _.na)(gh(a),function(a){return a != c}).join(" "))};_.ih = function(a,c){a.classList? (0, _.ma)(c,function(c){_.S(a,c)}): a.className = (0, _.na)(gh(a),function(a){return !_.ra(c,a)}).join(" ")};
8 |
9 | } catch( e) {_._DumpException(e) }
10 | try{
11 | var ak,ik,lk,kk;_.Vj = function(a){_.A(this,a,0,null)};_.w(_.Vj,_.z);_.Wj = function(){return _.D(_.J(),_.Vj,11)};_.Xj = function(a){_.A(this,a,0,null)};_.w(_.Xj,_.z);_.Zj = function(){var a=_.Yj();return _.B(a,9)};ak = function(a){_.A(this,a,0,null)};_.w(ak,_.z);_.bk = function(a){return null != _.B(a,2)? _.B(a,2): .001};_.ck = function(a){_.A(this,a,0,null)};_.w(_.ck,_.z);var dk=function(a){return null != _.B(a,3)? _.B(a,3): 1},ek=function(a){return null != _.B(a,2)? _.B(a,2): 1E-4},fk=function(a){_.A(this,a,0,null)};
12 | _.w(fk,_.z);_.gk = function(a){return _.B(a,10)};_.hk = function(a){return _.B(a,5)};_.Yj = function(){return _.D(_.J(),ak,4) || new ak};_.jk = function(a){var c="//www.google.com/gen_204?",c=c + a.d(2040 - c.length);ik(c)};ik = function(a){var c=new window.Image,d=kk;c.onerror = c.onload = c.onabort = function(){d in lk && delete lk[d]};lk[kk++] = c;c.src = a};lk = [];kk = 0;
13 | _.mk = function(){this.data = {}};_.mk.prototype.b = function(){window.console && window.console.log && window.console.log("Log data: ",this.data)};_.mk.prototype.d = function(a){var c=[],d; for (d in this.data)c.push((0, window.encodeURIComponent)(d) + "=" + (0, window.encodeURIComponent)(String(this.data[d])));return ("atyp=i&zx=" + (new Date).getTime() + "&" + c.join("&")).substr(0,a)};
14 | var nk=function(a){this.b = a};nk.prototype.log = function(a,c){try{if(this.A(a)){var d=this.k(a,c);this.d(d)}} catch( e) {}};nk.prototype.d = function(a){this.b? a.b(): _.jk(a)};var ok=function(a,c){this.data = {};var d=_.D(a,_.wa,8) || new _.wa;this.data.ei = _.G(_.gk(a));this.data.ogf = _.G(_.B(d,3));var e;e = window.google && window.google.sn? /.*hp$/.test(window.google.sn)? !1: !0: _.F(_.B(a,7));this.data.ogrp = e? "1": "";this.data.ogv = _.G(_.B(d,6)) + "." + _.G(_.B(d,7));this.data.ogd = _.G(_.B(a,21));this.data.ogc = _.G(_.B(a,20));this.data.ogl = _.G(_.hk(a));c && (this.data.oggv = c)};_.w(ok,_.mk);
15 | _.pk = function(a,c,d,e,f){ok.call(this,a,c);_.ua(this.data,{jexpid:_.G(_.B(a,9)),srcpg:"prop=" + _.G(_.B(a,6)),jsr:Math.round(1 / e),emsg:d.name + ":" + d.message});if(f){f._sn && (f._sn = "og." + f._sn); for (var g in f)this.data[(0, window.encodeURIComponent)(g)] = f[g]}};_.w(_.pk,ok);
16 | var qk=[1, 2, 3, 4, 5, 6, 9, 10, 11, 13, 14, 28, 29, 30, 34, 35, 37, 38, 39, 40, 41, 42, 43, 48, 49, 50, 51, 52, 53, 500],tk=function(a,c,d,e,f,g){ok.call(this,a,c);_.ua(this.data,{oge:e,ogex:_.G(_.B(a,9)),ogp:_.G(_.B(a,6)),ogsr:Math.round(1 / (rk(e)? _.H(dk(d)): _.H(ek(d)))),ogus:f});if(g){"ogw" in g && (this.data.ogw = g.ogw, delete g.ogw);"ved" in g && (this.data.ved = g.ved, delete g.ved);a = []; for (var h in g)0 != a.length && a.push(","), a.push(sk(h)), a.push("."), a.push(sk(g[h]));g = a.join("");"" != g && (this.data.ogad = g)}};_.w(tk,ok); var sk=function(a){return (a + "").replace(".","%2E").replace(",","%2C")},uk=null,rk=function(a){if(!uk){uk = {}; for (var c=0;c < qk.length;c++)uk[qk[c]] = !0}return !!uk[a]};
17 | var vk=function(a,c,d,e,f){this.b = f;this.F = a;this.O = c;this.ea = e;this.B = _.H(ek(a),1E-4);this.w = _.H(dk(a),1);c = Math.random();this.C = _.F(_.B(a,1)) && c < this.B;this.o = _.F(_.B(a,1)) && c < this.w;a = 0;_.F(_.B(d,1)) && (a |= 1);_.F(_.B(d,2)) && (a |= 2);_.F(_.B(d,3)) && (a |= 4);this.J = a};_.w(vk,nk);vk.prototype.A = function(a){return this.b || (rk(a)? this.o: this.C)};vk.prototype.k = function(a,c){return new tk(this.O,this.ea,this.F,a,this.J,c)};
18 | var wk=function(a,c,d,e){this.b = e;this.F = c;this.ea = d;this.w = _.H(_.bk(a),.001);this.O = _.F(_.B(a,1)) && Math.random() < this.w;c = null != _.B(a,3)? _.B(a,3): 1;this.C = _.H(c,1);this.o = 0;a = null != _.B(a,4)? _.B(a,4): !0;this.B = _.F(a,!0)};_.w(wk,nk);wk.prototype.log = function(a,c){wk.G.log.call(this,a,c);if(this.b && this.B)throw a;};wk.prototype.A = function(){return this.b || this.O && this.o < this.C};wk.prototype.k = function(a,c){try{return _.za(_.ya.N(),"lm").uf(a,c)} catch( d) {return new _.pk(this.F,this.ea,a,this.w,c) }}; wk.prototype.d = function(a){wk.G.d.call(this,a);this.o++};
19 | var xk;xk = null;_.yk = function(){if(!xk){var a=_.D(_.J(),_.ck,13) || new _.ck,c=_.Na(),d=_.Zj();xk = new wk(a,c,d,_.Ja)}return xk};_.I = function(a,c){_.yk().log(a,c)};_.zk = function(a,c){return function(){try{return a.apply(c,arguments)} catch( d) {_.I(d) }}};var Ak;Ak = null;_.Bk = function(){if(!Ak){var a=_.D(_.J(),fk,12) || new fk,c=_.Na(),d=_.Wj() || new _.Vj,e=_.Zj();Ak = new vk(a,c,d,e,_.Ja)}return Ak};_.U = function(a,c){_.Bk().log(a,c)};_.U(8,{m:"BackCompat" == window.document.compatMode? "q": "s"});
20 | } catch( e) {_._DumpException(e) }
21 | try{
22 | var Ck,Gk,Ik;Ck = [3, 5];_.Dk = function(a){_.A(this,a,0,Ck)};_.w(_.Dk,_.z);var Ek=function(a){_.A(this,a,0,null)};_.w(Ek,_.z);_.Fk = function(a){_.A(this,a,0,null)};_.w(_.Fk,_.z);_.Fk.prototype.Qa = function(){return _.B(this,6)};
23 | _.Hk = function(a,c,d,e,f,g){_.y.call(this);this.F = c;this.J = f;this.o = g;this.S = !1;this.k = {"":!0};this.H = {"":!0};this.A = [];this.w = [];this.R = ["//" + _.G(_.B(a,2)), "og/_/js", "k=" + _.G(_.B(a,3)), "rt=j"];this.O = "" == _.G(_.B(a,14))? null: _.B(a,14);this.K = ["//" + _.G(_.B(a,2)), "og/_/ss", "k=" + _.G(_.B(a,13))];this.B = "" == _.G(_.B(a,15))? null: _.B(a,15);this.U = _.F(_.B(a,1))? "?host=www.gstatic.com&bust=" + _.G(_.B(a,16)): "";this.T = _.F(_.B(a,1))? "?host=www.gstatic.com&bust=" + 1E11 * Math.random(): "";this.d = d;_.B(a,19);a = null !=
24 | _.B(a,17)? _.B(a,17): 1;this.b = _.H(a,1);a = 0; for (c = e[a];a < e.length;a++, c = e[a])Gk(this,c,!0)};_.w(_.Hk,_.y);_.Aa(_.Hk,"m");Gk = function(a,c,d){if(!a.k[c] && (a.k[c] = !0, d && a.d[c])) for (var e=0;e < a.d[c].length;e++)Gk(a,a.d[c][e],d)};Ik = function(a,c){ for (var d=[],e=0;e < c.length;e++) {var f=c[e];if(!a.k[f]){var g=a.d[f];g && (g = Ik(a,g), d = d.concat(g));d.push(f);a.k[f] = !0}}return d};
25 | _.Kk = function(a,c,d){c = Ik(a,c);0 < c.length && (c = a.R.join("/") + "/" + ("m=" + c.join(",")), a.O && (c += "/rs=" + a.O), c = c + a.U, Jk(a,c,(0, _.u)(a.P,a,d)), a.A.push(c))};_.Hk.prototype.P = function(a){_.E("api").Ta(); for (var c=0;c < this.w.length;c++)this.w[c].call(null);a && a.call(null)};
26 | var Jk=function(a,c,d,e){var f=window.document.createElement("SCRIPT");f.async = !0;f.type = "text/javascript";f.charset = "UTF-8";f.src = c;var g=!0,h=e || 1;e = (0, _.u)(function(){g = !1;this.o.log(47,{att:h,max:a.b,url:c});h < a.b? Jk(a,c,d,h + 1): this.J.log(Error("V`" + h + "`" + a.b),{url:c})},a);var l=(0, _.u)(function(){g && (this.o.log(46,{att:h,max:a.b,url:c}), g = !1, d && d.call(null))},a),q=function(a){"loaded" == a.readyState || "complete" == a.readyState? l(): g && window.setTimeout(function(){q(a)},100)};"undefined" !== typeof f.addEventListener?
27 | f.onload = function(){l()}: f.onreadystatechange = function(){f.onreadystatechange = null;q(f)};f.onerror = e;a.o.log(45,{att:h,max:a.b,url:c});window.document.getElementsByTagName("HEAD")[0].appendChild(f)};_.Hk.prototype.Jd = function(a,c){ for (var d=[],e=0,f=a[e];e < a.length;e++, f = a[e])this.H[f] || (d.push(f), this.H[f] = !0);0 < d.length && (d = this.K.join("/") + "/" + ("m=" + d.join(",")), this.B && (d += "/rs=" + this.B), d += this.T, Lk(d,c))};
28 | var Lk=function(a,c){var d=window.document.createElement("LINK");d.setAttribute("rel","stylesheet");d.setAttribute("type","text/css");d.setAttribute("href",a);d.onload = d.onreadystatechange = function(){d.readyState && "loaded" != d.readyState && "complete" != d.readyState || c && c.call(null)};window.document.getElementsByTagName("HEAD")[0].appendChild(d)};
29 | _.Hk.prototype.C = function(a){this.S || (void 0 != a? window.setTimeout((0, _.u)(this.C,this,void 0),a): (_.Kk(this,_.B(this.F,1),(0, _.u)(this.Q,this)), this.Jd(_.B(this.F,2)), this.S = !0))};_.Hk.prototype.Q = function(){_.v("gbar.qm",(0, _.u)(function(a){try{a()} catch( c) {this.J.log(c) }},this))};
30 | var Mk=function(a,c){var d={};d._sn = ["v.gas", c].join(".");_.I(a,d)};var Nk=["gbq1", "gbq2", "gbqfbwa"],Ok=function(a){var c=window.document.getElementById("gbqld");c && (c.style.display = a? "none": "block", c = window.document.getElementById("gbql")) && (c.style.display = a? "block": "none")};var Pk=function(){};var Qk=function(a,c,d){this.d = a;this.k = c;this.b = d || _.m};var Rk=function(){this.b = []};Rk.prototype.A = function(a,c,d){this.F(a,c,d);this.b.push(new Qk(a,c,d))};Rk.prototype.F = function(a,c,d){d = d || _.m; for (var e=0,f=this.b.length;e < f;e++) {var g=this.b[e];if(g.d == a && g.k == c && g.b == d){this.b.splice(e,1);break}}};Rk.prototype.w = function(a){ for (var c=0,d=this.b.length;c < d;c++) {var e=this.b[c];"hrc" == e.d && e.k.call(e.b,a)}};
31 | var Sk,Uk,Vk,Wk,Xk;Sk = null;_.Tk = function(){if(null != Sk)return Sk;var a=window.document.body.style;if(!(a = "flexGrow" in a || "webkitFlexGrow" in a))a:{if(a = window.navigator.userAgent){var c=/Trident\/(\d+)/.exec(a);if(c && 7 <= Number(c[1])){a = /\bMSIE (\d+)/.exec(a);a = !a || "10" == a[1];break a}}a = !1}return Sk = a};
32 | Uk = function(a,c,d){var e=window.NaN;window.getComputedStyle && (a = window.getComputedStyle(a,null).getPropertyValue(c)) && "px" == a.substr(a.length - 2) && (e = d? (0, window.parseFloat)(a.substr(0,a.length - 2)): (0, window.parseInt)(a.substr(0,a.length - 2),10));return e};
33 | Vk = function(a){var c=a.offsetWidth,d=Uk(a,"width");if(!(0, window.isNaN)(d))return c - d;var e=a.style.padding,f=a.style.paddingLeft,g=a.style.paddingRight;a.style.padding = a.style.paddingLeft = a.style.paddingRight = 0;d = a.clientWidth;a.style.padding = e;a.style.paddingLeft = f;a.style.paddingRight = g;return c - d};
34 | Wk = function(a){var c=Uk(a,"min-width");if(!(0, window.isNaN)(c))return c;var d=a.style.width,e=a.style.padding,f=a.style.paddingLeft,g=a.style.paddingRight;a.style.width = a.style.padding = a.style.paddingLeft = a.style.paddingRight = 0;c = a.clientWidth;a.style.width = d;a.style.padding = e;a.style.paddingLeft = f;a.style.paddingRight = g;return c};Xk = function(a,c){c || -.5 != a - Math.round(a) || (a -= .5);return Math.round(a)}; _.Yk = function(a){if(a){var c=a.style.opacity;a.style.opacity = ".99";_.lb(a.offsetWidth);a.style.opacity = c}};
35 | var Zk=function(a){_.y.call(this);this.b = a;this.d = [];this.k = []};_.w(Zk,_.y);Zk.prototype.L = function(){Zk.G.L.call(this);this.b = null; for (var a=0;a < this.d.length;a++)this.d[a].Y(); for (a = 0;a < this.k.length;a++)this.k[a].Y();this.d = this.k = null};
36 | Zk.prototype.La = function(a){void 0 == a && (a = this.b.offsetWidth); for (var c=Vk(this.b),d=[],e=0,f=0,g=0,h=0,l=0;l < this.d.length;l++) {var q=this.d[l],r=$k(q),x=Vk(q.b);d.push({item:q,gb:r,sh:x,tc:0});e += r.Gc;f += r.Vc;g += r.Sb;h += x}a = a - h - c - g;e = 0 < a? e: f;f = a;c = d;do {g = !0;h = []; for (l = q = 0;l < c.length;l++) {var r=c[l],x=0 < f? r.gb.Gc: r.gb.Vc,C=0 == e? 0: x / e * f + r.tc,C=Xk(C,g),g=!g;r.tc = al(r.item,C,r.sh,r.gb.Sb);0 < x && C == r.tc && (h.push(r), q += x)}c = h;f = a - (0, _.pa)(d,function(a,c){return a + c.tc},0);e = q } while (0 != f && 0 != c.length);
37 | for (l = 0;l < this.k.length;l++)this.k[l].La()};var cl=function(a){var c={};c.items = (0, _.oa)(a.d,function(a){return bl(a)});c.children = (0, _.oa)(a.k,function(a){return cl(a)});return c},dl=function(a,c){ for (var d=0;d < a.d.length;d++)a.d[d].b.style.width = c.items[d]; for (d = 0;d < a.k.length;d++)dl(a.k[d],c.children[d])};Zk.prototype.M = function(){return this.b};
38 | var el=function(a,c,d,e){Zk.call(this,a);this.w = c;this.A = d;this.o = e};_.w(el,Zk);
39 | var $k=function(a,c){var d=a.w,e=a.A,f;if(-1 == a.o){var g=c;void 0 == g && (g = Vk(a.b));f = bl(a);var h=cl(a),l=Uk(a.b,"width",!0);(0, window.isNaN)(l) && (l = a.b.offsetWidth - g);g = Math.ceil(l);a.b.style.width = f;dl(a,h);f = g}else f = a.o;return {Gc:d,Vc:e,Sb:f}},al=function(a,c,d,e){void 0 == d && (d = Vk(a.b));void 0 == e && (e = $k(a,d).Sb);c = e + c;0 > c && (c = 0);a.b.style.width = c + "px";d = a.b.offsetWidth - d;a.b.style.width = d + "px";return d - e},bl=function(a){var c=a.b.style.width;a.b.style.width = "";return c};
40 | var fl=function(a,c,d){var e;void 0 == e && (e = -1);return {className:a,gb:{Gc:c || 0,Vc:d || 0,Sb:e}}},gl={className:"gb_3b",items:[fl("gb_Ua"), fl("gb_ic"), fl("gb_Mb",0,2), fl("gb_jc"), fl("gb_ea",1,1)],eb:[{className:"gb_ea",items:[fl("gb_Lc",0,1), fl("gb_Kc",0,1)],eb:[function(a){a = a.gb_Lc;var c;if(a)c = a.M(); else{c = window.document.querySelector(".gb_Lc");if(!c)return null;a = new Zk(c)}c = c.querySelectorAll(".gb_m"); for (var d=0;d < c.length;d++) {var e;if(_.Q(c[d],"gb_o")){e = new el(c[d],0,1,-1);var f=c[d].querySelector(".gb_l");
41 | f && (f = new el(f,0,1,-1), e.d.push(f), a.k.push(e))}else e = new el(c[d],0,0,-1);a.d.push(e)}return a}, {className:"gb_Kc",items:[fl("gb_J"), fl("gb_4a"), fl("gb_Zb"), fl("gb_ma",0,1), fl("gb_Mc"), fl("gb_ia",0,1), fl("gb_Nc"), fl("gb_lc")],eb:[{className:"gb_ma",items:[fl("gb_oa",0,1)],eb:[{className:"gb_oa",items:[fl("gb_ka",0,1)],eb:[]}]}]}]}, {className:"gb_fc",items:[fl("gbqff",1,1), fl("gb_ec")],eb:[]}]},hl=function(a,c){var d=c;if(!d){d = window.document.querySelector("." + a.className);if(!d)return null;d = new Zk(d)} for (var e=
42 | {},f=0;f < a.items.length;f++) {var g=a.items[f],h;h = g;var l=window.document.querySelector("." + h.className);if(h = l? new el(l,h.gb.Gc,h.gb.Vc,h.gb.Sb): null)d.d.push(h), e[g.className] = h} for (f = 0;f < a.eb.length;f++) {var g=a.eb[f],q;"function" == typeof g? q = g(e): q = hl(g,e[g.className]);q && d.k.push(q)}return d};
43 | _.kl = function(a){_.y.call(this);this.B = new Rk;this.d = window.document.getElementById("gb");this.O = (this.b = window.document.querySelector(".gb_ea"))? this.b.querySelector(".gb_Kc"): null;this.C = [];this.he = 60;this.J = _.B(a,4);this.Bh = _.H(_.B(a,2),152);this.If = _.H(_.B(a,1),30);this.k = null;this.Ke = _.F(_.B(a,3),!0);this.o = 1;this.d && this.J && (this.d.style.minWidth = this.J + "px");_.il(this);this.Ke && (this.d && (jl(this), _.R(this.d,"gb_p"), this.b && _.R(this.b,"gb_p"), _.Tk() || (this.k = hl(gl))), this.La(), window.setTimeout((0, _.u)(this.La,
44 | this),0));_.v("gbar.elc",(0, _.u)(this.K,this));_.v("gbar.ela",_.kb);_.v("gbar.elh",(0, _.u)(this.S,this))};_.w(_.kl,_.y);_.Aa(_.kl,"el");var ll=function(){var a=_.kl.Lh();return {es:a? {f:a.Bh,h:a.he,m:a.If}: {f:152,h:60,m:30},mo:"md",vh:window.innerHeight || 0,vw:window.innerWidth || 0}};_.kl.prototype.L = function(){_.kl.G.L.call(this)};_.kl.prototype.La = function(a){a && jl(this);this.k && this.k.La(Math.max(window.document.documentElement.clientWidth,Wk(this.d)));_.Yk(this.b)};
45 | _.kl.prototype.H = function(){try{var a=window.document.getElementById("gb"),c=a.querySelector(".gb_ea");_.S(a,"gb_3c");c && _.S(c,"gb_3c"); for (var a=0,d;d = Nk[a];a++) {var e=window.document.getElementById(d);e && _.S(e,"gbqfh")}Ok(!1)} catch( f) {Mk(f,"rhcc") }this.La(!0)};_.kl.prototype.T = function(){try{var a=window.document.getElementById("gb"),c=a.querySelector(".gb_ea");_.R(a,"gb_3c");c && _.R(c,"gb_3c"); for (var a=0,d;d = Nk[a];a++)_.R(window.document.getElementById(d),"gbqfh");Ok(!0)} catch( e) {Mk(e,"ahcc") }this.La(!0)};
46 | _.il = function(a){if(a.d){var c=a.d.offsetWidth;0 == a.o? 900 <= c && (a.o = 1, a.w(new Pk)): 900 > c && (a.o = 0, a.w(new Pk))}};_.kl.prototype.K = function(a){this.C.push(a)};_.kl.prototype.S = function(a){var c=ll().es.h;this.he = c + a; for (a = 0;a < this.C.length;a++)try{this.C[a](ll())} catch( d) {_.I(d) }};var jl=function(a){if(a.b){var c;a.k && (c = cl(a.k));_.R(a.b,"gb_s");a.b.style.minWidth = a.b.offsetWidth - Vk(a.b) + "px";a.O.style.minWidth = a.O.offsetWidth - Vk(a.O) + "px";_.S(a.b,"gb_s");c && dl(a.k,c)}}; _.kl.prototype.A = function(a,c,d){this.B.A(a,c,d)};_.kl.prototype.F = function(a,c){this.B.F(a,c)};_.kl.prototype.w = function(a){this.B.w(a)};
47 | _.jb(function(){var a=_.D(_.J(),Ek,21) || new Ek,a=new _.kl(a);_.Ca("el",a);_.v("gbar.gpca",(0, _.u)(a.T,a));_.v("gbar.gpcr",(0, _.u)(a.H,a))});_.v("gbar.elr",ll);_.ml = function(a){this.k = _.kl.N();this.d = a};_.ml.prototype.b = function(a,c){0 == this.k.o? (_.R(a,"gb_r"), c? (_.S(a,"gb_la"), _.R(a,"gb_Oc")): (_.S(a,"gb_Oc"), _.R(a,"gb_la"))): _.ih(a,["gb_r", "gb_la", "gb_Oc"])};_.v("gbar.sos",function(){return window.document.querySelectorAll(".gb_hc")});_.v("gbar.si",function(){return window.document.querySelector(".gb_gc")});
48 | _.jb(function(){if(_.D(_.J(),_.Dk,16)){var a=window.document.querySelector(".gb_ea"),c=_.D(_.J(),_.Dk,16) || new _.Dk,c=_.F(_.B(c,1),!1),c=new _.ml(c);a && c.d && c.b(a,!1)}});
49 | } catch( e) {_._DumpException(e) }
50 | try{
51 | var nl=function(){_.La.k(_.I)};var ol=function(a,c){var d=_.zk(nl);a.addEventListener? a.addEventListener(c,d): a.attachEvent("on" + c,d)};var pl=[1, 2],ql=function(a,c){a.w.push(c)},rl=function(a){_.A(this,a,0,pl)};_.w(rl,_.z);var sl=function(){_.y.call(this);this.o = this.b = null;this.d = {};this.w = {};this.k = {}};_.w(sl,_.y);_.k = sl.prototype;_.k.Ze = function(a){a && this.b && a != this.b && this.b.close();this.b = a};_.k.Me = function(a){a = this.k[a] || a;return this.b == a};_.k.Fh = function(a){this.o = a};
52 | _.k.Le = function(a){return this.o == a};_.k.hd = function(){this.b && this.b.close();this.b = null};_.k.tf = function(a){this.b && this.b.getId() == a && this.hd()};_.k.Pb = function(a,c,d){this.d[a] = this.d[a] || {};this.d[a][c] = this.d[a][c] || [];this.d[a][c].push(d)};_.k.fd = function(a,c){var d=c.getId();if(this.d[a] && this.d[a][d]) for (var e=0;e < this.d[a][d].length;e++)try{this.d[a][d][e]()} catch( f) {_.I(f) }};_.k.Hh = function(a,c){this.w[a] = c};_.k.rf = function(a){return !this.w[a.getId()]};
53 | _.k.Qg = function(){return !!this.b && this.b.V};_.k.qf = function(){return !!this.b};_.k.Re = function(){this.b && this.b.la()};_.k.cf = function(a){this.k[a] && (this.b && this.b.getId() == a || this.k[a].open())};_.k.jh = function(a){this.k[a.getId()] = a};var tl;window.gbar && window.gbar._DPG? tl = window.gbar._DPG[0] || {}: tl = {};var ul;window.gbar && window.gbar._LDD? ul = window.gbar._LDD: ul = [];var vl=_.Na(),wl=new _.Hk(vl,_.D(_.J(),rl,17) || new rl,tl,ul,_.yk(),_.Bk());_.Ca("m",wl); if(_.F(_.B(vl,18),!0))wl.C(); else{var xl=_.H(_.B(vl,19),200),yl=(0, _.u)(wl.C,wl,xl);_.jb(yl)}ol(window.document,"DOMContentLoaded");ol(window,"load");
54 | _.v("gbar.ldb",(0, _.u)(_.La.k,_.La));_.v("gbar.mls",function(){});var zl=function(){_.y.call(this);this.k = this.b = null;this.w = 0;this.o = {};this.d = !1;var a=window.navigator.userAgent;0 <= a.indexOf("MSIE") && 0 <= a.indexOf("Trident") && (a = /\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a)) && a[1] && 9 > (0, window.parseFloat)(a[1]) && (this.d = !0)};_.w(zl,_.y);
55 | var Al=function(a,c,d){if(!a.d)if(d instanceof Array) for (var e in d)Al(a,c,d[e]); else{e = (0, _.u)(a.A,a,c);var f=a.w + d;a.w++;c.setAttribute("data-eqid",f);a.o[f] = e;c && c.addEventListener? c.addEventListener(d,e,!1): c && c.attachEvent? c.attachEvent("on" + d,e): _.I(Error("W`" + c))}};
56 | zl.prototype.Ne = function(a,c){if(this.d)return null;if(c instanceof Array){var d=null,e; for (e in c) {var f=this.Ne(a,c[e]);f && (d = f) }return d}d = null;this.b && this.b.type == c && this.k == a && (d = this.b, this.b = null);if(e = a.getAttribute("data-eqid"))a.removeAttribute("data-eqid"), (e = this.o[e])? a.removeEventListener? a.removeEventListener(c,e,!1): a.detachEvent && a.detachEvent("on" + c,e): _.I(Error("X`" + a));return d};zl.prototype.A = function(a,c){this.b = c;this.k = a;c.preventDefault? c.preventDefault(): c.returnValue = !1};
57 | _.Ca("eq",new zl);var Bl=function(){_.y.call(this);this.ge = [];this.jd = []};_.w(Bl,_.y);Bl.prototype.b = function(a,c){this.ge.push({uc:a,options:c})};Bl.prototype.init = function(){window.gapi = {};var a=_.Yj(),c=window.___jsl = {};c.h = _.G(_.B(a,1));c.ms = _.G(_.B(a,2));c.m = _.G(_.B(a,3));c.l = [];a = _.D(_.J(),_.Xj,5) || new _.Xj;_.B(a,1) && (a = _.B(a,3)) && this.jd.push(a);a = _.D(_.J(),_.Fk,6) || new _.Fk;_.B(a,1) && (a = _.B(a,2)) && this.jd.push(a);_.v("gapi.load",(0, _.u)(this.b,this));return this};
58 | var Cl=window,Dl,El=_.Yj();Dl = _.B(El,7);Cl.__PVT = _.G(Dl);_.Ca("gs",(new Bl).init());(function(){ for (var a=function(a){return function(){_.U(44,{n:a})}},c=0;c < _.Qa.length;c++) {var d="gbar." + _.Qa[c];_.v(d,a(d))}var e=_.ya.N();_.za(e,"api").Ta();ql(_.za(e,"m"),function(){_.za(e,"api").Ta()})})();var Fl=function(a){_.jb(function(){var c=window.document.querySelector("." + a);c && (c = c.querySelector(".gb_K")) && Al(_.E("eq"),c,"click")})};var Gl=window.document.querySelector(".gb_J"),Hl=/(\s+|^)gb_dc(\s+|$)/;Gl && !Hl.test(Gl.className) && Fl("gb_J");var Il=new sl;_.Ca("dd",Il);_.v("gbar.close",(0, _.u)(Il.hd,Il));_.v("gbar.cls",(0, _.u)(Il.tf,Il));_.v("gbar.abh",(0, _.u)(Il.Pb,Il,0));_.v("gbar.adh",(0, _.u)(Il.Pb,Il,1));_.v("gbar.ach",(0, _.u)(Il.Pb,Il,2));_.v("gbar.aeh",(0, _.u)(Il.Hh,Il));_.v("gbar.bsy",(0, _.u)(Il.Qg,Il));_.v("gbar.op",(0, _.u)(Il.qf,Il));
59 | Fl("gb_ma");_.jb(function(){var a=window.document.querySelector(".gb_Xa");a && Al(_.E("eq"),a,"click")});Fl("gb_4a");_.v("gbar.qfgw",(0, _.u)(window.document.getElementById,window.document,"gbqfqw"));_.v("gbar.qfgq",(0, _.u)(window.document.getElementById,window.document,"gbqfq"));_.v("gbar.qfgf",(0, _.u)(window.document.getElementById,window.document,"gbqf"));_.v("gbar.qfsb",(0, _.u)(window.document.getElementById,window.document,"gbqfb"));
60 | Fl("gb_Zb");Fl("gb_lc");
61 | } catch( e) {_._DumpException(e) }
62 | })(this.gbar_);
63 | // Google Inc.
64 |
--------------------------------------------------------------------------------