fimbullinter / wotan

Pluggable TypeScript and JavaScript linter
Apache License 2.0
282 stars 23 forks source link

autofixer might cause ASI error #198

Open ajafff opened 6 years ago

ajafff commented 6 years ago

no-debugger:

[]
debugger;
[1]

// effectively fixed to
[][1]

await-only-promise:

async function fn() {
  'use strict'
  await (1)
}

// effectively fixed to
async function fn() {
  'use strict'(1)
}

no-unused-label:

1
foo: <a & b > c

// effectively fixed to
1 < a & b > c

prefer-object-spread:

foo
Object.assign({}, {foo: 1})

// effectively fixed to
foo({foo: 1})
ajafff commented 6 years ago

type-assertion:

foo
bar() as void

// fixed to
foo
<void>bar()

// which is parsed as
(foo < void) > bar()
ajafff commented 6 years ago

prefer-dot-notation:

foo
1['toString']();

// fixed to
foo
(1).toString();

// parsed as
foo(1).toString();
ajafff commented 6 years ago

no-useless-strict:

'foo'
'use strict';
[1].toString()

// fixed to
'foo'
[1].toString()

// parsed as
'foo'[1].toString()

Though this case should be pretty rare in real world code.