Skip to content
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

[BUG] vue/attributes-order: always-error #1056

Closed
sense-it-gmbh opened this issue Feb 17, 2020 · 2 comments · Fixed by #1055
Closed

[BUG] vue/attributes-order: always-error #1056

sense-it-gmbh opened this issue Feb 17, 2020 · 2 comments · Fixed by #1055
Labels

Comments

@sense-it-gmbh
Copy link

sense-it-gmbh commented Feb 17, 2020

Tell us about your environment

  • ESLint version: 5.16.0
  • eslint-plugin-vue version: 6.2.0
  • Node version: v8.12.0

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?

either:

<v-img
    v-if="dataNotLoaded"
    v-show="tempoaryHidden"
/>

or:

<v-img
    v-show="tempoaryHidden"
    v-if="dataNotLoaded"
/>

What did you expect to happen?

One of the above examples is accepted as valid.

Since the alphabetical option is true 'v-if before v-show' should be accepted.

What actually happened?

None of the examples gets accepted.

either:

  132:15  error  Attribute "v-show" should go before "v-if"  vue/attributes-order

or:

  132:15  error  Attribute "v-if" should go before "v-show"        vue/attributes-order

EDIT: this seems to happen for all directives and also for events that have a modifier like @keydown.enter or @keydown.escape.

@ota-meshi
Copy link
Member

Thank you for this issue.
I will fix this bug.

@sense-it-gmbh
Copy link
Author

@ota-meshi thanks for your fast reaction.

I have an update: This seems to be a problem with directives in general. The same happend to me with:

        <v-img
            ref="image"
            v-test-e2e="'form-identificationPoint-map'"
            v-resize="recalculateMaxImageHeight"
        ></v-img>

No matter wich is first ESLint will complain always that the other one should be first. Im now convinced more than ever that this issue is related to #1053

ota-meshi added a commit that referenced this issue Feb 17, 2020
@ota-meshi ota-meshi added the bug label Feb 17, 2020
ota-meshi added a commit that referenced this issue Feb 17, 2020
…s-order' with `alphabetical` option. (#1055)

* Fixed false positives for binded and unbinded attrs in 'vue/attributes-order' with `alphabetical` option.

* Fixed #1056

* test timeout to 300000ms

* revert timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants