@@ -41,6 +41,7 @@ ruleTester.run("space-unary-ops", rule, {
4141 code : "foo.bar --" ,
4242 options : [ { nonwords : true } ]
4343 } ,
44+
4445 {
4546 code : "delete foo.bar" ,
4647 options : [ { words : true } ]
@@ -49,6 +50,14 @@ ruleTester.run("space-unary-ops", rule, {
4950 code : "delete foo[\"bar\"]" ,
5051 options : [ { words : true } ]
5152 } ,
53+ {
54+ code : "delete foo.bar" ,
55+ options : [ { words : false } ]
56+ } ,
57+ {
58+ code : "delete(foo.bar)" ,
59+ options : [ { words : false } ]
60+ } ,
5261
5362 {
5463 code : "new Foo" ,
@@ -79,6 +88,14 @@ ruleTester.run("space-unary-ops", rule, {
7988 code : "typeof {foo:true}" ,
8089 options : [ { words : true } ]
8190 } ,
91+ {
92+ code : "typeof (foo)" ,
93+ options : [ { words : true } ]
94+ } ,
95+ {
96+ code : "typeof(foo)" ,
97+ options : [ { words : false } ]
98+ } ,
8299 {
83100 code : "typeof!foo" ,
84101 options : [ { words : false } ]
@@ -100,6 +117,14 @@ ruleTester.run("space-unary-ops", rule, {
100117 code : "void foo" ,
101118 options : [ { words : true } ]
102119 } ,
120+ {
121+ code : "void foo" ,
122+ options : [ { words : false } ]
123+ } ,
124+ {
125+ code : "void(foo)" ,
126+ options : [ { words : false } ]
127+ } ,
103128
104129 {
105130 code : "-1" ,
@@ -217,12 +242,12 @@ ruleTester.run("space-unary-ops", rule, {
217242 options : [ { words : false , overrides : { new : false } } ]
218243 } ,
219244 {
220- code : "function *foo () { yield (0) }" ,
245+ code : "function *foo () { yield(0) }" ,
221246 options : [ { words : true , overrides : { yield : false } } ] ,
222247 parserOptions : { ecmaVersion : 6 }
223248 } ,
224249 {
225- code : "function *foo () { yield (0) }" ,
250+ code : "function *foo () { yield(0) }" ,
226251 options : [ { words : false , overrides : { yield : false } } ] ,
227252 parserOptions : { ecmaVersion : 6 }
228253 }
@@ -247,6 +272,15 @@ ruleTester.run("space-unary-ops", rule, {
247272 type : "UnaryExpression"
248273 } ]
249274 } ,
275+ {
276+ code : "delete (foo.bar)" ,
277+ output : "delete(foo.bar)" ,
278+ options : [ { words : false } ] ,
279+ errors : [ {
280+ message : "Unexpected space after unary word operator 'delete'." ,
281+ type : "UnaryExpression"
282+ } ]
283+ } ,
250284 {
251285 code : "new(Foo)" ,
252286 output : "new (Foo)" ,
@@ -256,6 +290,15 @@ ruleTester.run("space-unary-ops", rule, {
256290 type : "NewExpression"
257291 } ]
258292 } ,
293+ {
294+ code : "new (Foo)" ,
295+ output : "new(Foo)" ,
296+ options : [ { words : false } ] ,
297+ errors : [ {
298+ message : "Unexpected space after unary word operator 'new'." ,
299+ type : "NewExpression"
300+ } ]
301+ } ,
259302 {
260303 code : "new(Foo())" ,
261304 output : "new (Foo())" ,
@@ -265,6 +308,15 @@ ruleTester.run("space-unary-ops", rule, {
265308 type : "NewExpression"
266309 } ]
267310 } ,
311+ {
312+ code : "new [foo][0]" ,
313+ output : "new[foo][0]" ,
314+ options : [ { words : false } ] ,
315+ errors : [ {
316+ message : "Unexpected space after unary word operator 'new'." ,
317+ type : "NewExpression"
318+ } ]
319+ } ,
268320
269321 {
270322 code : "typeof(foo)" ,
@@ -275,6 +327,33 @@ ruleTester.run("space-unary-ops", rule, {
275327 type : "UnaryExpression"
276328 } ]
277329 } ,
330+ {
331+ code : "typeof (foo)" ,
332+ output : "typeof(foo)" ,
333+ options : [ { words : false } ] ,
334+ errors : [ {
335+ message : "Unexpected space after unary word operator 'typeof'." ,
336+ type : "UnaryExpression"
337+ } ]
338+ } ,
339+ {
340+ code : "typeof[foo]" ,
341+ output : "typeof [foo]" ,
342+ options : [ { words : true } ] ,
343+ errors : [ {
344+ message : "Unary word operator 'typeof' must be followed by whitespace." ,
345+ type : "UnaryExpression"
346+ } ]
347+ } ,
348+ {
349+ code : "typeof [foo]" ,
350+ output : "typeof[foo]" ,
351+ options : [ { words : false } ] ,
352+ errors : [ {
353+ message : "Unexpected space after unary word operator 'typeof'." ,
354+ type : "UnaryExpression"
355+ } ]
356+ } ,
278357 {
279358 code : "typeof{foo:true}" ,
280359 output : "typeof {foo:true}" ,
@@ -321,6 +400,15 @@ ruleTester.run("space-unary-ops", rule, {
321400 type : "UnaryExpression"
322401 } ]
323402 } ,
403+ {
404+ code : "void[foo];" ,
405+ output : "void [foo];" ,
406+ options : [ { words : true } ] ,
407+ errors : [ {
408+ message : "Unary word operator 'void' must be followed by whitespace." ,
409+ type : "UnaryExpression"
410+ } ]
411+ } ,
324412 {
325413 code : "void{a:0};" ,
326414 output : "void {a:0};" ,
@@ -330,6 +418,24 @@ ruleTester.run("space-unary-ops", rule, {
330418 type : "UnaryExpression"
331419 } ]
332420 } ,
421+ {
422+ code : "void (foo)" ,
423+ output : "void(foo)" ,
424+ options : [ { words : false } ] ,
425+ errors : [ {
426+ message : "Unexpected space after unary word operator 'void'." ,
427+ type : "UnaryExpression"
428+ } ]
429+ } ,
430+ {
431+ code : "void [foo]" ,
432+ output : "void[foo]" ,
433+ options : [ { words : false } ] ,
434+ errors : [ {
435+ message : "Unexpected space after unary word operator 'void'." ,
436+ type : "UnaryExpression"
437+ } ]
438+ } ,
333439
334440 {
335441 code : "! foo" ,
@@ -488,6 +594,18 @@ ruleTester.run("space-unary-ops", rule, {
488594 column : 19
489595 } ]
490596 } ,
597+ {
598+ code : "function *foo() { yield (0) }" ,
599+ output : "function *foo() { yield(0) }" ,
600+ options : [ { words : false } ] ,
601+ parserOptions : { ecmaVersion : 6 } ,
602+ errors : [ {
603+ message : "Unexpected space after unary word operator 'yield'." ,
604+ type : "YieldExpression" ,
605+ line : 1 ,
606+ column : 19
607+ } ]
608+ } ,
491609 {
492610 code : "function *foo() { yield+0 }" ,
493611 output : "function *foo() { yield +0 }" ,
0 commit comments