Simple require imports, for example const bar = require("foo")
:
- Regex:
(const|var|let)\b\s+(\w+)\s+=\s+require\s*\(["']([\/\w\-]+)["']\)\n
- Replace:
import $2 from "$3"\n
One-liner require & config/compute, for example const router = require("express").Router({ mergeParams: true })
:
- Regex:
(const|var|let)\b\s+(\w+)\s+=\s+require\s*\(["'](\w+)["']\)(?=\S+)