amilajack / eslint-plugin-compat

Check the browser compatibility of your code
MIT License
3.07k stars 104 forks source link

URLSearchParams.size not reported when targeting Safari / iOS <17 #611

Open davidjayb opened 8 months ago

davidjayb commented 8 months ago

Support for URLSearchParams.size was introduced in Safari 17:

https://caniuse.com/?search=URLSearchParams.size

However, when targeting Safari versions before 17 the compat plugin doesn't flag this as an error:

new URLSearchParams().size

I dug through the code an noticed this reference:

https://github.com/amilajack/eslint-plugin-compat/blob/v4.2.0/src/rules/compat.ts#L116

 * A small optimization that only lints APIs that are not supported by targeted browsers.
 * For example, if the user is targeting chrome 50, which supports the fetch API, it is
 * wasteful to lint calls to fetch.

Does this mean that because Safari >17 supports a subset of the URLSearchParams API it will not be reported? It seems like the caniuse provider will only check for URLSearchParams but not looking for broad compatibility:

https://github.com/amilajack/eslint-plugin-compat/blob/v4.2.0/src/providers/caniuse-provider.ts#L169