Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Allow specific file or folder names #42

Open
chimericdream opened this issue Apr 15, 2024 · 4 comments
Open

[Request] Allow specific file or folder names #42

chimericdream opened this issue Apr 15, 2024 · 4 comments

Comments

@chimericdream
Copy link

In our project, we want to use kebab case for all folders, but still allow a few specific strings like __mocks__. At present, it doesn't appear there is a way to allow this. We tried the following config, but it didn't appear to work:

        'check-file/folder-naming-convention': [
            'error',
            {
                '**/!(__mocks__)': 'KEBAB_CASE',
                '**/__mocks__': 'KEBAB_CASE',
            },
        ],

Ideally, I'd like to be able to do something like this:

        'check-file/folder-naming-convention': [
            'error',
            { '**': 'KEBAB_CASE' },
            { ignore: [ '__mocks__' ] },
        ],

I'd like to be able to do the same thing with the check-file/filename-naming-convention rule.

@dukeluo
Copy link
Owner

dukeluo commented Apr 16, 2024

@chimericdream You can write a glob expression to do this, and there is a similar example in the documentation:

To exclude tests folder in src, use the glob expression src/!(tests)/**/ to get the target folders.

@chimericdream
Copy link
Author

That works well enough if you know the precise location of the file or folder you want to ignore, but in our case we want to ignore all __mocks__ directories in a monorepo, regardless of whether they are at package/src/__mocks__, package/test/__mocks__, package/__mocks__, etc. I didn't think glob matching could do that kind of complex wildcard.

@chimericdream
Copy link
Author

Here is a screenshot of an example glob that would exclude __mocks__ directories at the lowest level in the folder structure, but nowhere else. I tried variations on this pattern to see if I could match the files on top without including any of the paths on bottom, but was unable to find a valid pattern.

Screenshot 2024-04-16 at 9 23 29 AM

@dukeluo
Copy link
Owner

dukeluo commented Apr 28, 2024

@chimericdream Could you share a minimal reproducible monorepo project so I can work on this? And it look like there is a way to work round this issue #38 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants