BenoitZugmeyer / eslint-plugin-html

An ESLint plugin to extract and lint scripts from HTML files.
ISC License
430 stars 51 forks source link

eslint-plugin-html error: It seems that eslint is not loaded. #60

Closed alexsasharegan closed 7 years ago

alexsasharegan commented 7 years ago

I upgraded to eslint 4.0 the other day and received this error. I figured a version compatible plugin update was coming. I saw today a v3 release, so I upgraded. I'm getting the same error.

It's very possible this is related to the vue plugin or eslint, but due to the error message, I thought I would start here.

Error Message

Error: eslint-plugin-html error: It seems that eslint is not loaded. If you think it is a bug, please file a report at https://github.com/BenoitZugmeyer/eslint-plugin-html/issues
    at iterateESLintModules (/Users/alex/dev/projects/artisanhd-v2/node_modules/eslint-plugin-vue/node_modules/eslint-plugin-html/src/index.js:65:11)
    at Object.<anonymous> (/Users/alex/dev/projects/artisanhd-v2/node_modules/eslint-plugin-vue/node_modules/eslint-plugin-html/src/index.js:36:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/alex/dev/projects/artisanhd-v2/node_modules/eslint-plugin-vue/index.js:3:1)
error Command failed with exit code 1.

Run Command

eslint --ext vue ./src/js

.eslintrc.json

{
    "root": true,
    "env": {
        "browser": true,
        "node": true
    },
    "plugins": ["vue", "html"],
    "extensions": ["vue"],
    "settings": {
        "html/html-extensions": [".html", ".vue", ".php", ".twig"]
    },
    "parserOptions": {
        "ecmaVersion": 2017,
        "sourceType": "module",
        "ecmaFeatures": {
            "impliedStrict": true,
            "experimentalObjectRestSpread": true,
            "jsx": true
        }
    },
    "globals": {
        "ajax": true,
        "axios": true,
        "Tether": true,
        "Promise": true
    },
    "extends": "eslint:recommended",
    "rules": {
        "indent": ["error", 4, {
            "SwitchCase": 1
        }],
        "linebreak-style": ["error", "unix"],
        "semi": ["error", "never"],
        "comma-dangle": ["warn", {
            "arrays": "ignore",
            "objects": "ignore",
            "imports": "ignore",
            "exports": "ignore",
            "functions": "never"
        }],
        "comma-style": ["error", "last"],
        "computed-property-spacing": ["error", "never"],
        "no-console": ["error", { "allow": ["warn", "error"] }],
        "no-alert": "error",
        "no-dupe-args": "error",
        "no-duplicate-case": "error",
        "no-duplicate-imports": "error",
        "no-empty": "error"
    }
}
dschreij commented 7 years ago

I am experiencing this same error as of this morning. Really strange, I have no idea where it is coming from or why it started to happen. My eslint server is running and other plugins do pick it up correctly.

[Info  - 3:56:31 PM] ESLint server is running.
[Info  - 3:56:31 PM] ESLint library loaded from: C:\Users\dsc\AppData\Roaming\npm\node_modules\eslint\lib\api.js
BenoitZugmeyer commented 7 years ago

Thanks for the report. It is probably because the vue plugin is using eslint-plugin-html v2. I just opened an issue here, let's see where it is going!

EDIT: in the meantime you should downgrade to ESLint v3 or use the experimental vue plugin which doesn't rely on eslint-plugin-html.

alexsasharegan commented 7 years ago

Thank you, @BenoitZugmeyer, for doing that! Most plugin authors just slap the upstream tag on it and call it a day. I appreciate that!

michalsnik commented 7 years ago

You should try eslint-plugin-vue@beta which will be an official version soon @alexsasharegan. We merged eslint-plugin-vue-trial to eslint-plugin-vue and we're gathering feedback so we would be glad if you also could try it :)

You can find new documentation here: https://github.com/vuejs/eslint-plugin-vue/tree/dev

In the meanwhile I'll try to patch eslint-plugin-vue@2.

gperrow commented 7 years ago

There's something else going on here since I'm seeing the same error but I'm not using eslint-plugin-vue. I don't even have it installed.

BenoitZugmeyer commented 7 years ago

@gperrow did you upgrade to eslint-plugin-html v3 ?

gperrow commented 7 years ago

No, I'm using 1.5.2.

BenoitZugmeyer commented 7 years ago

ESLint v4 is only supported by eslint-plugin-html v3, so you can't use eslint-plugin-html v1.5.2 with it (I should add a warning about this when trying to use the plugin with an incompatible version on ESLint).

If you do not use ESLint v4, please provide more information (package.json, a gist to reproduce, ...)

alexsasharegan commented 7 years ago

All right, I removed eslint-plugin-vue and reinstalled it @beta. I'm running eslint-plugin-html v3.0.0. I also made sure to remove a global eslint. Getting this error now:

eslint --ext vue ./src/js

Oops! Something went wrong! :(

ESLint couldn't find the plugin "eslint-plugin-vue". This can happen for a couple different reasons:

1. If ESLint is installed globally, then make sure eslint-plugin-vue is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin.

2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm i eslint-plugin-vue@latest --save-dev

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

error Command failed with exit code 1.

Here are the dependencies sections of my package.json:

{
    "dependencies": {
        "animate.css": "^3.5.2",
        "axios": "^0.16.2",
        "babel-polyfill": "^6.23.0",
        "babel-runtime": "^6.23.0",
        "bootstrap": "4.0.0-alpha.6",
        "bootstrap-vue": "^0.16.1",
        "cropperjs": "^1.0.0-rc.2",
        "date-fns": "^1.28.5",
        "dropzone": "^5.1.0",
        "font-awesome": "^4.7.0",
        "jquery": "^3.2.1",
        "lodash-es": "^4.17.4",
        "tether": "latest",
        "vue": "^2.3.4",
        "vue-cropperjs": "^2.1.1",
        "vue-router": "^2.5.3",
        "vue-touch": "next",
        "vuex": "^2.3.1",
        "vuex-router-sync": "^4.2.0"
    },
    "devDependencies": {
        "autoprefixer": "^7.1.1",
        "babel-core": "^6.25.0",
        "babel-helper-vue-jsx-merge-props": "^2.0.2",
        "babel-loader": "^7.0.0",
        "babel-plugin-syntax-jsx": "^6.18.0",
        "babel-plugin-transform-object-rest-spread": "^6.23.0",
        "babel-plugin-transform-runtime": "^6.23.0",
        "babel-plugin-transform-vue-jsx": "^3.4.3",
        "babel-preset-env": "^1.5.2",
        "babel-preset-stage-0": "^6.24.1",
        "concurrently": "^3.4.0",
        "cross-env": "^5.0.1",
        "css-loader": "^0.28.4",
        "eslint": "^4.0.0",
        "eslint-plugin-html": "^3.0.0",
        "eslint-plugin-vue": "beta",
        "extract-text-webpack-plugin": "^2.1.2",
        "file-loader": "^0.11.2",
        "node-sass": "^4.5.3",
        "optimize-css-assets-webpack-plugin": "^2.0.0",
        "postcss-loader": "^2.0.5",
        "sass-loader": "^6.0.5",
        "style-loader": "^0.18.2",
        "stylus": "^0.54.5",
        "stylus-loader": "^3.0.1",
        "url-loader": "^0.5.9",
        "vue-loader": "^12.2.1",
        "vue-template-compiler": "^2.3.4",
        "webpack": "2.x.x",
        "webpack-bundle-analyzer": "^2.8.2",
        "webpack-dev-server": "^2.4.5"
    }
}
alexsasharegan commented 7 years ago

I think the entry point is jacked up on eslint-plugin-vue on beta. It's looking for lib/index.js, but there is none, so it falls back to index.js, which also doesn't exist.

gperrow commented 7 years ago

I think my problem is solved. I had eslint v4 installed globally but one of my projects had 3.something in its dependencies so there was some version mismatches. Once I upgraded everything, the problem vanished.

alexsasharegan commented 7 years ago

Upgraded to "eslint-plugin-vue": "^2.1.0" and my problem appears to be solved. Closing.

lpcman commented 6 years ago

upgrade local eslint from 3.19.0 to 4.19.1 solved my problem, eslint-plugin-html is 4.0.1.