Skip to content

return-in-computed-property error not triggered #173

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
lgodard opened this issue Sep 4, 2017 · 2 comments · Fixed by #175
Closed

return-in-computed-property error not triggered #173

lgodard opened this issue Sep 4, 2017 · 2 comments · Fixed by #175

Comments

@lgodard
Copy link

lgodard commented Sep 4, 2017

Hi all,

I try the eslint plugin and the return-in-computed-property is not triggered on a test file

  • ESLint Version: 4.5.0 and 4.6.1
  • eslint-plugin-vue Version: 3.12.0 and 3.13.0
  • Node Version: 6.9.5

ESLint config

module.exports = {
    plugins: [
        'vue'
    ],
    extends: [
        'my/usecase/browser-es2015',
        'plugin:vue/recommended'
    ],
    rules: {
        // override/add rules' settings here
        'vue/return-in-computed-property': 'error',
        'vue/no-template-key': 'error',
        'vue/require-v-for-key': 'off',
        'vue/valid-v-for': 'off',
        'vue/no-shared-component-data': 'error'
    }
}

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

$ eslint . --ext .js,.vue

targetting this source file triggering an error

// @vue/component
export default {
    computed: {
        my_FALSE_test() {
            let aa = 2;
            this.my_id = aa;
        }
    }

};

What did you expect to happen?
the computed property my_FALSE_test should be reported as faulty

What actually happened? Please include the actual, raw output from ESLint.

the file is analyzed, but no error reported. nothing returned

digging further, in plugin source code
at this line

computedProperties.forEach(cp => {

here is the state of the variables (console.log output)

forbiddenNodes = [ ]

computedProperties =  [ { key: 'my_FALSE_test',
    value: 
     Node {
       type: 'BlockStatement',
       start: 76,
       end: 140,
       loc: [Object],
       range: [Object],
       body: [Object] } } ]

my understanding (though i may be wrong) is that utils.executeOnFunctionsWithoutReturn does not parse the file correctly and does not detect the computed property

Is it something I do wrong ?

Feel free to ask if more info needed

Thanks !

Laurent

@armano2
Copy link
Contributor

armano2 commented Sep 4, 2017

@lgodard Nice catch, issue is with order how queries are executed
in this case executeOnVue is triggered before executeOnFunctionsWithoutReturn

-> ObjectExpression => ObjectExpression:exit

@lgodard
Copy link
Author

lgodard commented Sep 5, 2017

verified, it works like a charm
Thanks a lot !

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

Successfully merging a pull request may close this issue.

2 participants