Skip to content

require-explicit-emits does not find 'emits' in quotes #1414

Closed
@ehutch79

Description

@ehutch79

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.18.0
  • eslint-plugin-vue version: 7.4.1
  • Node version: v14.15.4
  • Operating System: macOS 11.1

Please show your full configuration:

module.exports = {
  'env': {
    'browser': true,
    'es6': true,
    'node': true,
  },
  'extends': [
    'airbnb-base',
    'plugin:vue/vue3-recommended',
  ],
  'plugins': [
    'vue',
  ],
  'rules': {
    'semi': 'error',
    'quotes': ['error', 'single'],
    'quote-props': ['error', 'always'],
    'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 1 }],
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
    'vue/no-unused-components': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
    'vue/max-attributes-per-line': 'off',
    'vue/prop-name-casing': ['error', 'camelCase'],
    'max-len': ['error', {
      'code': 240, 'ignoreStrings': true, 'ignoreComments': true, 'ignoreTrailingComments': true, 'ignoreUrls': true,
    }],
    'indent': ['error', 2],
    'comma-dangle': ['error', {
      'arrays': 'only-multiline',
      'objects': 'always-multiline',
      'imports': 'only-multiline',
      'exports': 'only-multiline',
      'functions': 'never',
    }],
    'no-param-reassign': ['warn', { 'props': false }],
    'lines-between-class-members': 'off',
    'prefer-destructuring': ['error', { 'object': true, 'array': false }],
    'no-plusplus': ['error', { 'allowForLoopAfterthoughts': true }],
    'import/no-extraneous-dependencies': 'off',
  },
  'ignorePatterns': ['temp.js', '**/fontawesome-pro/**'],
  'settings': {
    'import/resolver': {
      'alias': {
        'map': [
          ['@', './src'],
        ],
        'extensions': ['.ts', '.js', '.jsx', '.json', '.vue'],
      },
    },
  },
};

What did you do?

<template>
  <div class="w-16 h-16 flex flex-wrap justify-center content-center">
    <span class="text-2xl" @click="$emit('actionclicked')"><i :class="`fal fa-${icon}`" /></span>
    <span v-if="label">{{ label }}</span>
  </div>
</template>

<script>
export default {
  'props': {
    'icon': { 'type': String, 'required': true },
    'label': { 'type': String, 'default': '' },
    'active': { 'type': Boolean, 'default': false },
  },
  'emits': ['actionclicked'],
};
</script>

What did you expect to happen?
No warning

What actually happened?

/Users/ehutch79/Sites/Slate/slate-v4-testing/src/views/base/navbar/navbarAction.vue
3:42 warning The "actionclicked" event has been triggered but not declared on emits option vue/require-explicit-emits

I have the 'quote-props' rule turned on, and with autofix in vscode, option properties like props and emits get quoted automatically.

vue/require-explicit-emits works fine if I remove the quotes from from the emits property, and disable the 'quote-props' check for the line with // eslint-disable-next-line quote-props.

The issue is definitely that the rule check is not finding emits when declared with quotes.

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