Skip to content

findMutating matches beyond standard array functions #1579

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
2 tasks done
fletcherhaz opened this issue Jul 25, 2021 · 0 comments · Fixed by #1584
Closed
2 tasks done

findMutating matches beyond standard array functions #1579

fletcherhaz opened this issue Jul 25, 2021 · 0 comments · Fixed by #1584
Labels

Comments

@fletcherhaz
Copy link

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 7.28.0
  • eslint-plugin-vue version: 7.13.0
  • Node version: 16.0.0
  • Operating System: macOS 11.2.3

Please show your full configuration:

module.exports = {
    root: true,
    env: { browser: true },
    parser: 'vue-eslint-parser',
    parserOptions: {
        ecmaVersion: 2020,
        parser: '@typescript-eslint/parser'
    },
    rules: {
        'vue/no-mutating-props': 'error'
    }
}

What did you do?

<script>
  export default {
    props: ['prop']
    setup(props) {
      props.prop.sortAscending()
    }
  }
</script>

What did you expect to happen?
This rule should not warn because it does not match the standard array functions.

What actually happened?

error Unexpected mutation of "prop" prop vue/no-mutating-props

Repository to reproduce this issue

This issue is caused by the regex here:

/^push|pop|shift|unshift|reverse|splice|sort|copyWithin|fill$/u

Currently, the starting and ending anchors only apply to the first (push) and last (fill) strings. I don't think this is the intended behavior because it matches many other functions. See here for some examples.

Adding parentheses makes the regex perform more like I imagine was intended:

/^(push|pop|shift|unshift|reverse|splice|sort|copyWithin|fill)$/u

Here are the results.

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

Successfully merging a pull request may close this issue.

2 participants