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

[feature] Share rules #628

Open
q0w opened this issue Sep 7, 2023 · 4 comments
Open

[feature] Share rules #628

q0w opened this issue Sep 7, 2023 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@q0w
Copy link

q0w commented Sep 7, 2023

⭐ Suggestion

A way to use external rules, not only in local dirs.

💻 Use Cases

I want to implement a set of rules in one repo and use it in another. It would be great with some way to enable external rules.

@q0w q0w added the enhancement New feature or request label Sep 7, 2023
@HerringtonDarkholme
Copy link
Member

Hi @q0w , thanks for your continuous support for ast-grep!

Sharing rules are not done on purpose because I have not decided the best way to share rules.

Is using git submodule solving your problem? Or publishing it on npm?

Looking forward to your feedback.

@HerringtonDarkholme HerringtonDarkholme added the question Further information is requested label Sep 16, 2023
@q0w
Copy link
Author

q0w commented Sep 26, 2023

I can package my rules through pypi, but the problem is an auto-discovery of these rules. Users can use different names for virtualenv. I cant force it in config ruleDirs. Maybe local configs + default root config can solve this

@HerringtonDarkholme
Copy link
Member

If I understand it correctly, you are suggesting local configs which can discover rules installed in virtualenv?
It will require ast-grep implement pypi's resolution logic or discovery logic. Is it correct?

@q0w
Copy link
Author

q0w commented Oct 11, 2023

I think ast-grep should not implement pyp's resolution logic. Local config is needed to provide a path for a local venv.

So there is a root config sgconfig.yml that handles local rules:

ruleDirs:
  - .rules
  - .venv/package-name/rules # default venv name

And there is a local user config which is not tracked by git

ruleDirs:
  - .venv2/package-name/rules # user's venv name

Ast-grep should merge ruleDirs = .rules + .venv/package-name/rules + .venv2/package-name/rules

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

No branches or pull requests

2 participants