Skip to content

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

Closed
@lgodard

Description

@lgodard

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions