Skip to content

Add support for defineOptions to vue/no-duplicate-attr-inheritance #1886

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

Closed
2 tasks done
alokVishu opened this issue May 11, 2022 · 4 comments · Fixed by #2178
Closed
2 tasks done

Add support for defineOptions to vue/no-duplicate-attr-inheritance #1886

alokVishu opened this issue May 11, 2022 · 4 comments · Fixed by #2178

Comments

@alokVishu
Copy link

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.13.0
  • eslint-plugin-vue version:NA
  • Node version:LTS
  • Operating System:Windows

Please show your full configuration:

module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  extends: [
    '@antfu',
    'plugin:vue/vue3-recommended',
    'plugin:import/recommended',
    'plugin:import/typescript',
    'plugin:promise/recommended',
    'plugin:sonarjs/recommended',
  ],
  parserOptions: {
    ecmaVersion: 13,
    parser: '@typescript-eslint/parser',
    sourceType: 'module',
  },
  plugins: ['vue', '@typescript-eslint'],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

    // Disable max-len
    'max-len': 'off',

    // we don't want it
    semi: ['error', 'never'],

    // add parens ony when required in arrow function
    'arrow-parens': ['error', 'as-needed'],

    // add new line above comment
    'newline-before-return': 'error',

    // add new line above comment
    'lines-around-comment': [
      'error',
      {
        beforeBlockComment: true,
        beforeLineComment: true,
        allowBlockStart: true,
        allowClassStart: true,
        allowObjectStart: true,
        allowArrayStart: true,
      },
    ],

    'array-element-newline': ['error', 'consistent'],
    'array-bracket-newline': ['error', 'consistent'],

    'vue/multi-word-component-names': 'off',

    // Plugin: eslint-plugin-import
    'import/prefer-default-export': 'off',

    // Plugin: eslint-plugin-import
    // For omitting extension for ts files
    'import/extensions': [
      'error',
      'ignorePackages',
      {
        js: 'never',
        jsx: 'never',
        ts: 'never',
        tsx: 'never',
      },
    ],

    // Thanks: https://stackoverflow.com/a/63961972/10796681
    'no-shadow': 'off',
    '@typescript-eslint/no-shadow': ['error'],

    '@typescript-eslint/consistent-type-imports': 'error',

    // Plugin: eslint-plugin-promise
    'promise/always-return': 'off',
    'promise/catch-or-return': 'off',

    // ESLint plugin vue
    'vue/block-tag-newline': 'error',
    'vue/component-api-style': 'error',
    'vue/component-name-in-template-casing': 'error',
    'vue/custom-event-name-casing': 'error',
    'vue/define-macros-order': 'error',
    'vue/html-comment-content-newline': 'error',
    'vue/html-comment-content-spacing': 'error',
    'vue/html-comment-indent': 'error',
    'vue/match-component-file-name': 'error',
    'vue/no-child-content': 'error',
    'vue/no-duplicate-attr-inheritance': 'error',
    'vue/no-empty-component-block': 'error',
    'vue/no-multiple-objects-in-class': 'error',
    'vue/no-reserved-component-names': 'error',
    'vue/no-template-target-blank': 'error',
    'vue/no-useless-mustaches': 'error',
    'vue/no-useless-v-bind': 'error',
    'vue/padding-line-between-blocks': 'error',
    'vue/prefer-separate-static-class': 'error',
    'vue/prefer-true-attribute-shorthand': 'error',
    'vue/v-on-function-call': 'error',

    // -- Extension Rules
    'vue/no-irregular-whitespace': 'error',
    'vue/template-curly-spacing': 'error',

    // Internal Rules
    'valid-appcardcode-code-prop': 'error',
  },
  settings: {
    // 'import/parsers': {
    //   '@typescript-eslint/parser': ['.ts', '.tsx'],
    // },
    'import/resolver': {
      typescript: {
        // alwaysTryTypes: true,
        // project: './tsconfig.json',
      },
    },
  },
}

What did you do?

 <v-card v-bind="$attrs">
...
 </v-card>

<script setup lang="ts">
// inherit Attribute make false
defineOptions({
  inheritAttrs: false,
})
</script>

What did you expect to happen?
Error should gone.

What actually happened?

Set "inheritAttrs" to false.eslintvue/no-duplicate-attr-inheritance

Repository to reproduce this issue

I have used the unplugin-vue-define-options plugin for the above declaration.

@FloEdelmann
Copy link
Member

defineOptions is currently only suggested in an RFC, so it's not officially supported by eslint-plugin-vue. Users of the unplugin should disable that rule.

@mat813
Copy link

mat813 commented May 16, 2023

defineOptions is now a thing, and it seems this error is still thrown.

@FloEdelmann
Copy link
Member

Seems like we missed this in #2118/#2127. Thanks for letting us know! I'll reopen this.

@FloEdelmann FloEdelmann reopened this May 16, 2023
@FloEdelmann FloEdelmann added bug and removed won't do labels May 16, 2023
@FloEdelmann FloEdelmann changed the title Set "inheritAttrs" false error shown after define the same. Support defineOptions in vue/no-duplicate-attr-inheritance May 16, 2023
@FloEdelmann FloEdelmann changed the title Support defineOptions in vue/no-duplicate-attr-inheritance Add support for defineOptions to vue/no-duplicate-attr-inheritance May 16, 2023
@ota-meshi
Copy link
Member

I didn't know we could use $attrs with <script setup>. We probably have the same problem with <script>export default {inheritAttrs: false}</script> with <script setup>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants