word-wrap
word-wrap copied to clipboard
revert compatibility
In commit 9f626935f3fac6ec0f3c4b26baea4eb9740d9645, let was used.
https://github.com/jonschlinkert/word-wrap/blob/207044ebda1dd3809d15b6000a48409266536771/index.js#L9-L10
However, the package.json specifies "node": ">=0.10.0" compatibility.
https://github.com/jonschlinkert/word-wrap/blob/207044ebda1dd3809d15b6000a48409266536771/package.json#L28
This resulted in the following errors for older Node.js:
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Thus, we should change let to var to maintain compatibility for ^1.x.x in adherence to semver.
If compatibility needs to be upgraded, it should be the next major semver (^2.x.x) release.
Thanks @lamweili . Should const also be replaced?
@doowb, const is good according to node.green.
My GitHub actions, which test older Node.js (v4) for compatibility issues, didn't flag any errors.
@lamweili Thanks! Have the same issue with node v4
I'm having a problem with let on node 4 as well:
21:12:26 let lastCharPos = str.length - 1;
21:12:26 ^^^
21:12:26
21:12:26 SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
If I edit index.js by hand after installing and add 'use strict'; at the beginning of the file then I don't get this error.
Although we might not use word-wrap explicitly, it is used by dependencies such as eslint.
(eslint@>=2 <=7.0.0-alpha.3 > optionator@^0.8 > word-wrap@~1.2.3)
Editing the index.js by hand is a workaround but might be overridden by npm.
It will be good to quickly patch it back to restore compatibility instead of all dependencies changing major semver.
Can confirm, I'm hitting this because of eslint.
For clarification, I wasn’t suggesting editing index.js as a workaround. But if the maintainer wants to keep let, then use strict might be an alternative.
@doowb, any chance of merging and releasing it soon?
It seems like @doowb is busy. How about @jonschlinkert?
Bump! @doowb @jonschlinkert