2

Is there an eslint rule to catch an await used in a function that is not async. Perhaps I'm just not searching the correct keywords. Would love to have a rule such that the following code causes a linting error:

function doSomething() {
  await doAsync()
}

EDIT: May be an issue with vim + ALE config? Any ideas there?

Thanks!

jonschlinkert
  • 10,872
  • 4
  • 43
  • 50
holtc
  • 1,780
  • 3
  • 16
  • 35
  • 1
    It'll cause a *syntax* error [in 99% of cases](https://stackoverflow.com/questions/55934490/why-are-await-and-async-valid-variable-names), which (I'd think) would be sufficient. When a file has a syntax error and can't be parsed, ESLint can't lint it – CertainPerformance Apr 05 '22 at 18:43
  • I don't have any syntax errors thrown using vim + ale in these cases. What ruleset needs to be used for this to throw a syntax error in JS? – holtc Apr 05 '22 at 18:44
  • 1
    Sounds like a bug in ALE if it doesn't detect that that's invalid syntax – CertainPerformance Apr 05 '22 at 18:45
  • Gotcha, thanks. Will look into it – holtc Apr 05 '22 at 18:46
  • Its also not throwing a syntax error when running some tests, so I'll have to dig in – holtc Apr 05 '22 at 18:47
  • Your question "What ruleset needs to be used for this to throw a syntax error in JS" might get more answers on https://vi.stackexchange.com/ – uɥƃnɐʌuop Apr 05 '22 at 18:49

0 Answers0