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

Disable expected statement, but got empty on event handler #388

Closed
donnysim opened this issue Feb 12, 2018 · 4 comments
Closed

Disable expected statement, but got empty on event handler #388

donnysim opened this issue Feb 12, 2018 · 4 comments
Assignees

Comments

@donnysim
Copy link

donnysim commented Feb 12, 2018

Tell us about your environment

  • ESLint Version: 4.17.0
  • eslint-plugin-vue Version: 4.2.2
  • Node Version: 8.7.0

Please show your full configuration:

module.exports = {
    parserOptions: {
        parser: 'babel-eslint',
        ecmaVersion: 6,
        sourceType: 'module',
        ecmaFeatures: {
            experimentalObjectRestSpread: true,
        },
    },
    env: {
        browser: true,
    },
    extends: [
        'plugin:vue/base',
    ],
    rules: {
        'vue/no-parsing-error': [2, {
            'missing-attribute-value': false,
        }],
    },
};

What did you do? Please include the actual source code causing the issue.

<template>
    <div @click.stop="" @mousedown.stop="">
    </div>
</template>

What did you expect to happen?
It would not complain about @click not having a value.

What actually happened? Please include the actual, raw output from ESLint.
It throws error Expected to be statements, but got empty. Maybe have a separate config that allows events to have an empty handler?

This is a valid and often encountered use case.

@mysticatea
Copy link
Member

Thank you for the report.

I confirmed it. This is a bug in vue-eslint-parser.

mysticatea added a commit to vuejs/vue-eslint-parser that referenced this issue Feb 17, 2018
@mysticatea
Copy link
Member

I published vue-eslint-parser@2.0.3 that should fix this issue.
Please try re-install.

@michalsnik
Copy link
Member

Looks like this change breaks tests on fresh install. CircleCI seem to cache node_modules, but in fact they should fail now.

We expect following case to be invalid:

{
      filename: 'test.vue',
      code: '<template><div v-show="">hello</div></template>',
      errors: [
        { message: 'Parsing error: Expected to be an expression, but got empty.', column: 24 }
      ]
    },

But now it won't throw a parsing error. Is it desired @mysticatea ?

@mysticatea
Copy link
Member

Yes, that test case is invalid and it's the bug I fixed. Vue.js seems to ignore empty attribute values without warnings: https://jsfiddle.net/5w9eyncg/

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

No branches or pull requests

3 participants