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

Using variable matchers to lint a more generic object #62

Open
kylegillen opened this issue Dec 28, 2024 · 1 comment · May be fixed by #63
Open

Using variable matchers to lint a more generic object #62

kylegillen opened this issue Dec 28, 2024 · 1 comment · May be fixed by #63
Labels
feature request New feature or request

Comments

@kylegillen
Copy link

Hi. Great plugin!
I went through the docs and saw the examples that target specific variables and object properties.

Wondering if / how I could get the plugin to lint this structure:

  const buttonStyles = {
    base: 'ui-rounded-lg px-md ui-h-11 ui-px-sm ui-transition-all ui-text-base ui-shadow-sm ui-flex-1',
    disabled: 'disabled:ui-bg-brand-primary-disabled disabled:ui-cursor-not-allowed',
    primary: 'ui-bg-brand-primary ui-text-brand-onprimary hover:ui-bg-brand-primary-hover uif',
  }

Essentially, the variables will always end in Styles (e.g. buttonStyles), and I would like the matcher to apply to all properties within that object.

I tried the following, but as the type of matcher suggests, the name property is simply a string(?) not a regex, and my regex skills sadly aren't polished enough to match all the properties / values within the object.

variables: [[
  // matches variables endting in `Styles`
  '.*Styles',
  // matches the object value for the `base` key (ideally, should match ALL values for ALL keys).
  [
    {
      match: 'objectValues',
      pathPattern: '^base|\\.base',
    },
  ],
]],

I appreciate any help you could lend.
Thanks again!

@schoero schoero added the feature request New feature or request label Jan 1, 2025
@schoero schoero linked a pull request Jan 1, 2025 that will close this issue
@schoero
Copy link
Owner

schoero commented Jan 7, 2025

Unfortunately, changing the names to regular expressions is a breaking change.

I have a few other updates planned for v2. Once those are ready, I’ll include this change to release all breaking changes together.

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

Successfully merging a pull request may close this issue.

2 participants