Skip to content

[Bug] eslint-plugin-vue doesn't working with separate files #887

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

Closed
runyasak opened this issue May 2, 2019 · 4 comments
Closed

[Bug] eslint-plugin-vue doesn't working with separate files #887

runyasak opened this issue May 2, 2019 · 4 comments

Comments

@runyasak
Copy link

runyasak commented May 2, 2019

Tell us about your environment

  • ESLint version: 5.16.0
  • eslint-plugin-vue version: 5.0.0
  • Node version: 10.15.2

Please show your full configuration:

{
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/recommended',
    '@vue/standard'
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'vue/html-closing-bracket-newline': 'off',
    'vue/html-self-closing': 'off'
  },
  parserOptions: {
    parser: 'babel-eslint'
  }
}

What did you do?
I have created a Vue single file with separating script file, like this vue-separate-files.
First, the script was separated and it didn't warn any sign. But, when I wrote them in .vue file, warnings are appeared.

// MyComponent.vue
<template>
  <div class="container">
    <p>{{ label }}</p>
  </div>
</template>

<script src="my-script.js"></script>
// my-script.js
export default {
  name: 'MyComponent',
  props: {
    label: String
  }
}

It should appear eslint(vue/require-default-prop) but it doesn't.

What did you expect to happen?
The eslint warning should be worked on a js file.

What actually happened?

The eslint doesn't show any sign of warning.

@mysticatea
Copy link
Member

Thank you for this issue.

But this is not a bug, because ESLint checks each file independently.

@AGPDev
Copy link

AGPDev commented May 30, 2019

I have this problem, 4 hours trying resolve the same problem, and 'vue/order-in-components',

After see this answer i run test with clean Vue CLI 3 project, and using .vue the lint works but make import js in src script tag not work.

so @mysticatea yes, this probably a bug or conf

@AGPDev
Copy link

AGPDev commented May 30, 2019

@runyasak try add // @vue/component in your .js see vuejs/vue-cli#1602,

For me this work

@ghm-salvarado
Copy link

I came here looking for a solution for the same thing. @AGPDev got it right.

Just wanted to add for anyone who finds this in the future, as explained in vuejs/vue-cli#1602, the // @vue/component marker needs to come immediately before export default { ... } in your script — not necessarily at the top of the file. I was putting it before my imports which doesn't work. Totally fine when you do it correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants