Skip to content

vue/sort-keys runOutsideVue option #1865

Closed
@lukethompson

Description

@lukethompson

What rule do you want to change?
vue/sort-keys add option to give the ability to only run inside of Vue. My team likes to alphabetize our props, computed, methods etc... but we do not want to enforce all object keys being sorted.

vue/sort-keys does already have a runOutsideVue option but it is not used in the rule.

Does this change cause the rule to produce more or fewer warnings?
Fewer if the option is set.

How will the change be implemented? (New option, new default behavior, etc.)?
vue/sort-keys already has options.runOutsideVue, the default value is true passing false doesn't do anything. The change will use the value passed by this option to allow users to ignore sorting outside of vue.

Please provide some example code that this change will affect:

// runOutsideVue: false

export default {
    methods: {
       // Will sort keys inside of `methods`, `props`, `computed` etc...
        createArticle () {
            return this.createEntity({
                // Will ignore keys not on a Vue instance
                id: 1,
                type: 'article',
                attributes: { createdAt: new Date() }
            })
        },
        deleteArticle (id) {}
    },
}

What does the rule currently do for this code?
options.runOutsideVue exists but is not used. Currently all object keys are sorted by this rule.

What will the rule do after it's changed?
Use the options.runOutsideVue option, currently is defaulted to true so this change will have no impact on existing uses.

Additional context
This change will somewhat address the issue here #630

I have already implemented this change and will link the PR below.

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