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

Issue:
`defineProps` should be able to work with local imported bindings, but reported as error
<!--
  ❗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.3.0
- **eslint-plugin-vue version:** 8.1.1
- **Node version:** v16.11.0
- **Operating System:** Windows 10

**Please show your full configuration:**
<!-- Paste content of your .eslintrc file -->
```js
// http://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  env: {
    browser: true,
  },
  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
  extends: ['plugin:vue/vue3-recommended', 'plugin:prettier/recommended'],
  // required to lint *.vue files
  plugins: ['html'],
  parserOptions: {
    ecmaVersion: 2020,
    ecmaFeatures: {
      jsx: true,
    },
  },
  // add your custom rules here
  rules: {
    'prettier/prettier': [
      'error',
      {
        endOfLine: 'auto',
        semi: true,
        singleQuote: true,
        trailingComma: 'es5',
      },
    ],
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
    'vue/multi-word-component-names': 0,
    'vue/no-v-html': 0,
  },
};

```

**What did you do?**	
<!-- Please include the actual source code causing the issue. -->
```vue
<script setup>
import { linkProps } from '../../props/link.props';

defineProps({
  ...linkProps,
  active: { type: Boolean, default: false },
});
</script>
```

**What did you expect to happen?**

No error should be reported. as the document https://v3.vuejs.org/api/sfc-script-setup.html#defineprops-and-defineemits said:

> However, it can reference imported bindings since they are in the module scope as well.

It does not require the import statement to inside a normal script instead of setup script.

**What actually happened?**
<!--
  Please include the actual, raw output from ESLint.
  If you are only looking at the results of your editor extension, also check the CLI results.
-->
```
ESLint: `defineProps` are referencing locally declared variables.(vue/valid-define-props)
```

**Repository to reproduce this issue**
<!--
  ❗ Please share a repository that can reproduce your issue.
  ❗ If you don't share it, we just label it as requesting a repository that can reproduce your issue.
  ❗ If you don't share it for a few days, we silently close this issue.
-->

https://github.com/uiv-lib/uiv/blob/dev/src/components/button/Btn.vue

just change the import statement from normal script to setup script to see what happen.


Discussion:

Patch:
diff --git a/lib/rules/valid-define-emits.js b/lib/rules/valid-define-emits.js
index 6f433a835..d7480d538 100644
--- a/lib/rules/valid-define-emits.js
+++ b/lib/rules/valid-define-emits.js
@@ -79,6 +79,7 @@ module.exports = {
                   variable.defs.length &&
                   variable.defs.every(
                     (def) =>
+                      def.type !== 'ImportBinding' &&
                       utils.inRange(scriptSetup.range, def.name) &&
                       !utils.inRange(defineEmits.range, def.name)
                   )
diff --git a/lib/rules/valid-define-props.js b/lib/rules/valid-define-props.js
index 3a084dd68..849437b1e 100644
--- a/lib/rules/valid-define-props.js
+++ b/lib/rules/valid-define-props.js
@@ -80,6 +80,7 @@ module.exports = {
                   variable.defs.length &&
                   variable.defs.every(
                     (def) =>
+                      def.type !== 'ImportBinding' &&
                       utils.inRange(scriptSetup.range, def.name) &&
                       !utils.inRange(defineProps.range, def.name)
                   )


Test patch:
diff --git a/tests/lib/rules/valid-define-emits.js b/tests/lib/rules/valid-define-emits.js
index 557101d67..dd0b1f88f 100644
--- a/tests/lib/rules/valid-define-emits.js
+++ b/tests/lib/rules/valid-define-emits.js
@@ -117,6 +117,16 @@ tester.run('valid-define-emits', rule, {
       });
       </script>
       `
+    },
+    {
+      filename: 'test.vue',
+      code: `
+      <script setup>
+      import { propsDef, emitsDef } from './defs';
+
+      defineProps(propsDef);
+      defineEmits(emitsDef);
+      </script>`
     }
   ],
   invalid: [
diff --git a/tests/lib/rules/valid-define-props.js b/tests/lib/rules/valid-define-props.js
index 10894e069..2d866274b 100644
--- a/tests/lib/rules/valid-define-props.js
+++ b/tests/lib/rules/valid-define-props.js
@@ -120,6 +120,16 @@ tester.run('valid-define-props', rule, {
       });
       </script>
       `
+    },
+    {
+      filename: 'test.vue',
+      code: `
+      <script setup>
+      import { propsDef, emitsDef } from './defs';
+
+      defineProps(propsDef);
+      defineEmits(emitsDef);
+      </script>`
     }
   ],
   invalid: [