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

Fixed javascript, javascriptreact, typescript and typescriptreact file types. #34

Merged
merged 5 commits into from
Aug 4, 2024

Conversation

RoboG-11
Copy link
Contributor

@RoboG-11 RoboG-11 commented Aug 4, 2024

The master branch of the extension contains an error when handling javascript, javascriptreact, typescript and typescriptreact file types. The issue lies in the /queries/typescript/class.scm file, which inherits its configuration from the queries/javascript/class.scm file. This causes the class concealing functionality to malfunction in javascriptreact files.

Images to Illustrate the Issue

Extension configuration

image

Working in typescriptreact

image

Working in javascriptreact

image

The solution to this error is to explicitly specify the file types in queries/javascript/class.scm

(call_expression
  function: [
    (identifier) @ident
    (member_expression
      object: (identifier) @object-ident)
  ]
  (#any-of? @ident "clsx" "classnames" "tw" "css")
  (#eq? @object-ident "tw")
  arguments: [
    (arguments
      (_)+) @tailwind ; the actual class range is extracted in the code
    (template_string
      (string_fragment) @tailwind)
  ])

(jsx_attribute
  (property_identifier) @_attribute_name
  (#any-of? @_attribute_name "class" "className" "style" "css" "tw")
  [
    (string
      (string_fragment) @tailwind)
    (jsx_expression
      (_) @tailwind)
  ])

Images to illustrate the solution

Extension configuration

image

Working in typescriptreact

image

Working in javascriptreact

image

@luckasRanarison luckasRanarison merged commit 8c5766c into luckasRanarison:master Aug 4, 2024
4 checks passed
@luckasRanarison
Copy link
Owner

I've slightly changed the javascript query and added more tests. Thanks for the PR :)

@RoboG-11
Copy link
Contributor Author

RoboG-11 commented Aug 4, 2024

Thank you for accepting my first PR in the Open Source world :,)

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

Successfully merging this pull request may close these issues.

2 participants