Giter VIP home page Giter VIP logo

eslint-plugin-vue-extras's Introduction

eslint-plugin-vue-extras

Installation

You'll first need to install ESLint:

yarn add eslint eslint-plugin-vue --dev

Next, install eslint-plugin-vue-extras:

yarn add eslint-plugin-vue-extras --dev

Usage

Add eslint-vue-extra to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "vue-extras"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "vue-extras/no-this-in-before-route-enter": 2,
        "vue-extras/use-attribute-shortcut": 2,
        "vue-extras/type-object-props": 2,
        "vue-extras/no-empty-methods": 2,
        "vue-extras/no-empty-computed": 2
    }
}

Supported Rules

vue-extras/no-this-in-before-route-enter

Bad:

<script>
export default {
  beforeRouteEnter() {
    this.method()
  }
}
</script>

In a beforeRouteEnter method this is undefined. Details: link

vue-extras/use-attribute-shortcut

Bad:

<template>
  <component :attr="true" />
</template>

Good:

<template>
  <component attr />
  <component attr="true" />
  <component :attr="false" />
</template>

Force attribute shortcut. Add --fix flag to apply shortcut.

vue-extras/no-empty-methods

Bad:

export default {
  methods: {}
}

Good:

export default {
}
export default {
  methods: {
    method() {

    }
  }
}

Add --fix flag to apply shortcut.

vue-extras/no-empty-computed

Bad:

export default {
  computed: {}
}

Good:

export default {
}
export default {
  computed: {
    item() {

    }
  }
}

Add --fix flag to apply shortcut.

TypeScript only

vue-extras/type-object-props

  • requires @typescript-eslint/parser

Bad:

<script lang="ts">
export default {
  props: {
    prop: {
      type: Object // Object props has to be typed
    }
  }
}
</script>

Good:

<script lang="ts">
import { Prop } from 'vue/types/options';

export default {
  props: {
    prop: {
      type: Object as Prop<{}>
    }
  }
}
</script>

eslint-plugin-vue-extras's People

Contributors

dependabot[bot] avatar przemyslawjanpietrzak avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.