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

Rule proposition: no-dupe-keys. #86

Closed
armano2 opened this issue Jul 17, 2017 · 4 comments
Closed

Rule proposition: no-dupe-keys. #86

armano2 opened this issue Jul 17, 2017 · 4 comments

Comments

@armano2
Copy link
Contributor

armano2 commented Jul 17, 2017

There is many fields in vue instance/component where we can specify properties visible inside component, data, props, computed, methods.
Invalid Code:

export default {
  props: ['foo'],
  props: {
    foo: String  
  },
  computed: {
    foo () {
    }
  },
  data() {
    return {
      foo: null
    }
  },
  data: {
    foo: null
  },
  methods: {
    foo () {
    }
  }
}

Also there is few reserved names witch should not be overridden by vue instance:

  • properties: $data, $props, $el, $options, $parent, $root, $children, $slots, $scopedSlots, $refs, $isServer, $attrs, $listeners
  • methods: $watch, $set, $delete, $on, $once, $off, $emit, $mount, $forceUpdate, $nextTick, $destroy .....

also user should be able to specify his own reserved names to remove conflicts with used plugins.

@mysticatea
Copy link
Member

Thank you for the proposal!

Sounds reasonable to me.
no-dupe-keys core rule cannot catch duplication of Vue's definition. We should catch it.

Also, the names which start with _ in data are reserved by Vue.js.

@armano2
Copy link
Contributor Author

armano2 commented Jul 19, 2017

@mysticatea i think we should rename this rule to same as core no-dupe-keys instead of no-duplicate-field-names

Also, the names which start with _ in data are reserved by Vue.js.

👍 i didn't know that but i will add this.

@armano2 armano2 changed the title Rule proposition: no-duplicate-field-names. Rule proposition: no-dupe-keys. Jul 19, 2017
@michalsnik
Copy link
Member

michalsnik commented Jul 21, 2017

I like this proposition a lot, but.. I think this rule should be splitted into two rules.

  1. no-dupe-keys
  2. no-reservered-keys

So that each rule does only one thing. What do you think @mysticatea @armano2 ?

@armano2
Copy link
Contributor Author

armano2 commented Jul 22, 2017

eslint recommends to make functions to small chunks and split them to separate rules.

One rule should do one think

@michalsnik i like it 👍

armano2 added a commit to armano2/eslint-plugin-vue that referenced this issue Jul 31, 2017
armano2 added a commit to armano2/eslint-plugin-vue that referenced this issue Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants