Closed rebers closed 8 years ago
Restarting Atom did the trick!
I get this issue when trying to run eslint through webpack for .vue
files.
eslint versions:
"eslint": "^3.5.0",
"eslint-config-airbnb-base": "^7.1.0",
"eslint-loader": "^1.5.0",
"eslint-plugin-html": "^1.5.2",
"eslint-plugin-import": "^1.15.0",
webpack versions: "webpack": "^1.12.2",
.eslintrc.js
file:
module.exports = {
root: true,
parserOptions: {
sourceType: 'module'
},
extends: 'airbnb-base',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
rules: {
'import/no-unresolved': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
// allow console.log in dev.
'no-console': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-param-reassign': 0,
'default-case': 0,
// Sometimes we add propery starting with `_` e.g _type to make
// sure we dont colide with an existing object property named type.
'no-underscore-dangle': 0,
'no-unused-vars': [1, {'vars': 'local', 'args': 'none'}],
},
}
webpack config:
module: {
preLoaders: [
{ test: /\.vue$/, loader: 'eslint', exclude: /node_modules/ }
],
},
eslint: {
failOnWarning: false,
failOnError: true
},
I indeed still get this error every now and then, but a quick restart fixes this.
It's definitely a bug, I just don't know how to reproduce it yet.
Working on it.
I can't reproduce the error. This setup seems to work as expected:
~/tmp/test-eslint-plugin-html-issue-28 % webpack
Hash: 396f0bfb9d565b6f60f0
Version: webpack 1.12.2
Time: 682ms
+ 1 hidden modules
ERROR in ./foo.vue
/home/alk/tmp/test-eslint-plugin-html-issue-28/foo.vue
3:1 error Unexpected var, use let or const instead no-var
3:5 warning 'foo' is defined but never used no-unused-vars
✖ 2 problems (1 error, 1 warning)
ERROR in ./foo.vue
Module build failed: Error: Module failed because of a eslint error.
/home/alk/tmp/test-eslint-plugin-html-issue-28/foo.vue
3:1 error Unexpected var, use let or const instead no-var
3:5 warning 'foo' is defined but never used no-unused-vars
✖ 2 problems (1 error, 1 warning)
@jrenton would you mind providing a gist like this one so I can better figure out what's wrong? you can fork it for instance. The npm shrinkwrap would provide valuable informations about your setup too.
@BenoitZugmeyer Thanks for looking into this. I determined the root of the problem was due to the odd way in which eslint is referenced. I created a pull request #33 here that fixes it.
I did require ESLint this way because I feared to have issues when ESLint is installed globally and the plugin locally or conversely. But it turns out you have to install plugins globally when ESLint is installed globally anyway, so it's kind of pointless.
If it fixes your issue, then great, let's simplify this!
Sorry, I am not satisfied by this fix. Let's find something else!
How is it now?
@blade254353074 I found why it could fail (that's probably because webpack or atom is messing with the require
module cache), but I still didn't reproduce. If anyone could provide steps to reproduce consistently, it would help me a lot.
@BenoitZugmeyer Why are you not satisfied with the fix? I provided the configuration to reproduce above.
@BenoitZugmeyer OK
@BenoitZugmeyer
https://github.com/blade254353074/multi-vue
eslint is related to:
/.eslintrc.js
/.eslintignore
/tools/webpack/conf.base.js
You can start with npm run dev
, then you can see:
@jrenton yes, you gave me partial configuration to reproduce, and I replied to you with a gist using it but still didn't manage to reproduce, so I asked you for more information but you didn't answer my request. require("eslint")
doesn't satisfy me because you can't be sure it'll return the eslint currently loaded. For example, if you are using npm link
to install this plugin, require("eslint")
will either raise a Cannot find module 'eslint'
or load another instance of eslint.
@blade254353074 thank you very much, I can reproduce now. Working on it!
@blade254353074 ok so the issue was caused by loading both eslint and standard (which in turn loads eslint again) in the same process. I pushed a patch that should fix this, could you confirm? It probably fixes other issues mentioned here too.
@BenoitZugmeyer Okay, I can test it right now.
@BenoitZugmeyer I think the error was resolved. Dev environment looks fine to me. Thank you.
Ok let's close this issue. Let me know if someone have still this error.
Hi guys,
I'm trying to use your extremely useful plugin in the default Vue.js webpack template. It comes preconfigured and is required in its latest version (@1.5.1). Using Atom, normal JS files lint just well, but in
.vue
components I receive the following error:While typing / saving the file.
The file is the default
Hello.vue
from the webpack template:My
package.json
:Using it on node a
v6.3.1
and everything else runs smoothly.Any idea on why this is happening and how it can be fixed would be greatly appreciated.