Closed
Description
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.