Autocomplete - eslint is flagging use of $

AI-generated summary

In a discussion about implementing Autocomplete while avoiding jQuery (which ESLint flags with ember/no-global-jquery), merefield asks whether to use import $ from 'jquery'; or aim for a native solution. david confirms importing jQuery is acceptable as a medium-term fix, noting that core code still uses it and the ESLint rule helps track jQuery usage for eventual removal. He adds that while native browser APIs are preferred long-term, there’s no set timeline for eliminating jQuery entirely. merefield thanks him and opts not to pursue a full native rewrite for now.

What’s the recommended approach to implementing Autocomplete if the use of $ and jquery in general is discouraged?

I note there is still a lot of apparent reliance on $().autocomplete in the core codebase?

But my plugin javascript code is making eslint sad :frowning:

error  Do not use global `$` or `jQuery`  ember/no-global-jquery

I can get rid of this by adding this import:

import $ from 'jquery';

But should we be shooting for a completely native solution without jquery now or is this good enough?

You can import it as a medium-term solution - no problem. We do that in a bunch of places in core. :+1:

We’ve enabled the ESLint rule to give us a better view of how much JQuery is still being used, so that we can eventually aim to remove it completely.

So, in the long term, yes it would be much better to update any uses of JQuery to use native browser APIs. We’ve been doing that slowly over the last few years in core, but we have no specific plan or timeline on removing it.

Thanks … I’ll not bite off more for the time being! :slight_smile: