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
Code structure of "utilities" is inconsistent #10559
Comments
I've created #10579 for what I think are the least controversial of the moves I am recommending (lib/logging.js and lib/timing.js into the lib/util directory). I'll wait on making any further PRs until some discussion occurs or a few days/weeks pass without objections. |
what about and personally I'd like to rename |
Given how much code uses |
we might also need to move corresponding test files. 😄 |
@aladdin-add Can you name examples where we didn't do that correctly? (In my commits, lib/util/logging and lib/util/timing didn't have test files, and I did move tests/lib/file-finder correctly.) |
I moved |
* Chore: rename test files for consistency (refs #10559) * Chore: rename util => utils for consistency
Okay, I've taken another look after the PRs we've sent so far. Here is what I think we could still move (including some new ones): Moving to utils:
Moving from utils:
Also wondering if it might be worth creating a lib/autofix folder for everything related to autofix. |
@platinumazure are you still working on this? |
@nzakas Thank you for the reminder! I'll look at this again this week and determine if there are other changes to pursue. (I believe there will be other changes, but this hasn't been a priority.) |
#11116) * Chore: Move lib/ignored-paths to lib/util/ignored-paths * Chore: Move lib/report-translator to lib/util/report-translator
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
The modules that CLIEngine or Linter depend on are sometimes stored in inconsistent locations (at least, it seems that way to me).
At this point, it can be hard to see a consistent difference between files stored in
lib/
, vs files stored inlib/util/
. That is, in both directories, we can see both "core" and "utility" modules. I would like to see if we could store only "core" modules inlib/
, and only "utility" modules inlib/util/
. (The rule of thumb I would use for what constitutes a "core" module is as follows: Anything important enough to document in our Node.js API documentation page, or anything directly called by CLIEngine or Linter that performs a key piece of linting, should probably be "core" and should probably be inlib/
.)I think it could help new contributors find their way around the codebase better if we try to be more consistent about placing core modules in
lib/
and utility modules inlib/util/
.Some examples of modules that I think should be moved from
lib/
tolib/util/
:lib/ast-utils.js
: This is used by many rules, but it is not a strategic part of our API. I think this should be in lib/util.lib/file-finder.js
: This is used in the config file operations for helping find files on the filesystem. Config APIs themselves (e.g., in lib/config.js) should be "core" and be in the lib directory, but I think this file should be in lib/util.lib/logging.js
: This is clearly not a core module, but rather something used for internal logging only. Should be in lib/util.lib/timing.js
: This is clearly not a core module, but rather something to help with performance testing only.(I do think there could be other modules on this list, especially around rule management, but this is a good start.)
Some examples of modules that I think should be moved from
lib/util/
tolib/
:lib/util/rule-fixer.js
: This API is used in all core and custom rules that support autofixing, which is a key component of the linter.lib/util/source-code-fixer.js
: This code is a key part of tracking and applying autofixes, which is a key component of the linter.Would love to get feedback from the rest of the team on this.
The text was updated successfully, but these errors were encountered: