From 8828bbb69dcbb1b36dd4c79a2ce05cec86586dbe Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Sun, 11 Sep 2022 07:53:36 +0900 Subject: [PATCH] Add `vue/no-ref-object-destructure` rule (#1965) * Add `vue/no-ref-object-destructure` rule * add test cases * fix test case * Apply suggestions from code review Co-authored-by: Flo Edelmann * remove comment in testcases * add rfc link to doc Co-authored-by: Flo Edelmann --- docs/rules/README.md | 1 + docs/rules/no-ref-object-destructure.md | 55 ++ lib/index.js | 1 + lib/rules/no-ref-as-operand.js | 79 +-- lib/rules/no-ref-object-destructure.js | 183 ++++++ lib/utils/property-references.js | 104 ++- lib/utils/ref-object-references.js | 621 ++++++++++++++++++ .../$-with-destructuring/result.js | 16 + .../$-with-destructuring/source.js | 16 + .../reactive-vars/$/result.js | 6 + .../reactive-vars/$/source.js | 6 + .../reactive-vars/$computed/result.js | 5 + .../reactive-vars/$computed/source.js | 5 + .../reactive-vars/$customRef/result.js | 10 + .../reactive-vars/$customRef/source.js | 10 + .../reactive-vars/$ref/result.js | 5 + .../reactive-vars/$ref/source.js | 5 + .../reactive-vars/$shallowRef/result.js | 5 + .../reactive-vars/$shallowRef/source.js | 5 + .../reactive-vars/$toRef/result.js | 5 + .../reactive-vars/$toRef/source.js | 5 + .../ref-objects/computed/result.js | 5 + .../ref-objects/computed/source.js | 5 + .../ref-objects/customRef/result.js | 10 + .../ref-objects/customRef/source.js | 10 + .../ref-objects/ref-to-pattern/result.js | 9 + .../ref-objects/ref-to-pattern/source.js | 9 + .../ref-objects/ref/result.js | 5 + .../ref-objects/ref/source.js | 5 + .../ref-objects/shallowRef/result.js | 5 + .../ref-objects/shallowRef/source.js | 5 + .../ref-objects/toRef/result.js | 5 + .../ref-objects/toRef/source.js | 5 + .../ref-objects/toRefs-to-pattern/result.js | 5 + .../ref-objects/toRefs-to-pattern/source.js | 5 + .../ref-objects/toRefs/result.js | 18 + .../ref-objects/toRefs/source.js | 18 + tests/lib/rules/no-ref-object-destructure.js | 449 +++++++++++++ tests/lib/utils/ref-object-references.js | 164 +++++ 39 files changed, 1804 insertions(+), 81 deletions(-) create mode 100644 docs/rules/no-ref-object-destructure.md create mode 100644 lib/rules/no-ref-object-destructure.js create mode 100644 lib/utils/ref-object-references.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$-with-destructuring/result.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$-with-destructuring/source.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$/result.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$/source.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$computed/result.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$computed/source.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$customRef/result.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$customRef/source.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$ref/result.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$ref/source.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$shallowRef/result.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$shallowRef/source.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$toRef/result.js create mode 100644 tests/fixtures/utils/ref-object-references/reactive-vars/$toRef/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/computed/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/computed/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/customRef/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/customRef/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/ref-to-pattern/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/ref-to-pattern/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/ref/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/ref/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/shallowRef/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/shallowRef/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/toRef/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/toRef/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/toRefs-to-pattern/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/toRefs-to-pattern/source.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/toRefs/result.js create mode 100644 tests/fixtures/utils/ref-object-references/ref-objects/toRefs/source.js create mode 100644 tests/lib/rules/no-ref-object-destructure.js create mode 100644 tests/lib/utils/ref-object-references.js diff --git a/docs/rules/README.md b/docs/rules/README.md index 4343ba647..de00e7e53 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -227,6 +227,7 @@ For example: | [vue/no-empty-component-block](./no-empty-component-block.md) | disallow the `