Repository: vuejs/eslint-plugin-vue (JavaScript)

Issue:
`vue/no-mutating-props` does not report `delete` operations
<!--
  ❗Please don't ignore this template.❗

  If you ignore it, we're just going to respond asking you to fill it out, which wastes everyone's time.
  The more relevant information you can include, the faster we can find the issue and fix it without asking you for more info.
-->

<!--
  Before posting the issue, please confirm that the problem you're getting
  is not related with your code editor configuration.
  To make sure it's not, run: yarn eslint src/your-file.vue
-->

**Checklist**

- [x] I have tried restarting my IDE and the issue persists.
- [x] I have read the [FAQ](https://eslint.vuejs.org/user-guide/#faq) and my problem is not listed.
<!-- If you do not read the FAQ and open an issue that is listed in the FAQ, we may silently close the issue. -->

**Tell us about your environment**

- **ESLint version:** 8.16.0
- **eslint-plugin-vue version:** 9.0.1

**What did you do?**	

See [the demo here](https://ota-meshi.github.io/eslint-plugin-vue-demo/#eJx1VElu3DAQ/Iqgkw2YNpKjMTYC+AHJA+bSoloSbYpUuMwSY/6eojRDLXEOg0FXNVvd1ctnKW3N5XO5C9wPmgK/7k1R7Gp1KH5IreTHy77syNSa35K1L193TyDhtXtaPNl56dQQCs8hDrClNT4Ug7ODL16Kmhtl+Fey7j5T/Mba5+Jn9c4yPOzN5X5v9qaJRgZlTbH43N19Mfqn3xjsES8fK3II+i09KhBbc+A1m5hLynDKCvmUD6WLmn35/FkeIj9J2/dsgqiVQw7qAAm+P4zMuz+J6NmLAzmf0SmQGMvb0GOpLspgnfBxYDeiDaxrcGtGpOUQ2AmHEG5CjBXkz0YKJN8rz4JPLCPi3FhJAGuWmhylOD4TmrzHY6/aHAolDeRYGG7FH3Z2xk39jytS/gojSJL8Vc56YoKzGpm3fLqBNVexbdnNdmpDUiUj0EKQa/0KmDLvua/YrRnWKFY1K+yDz0snjATGbZTlhmIEw3llCNlBLpm0Hj+2JgdKXci18WkjA5+CI1FZq5lM+lJYM557dUMa0jp0zsa2yxCGeBOx1bYivQFVP1i3bYEyBkl/1W9lDqRVPbVgyKiDHeEsjp0K7AeSWRdtIbNtMFoslV90E4OG0mpl2v8J1asT12KMhhnD8ASqMmn4KPy5r6zOiDVWBlSIxFWPf/aShpyIrd4ho9Y5wuh8MzD5wYYzWl1FpYOaS3Y8CcEzgNqvad0wz7rZiOi/WjPfUW2PALGpChXXwlC/CIPF8WlYHc3zFjrlRcVYZF7sNYhocM9mAw3hMWQfUYDGoZs5xwSRK72APDUscA4hyXmDYnNpuXhX2A4JhLAIpQwaN/O4RLXQVPEs7xXM5ylBkIkxDhXJD8cNOzbzoNxIbJbstuC6lUcVJg/HvyNumzgr1vWIxLS73tCU+zSsqa22ySc0TVYMKBCTN15rMJfLXwOGPDg=).

<img width="347" alt="image" src="https://user-images.githubusercontent.com/5101076/169774823-40be99da-ca13-499a-9d39-da600131f8c2.png">


**What did you expect to happen?**

`vue/no-mutating-props` should report the **`delete` operation** on properties of prop objects, but currently it doesn't.

I noticed that the implementation of [`findMutating`](https://github.com/vuejs/eslint-plugin-vue/blob/35bf1009d9b85d88b558d1739ddaadf665bb17dd/lib/utils/index.js#L1774) does not check for `UnaryExpression`. Since deleting properties is also reactive in 3.x, this kind of code will probably come up more often.



Discussion:

Patch:
diff --git a/lib/utils/index.js b/lib/utils/index.js
index 5a423faa4..b76924deb 100644
--- a/lib/utils/index.js
+++ b/lib/utils/index.js
@@ -1798,6 +1798,16 @@ module.exports = {
             pathNodes
           }
         }
+        case 'UnaryExpression': {
+          if (target.operator === 'delete') {
+            return {
+              kind: 'update',
+              node: target,
+              pathNodes
+            }
+          }
+          break
+        }
         case 'CallExpression': {
           if (pathNodes.length > 0 && target.callee === node) {
             const mem = pathNodes[pathNodes.length - 1]


Test patch:
diff --git a/tests/lib/rules/no-mutating-props.js b/tests/lib/rules/no-mutating-props.js
index 5c976baa2..22ef3aaf7 100644
--- a/tests/lib/rules/no-mutating-props.js
+++ b/tests/lib/rules/no-mutating-props.js
@@ -370,11 +370,12 @@ ruleTester.run('no-mutating-props', rule, {
             <div v-if="this.prop6++ && this.someProp < 10"></div>
             <div v-text="this.prop7.shift()"></div>
             <div v-text="this.prop8.slice(0).shift()"></div>
+            <div v-if="delete prop9.a"></div>
           </div>
         </template>
         <script>
           export default {
-            props: ['prop1', 'prop2', 'prop3', 'prop4', 'prop5', 'prop6', 'prop7', 'prop8']
+            props: ['prop1', 'prop2', 'prop3', 'prop4', 'prop5', 'prop6', 'prop7', 'prop8', 'prop9']
           }
         </script>
       `,
@@ -402,6 +403,10 @@ ruleTester.run('no-mutating-props', rule, {
         {
           message: 'Unexpected mutation of "prop7" prop.',
           line: 10
+        },
+        {
+          message: 'Unexpected mutation of "prop9" prop.',
+          line: 12
         }
       ]
     },
@@ -507,6 +512,7 @@ ruleTester.run('no-mutating-props', rule, {
                 ++this.items
                 this.todo.type = 'completed'
                 this.items.push('something')
+                delete this.todo.type
               }
             }
           }
@@ -524,6 +530,10 @@ ruleTester.run('no-mutating-props', rule, {
         {
           message: 'Unexpected mutation of "items" prop.',
           line: 18
+        },
+        {
+          message: 'Unexpected mutation of "todo" prop.',
+          line: 19
         }
       ]
     },
@@ -651,6 +661,7 @@ ruleTester.run('no-mutating-props', rule, {
               props.a ++
               props.b = 1
               props.c.push(1)
+              delete props.d
             }
           }
         </script>
@@ -667,6 +678,10 @@ ruleTester.run('no-mutating-props', rule, {
         {
           message: 'Unexpected mutation of "c" prop.',
           line: 7
+        },
+        {
+          message: 'Unexpected mutation of "d" prop.',
+          line: 8
         }
       ]
     },
@@ -681,6 +696,7 @@ ruleTester.run('no-mutating-props', rule, {
               c.push(1)
 
               c.x.push(1)
+              delete c.y
               e.foo++
               f.foo++
             }
@@ -705,12 +721,16 @@ ruleTester.run('no-mutating-props', rule, {
           line: 9
         },
         {
-          message: 'Unexpected mutation of "d" prop.',
+          message: 'Unexpected mutation of "c" prop.',
           line: 10
         },
         {
           message: 'Unexpected mutation of "d" prop.',
           line: 11
+        },
+        {
+          message: 'Unexpected mutation of "d" prop.',
+          line: 12
         }
       ]
     },
@@ -722,6 +742,7 @@ ruleTester.run('no-mutating-props', rule, {
           export default {
             setup({a: foo, b: [...bar], c: baz = 1}) {
               foo.x ++
+              delete foo.y
               bar.x = 1
               baz.push(1)
             }
@@ -734,12 +755,16 @@ ruleTester.run('no-mutating-props', rule, {
           line: 5
         },
         {
-          message: 'Unexpected mutation of "b" prop.',
+          message: 'Unexpected mutation of "a" prop.',
           line: 6
         },
         {
-          message: 'Unexpected mutation of "c" prop.',
+          message: 'Unexpected mutation of "b" prop.',
           line: 7
+        },
+        {
+          message: 'Unexpected mutation of "c" prop.',
+          line: 8
         }
       ]
     },
@@ -752,6 +777,7 @@ ruleTester.run('no-mutating-props', rule, {
               props.a ++
               props.b = 1
               props.c.push(1)
+              delete props.d
             }
           }
         </script>
@@ -768,6 +794,10 @@ ruleTester.run('no-mutating-props', rule, {
         {
           message: 'Unexpected mutation of "c" prop.',
           line: 7
+        },
+        {
+          message: 'Unexpected mutation of "d" prop.',
+          line: 8
         }
       ]
     },