Closed jay-meister closed 7 years ago
I had this issue also before, on this occasion I just ignore the line:
require('env2')('.env') // eslint-disable-line
var ...
I'm not sure if there is a specific eslint rule or options for this case. Does anyone manage to resolve this without eslint-disable-line?
require('env2')('.env')
var ... ; // eslint-disable-line
Thanks. Although I had to disable the var line, not the require line.
@JMurphyWeb This really strikes me more as a problem with hapi-postgres-connection
than with goodparts
.
Specifically, why is the plugin reaching out into the outside world and asserting that some environment variable exists? It should instead apply a little dependency injection and either accept DB config as an argument to a wrapping function, or as a field in the plugin options object.
@JMurphyWeb you could assign the require to a variable and then disable it:
var env = require('env2')('.env'); // eslint-disable-line
Yeah I tried that, then saw that env
is never used. So either way we need to es-lint-disable-line
@jackcarlisle are you guys using good parts in your project then?
@eliascodes whilst I am sure you are right, I don't like the thought of my linter dictating which modules I choose to use.. It dictates enough already in my life.
@JMurphyWeb yeah it's a one line solution as opposed to putting es-lint-disable-line
beside every var
.
Yeah we're using it in our project!
@JMurphyWeb I understand that you want to just get on with writing code, and not having a ball-ache every time some style issue crops up. Fair enough, disabling the line is fine.
I was just making a wider point. And as far as '... my linter dictating which modules I choose to use ...', surely that's the whole point. If the module you want to use forces (or encourages) you to write anti-patterns or code in some other way that might introduce issues, then the linter should try to stop you, and the burden should fall on you (or in this case the module writer), not the linter.
As the kind linter keeps reminding me, I am supposed to declare all variables at the top of the file. I want to require env2 to allow me to require hapi-postgres-connection. But this rubs the linter up the wrong way. I tried declaring it as a
var
but then it complained that the var was never used.Advice much appreciated.