loeffel-io / ls-lint

An extremely fast directory and filename linter - Bring some structure to your project filesystem

Home Page:https://ls-lint.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: ignore abbreviations

soc221b opened this issue Β· comments

I'm wondering if this is useful to anyone else πŸ€”:

ls:
  packages/*/{src,__tests__}:
    .js: kebab-case
    .ts: camelCase | PascalCase
    .d.ts: camelCase
    .spec.ts: camelCase | PascalCase
    .mock.ts: camelCase

ignore:
  - node_modules
+
+ abbr:
+  - HTTP
+  - SMS

Thank you~

Hey @iendeavor, could you please provide more context

thank you

Hi, @loeffel-io
Thanks for your quick reply.

For example, we might have some files containing the abbreviation "SMS", but it violates the PascalCase rule:

ls:
  .ts: PascalCase
path/
β”‚
└─ to/
  β”‚
  β”œβ”€ EmailService.ts # valid
  β”‚
  └─ SMSService.ts # invalid

Hey @iendeavor

for this you can use the regex rule and allow only specific values or the negative of them with something like

ls:
    to:
         .ts: regex:(Email|Foo|Bla)Service # allow EmailService, FooService, BlaService

the negative could be this, but this isn't supported by re2 and go

ls:
    to:
         .ts: regex:(?!HTTP|SMS).*Service # do not allow HTTPService, SMSService

for this a not_regex rule could make sense

Yes, this makes sense for the example mentioned earlier, but we might have any name anywhere in the filename, and we also want to validate it based on specific rules, like:

Example 1: https://github.com/facebook/react-native/tree/6e42c98aa3423cfbc389e4fe877b5c6b559c8a81/packages/community-cli-plugin/src/commands/bundle

ls:
  .js: camelCase
../
β”‚
└─ bundle/
  β”‚
  β”œβ”€ assetCatalogIOS.js
  β”‚
  β”œβ”€ getAssetDestPathIOS.js
  β”‚
  └─ __tests__/
    β”‚
    └─ getAssetDestPathIOS-test.js

Example 2: https://github.com/apple/swift/tree/main/lib/AST

ls:
  .cpp: PascalCase
../
β”‚
β”œβ”€ AST/
β”‚ β”‚
β”‚ β”œβ”€ ASTScope.cpp
β”‚ β”‚
β”‚ β”œβ”€ ASTScopePrinting.cpp
β”‚ β”‚
β”‚ └─ ASTScopeSourceRange.cpp
β”‚
└─ RemoteAST/
  β”‚
  └─ RemoteAST.cpp

what about

ls:
    to:
         .ts: regex:(Email|Foo|Bla)Service | camelCase # allow EmailService, FooService, BlaService and all camelCase

filenames like getAssetDestPathIOS-test.js are an anti pattern imo

Closing this for now - please let me know if you have any further questions