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

Refactor: Improve folder structure #417

Open
azat-io opened this issue Dec 13, 2024 · 4 comments
Open

Refactor: Improve folder structure #417

azat-io opened this issue Dec 13, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@azat-io
Copy link
Owner

azat-io commented Dec 13, 2024

We currently have a mess of files in the utils folder.

I think we should clean up this folder and move utilities to folders related to rules:

.
├── rules/
│   ├── sort-classes/
│   │   ├── some-class-utility.ts
│   │   └── types.ts
│   ├── sort-imports/
│   │   └── detect-import-type.ts
│   ├── sort-classes.ts
│   ├── sort-imports.ts
│   └── sort-exports.ts
├── test/
│   ├── rules/
│   │   ├── sort-classes/
│   │   │   └── types.test.ts
│   │   ├── sort-classes.test.ts
│   │   └── sort-imports.test.ts
│   └── utils/
│       └── compare.test.ts
└── utils/
    └── compare.ts

Common utilities should remain in the utils folder.

@azat-io azat-io added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Dec 13, 2024
@hugop95
Copy link
Contributor

hugop95 commented Dec 13, 2024

@azat-io

I think we should clean up this folder and move utilities to folders related to rules

👍 100% agree

What do you think about moving test files next to their source?

.
├── rules/
   ├── sort-classes/
      ├── some-class-utility.ts
      ├── types.ts
      └── types.test.ts
   ├── sort-imports/
      ├── detect-import-type.ts
      └── detect-import-type.test.ts
   ├── sort-classes.ts
   ├── sort-classes.test.ts
   ├── sort-imports.ts
   ├── sort-imports.test.ts
   ├── sort-exports.ts
   └── sort-exports.test.ts
└── utils/
    ├── compare.ts
    └── compare.test.ts

@azat-io
Copy link
Owner Author

azat-io commented Dec 13, 2024

@hugop95 I don't know, I think it would be cleaner if the tests were kept in a separate folder.

What do you think?

@hugop95
Copy link
Contributor

hugop95 commented Dec 13, 2024

@azat-io I think there are pros and cons with each. Ultimately though, it's really a matter of personal preference.

Pros of having tests next to their source code

  • Easy to go to the tests of a given file, especially for bigger projects with a lot of nested folders (not necessarily the case here at the moment). Most IDEs make it easy to distinguish between source and test files.
Example

image

Cons

  • We have to switch from configuring things based on folders (rules vs tests) to configuring things based on file suffix (.test.ts or not).

@azat-io
Copy link
Owner Author

azat-io commented Dec 13, 2024

I just feel like there would be too many files in the rules folder and it would be a little harder to navigate if I wanted to read only the tests or only the source code of the rules.

Personally, I prefer a separate folder for tests.

I would like to hear other opinions.

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

No branches or pull requests

2 participants