ls-lint icon indicating copy to clipboard operation
ls-lint copied to clipboard

Wildcard support for file extensions?

Open NicolasReibnitz opened this issue 3 years ago • 8 comments

Hi!

First of all, I'd like to say that I love this! Exactly what I was looking for! Thanks!

One feature that seems to be missing (or would be great to have) is the option to set a general rule for all files. Specifically to say that all files and folders should be lowercase, regardless of their extension.

It seems that something like this isn't possible:

ls:
    .*: lowercase
    .dir: kebab-case
    .js: kebab-case
    ...

Correct?

The alternative would be to find out what extensions are in a project and what extensions could come up in the future, which isn't really feasible.

Or do you have another idea?

Thanks in advance!

P.S. One could, of course, run something like this to find all files and folders that have uppercase letters in them:

find . -path ./node_modules -prune -false -o -name "*[[:upper:]]*"

But depending on the number of folders to ignore, this can quickly get pretty messy.

NicolasReibnitz avatar Jul 12 '21 03:07 NicolasReibnitz

I've found myself wanting to use wildcards (i.e. glob) for other things like ignore paths as well. For examples I'd like to ignore **/node_modules. When I specify just node_modules, my first assumption was that whenever it runs across any file/directory located in any node_modules it'll ignore it, but node_modules just means the node_modules folder in the root where the configuration is.

Is it possible to use globs wherever matching needs to happen (e.g., extensions, paths, ignore)?

jgornick avatar Aug 31 '21 17:08 jgornick

Indeed, using a default rule for all files (possibly in a subdirectory) would be super helpful. My use case : checking that image files are all kebab case. Currently I cannot use ls-lint for that as for instance I don't know how to write a rule for don_t_like_this_name.JPG because it's the extension that is breaking the naming convention...

aphecetche avatar Feb 01 '22 10:02 aphecetche

Hey,

agree to all of you and i'll try to bring more and more glob patterns to ls-lint.

@aphecetche .JPG: kebeb-case isn't working?

loeffel-io avatar Feb 01 '22 20:02 loeffel-io

Hey,

agree to all of you and i'll try to bring more and more glob patterns to ls-lint.

@aphecetche .JPG: kebeb-case isn't working?

sorry for the late answer : no, it does not work (at least for what I want to do, I.e. have the full filename be kebab-case), as the casing of the extension itself is not checked as far as I can tell.

aphecetche avatar Feb 20 '22 15:02 aphecetche

Wildcard support would be perfect (but not only for ignores) I plan to define a regexp to forbid some file-extensions

ls:
  
  components/assets:
    .dir: kebab-case
    .png: kebab-case
    .*: regex:only-png-files-allowed

crazyx13th avatar Aug 04 '22 09:08 crazyx13th

wildcard support, or default rule, please

tigerinus avatar Jun 07 '23 20:06 tigerinus

I think this would be also useful for files without extensions. For example binary/executable files are often without extension.

lo1tuma avatar Jun 15 '23 12:06 lo1tuma

Love the library! Thanks for making it.

I'm going to add another use case for this that I've run into, which is sub-extensions. My app uses SvelteKit and Vite, which means I'm dealing with .d.ts, .config.ts, .server.ts. For all of those I want camelCase for the base name and would love to be able to do .*.ts: camelcase instead of individually calling out all those sub-extensions.

ethanjdiamond avatar Oct 13 '23 15:10 ethanjdiamond