Skip to content

Commit 3047d1f

Browse files
committed
Update prettier to version 2.
1 parent 58b69e6 commit 3047d1f

File tree

7 files changed

+58
-56
lines changed

7 files changed

+58
-56
lines changed

js/compile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/* eslint-disable strict */
1414
/* eslint-disable no-console */
1515

16-
;(function() {
16+
;(function () {
1717
'use strict'
1818
var path = require('path')
1919
var tmpl = require(path.join(__dirname, 'tmpl.js'))
@@ -31,7 +31,7 @@
3131
var list = []
3232
var code
3333
// Extend the Templating engine with a print method for the generated functions:
34-
tmpl.print = function(str) {
34+
tmpl.print = function (str) {
3535
// Only add helper functions if they are used inside of the template:
3636
var helper = helperRegexp.test(str) ? tmpl.helper : ''
3737
var body = str.replace(tmpl.regexp, tmpl.func)
@@ -49,7 +49,7 @@
4949
)
5050
}
5151
// Loop through the command line arguments:
52-
process.argv.forEach(function(file, index) {
52+
process.argv.forEach(function (file, index) {
5353
var listLength = list.length
5454
var stats
5555
var content

js/demo/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
/* eslint-disable strict */
1515

16-
;(function() {
16+
;(function () {
1717
'use strict'
1818

1919
var templateInput = document.getElementById('template')

js/runtime.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
/* eslint-disable strict */
1515

16-
;(function($) {
16+
;(function ($) {
1717
'use strict'
18-
var tmpl = function(id, data) {
18+
var tmpl = function (id, data) {
1919
var f = tmpl.cache[id]
2020
return data
2121
? f(data, tmpl)
22-
: function(data) {
22+
: function (data) {
2323
return f(data, tmpl)
2424
}
2525
}
@@ -32,14 +32,14 @@
3232
'"': '"',
3333
"'": '''
3434
}
35-
tmpl.encode = function(s) {
35+
tmpl.encode = function (s) {
3636
// eslint-disable-next-line eqeqeq
37-
return (s == null ? '' : '' + s).replace(tmpl.encReg, function(c) {
37+
return (s == null ? '' : '' + s).replace(tmpl.encReg, function (c) {
3838
return tmpl.encMap[c] || ''
3939
})
4040
}
4141
if (typeof define === 'function' && define.amd) {
42-
define(function() {
42+
define(function () {
4343
return tmpl
4444
})
4545
} else if (typeof module === 'object' && module.exports) {

js/tmpl.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
/* eslint-disable strict */
1818

19-
;(function($) {
19+
;(function ($) {
2020
'use strict'
21-
var tmpl = function(str, data) {
21+
var tmpl = function (str, data) {
2222
var f = !/[^\w\-.:]/.test(str)
2323
? (tmpl.cache[str] = tmpl.cache[str] || tmpl(tmpl.load(str)))
2424
: new Function( // eslint-disable-line no-new-func
@@ -31,16 +31,16 @@
3131
)
3232
return data
3333
? f(data, tmpl)
34-
: function(data) {
34+
: function (data) {
3535
return f(data, tmpl)
3636
}
3737
}
3838
tmpl.cache = {}
39-
tmpl.load = function(id) {
39+
tmpl.load = function (id) {
4040
return document.getElementById(id).innerHTML
4141
}
4242
tmpl.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g
43-
tmpl.func = function(s, p1, p2, p3, p4, p5) {
43+
tmpl.func = function (s, p1, p2, p3, p4, p5) {
4444
if (p1) {
4545
// whitespace, quote and backspace in HTML context
4646
return (
@@ -76,9 +76,9 @@
7676
'"': '"',
7777
"'": '''
7878
}
79-
tmpl.encode = function(s) {
79+
tmpl.encode = function (s) {
8080
// eslint-disable-next-line eqeqeq
81-
return (s == null ? '' : '' + s).replace(tmpl.encReg, function(c) {
81+
return (s == null ? '' : '' + s).replace(tmpl.encReg, function (c) {
8282
return tmpl.encMap[c] || ''
8383
})
8484
}
@@ -87,7 +87,7 @@
8787
",print=function(s,e){_s+=e?(s==null?'':s):_e(s);}" +
8888
',include=function(s,d){_s+=tmpl(s,d);}'
8989
if (typeof define === 'function' && define.amd) {
90-
define(function() {
90+
define(function () {
9191
return tmpl
9292
})
9393
} else if (typeof module === 'object' && module.exports) {

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"eslint-plugin-jsdoc": "22",
2727
"eslint-plugin-prettier": "3",
2828
"mocha": "7",
29-
"prettier": "1",
29+
"prettier": "2",
3030
"uglify-js": "3"
3131
},
3232
"eslintConfig": {
@@ -45,9 +45,11 @@
4545
"test/vendor"
4646
],
4747
"prettier": {
48+
"arrowParens": "avoid",
4849
"proseWrap": "always",
4950
"semi": false,
50-
"singleQuote": true
51+
"singleQuote": true,
52+
"trailingComma": "none"
5153
},
5254
"scripts": {
5355
"lint": "eslint .",

test/test.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
/* eslint-disable strict */
1515

16-
;(function(context, expect, tmpl) {
16+
;(function (context, expect, tmpl) {
1717
'use strict'
1818

1919
if (context.require === undefined) {
2020
// Override the template loading method:
21-
tmpl.load = function(id) {
21+
tmpl.load = function (id) {
2222
switch (id) {
2323
case 'template':
2424
return '{%=o.value%}'
@@ -28,7 +28,7 @@
2828

2929
var data
3030

31-
beforeEach(function() {
31+
beforeEach(function () {
3232
// Initialize the sample data:
3333
data = {
3434
value: 'value',
@@ -37,7 +37,7 @@
3737
zeroValue: 0,
3838
special: '<>&"\'\x00',
3939
list: [1, 2, 3, 4, 5],
40-
func: function() {
40+
func: function () {
4141
return this.value
4242
},
4343
deep: {
@@ -46,66 +46,66 @@
4646
}
4747
})
4848

49-
afterEach(function() {
49+
afterEach(function () {
5050
// Purge the template cache:
5151
tmpl.cache = {}
5252
})
5353

54-
describe('Template loading', function() {
55-
it('String template', function() {
54+
describe('Template loading', function () {
55+
it('String template', function () {
5656
expect(tmpl('{%=o.value%}', data)).to.equal('value')
5757
})
5858

59-
it('Load template by id', function() {
59+
it('Load template by id', function () {
6060
expect(tmpl('template', data)).to.equal('value')
6161
})
6262

63-
it('Retun function when called without data parameter', function() {
63+
it('Retun function when called without data parameter', function () {
6464
expect(tmpl('{%=o.value%}')(data)).to.equal('value')
6565
})
6666

67-
it('Cache templates loaded by id', function() {
67+
it('Cache templates loaded by id', function () {
6868
tmpl('template')
6969
expect(tmpl.cache.template).to.be.a('function')
7070
})
7171
})
7272

73-
describe('Interpolation', function() {
74-
it('Escape HTML special characters with {%=o.prop%}', function() {
73+
describe('Interpolation', function () {
74+
it('Escape HTML special characters with {%=o.prop%}', function () {
7575
expect(tmpl('{%=o.special%}', data)).to.equal('&lt;&gt;&amp;&quot;&#39;')
7676
})
7777

78-
it('Allow HTML special characters with {%#o.prop%}', function() {
78+
it('Allow HTML special characters with {%#o.prop%}', function () {
7979
expect(tmpl('{%#o.special%}', data)).to.equal('<>&"\'\x00')
8080
})
8181

82-
it('Function call', function() {
82+
it('Function call', function () {
8383
expect(tmpl('{%=o.func()%}', data)).to.equal('value')
8484
})
8585

86-
it('Dot notation', function() {
86+
it('Dot notation', function () {
8787
expect(tmpl('{%=o.deep.value%}', data)).to.equal('value')
8888
})
8989

90-
it('Handle single quotes', function() {
90+
it('Handle single quotes', function () {
9191
expect(tmpl("'single quotes'{%=\": '\"%}", data)).to.equal(
9292
"'single quotes': &#39;"
9393
)
9494
})
9595

96-
it('Handle double quotes', function() {
96+
it('Handle double quotes', function () {
9797
expect(tmpl('"double quotes"{%=": \\""%}', data)).to.equal(
9898
'"double quotes": &quot;'
9999
)
100100
})
101101

102-
it('Handle backslashes', function() {
102+
it('Handle backslashes', function () {
103103
expect(tmpl('\\backslashes\\{%=": \\\\"%}', data)).to.equal(
104104
'\\backslashes\\: \\'
105105
)
106106
})
107107

108-
it('Interpolate escaped falsy values except undefined or null', function() {
108+
it('Interpolate escaped falsy values except undefined or null', function () {
109109
expect(
110110
tmpl(
111111
'{%=o.undefinedValue%}' +
@@ -117,7 +117,7 @@
117117
).to.equal('false0')
118118
})
119119

120-
it('Interpolate unescaped falsy values except undefined or null', function() {
120+
it('Interpolate unescaped falsy values except undefined or null', function () {
121121
expect(
122122
tmpl(
123123
'{%#o.undefinedValue%}' +
@@ -129,25 +129,25 @@
129129
).to.equal('false0')
130130
})
131131

132-
it('Preserve whitespace', function() {
132+
it('Preserve whitespace', function () {
133133
expect(tmpl('\n\r\t{%=o.value%} \n\r\t{%=o.value%} ', data)).to.equal(
134134
'\n\r\tvalue \n\r\tvalue '
135135
)
136136
})
137137
})
138138

139-
describe('Evaluation', function() {
140-
it('Escape HTML special characters with print(data)', function() {
139+
describe('Evaluation', function () {
140+
it('Escape HTML special characters with print(data)', function () {
141141
expect(tmpl('{% print(o.special); %}', data)).to.equal(
142142
'&lt;&gt;&amp;&quot;&#39;'
143143
)
144144
})
145145

146-
it('Allow HTML special characters with print(data, true)', function() {
146+
it('Allow HTML special characters with print(data, true)', function () {
147147
expect(tmpl('{% print(o.special, true); %}', data)).to.equal('<>&"\'\x00')
148148
})
149149

150-
it('Print out escaped falsy values except undefined or null', function() {
150+
it('Print out escaped falsy values except undefined or null', function () {
151151
expect(
152152
tmpl(
153153
'{% print(o.undefinedValue); %}' +
@@ -159,7 +159,7 @@
159159
).to.equal('false0')
160160
})
161161

162-
it('Print out unescaped falsy values except undefined or null', function() {
162+
it('Print out unescaped falsy values except undefined or null', function () {
163163
expect(
164164
tmpl(
165165
'{% print(o.undefinedValue, true); %}' +
@@ -171,19 +171,19 @@
171171
).to.equal('false0')
172172
})
173173

174-
it('Include template', function() {
174+
it('Include template', function () {
175175
expect(
176176
tmpl('{% include("template", {value: "value"}); %}', data)
177177
).to.equal('value')
178178
})
179179

180-
it('If condition', function() {
180+
it('If condition', function () {
181181
expect(
182182
tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data)
183183
).to.equal('true')
184184
})
185185

186-
it('Else condition', function() {
186+
it('Else condition', function () {
187187
expect(
188188
tmpl(
189189
'{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}',
@@ -192,7 +192,7 @@
192192
).to.equal('true')
193193
})
194194

195-
it('For loop', function() {
195+
it('For loop', function () {
196196
expect(
197197
tmpl(
198198
'{% for (var i=0; i<o.list.length; i++) { %}' +
@@ -202,7 +202,7 @@
202202
).to.equal('12345')
203203
})
204204

205-
it('For loop print call', function() {
205+
it('For loop print call', function () {
206206
expect(
207207
tmpl(
208208
'{% for (var i=0; i<o.list.length; i++) {print(o.list[i]);} %}',
@@ -211,7 +211,7 @@
211211
).to.equal('12345')
212212
})
213213

214-
it('For loop include template', function() {
214+
it('For loop include template', function () {
215215
expect(
216216
tmpl(
217217
'{% for (var i=0; i<o.list.length; i++) {' +
@@ -221,7 +221,7 @@
221221
).to.equal('12345')
222222
})
223223

224-
it('Modulo operator', function() {
224+
it('Modulo operator', function () {
225225
expect(
226226
tmpl(
227227
'{% if (o.list.length % 5 === 0) { %}5 list items{% } %}',

0 commit comments

Comments
 (0)