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

Problem with nested rules #31

Closed
tobiastimm opened this issue Sep 15, 2020 · 9 comments
Closed

Problem with nested rules #31

tobiastimm opened this issue Sep 15, 2020 · 9 comments
Assignees
Labels

Comments

@tobiastimm
Copy link

tobiastimm commented Sep 15, 2020

I have the following .ls-lint.yml:

ls:
  services/*/components/*/__tests__:
    .test.ts: PascalCase
  services/*/:
    .vue: PascalCase
    .ts: kebab-case

I want that every TypeScript file validates against kebab-case except the ones within the components __tests__ directory.

The console is throwing errors that within ../components/Button/__tests__/
Button.test.ts
has not a file-name with kebab-case

Is this intended? I would assume that more specialized rules overwrite the general ones

@loeffel-io
Copy link
Owner

This should work pretty fine
Could you try to swap the directories like

ls:
  services/*/:
    .vue: PascalCase
    .ts: kebab-case
  services/*/components/*/__tests__:
    .test.ts: PascalCase

@loeffel-io loeffel-io self-assigned this Sep 15, 2020
@loeffel-io
Copy link
Owner

@tobiastimm any updates?

@tobiastimm
Copy link
Author

@loeffel-io
This seems to work for the components/__tests__ directory and all sub __tests__ directories

ls:
  services/*/:
    .vue: PascalCase
    .ts: kebab-case
  services/*/components/__tests__:
    .test.ts: PascalCase
  services/*/components/*/__tests__:
    .test.ts: PascalCase

@loeffel-io
Copy link
Owner

the real problem could be the trailing / at services/*/ - could you please try it without the slash

if this breaks any yaml rules you can just write something like 'services/*'

@tobiastimm
Copy link
Author

I will try it out tomorrow! Thanks

@loeffel-io
Copy link
Owner

Hey @tobiastimm, could you already check the issue? Thanks

@tobiastimm
Copy link
Author

@loeffel-io Sry will do first thing in the morning!

@tobiastimm
Copy link
Author

tobiastimm commented Sep 22, 2020

@loeffel-io it does not work with these settings

ls:
  services/*:
    .vue: PascalCase
    .ts: kebab-case
  services/*/components/*/__tests__:
    .test.ts: PascalCase

2020/09/22 11:11:37 ./services/cart/components/__tests__/Benefit.test.ts failed for rules: kebabcase

I need to explicitly set

  services/*/components/__tests__:
    .test.ts: PascalCase

to make it work.

@loeffel-io
Copy link
Owner

loeffel-io commented Sep 22, 2020

Finally got it!

services/*/components/*/__tests__ will just works if there are is any directory between components and __tests__

Here you can see that services/*/components/*/__tests__ is not a valid pattern for your case:

services/*/components/*/__tests__:

Glob tester

services/*/components/__tests__:

Glob tester

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

No branches or pull requests

2 participants