Skip to content

vue/no-unused-properties: does not recognise props used in data #1323

Closed
@EmilyRosina

Description

@EmilyRosina

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: 7.10.0
  • eslint-plugin-vue version: 7.0.1
  • Node version: 13.14.0
  • Operating System: Ubuntu 20.04.1 LTS

Please show your full configuration:

// http://eslint.org/docs/user-guide/configuring

const isProd = process.env.NODE_ENV === 'production'
const isTest = process.env.NODE_ENV === 'testing'
const isDev = process.env.NODE_ENV === 'development'

module.exports = {
  root: true,

  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module',
    ecmaVersion: 2020,
    allowImportExportEverywhere: true
  },

  env: {
    browser: true,
    node: true,
    jest: true
  },

  extends: [
    /** https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style */
    'standard',
    /** https://vuejs.github.io/eslint-plugin-vue/rules/ */
    'plugin:vue/recommended',
    /** https://www.npmjs.com/package/eslint-plugin-jest-formatting */
    'plugin:jest-formatting/recommended',
    /** https://github.com/cypress-io/eslint-plugin-cypress */
    'plugin:cypress/recommended',
    /** https://github.com/xjamundx/eslint-plugin-promise */
    'plugin:promise/recommended'
  ],

  // required to lint *.vue files
  plugins: [
    'vue',
    'import'
  ],

  globals: {
    _: false,
    Stripe: false,
    describeComponent: false
  },

  // add your custom rules here
  rules: {
    /** https://eslint.org/docs/rules/arrow-parens */
    'arrow-parens': 'error',
    /** https://eslint.org/docs/rules/generator-star-spacing */
    'generator-star-spacing': 'error',
    /** https://eslint.org/docs/rules/no-debugger */
    'no-debugger': isProd ? 'error' : 'off',
    /** https://eslint.org/docs/rules/camelcase */
    camelcase: [
      'error',
      {
        properties: 'never',
        ignoreDestructuring: true
      }
    ],
    /** https://eslint.org/docs/rules/consistent-this */
    'consistent-this': [
      'error',
      'self'
    ],
    /** https://eslint.org/docs/rules/prefer-const */
    'prefer-const': [
      'error',
      {
        destructuring: 'all',
        ignoreReadBeforeAssign: false
      }
    ],
    /** https://eslint.org/docs/rules/no-console */
    'no-console': [(isDev || isTest) ? 'warn' : 'error', { allow: ['warn', 'error', 'info'] }],
    /** https://eslint.org/docs/rules/quotes#enforce-the-consistent-use-of-either-backticks-double-or-single-quotes-quotes */
    quotes: [
      'error',
      'single',
      { allowTemplateLiterals: true }
    ],
    /** https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/attributes-order.md */
    'vue/attributes-order': [
      2,
      {
        order: [
          'GLOBAL',
          'CONDITIONALS',
          'RENDER_MODIFIERS',
          'LIST_RENDERING',
          'UNIQUE',
          'TWO_WAY_BINDING',
          'OTHER_DIRECTIVES',
          'OTHER_ATTR',
          'EVENTS',
          'CONTENT',
          'DEFINITION'
        ]
      }
    ],
    /** https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-closing-bracket-newline.md */
    'vue/html-closing-bracket-newline': [
      'error',
      {
        singleline: 'never',
        multiline: 'never'
      }
    ],
    /** https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-closing-bracket-spacing.md */
    'vue/html-closing-bracket-spacing': [
      'error',
      {
        startTag: 'never',
        endTag: 'never',
        selfClosingTag: 'never'
      }
    ],
    /** https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-v-html.md */
    'vue/no-v-html': 'off',
    /** https://eslint.org/docs/rules/no-prototype-builtins */
    'no-prototype-builtins': 'off',
    /** https://eslint.org/docs/rules/no-restricted-imports */
    'no-restricted-imports': [
      'error',
      {
        paths: [
          {
            name: 'lodash',
            message: 'Lodash is already available globally, please remove the import.'
          },
          {
            name: 'faker',
            importNames: [
              'fakerLorem',
              'fakerRand',
              'fakerInet'
            ],
            message: 'Please use the named import directly, i.e. lorem, rand etc.'
          }
        ]
      }
    ],
    /** https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/component-name-in-template-casing.md */
    'vue/component-name-in-template-casing': [
      'error',
      'PascalCase',
      {
        registeredComponentsOnly: true,
        ignores: []
      }
    ],
    /** https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/object-curly-spacing.md */
    'vue/object-curly-spacing': [
      'error',
      'always'
    ],
    /** https://eslint.vuejs.org/rules/padding-line-between-blocks.html#vue-padding-line-between-blocks */
    'vue/padding-line-between-blocks': [
      'error',
      'always'
    ],
    /** https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-unused-properties.md */
    'vue/no-unused-properties': ['warn', {
      groups: ['props', 'data', 'computed', 'methods']
    }]
  }
}

What did you do?

props: {
    rowsPerPage: {
      type: Number,
      default: 10
    }
},
data: ({ rowsPerPage }) => ({
    dataTable: {
      descending: false,
      rowsPerPage,
      sortBy: 'name',
      totalItems: 0
    }
})

What did you expect to happen?
For vue/no-unused-properties to pass, as it's being used in data (but nowhere else in the file).

What actually happened?

warning: 'rowsPerPage' of property found, but never used (vue/no-unused-properties) at src/components/data-table-yd-api.vue:282:5:
  280 |       default: ''
  281 |     },
> 282 |     rowsPerPage: {
      |     ^
  283 |       type: Number,
  284 |       default: 10
  285 |     },
1 warning found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions