dwyl / goodparts

:see_no_evil: An ESLint Style that only allows JavaScript the Good Parts (and "Better Parts") in your code.
GNU General Public License v2.0
78 stars 26 forks source link

how to disable the back-tick ` #275

Open jay-meister opened 8 years ago

jay-meister commented 8 years ago

Back-ticks are useful for writing sql queries that can span multiple lines without lots of these: ' \n + '. We are not using es6 template literals so it will still make sense to any one seeing the code.

I am struggling to ignore it though.

`` //eslint-disable-line

It still gives me the error unexpected token '`'

Assistance much appreciated.

nelsonic commented 8 years ago

@JMurphyWeb I agree that ` (back tick) could be useful for multi-line SQL queries. ✅ If you are able to investigate this further, please do. 🔎

eliasmalik commented 8 years ago

@JMurphyWeb are you sure backticks are valid ES5? I'm not so sure. I think the unexpected token error you're seeing is because we've set ecmaVersion: 5 and so all ES6 syntax is treated as a syntax error.

Another way to do multi-line strings without + string concatenation is with Array.join:

var query = [
  'SELECT * FROM foo',
  'WHERE bar=$1',
].join(' ');
jay-meister commented 8 years ago

I didn't know that you had defined the version, and that it could not be ignored, so thanks for pointing that out.