Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Add option for object-literal-sort-keys to not ignore blank lines #4756

Closed
dmitryshimkin opened this issue Jun 7, 2019 · 3 comments · Fixed by #4808
Closed

Add option for object-literal-sort-keys to not ignore blank lines #4756

dmitryshimkin opened this issue Jun 7, 2019 · 3 comments · Fixed by #4808

Comments

@dmitryshimkin
Copy link

dmitryshimkin commented Jun 7, 2019

Bug Report

  • TSLint version: 5.17.0
  • TypeScript version: 2.7.2
  • Running TSLint via: CLI

TypeScript code being linted

const test = {
  b: 'b',

  a: 'a',

  c: 'c',
};

with tslint.json configuration:

"object-literal-sort-keys": [
  true,
  "ignore-case",
  "locale-compare"
]

Actual behavior

No lint errors

Expected behavior

"Properties are not sorted" error.

@ghost
Copy link

ghost commented Jun 9, 2019

After see the rule documentation seems the correct behavior:

When using the default alphabetical ordering, additional blank lines may be used to group object properties together while keeping the elements within each group in alphabetical order.

@dmitryshimkin
Copy link
Author

dmitryshimkin commented Jun 9, 2019

After see the rule documentation seems the correct behavior:

When using the default alphabetical ordering, additional blank lines may be used to group object properties together while keeping the elements within each group in alphabetical order.

Right, according to the docs it seems to be expected behaviour. Now I wonder if there is a way to opt out this. Otherwise, this rule cannot be used in cases when all properties are separated with blank lines for better readability.

@JoshuaKGoldberg JoshuaKGoldberg changed the title object-literal-sort-keys doesn't work when keys are separated with blank lines Add option for object-literal-sort-keys to not ignore blank lines Jun 15, 2019
@JoshuaKGoldberg
Copy link
Contributor

Seems like a reasonable idea - accepting PRs to add an option to not ignore blank lines.

Do keep #4534 in mind: custom rules including forks of built-in rules such as object-literal-sort-keys are always an option and can be maintained outside this repo.

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

Successfully merging a pull request may close this issue.

2 participants