Skip to content
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

False positive on vue/no-mutating-props #2080

Closed
2 tasks done
asselin opened this issue Jan 24, 2023 · 1 comment
Closed
2 tasks done

False positive on vue/no-mutating-props #2080

asselin opened this issue Jan 24, 2023 · 1 comment

Comments

@asselin
Copy link

asselin commented Jan 24, 2023

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: 8.32.0
  • eslint-plugin-vue version: 9.9.0
  • Node version: 16.18.1
  • Operating System: Mac

Please show your full configuration:

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
  root: true,
  ignorePatterns: ['coverage/*'],
  extends: [
    'plugin:vue/essential',
    'eslint:recommended',
    '@vue/eslint-config-typescript/recommended',
    '@vue/eslint-config-prettier',
    'plugin:json/recommended',
  ],
  rules: {
    '@typescript-eslint/no-non-null-assertion': 'off',
    '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
  },
};

What did you do?

<!-- ------------- Parent.vue -------------- -->
<template>
  <child-comp v-model="homeAddress" />
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import ChildComp from './Child.vue';

export default defineComponent({
  name: 'ParentComp',
  components: {
    ChildComp,
  },
  data: () => ({
    homeAddress: { address1: '123 Main st' },
  }),
});
</script>

<!-- ------------- Child.vue -------------- -->
<template>
  <div>
    Enter street address
    <input v-model="value.address1" />
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';

export default defineComponent({
  name: 'ChildComp',
  props: {
    value: {
      type: Object,
      required: true,
    },
  },
});
</script>

What did you expect to happen?
No ESLint errors.

What actually happened?
Received the error for Child.vue: "4:21 error Unexpected mutation of "value" prop vue/no-mutating-props".

Child does not mutate the prop, it mutates a property inside the passed prop. Vue does not give any error at runtime about mutating a prop. The test cases for this rule seem to indicate that this should be valid... but the rule is complaining.

Repository to reproduce this issue
(https://github.com/asselin/eslint-vue-bug)

@FloEdelmann
Copy link
Member

Duplicate of #1371

@FloEdelmann FloEdelmann marked this as a duplicate of #1371 Jan 24, 2023
@FloEdelmann FloEdelmann closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants