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

Do not mix up props before and after spread operator #15

Closed
pahan35 opened this issue Apr 18, 2020 · 1 comment · Fixed by #17
Closed

Do not mix up props before and after spread operator #15

pahan35 opened this issue Apr 18, 2020 · 1 comment · Fixed by #17

Comments

@pahan35
Copy link
Contributor

pahan35 commented Apr 18, 2020

Relates to #3

Versions

eslint-plugin-sort-keys-fix: 1.1.0
Node.js: 13.7.0

Dependencies

npm i -D babel-eslint eslint eslint-plugin-sort-keys-fix

.eslintrc

{
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 8,
    "sourceType": "module",
  },
  "plugins": [
    "sort-keys-fix"
  ],
  "env": {
      "browser": true,
      "es6": true,
    },
  "rules": {
    "sort-keys-fix/sort-keys-fix": "error"
  }
}

Code to reproduce

var z = {}
var obj = {b:1, ...z, a:1}

Expected

No violations

Actual

ESLint: Expected object keys to be in ascending order. 'a' should be before 'b'.(sort-keys-fix/sort-keys-fix)

image

Motivation

It's problematic in cases where we want to allow overriding some in the target object

function foo(overridings) {
  const target = {b: 7, ...overridings, a: 5}
}

Also, current behavior causes bugs like described in #2 (comment)

@leo-buneev
Copy link
Owner

Thx @pahan35 . Released in 1.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants