sindresorhus/eslint-plugin-unicorn

Do you want to work on this issue?

You can request for a bounty in order to promote it!

[unicorn/prefer-at] should avoid auto fix " parent?.childNodes[parent.childNodes.length - 1];" #2098

tjx666 posted onGitHub

<!-- ✨ Thanks for reporting a bug! ➡️ Please don't ignore this template -->

<!-- 1️⃣ Explain here what's wrong -->

origin:

parent?.childNodes[parent.childNodes.length - 1];

after auto fix:

parent?.childNodes.at(-1);

<!-- 2️⃣ Specify which rule is buggy here and in the title -->

unicorn/prefer-at

<!-- 3️⃣ Add some examples where the issue appears -->

not safe


Why is it not safe?

posted by sindresorhus over 1 year ago

childNodes has no at method

posted by tjx666 over 1 year ago

Mentioned in the proposal, they should support https://github.com/tc39/proposal-relative-indexing-method#convertable-interfaces, but seems no browser support NodeList.at yet.

posted by fisker over 1 year ago

"should be upgradable" does not mean that upgrading them was in the scope of the proposal (which would be impossible anyway given that those interfaces are not defined by a spec maintained by the same standard body)

posted by stof over 1 year ago

@sindresorhus @fisker how do you want to handle this ? currently, the recommended config breaks code dealing with DOM APIs

posted by stof over 1 year ago

Use suggestions instead of autofix?

posted by fisker over 1 year ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests