/unjquerify

AST-based tool for converting jQuery code to modern vanilla JavaScript

Primary LanguageTypeScriptMIT LicenseMIT

unjQuerify

UnjQuerify is a project that can assist developers in migrating code from jQuery to vanilla DOM APIs.

In:

$("#submit").click(function() {
    $("#output").text("The button was clicked!");
    $(".post").hide();
});

Output:

document.getElementById("submit").addEventListener("click", function () {
    document.getElementById("output").textContent = "The button was clicked!";
    document.getElementsByClassName("post").map((_element) => _element.style.display = "none");
});

Built With

  • babel to build an AST and to transform nodes.

Usage

CLI

  • Ensure that npm is available.
  • Use npm install to install dependencies.
  • Run unjQuerify with the provided example script: npm --silent start sample/simple.js.
  • Verify that the console shows the transformed script.

As dependency

  • Ensure that npm is available.
  • Run npm install unjquerify.
  • Import unjQuerify's plugins using `require('unjquerify/build/src/all-plugins')`` or a similar method.

Contributing

Contributions are always welcome. Please see this project's issue tracker.

Some useful resources are the following:

Before submitting a pull request, please verify that your changes pass linting (run with npm run lint). Please include tests for new features.