Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check .vue files? #750

Closed
scriptPilot opened this issue Jan 19, 2017 · 15 comments

Comments

@scriptPilot
Copy link

commented Jan 19, 2017

Hello everybody! Is there any way, to check .vue files?

Only the script path should be checked.

After load these files with Vue Webpack loader, the source code isn't standard anymore, so must be checked before.

Documentation: Vue Single File Components

Example code:

<template>
  <p>Some HTML Code</p>
</template>

<script>
  module.exports = {}
</script>
@feross

This comment has been minimized.

Copy link
Member

commented Jan 19, 2017

This is a tricky one. I think the easiest way to support this is for you (or someone else) to write a tool that extracts the <script> portion of the .vue file and run standard on it.

@zeke did something similar with standard-markdown, which lints the JS in your markdown files (like README.md, etc.).

This definitely doesn't belong in the main standard tool because then we'd have to also add support for hundreds of other similar JS libraries. Hope that makes sense.

@feross feross closed this Jan 19, 2017

@zeke

This comment has been minimized.

Copy link
Contributor

commented Jan 20, 2017

After I wrote standard-markdown I realized it could also be really useful for linting inline scripts. I don't have an immediate need for that, but the standard-markdown module could be easily modfied (or forked) to support it. Here's an issue for tracking: zeke/standard-markdown#11

@exah

This comment has been minimized.

Copy link

commented Jan 20, 2017

Since .vue files is valid html, you can check them with eslint-plugin-html, like so:

$ standard --plugin html '**/*.{js,vue}'
@scriptPilot

This comment has been minimized.

Copy link
Author

commented Jan 20, 2017

@exah - Thank you for that hint - how could I integrate it in Webpack 1 configuration?

@feross

This comment has been minimized.

Copy link
Member

commented Jan 20, 2017

@exah Wow, that is extremely elegant.

Looks like eslint-plugin-markdown also exists, as a generic solution to the linting markdown code blocks problem, though it doesn't filter out all the same rules as standard-markdown which makes it harder to work with.

$ standard --plugin markdown '**/*.md'
@feross

This comment has been minimized.

Copy link
Member

commented Jan 20, 2017

I just sent a PR to include a section in the readme about these plugins. #753

@zeke

This comment has been minimized.

Copy link
Contributor

commented Jan 20, 2017

that is extremely elegant

Indeed! Good to know it's going in the readme.

it doesn't filter out all the same rules as standard-markdown

Yeah.. after using it with vanilla standard for a few days, it became clear that a few of the rules were too restrictive for code samples, so we added a few exceptions: zeke/standard-markdown#2

@feross

This comment has been minimized.

Copy link
Member

commented Jan 20, 2017

Yeah, I mention standard-markdown first for that reason ;-)

@scriptPilot scriptPilot referenced this issue Jan 23, 2017
3 of 3 tasks complete
@scriptPilot

This comment has been minimized.

Copy link
Author

commented Jan 25, 2017

@exah - Okay, solved it with npm run ... - fine now :-)

@timoxley timoxley referenced this issue Mar 6, 2017
@ArmorDarks

This comment has been minimized.

Copy link

commented Feb 13, 2018

Does eslint-plugin-html work for anyone with Standard?

On Windows machine

standard --plugin html "**/*.{js,vue}"

throws

standard: Unexpected linter output:

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 (J:\Work\Greencard\green-card-app\node_modules\eslint-plugin-html\src\index.js:65:11)
    at Object.<anonymous> (J:\Work\Greencard\green-card-app\node_modules\eslint-plugin-html\src\index.js:26:1)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.load (J:\Work\Greencard\green-card-app\node_modules\standard\node_modules\eslint\lib\config\plugins.js:129:26)

If you think this is a bug in `standard`, open an issue: https://github.com/standard/standard/issues
@exah

This comment has been minimized.

Copy link

commented Feb 14, 2018

@ArmorDarks As of today you should use official eslint-plugin-vue instead of eslint-plugin-html.

@ArmorDarks

This comment has been minimized.

Copy link

commented Feb 14, 2018

Oh, I didn't encounter eslint-plugin-vue before. Thanks!

Still, we'd want to use eslint-plugin-html for some occasional inlined scripts in HTML. Does it work for anyone? Can't figure out is it eslint-plugin-html issue or standards.

@lqfxz520

This comment has been minimized.

Copy link

commented Mar 10, 2018

In sublime, how do you check files?

@timwis

This comment has been minimized.

Copy link

commented Apr 6, 2018

Just wanted to share how I have it working... is there a better way? I use eslint-config-standard with the following .eslintrc file:

{
  "extends": [
    "plugin:vue/recommended",
    "standard"
  ],
  "parserOptions": {
    "ecmaVersion": 2017
  }
}

I would prefer to use the standard binary instead of eslint-config-standard (if for no other reason than fewer devDeps in my package.json), but I couldn't get the Vue eslint plugin to work via the standard CLI. Has anyone figured it out?

@ArmorDarks

This comment has been minimized.

Copy link

commented Apr 10, 2018

Yeap, it seems to be impossible to specify which eslint-plugin-vue rules should be used. Or am I missing something?

@lock lock bot locked as resolved and limited conversation to collaborators Jul 9, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
7 participants
You can’t perform that action at this time.