xojs/xo

With 0.50, seeing errors from new eslint-plugin-n that can't be suppressed

AndrewMSHowe opened this issue · 4 comments

xo 0.50 changed from eslint-plugin-node to eslint-plugin-n ('n'). I have some TypeScript code using optional chaining and nullish coalascing operators. eslint-plugin-n objects that as my node version is set to less than 14, I should not be using this syntax. However TypeScript transpiles these operators, as it knows what node version I am targeting. The 'n' documentation says "If you are using transpilers, maybe you want to ignore the warnings about some features. You can use this ignores option to ignore the given features."

I have in my .xo-config.json:
"n/no-unsupported-features/es-syntax": ["error", { "ignores": [ "optionalChaining", "nullishCoalescingOperators" ] }]

The errors are not suppressed. I was encouraged to submit an issue to 'n'. However it doesn't seem to be a problem with the 'n' plugin. I browsed the plugin code and it looks correct. Also I had previously left an 's' off the end of one of the 'ignores' strings and that should have reported an error, but I didn't see it.

I suspect that xo is not forwarding this config to the plugin correctly. Perhaps it is to do with your opinionated defaults that you want to apply? Sorry I don't really know how xo works internally. Anyway I have reverted to xo 0.49 for now.

I was able to repro. I've put a xo config in package.json to turn off the rule:

  "xo": {
    "rules": {
      "n/no-unsupported-features/es-syntax": 0
    }
  }

However, it does not work. I ran xo --print-config the output config is:

"n/no-unsupported-features/es-syntax": [
	"error",
	{
		"version": ">=12",
		"ignores": [
			"modules"
		]
	}
],

BTW when I downgrade to xo 0.49, it complains "Definition for rule n/no-unsupported-features/es-syntax was not found."
Of course I still have the exclusion rule in my .xo-config.json until I remove it, but I am just saying that in this state it is putting something in the config.
In this case, my node/no-unsupported-features/es-syntax config entry looks like @aladdin-add 's above, but my n/ one is exactly what I had in my .xo-config.json (it is outputting both as of 0.49)
With 0.50, my n/ entry looks like @aladdin-add 's, and there is also a node/ one that's just ["off"].

Duplicate of #613

Closing as duplicate