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

feat: support for highlighting JSX evaluated expressions #222

Merged

Conversation

KeyboardSounds
Copy link
Contributor

@KeyboardSounds KeyboardSounds commented Aug 27, 2022

In JSX, you can include JS expressions within tags, like:

{doSomething(‘a’, 7)}

This PR adds syntax highlighting for those expressions.

Limitations

It will still highlight JS that isn’t valid to include in a JSX evaluated expression (eg. a class definition), which as far as I can tell is a limitation of how embedded languages work in TextMate syntax highlighting definitions.

@changeset-bot
Copy link

changeset-bot bot commented Aug 27, 2022

🦋 Changeset detected

Latest commit: a6316bf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vscode-mdx Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

📊 Package size report   No changes

File Before After
Total (Includes all files) 29.7 kB 29.7 kB
Tarball size 12.4 kB 12.4 kB
Unchanged files
File Size
.changeset/config.json 312 B
.changeset/README.md 510 B
.commitlintrc 35 B
.editorconfig 161 B
.eslintignore 32 B
.eslintrc 191 B
.github/FUNDING.yml 234 B
.github/workflows/ci.yml 551 B
.github/workflows/pkg-size.yml 496 B
.github/workflows/publish.yml 1.2 kB
.github/workflows/release.yml 323 B
.github/workflows/version.yml 853 B
.lintstagedrc.js 46 B
.prettierrc 24 B
.remarkrc 42 B
.renovaterc 35 B
.simple-git-hooks.js 51 B
.vscode/launch.json 540 B
.vscodeignore 103 B
.yarnrc 20 B
assets/mdx.png 3.3 kB
CHANGELOG.md 3.9 kB
language-configuration.jsonc 1.1 kB
LICENSE 1.1 kB
package.json 4.6 kB
patches/eslint-mdx+2.0.2.patch 796 B
README.md 7.3 kB
syntaxes/mdx.tmLanguage.json 1.3 kB
test/component.js 54 B
test/fixture.mdx 423 B

🤖 This report was automatically generated by pkg-size-action

@KeyboardSounds
Copy link
Contributor Author

In its current state, this PR fails linting:

yarn run v1.22.15
$ /workspaces/vscode-mdx-1/node_modules/.bin/lint-staged
✔ Preparing lint-staged...
❯ Running tasks for staged files...
  ❯ .lintstagedrc.js — 2 files
    ↓ *.{*sh,env,env.*,gql,ini,properties,rb,css,less,sass,scss,styl,stylus,svelte,vue} — no files [SKIPPED]
    ↓ .!(browserslistrc|nvm)rc — no files [SKIPPED]
    ↓ Dockerfile — no files [SKIPPED]
    ❯ *.{cjs,cts,js,json,jsonc,json5,jsx,html,md,mdx,mjs,mts,pug,svelte,toml,ts,tsx,vue,yaml,yml} — 2 files
      ✖ eslint --cache -f friendly --fix [FAILED]
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ eslint --cache -f friendly --fix:


  ✘  http://eslint.org/docs/rules/

     Parsing error: Could not parse expression with acorn: Expecting Unicode escape sequence \uXXXX


     test/fixture.mdx:28:5
     26 | Lorem ipsum dolor sit _amet_, consectetur adipiscing elit. Ut ac lobortis velit.
     27 | 
   > 28 | {3 \* 7}
        |     ^
     29 | 

✘ 1 problem (1 error, 0 warnings)


Errors:
  1  http://eslint.org/docs/rules/null
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I could change the text case to avoid this, but that seems dodgy. Does anyone have any pointers on how to fix this? I’m a bit lost on how the linting config works for this repo.

Copy link
Member

@remcohaszing remcohaszing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

It looks like CI failed due to a bug in eslint-mdx. Since the ESLint check has been removed, this should no longer be an issue.

Your changes look great! Could you rebase?

.changeset/short-coins-bow.md Outdated Show resolved Hide resolved
syntaxes/mdx.tmLanguage.json Outdated Show resolved Hide resolved
@remcohaszing remcohaszing marked this pull request as ready for review December 22, 2022 09:27
@remcohaszing remcohaszing changed the title feat Support for highlighting JSX evaluated expressions feat: support for highlighting JSX evaluated expressions Dec 22, 2022
@remcohaszing remcohaszing merged commit d2eb7a7 into mdx-js:master Dec 22, 2022
@remcohaszing
Copy link
Member

Your changes have been released in version 1.1.0. Thanks again! ❤️

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

Successfully merging this pull request may close these issues.

2 participants