sed
POSIX正規表現エンジンはルックアラウンドを知らないため、それを行うことはできないと思います。ただし、(たとえば) Python スクリプトでは、操作を 2 つのステップに分割することで可能になります。
import re
with open("myfile.js") as infile, open("myfile.jsconv", "w") as outfile:
for line in infile:
line = line.sub(
r"""(?x)" # Match a double quote
(?= # only if it's followed by:
(?: # an even number of quotes, defined like this:
(?: # Either...
\\. # any escaped character
| # or
[^'\\] # a character except single quotes
)* # repeated as needed, followed by
' # a single quote.
(?:\\.|[^'\\])* # (Repeat this to ensure an even
' # number of quotes)
)* # Do this zero or more times.
(?:\\.|[^'\\])* # Then match any remaining characters
$ # until the end of the line.
) # End of loohahead""",
'\\"', line)
line = re.sub(
r"""(?x)' # Match a single quote
( # Match and capture
(?: # either...
\\. # an escaped character
| # or
[^'\\] # a character besides quotes or backslashes
)* # any number of times.
) # End of capturing group number 1
' # Match a single quote""",
r'"\1"', line)
outfile.write(line)