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

Feature Proposal: Blocklists #201

Closed aleinin closed 4 months ago

aleinin commented 8 months ago

Hello, thank you for making ls-lint!

It would be nice to be able to block certain files. Here is my use case:

ls:
  # tsx
  .router.test.tsx: PascalCase
  .router.tsx: PascalCase
  .types.tsx: PascalCase
  # Pascal case regex allowing for prefix use for hooks
  .tsx: regex:^(use)*[A-Z][a-z]+(?:[A-Z][a-z]+)*$
  .test.tsx: regex:^(use)*[A-Z][a-z]+(?:[A-Z][a-z]+)*$
  # scss
  .module.scss: PascalCase
  # block list
  .modules.scss: regex:module-not-modules
  .test.ts: regex:spec-for-ts
  .spec.tsx: regex:test-for-tsx
  .css: regex:use-scss
  .jsx: regex:use-tsx

ignore:
  - .git
  - node_modules

2024/02/27 01:35:29 src/app/Cool.jsx failed for rules: regex (use-tsx)

As you can see, I have a small blocklist where I'm using the regex rule to error on certain file types to enforce a particular usage. Honestly, this works quite well. But, it would be nice if there was a more natural way to go about this than misusing the regex rule.

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 5 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

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