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

fix: prevent deprecation warnings with highlight.js v10.7 #127

Merged
merged 3 commits into from Mar 28, 2021

Conversation

loriswit
Copy link
Contributor

Issue

This package is still using the deprecated highlight.js API, which now results in warnings being printed to the console. See highlightjs/highlight.js#2277.

This PR fixes this issue by using the new API instead. I also had to bump highlight.js to get the proper type definitions (as well as drop @types/highlight.js which is now deprecated). This breaks many tests however, because the generated highlighted code is now different for some languages. I suppose we'll have to generate a new test snapshot?

(This should also fix typeorm/typeorm#7489)

How to reproduce

npm init
npm i cli-highlight
echo "const hl = require('cli-highlight').highlight; console.log(hl('{}', {language: 'json'}))" > index.js
node index.js

Current output:

Deprecated as of 10.7.0. highlight(lang, code, ...args) has been deprecated.
Deprecated as of 10.7.0. Please use highlight(code, options) instead.
https://github.com/highlightjs/highlight.js/issues/2277
{}

type definitions are included with highlight.js since v10.1.0
prevents deprecation warnings in console
@codecov
Copy link

codecov bot commented Mar 23, 2021

Codecov Report

Merging #127 (c01de8b) into main (151dfed) will not change coverage.
The diff coverage is 0.00%.

❗ Current head c01de8b differs from pull request most recent head 130d101. Consider uploading reports for the commit 130d101 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##             main     #127   +/-   ##
=======================================
  Coverage   69.64%   69.64%           
=======================================
  Files           2        2           
  Lines          56       56           
  Branches       12       12           
=======================================
  Hits           39       39           
  Misses         17       17           
Impacted Files Coverage Δ
src/index.ts 94.11% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 151dfed...130d101. Read the comment docs.

Copy link
Owner

@felixfbecker felixfbecker left a comment

Choose a reason for hiding this comment

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

LGTM. You can update the snapshots automatically using npm run test -- -u.

@ecyrbe
Copy link

ecyrbe commented Mar 28, 2021

could you please merge and update cli-highlight.
this message is breaking many users output.

@felixfbecker felixfbecker merged commit 01b7e45 into felixfbecker:main Mar 28, 2021
@github-actions
Copy link

🎉 This PR is included in version 2.1.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Fix deprecation warnings for highlight.js v10.7
3 participants