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

feat: allow type: unsorted for all remaining rules #468

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

hugop95
Copy link
Contributor

@hugop95 hugop95 commented Feb 11, 2025

Most of the added lines are documentation and tests.

Description

Today, only the following rules support type: unsorted directly in the options object (meaning: outside of customGroups)

  • sort-array-includes
  • sort-sets
  • sort-maps (is supposed to but actually isn't due to its JSON schema, and a test is missing about that)
  • sort-objects
  • sort-interfaces
  • sort-object-types

These rules support this feature because they have a useConfigurationIf option, which synergizes well together.

The problem

The current implementation of type: unsorted is simple, but is lacking as it returns very early. As such,

  • It ignores newlinesBetween.
  • It ignores groups.
  • It ignores dependency order (although this is less of an issue as we don't enforce a specific sort order here).

Users may want to type: unsorted with:

  • newlinesBetween, in order not to enforce sorting order, but to enforce no newline between elements.
  • groups, to enforce grouping, but not enforce any sorting other than required dependency sort.

Proposal

This PR focuses on the following:

  1. Prevents type: unsorted from returning early and ignoring newlinesBetween and groups options.
  2. Enables type: unsorted for all remaining rules that did not support it.

Commit split

  • Commits 1-2: Documentation fixes from previous PRs.
  • Commit 3: Fixes sort-maps not handling type: unsorted when it should already be.
  • Commits 4-6: Refactor and adds additional tests to rules already handling type: unsorted.
  • Commit 7: Enables type: unsorted for all remaining rules.
  • Commits 8+: 1 commit per rule
    • Simplifying code if needed.
    • Updating documentation.
    • Adding tests.

Impacted tests

No test was removed or had its content updated.

What is the purpose of this pull request?

  • New Feature

- It was only handled in `customGroups` and a test was missing.
- We will be adding additional tests in the next commit
@hugop95 hugop95 changed the title feat: allows type: unsorted for all remaining rules feat: enable type: unsorted for all remaining rules Feb 11, 2025
@hugop95 hugop95 changed the title feat: enable type: unsorted for all remaining rules feat: allow type: unsorted for all remaining rules Feb 11, 2025
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 this pull request may close these issues.

1 participant