dolsem / eslint-plugin-filename-rules

MIT License
36 stars 7 forks source link

Feature: add a rule that is the inverse of the 'match' rule #13

Closed TSMMark closed 1 year ago

TSMMark commented 1 year ago

Thanks for this library!

I want to be able to specify that certain regex patterns are NOT allowed.

E.g. I noticed that an adblocker was blocking one of my codesplit files, which happened to be named AdBanner.js. I renamed our module to RecommendationBanner.js to avoid this.

So I want to be able to disallow the word Ad from filenames.

Imagining rejecting files matching a pattern kind of like:

'filename-rules/not-match': [2, /(^|[\Wa-z])Ad([\WA-Z]|$)/],

to reject file names such as:

Here's a regex playground POC showing matches vs non-matches of the above pattern example:

https://regex-playground-cloworm.vercel.app/?matches=ad_banner.tsx&matches=banner_ad.tsx&matches=AdBanner&matches=BannerAd&matches=load.tsx&matches=additional.tsx&matches=some_additional.tsx&pattern=%28%5B_.a-z0-9%5DAd%7CAd%5B_.A-Z0-9%5D%7C%5B_.0-9%5Dad_%7C%28%5B%5EA-Za-z%5D%7C%5E%29ad%5B_.A-Z0-9%5D%29

Would you accept a PR for this change?

Thanks

TSMMark commented 1 year ago

I should have a PR by EOD