user1037355
user1037355

Reputation:

typescript vuejs interface imported and used but complains not used

<template>
    <div>
        <div v-if="$root.isNotEmptyObj(error422)">
            <p v-for="error in error422.errors" v-bind:key="error.message">
                <span v-for="message in error.messages">{{ $t(message) }}</span>
            </p>
        </div>
    </div>
</template>

<script lang="ts">
  import { Component, Prop, Vue } from 'vue-property-decorator';
  import { Generic422 } from '@/api/ms-authentication/services/interfaces';

  @Component
  export default class MFormError422 extends Vue {
    @Prop()
    private error422!: Generic422;
  }
</script>

So the above component imports Generic422 as the type for the private class variable.. but the ide and the linter complains and says it is not being used.

Am I defining the prop correctly here? I really only want the typical typescript support here for ensure the prop is injectect properly.

The eslint file:

module.exports = {
  // Which files to not lint
  ignorePatterns: [
    'node_modules',
    'src/api/**/*',
    'tests/**/*',
  ],

  extends: [
    'plugin:vue/essential',
    'eslint:recommended',
    '@vue/typescript'
  ],
  rules: {
  }
}

enter image description here

Upvotes: 1

Views: 1011

Answers (1)

user1037355
user1037355

Reputation:

module.exports = {
  // Which files to not lint
  ignorePatterns: [
    'node_modules',
    'src/api/**/*',
    'tests/**/*',
  ],

  extends: [
    'plugin:vue/essential',
    'eslint:recommended',
    '@vue/typescript'
  ],

  // additional function from 3rd parties
  plugins: [
    'deprecate',
  ],

  rules: {
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-unused-vars': [
      'error',
      { vars: 'all', args: 'none', ignoreRestSiblings: false },
    ],
    quotes: ['error', 'single', { avoidEscape: true }],
    curly: ['error', 'all'],
    'max-lines-per-function': ['error', 40],
    'deprecate/function': 2,
    'deprecate/member-expression': 2,
    'deprecate/import': 2,
  }
}

this lint file fixed it

Upvotes: 1

Related Questions