webpack-contrib / eslint-loader

[DEPRECATED] A ESlint loader for webpack
MIT License
1.06k stars 121 forks source link

DefinePlugin and eslint-disable-next-line doesn't work #157

Closed merksam closed 7 years ago

merksam commented 7 years ago

Hello guys, I have the issue with using together both of DefinePlugin and eslint-disable-next-line. I use it with webpack2, HappyPack and babel-loader. For example, I have the next DefinePlugin options:

new webpack.DefinePlugin({
    "__DEV__"        : env.dev
})

env comes from command line. And I use DEV like this:

__DEV__ && console.log('Some message');

of course, eslint says me that "__DEV__ is not defined" so I use next code to prevent this error:

// eslint-disable-next-line no-undef
__DEV__ && console.log('Some message');

Build compiles as well, but when I open the app in browser, I have an error "__DEV__ is not defined", when __DEV__ should be true or false. I thought eslint-loader just watching files and says me if I made mistake, but doesn't influence the code for next loaders. Please tell if I'm doing something wrong. Thank you so much!

merksam commented 7 years ago

I'm so sorry, it was my bad, I've figured out it.

neo-of-matrix commented 7 years ago

Hi,how to solve this problem?

merksam commented 7 years ago

@designersmallweb Hi, I really don't remember what was exactly the issue, but it was really mistake in code. Maybe you don't fire DefinePlugin, maybe variable you try to use in DefinePlugin is really undefined. I think I can help you if I'll see the code.