eslint-community/eslint-plugin-n

n/no-unsupported-features/es-syntax with TypeScript transpilation

Closed this issue · 8 comments

I'm not sure if this is a problem with eslint-plugin-n or what, but here goes...
So XO from 0.49 to 0.50 has changed from eslint-plugin-node to eslint-plugin-n, and now I am getting a bunch of errors. They're bogus because TypeScript is transpiling, so for example optional chainings & nullish coalescing operators work just fine with node 12 and don't need node 14.
The doc says "If you are using transpilers, maybe you want to ignore the warnings about some features." so I added this to my config file (which is .xo-config.json in this case, it should be forwarded to eslint):
"n/no-unsupported-features/es-syntax": ["error", { "ignores": [ "optionalChaining", "nullishCoalescingOperator" ] }]
But I am still seeing the errors.
Again, I am not sure this is a problem with eslint-plugin-n or XO or what?
In future maybe it would be possible to fix things such that TypeScript transpilation would be recognised and these errors would not be generated?

More info: I downgraded XO back to 0.49, and I got a bunch of errors about "Definition for rule n/no-unsupported-features/es-syntax was not found." That was what I added to my config file. And removing that made it the errors go away. So It is somehow hooking up with eslint-plugin-n, but the ignores thing is not working I think?

as seen in the node.green:

ofc, you can safely disable the rule if using a transpiier like ts/babel/esbuild/...

if using xo v0.49 => the rule is node/no-unsupported-features/es-syntax.
xo v0.50 => n/no-unsupported-features/es-syntax. (a breaking change)

OK, but I had xo 0.50, and I had "n/", and it didn't seem to ignore those rules.

In theory, should this have worked? Or is there an issue with what I have written?
"n/no-unsupported-features/es-syntax": ["error", { "ignores": [ "optionalChaining", "nullishCoalescingOperator" ] }]

yes,sounds a bug to me. will take a look later.~

I tried with the provided config, it output a config errror:

ESLint: 8.15.0

Error: .eslintrc.js:
        Configuration for rule "n/no-unsupported-features/es-syntax" is invalid:
        Value "nullishCoalescingOperator" should be equal to one of the allowed values.

turns out it should be named "nullishCoalescingOperators" 😂. Not sure you didn't see it, maybe an issue in xo?

I'm not sure where I got those strings from, but anyway changing it to "nullishCoalescingOperators" didn't fix anything. And it doesn't explain why "optionalChaining" doesn't work. Well, it does seem that maybe xo is not forwarding these or returning the above error. Someone on the eslint discord channel was sure it was a problem with the n module, but I was not so sure. I guess I'll try reporting it to xo and see if they want to punt it somewhere else :) Thanks for looking into it, anyway.