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

Code structure of "utilities" is inconsistent #10559

Closed
platinumazure opened this issue Jul 4, 2018 · 10 comments
Closed

Code structure of "utilities" is inconsistent #10559

platinumazure opened this issue Jul 4, 2018 · 10 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue chore This change is not user-facing help wanted The team would welcome a contribution from the community for this issue

Comments

@platinumazure
Copy link
Member

platinumazure commented Jul 4, 2018

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 in lib/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 in lib/, and only "utility" modules in lib/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 in lib/.)

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 in lib/util/.

Some examples of modules that I think should be moved from lib/ to lib/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/ to lib/:

  • 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.

@platinumazure platinumazure added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion chore This change is not user-facing labels Jul 4, 2018
@platinumazure
Copy link
Member Author

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.

platinumazure added a commit that referenced this issue Jul 9, 2018
…0579)

* Chore: Move lib/logging to lib/util/logging

* Chore: Move lib/timing to lib/util/timing
@aladdin-add
Copy link
Member

what about lib/ast-utils.js => lib/util/ast-utils.js?
if so, all utils will be in lib/util/ dir.

and personally I'd like to rename ast-utils.js => ast-util.js, so it could be consistent to other util, like npm-util.js, path-util.js.

@not-an-aardvark
Copy link
Member

Given how much code uses ast-utils and variables like astUtils, it would probably be simpler to rename npm-util to npm-utils and path-util to path-utils.

aladdin-add added a commit to aladdin-add/eslint that referenced this issue Jul 26, 2018
aladdin-add added a commit to aladdin-add/eslint that referenced this issue Jul 26, 2018
platinumazure pushed a commit that referenced this issue Jul 28, 2018
* Chore: mv lib/ast-utils => lib/util/ast-utils (refs #10559)

* Chore: rename *-util => *-utils (refs #10559)
@aladdin-add
Copy link
Member

we might also need to move corresponding test files. 😄

@platinumazure
Copy link
Member Author

@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.)

@aladdin-add
Copy link
Member

I moved lib/ast-utils to lib/util/ast-utils, and renamed *-util to *-utils in #10680. but I'm sorry to forgot changing the tests. 😂

@aladdin-add aladdin-add added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 3, 2018
platinumazure pushed a commit that referenced this issue Aug 3, 2018
* Chore: rename test files for consistency (refs #10559)

* Chore: rename util => utils for consistency
@platinumazure
Copy link
Member Author

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:

  • lib/ignored-paths.js --> lib/util/ignored-paths.js
  • lib/load-rules.js --> lib/util/load-rules.js
  • lib/report-translator.js --> lib/util/report-translator.js

Moving from utils:

  • lib/util/rule-fixer.js --> lib/rule-fixer.js
  • lib/util/source-code-fixer.js --> lib/source-code-fixer.js
  • lib/util/source-code.js --> lib/source-code.js

Also wondering if it might be worth creating a lib/autofix folder for everything related to autofix.

@kaicataldo kaicataldo added help wanted The team would welcome a contribution from the community for this issue Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ labels Oct 15, 2018
@kaicataldo kaicataldo removed Hacktoberfest Recommended issue for those participating in Hacktoberfest https://hacktoberfest.digitalocean.com/ labels Nov 13, 2018
@nzakas
Copy link
Member

nzakas commented Nov 14, 2018

@platinumazure are you still working on this?

@platinumazure
Copy link
Member Author

@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.)

platinumazure added a commit that referenced this issue Nov 28, 2018
#11116)

* Chore: Move lib/ignored-paths to lib/util/ignored-paths

* Chore: Move lib/report-translator to lib/util/report-translator
@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Dec 15, 2018
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that accepted issues failing to be implemented after 90 days tend to
never be implemented, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 14, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue chore This change is not user-facing help wanted The team would welcome a contribution from the community for this issue
Projects
None yet
Development

No branches or pull requests

5 participants