43081j / eslint-plugin-lit

lit-html support for ESLint
116 stars 21 forks source link

Optional chaining in code #110

Closed LarsDenBakker closed 3 years ago

LarsDenBakker commented 3 years ago

The published package contains optional chaining, which is not supported below node v14.

https://github.com/43081j/eslint-plugin-lit/blob/master/src/rules/attribute-value-entities.ts https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility

Do you intend to support lower versions of node? Probably good to add an engine field as well to make it clear what's supported.

Haprog commented 3 years ago

I want to add some context here since I ran into a problem caused by this in few projects where CI was running Node 12.

The optional chaining has been there in the source since v1.3.0, but it started breaking on Node 12 only after v1.5.0 because the tsconfig target was updated from es2017 to es2020 which meant that the optional chaining was not transpiled away on 1.5.0 anymore.

43081j commented 3 years ago

Aha thanks so much for catching that. I thought it seemed strange we had to drop something that had been there a while.

I'll try find time this week to see where the 2020 bump came from and why.

Haprog commented 3 years ago

That target bump seems to have been introduced in this commit https://github.com/43081j/eslint-plugin-lit/commit/51c53c70454c695e230e909fe74d4c74133541c3 ("highlight escape sequence rather than quasi (#103) ")

And it was further updated in https://github.com/43081j/eslint-plugin-lit/commit/b18c15886ccf540f109a91ea1f58e86288dbe088 ("Add node v12 support back (#112)") which is now in v1.5.1

So here's the current/latest version: https://github.com/43081j/eslint-plugin-lit/blob/b18c15886ccf540f109a91ea1f58e86288dbe088/tsconfig.json#L3-L11

43081j commented 3 years ago

Yup the second one is us removing the optional chaining as we assumed that's what broke the build. The first one seems to be the culprit, possibly could be leftover from one of the iterations in that pr, I'll see if I can reintroduce the chaining and decrease the target