loeffel-io / ls-lint

An extremely fast directory and filename linter - Bring some structure to your project filesystem
https://ls-lint.org
MIT License
1.74k stars 32 forks source link

#201: implement disallow rule #202

Closed aleinin closed 4 months ago

aleinin commented 8 months ago

Example implementation for a disallow rule as I mentioned in #201 if the maintainers are interested in the feature. Open to all feedback.

I have not written Go before, so I apologize if there are beginner mistakes, but I added testing where possible.

I compiled and installed it locally and here is an example usage and the results:

ls:
  .blocked: disallow
  .no: disallow:use something else
  .actually.no: disallow:no

ignore:
  - node_modules

will result in (given matches for each)

2024/02/28 00:35:55 src/utils/fil3.blocked failed for rules: disallow
2024/02/28 00:35:55 src/utils/file2.no failed for rules: disallow (use something else)
2024/02/28 00:35:55 src/utils/file4.maybe.actually.no failed for rules: disallow (no)
loeffel-io commented 7 months ago

Thanks @aleinin for your contribution!

For now i am not sure if this will make it into ls-lint in case of some downsides to this - but i will leave this open! the pr LGTM

ccoVeille commented 4 months ago

I like this rule. This one is somehow a negation of "exists" rules

loeffel-io commented 4 months ago

its like the new exists:0 definition

ccoVeille commented 4 months ago

I assumed it, thanks for confirming

ccoVeille commented 4 months ago

For anyone interested. You can now use exists:0 as a rule. Please check the documentation

loeffel-io commented 4 months ago

@ccoVeille v2.3.0 is not released yet - there is one single piece that is missing

ccoVeille commented 4 months ago

Author opened the issue 4 months ago. I assumed he could wait a few more days/week.

But you are right, it's not yet available or documented

loeffel-io commented 4 months ago

As far i can tell this is one of the most challenging tasks for me - its beautiful how wildcard extensions, selected files and exists working together magically

ccoVeille commented 4 months ago

Exists without wildcards would have been very limited

loeffel-io commented 3 months ago

This feature is now available in the v2.3.0-beta.1 release. Please test it and let me know if there are any issues ❤️

The upcoming v2.3.0 blog post: https://ls-lint.org/blog/announcements/v2.3.0.html The docs: https://ls-lint.org/2.3/getting-started/introduction.html The release notes: https://github.com/loeffel-io/ls-lint/releases/tag/v2.3.0-beta.1