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

How to disable some specific names?

Open basharov opened this issue 3 years ago • 10 comments

I'd like to prohibit using filename index.css in my components but cannot find details about the syntax of regex used in the project to build a proper expression.

Please advise.

basharov avatar Jan 14 '21 11:01 basharov

So everything for .css should be allowed expect index.css?

loeffel-io avatar Jan 14 '21 12:01 loeffel-io

You're right, I want to allow any css filenames except index.css

basharov avatar Jan 14 '21 12:01 basharov

https://regex101.com/r/xYtUN5/1 could work

loeffel-io avatar Jan 14 '21 12:01 loeffel-io

@loeffel-io It showd the error:

error parsing regexp: invalid or unsupported Perl syntax: (?!

basharov avatar Jan 14 '21 12:01 basharov

"Go regex does not support lookarounds." - thats sad

In this case you have to find a way to convert your lookarounds to std regex

loeffel-io avatar Jan 14 '21 12:01 loeffel-io

just keep in mind that there is the ignore pattern: https://ls-lint.org/1.x/configuration/the-basics.html#creating-configuration maybe this can help you too

loeffel-io avatar Jan 14 '21 12:01 loeffel-io

@basharov to make it more easy we could provide a not_regex rule in v2 🤔

loeffel-io avatar Jan 15 '21 08:01 loeffel-io

I also encountered the same scene. In my scenario, I want all tsx files except for the file name use***.tsx to use the pascal case rule, and use***.tsx to use the camel case rule. It doesn’t seem to meet my needs so far

LaamGinghong avatar Aug 14 '21 07:08 LaamGinghong

I also encountered the same scene. In my scenario, I want all tsx files except for the file name use***.tsx to use the pascal case rule, and use***.tsx to use the camel case rule. It doesn’t seem to meet my needs so far

@LaamGinghong I keep all of my hooks in a separate directory (src/hooks). That way, I can set up a separate rule for my hooks directory.

jfairley avatar Feb 02 '22 22:02 jfairley

@loeffel-io I'm here looking for something similar. It would be nice to define reject patterns. index.css is one example, but similarly, imagine a project using something like SASS or LESS. I would want to forbid all .css files.

In my specific case, I'm trying to target inconsistent naming between .types.ts and .type.ts. I want to blacklist one of those. I tried .type.ts: "regex:" but empty regex isn't allowed. Admittedly, that's a hack anyway.


Edit: Ah, I'm interested in the proposed "Strict Mode" #32.

jfairley avatar Feb 02 '22 22:02 jfairley