[PR #1422] [MERGED] Better JS language integration for Pre-Request scripts and Test scripts #3301

Closed
opened 2026-03-17 00:55:46 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/1422
Author: @AndrewBastin
Created: 1/9/2021
Status: Merged
Merged: 1/22/2021
Merged by: @liyasthomas

Base: mainHead: feat/js-integrations


📝 Commits (10+)

  • 37fd085 Add tern as dependency
  • febd15f Add build rule to transpile mjs
  • ad5d135 Initial implementation of the auto complete engine
  • 157e91f Separate out the tern server code to separate file
  • b839b60 Added extra type defs for tern server
  • 0d78394 Boost the pw completion result to the top of the list
  • ce87498 Added acorn and acorn-walk as dependency
  • c39cda7 Semantic linting powered by tern
  • e745a2a Merge branch 'main' into feat/js-integrations
  • d0e494d Fix DeepCode warnings for js-editor

📊 Changes

11 files changed (+2434 additions, -36 deletions)

View changed files

📝 components/ui/js-editor.vue (+139 -30)
helpers/tern.js (+119 -0)
helpers/terndoc/ecma.json (+1284 -0)
helpers/terndoc/pw-extras.json (+51 -0)
helpers/terndoc/pw-pre.json (+8 -0)
helpers/terndoc/pw-test.json (+24 -0)
helpers/ternlint.js (+672 -0)
📝 nuxt.config.js (+6 -0)
📝 package-lock.json (+126 -6)
📝 package.json (+3 -0)
📝 pages/index.vue (+2 -0)

📄 Description

This PR intends to bring better JS integration features to the Pre-Request and Test script editors in Hoppscotch.

With current implementation, we only have basic syntax linting powered by Esprima.

The new proposed implementation hopes to bring the following changes:

  • Retire Esprima for syntax linting and implement a more powerful type checking linter with the help of Tern.
  • Bring code completion (powered with typings) to the editors.
  • Restrict usage of browser APIs as a security measure (console object is proposed to be still accessible still though)

Progress

  • Tern Autocompletion implementation
  • Type Docs for both the script types
  • Type checking linter and retire Esprima (we are gonna keep esprima around for now)
  • Restricting usage of browser APIs (delayed, will be transitioned slowly over time)

Happy Hacking!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/1422 **Author:** [@AndrewBastin](https://github.com/AndrewBastin) **Created:** 1/9/2021 **Status:** ✅ Merged **Merged:** 1/22/2021 **Merged by:** [@liyasthomas](https://github.com/liyasthomas) **Base:** `main` ← **Head:** `feat/js-integrations` --- ### 📝 Commits (10+) - [`37fd085`](https://github.com/hoppscotch/hoppscotch/commit/37fd0854c5bd010eff3560647f10ce7d6581606c) Add tern as dependency - [`febd15f`](https://github.com/hoppscotch/hoppscotch/commit/febd15f728fa6252d6402280a2d963dcbbe27773) Add build rule to transpile mjs - [`ad5d135`](https://github.com/hoppscotch/hoppscotch/commit/ad5d1352e82080eb2afbcc02219589822dc9f7dd) Initial implementation of the auto complete engine - [`157e91f`](https://github.com/hoppscotch/hoppscotch/commit/157e91f282a8510387bef019c05d2f4e85d83970) Separate out the tern server code to separate file - [`b839b60`](https://github.com/hoppscotch/hoppscotch/commit/b839b60fb1c9782df9a96a0a8b71a6cdd5df16c6) Added extra type defs for tern server - [`0d78394`](https://github.com/hoppscotch/hoppscotch/commit/0d78394b5e17ea1815ebb8617bec9a3d58b6dd70) Boost the pw completion result to the top of the list - [`ce87498`](https://github.com/hoppscotch/hoppscotch/commit/ce87498854553f5b3054413a0dd526cffc5db485) Added acorn and acorn-walk as dependency - [`c39cda7`](https://github.com/hoppscotch/hoppscotch/commit/c39cda7db1b66e035627e663c6b7489d51bac7e9) Semantic linting powered by tern - [`e745a2a`](https://github.com/hoppscotch/hoppscotch/commit/e745a2ad539adb091810abca6a82e23bc8979123) Merge branch 'main' into feat/js-integrations - [`d0e494d`](https://github.com/hoppscotch/hoppscotch/commit/d0e494dcdef8416e8afa9b7a4d8e793e4240ccbd) Fix DeepCode warnings for js-editor ### 📊 Changes **11 files changed** (+2434 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `components/ui/js-editor.vue` (+139 -30) ➕ `helpers/tern.js` (+119 -0) ➕ `helpers/terndoc/ecma.json` (+1284 -0) ➕ `helpers/terndoc/pw-extras.json` (+51 -0) ➕ `helpers/terndoc/pw-pre.json` (+8 -0) ➕ `helpers/terndoc/pw-test.json` (+24 -0) ➕ `helpers/ternlint.js` (+672 -0) 📝 `nuxt.config.js` (+6 -0) 📝 `package-lock.json` (+126 -6) 📝 `package.json` (+3 -0) 📝 `pages/index.vue` (+2 -0) </details> ### 📄 Description This PR intends to bring better JS integration features to the Pre-Request and Test script editors in Hoppscotch. With current implementation, we only have basic syntax linting powered by [Esprima](https://esprima.org/). The new proposed implementation hopes to bring the following changes: - Retire Esprima for syntax linting and implement a more powerful type checking linter with the help of [Tern](https://ternjs.net/). - Bring code completion (powered with typings) to the editors. - Restrict usage of browser APIs as a security measure (`console` object is proposed to be still accessible still though) ### Progress - [x] Tern Autocompletion implementation - [x] Type Docs for both the script types - [x] Type checking linter ~~and retire Esprima~~ (we are gonna keep esprima around for now) - [x] ~~Restricting usage of browser APIs~~ (delayed, will be transitioned slowly over time) Happy Hacking! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 00:55:46 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#3301
No description provided.