Skip to content

False positive on 'vue/attributes-order' with 'alphabetical' for directives #1094

Closed
@sense-it-gmbh

Description

@sense-it-gmbh

Seems to be related to #1055

Tell us about your environment

  • ESLint version: 5.16.0
  • eslint-plugin-vue version: 6.2.2
  • Node version: v12.16.1

Please show your full configuration:

const INLINE_ELEMENTS = [
  'a',
  'abbr',
  'audio',
  'b',
  'bdi',
  'bdo',
  'canvas',
  'cite',
  'code',
  'data',
  'del',
  'dfn',
  'em',
  'i',
  'iframe',
  'ins',
  'kbd',
  'label',
  'map',
  'mark',
  'noscript',
  'object',
  'output',
  'picture',
  'q',
  'ruby',
  's',
  'samp',
  'small',
  'span',
  'strong',
  'sub',
  'sup',
  'svg',
  'time',
  'u',
  'var',
  'video'
]

const ERROR = 'error'
const WARN = 'warn'
const OFF = 'off'

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/essential',
    'plugin:vue/strongly-recommended',
    'plugin:vue/recommended',
    '@vue/standard'
  ],
  globals: {
    __VERSION__: true
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? ERROR : OFF,
    'no-debugger': process.env.NODE_ENV === 'production' ? ERROR : OFF,
    'indent': [ERROR, 2],
    'no-unused-vars': WARN,
    'vue/html-indent': [ERROR, 2, {
      attribute: 2,
      baseIndent: 1,
      closeBracket: 0,
      alignAttributesVertically: false,
      ignores: []
    }],
    'vue/html-self-closing': [WARN, {
      html: {
        normal: 'never',
        void: 'any',
        component: 'any'
      },
      svg: 'any',
      math: 'any'
    }],
    'vue/multiline-html-element-content-newline': [WARN, {
      ignoreWhenEmpty: true,
      ignores: ['v-btn', 'v-icon', ...INLINE_ELEMENTS],
      allowEmptyLines: false
    }],
    'vue/name-property-casing': [ERROR, 'PascalCase'],
    'vue/singleline-html-element-content-newline': [WARN, {
      ignoreWhenNoAttributes: true,
      ignoreWhenEmpty: true,
      ignores: ['v-btn', 'v-icon', ...INLINE_ELEMENTS]
    }],
    'vue/array-bracket-spacing': [ERROR, 'always', {
      objectsInArrays: false,
      arraysInArrays: false
    }],
    'vue/object-curly-spacing': [ERROR, 'always'],
    'vue/arrow-spacing': [ERROR],
    'vue/block-spacing': [ERROR],
    'vue/brace-style': [ERROR],
    'vue/camelcase': [ERROR],
    'vue/comma-dangle': [ERROR],
    'vue/component-name-in-template-casing': [ERROR, 'kebab-case'],
    'vue/dot-location': [ERROR, 'property'],
    'vue/eqeqeq': [ERROR],
    'vue/key-spacing': [ERROR],
    'vue/keyword-spacing': [ERROR],
    'vue/match-component-file-name': [ERROR, {
      shouldMatchCase: false,
      extensions: ['vue']
    }],
    'vue/no-boolean-default': [ERROR, 'default-false'],
    'vue/no-deprecated-scope-attribute': [ERROR],
    'vue/space-infix-ops': [ERROR],
    'vue/space-unary-ops': [ERROR, {
      words: true,
      nonwords: false
    }],
    'vue/attributes-order': [ERROR, {
      'alphabetical': true
    }]
  },
  parserOptions: {
    parser: 'babel-eslint'
  },
  overrides: [{
    files: [
      '**/__tests__/*.{j,t}s?(x)'
    ],
    env: {
      mocha: true
    }
  }]
}

What did you do?

Take note of the directive order!

Example 1

<template>
  <my-component
      v-model="model"
      v-osk="keyboardName"
      v-test-e2e="'e2e-id-for-references-in-tests'"
  />
</template>

<script>
export default {
  name: 'MyComponent',
  data: () => ({
    keyboardName: 'default',
    model: ''
  })
}
</script>

- O R -

Example 2:

<template>
  <my-component
      v-model="model"
      v-test-e2e="'e2e-id-for-references-in-tests'"
      v-osk="keyboardName"
  />
</template>

<script>
export default {
  name: 'MyComponent',
  data: () => ({
    keyboardName: 'default',
    model: ''
  })
}
</script>

What did you expect to happen?

  • Expect Example 1 to not have error
  • Expect Example 2 to have error

What actually happened?

Both examples triggerd errors:

  • Message for example 1: ESLint: Attribute "v-test-e2e" should go before "v-osk".(vue/attributes-order)
  • Message for example 2: ESLint: Attribute "v-osk" should go before "v-test-e2e".(vue/attributes-order)

--> only one can be correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions