Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array methods not reporting errors #258

Open
davidbarredo opened this issue Aug 27, 2019 · 4 comments
Open

Array methods not reporting errors #258

davidbarredo opened this issue Aug 27, 2019 · 4 comments
Assignees

Comments

@davidbarredo
Copy link

davidbarredo commented Aug 27, 2019

The plugin is no reporting errors for array methods such as:

arr1 = [1, 2, [3, 4]];
arr1.flat();

The flat method is not supported in IE (https://caniuse.com/#feat=array-flat), but the plugin is not reporting it as an error.

To test it, just add these lines into index.js file inside the demo: https://github.com/amilajack/eslint-plugin-compat-demo

I've just saw #168 (comment) and tested Array.flat();. Is showing the error.

Maybe adding these methods as a warning when not able to check te type is a good enough solution.

@ReneF1
Copy link

ReneF1 commented Feb 4, 2020

I ran into the same issue today. Any update on this?

@amilajack
Copy link
Owner

@davidbarredo After thinking about this for some time I think that this is finally a good solution for now. Would love if anyone could work on this

@brettz9
Copy link
Contributor

brettz9 commented Apr 1, 2020

I think this should be closed in favor of the more generic #206 (letting that apply to all ES features).

@amilajack amilajack assigned jooohhn and amilajack and unassigned jooohhn May 15, 2020
@azu
Copy link

azu commented Aug 19, 2020

As proof of concept(PoC), I've created eslint-plugin-typescript-compat to resolve this issue.
This rule use TypeScript compiler and lint TypeScript codebase.

For example, TypeScript Compiler know arr1 is Array instance type.
So, eslint-plugin-typescript-compat can lint the usage of Array.prototype.flat method.

const arr1 = [1, 2, [3, 4]];
arr1.flat();
^^^^
TypeScript compiler know `arr1` is `Array` instance

This plugin get type information from TypeScript and lint it.

📝 This plugin only works on TypeScript. It requires TypeScript compiler and TypeScript codebase.
Currently, this plugin only supports ECMAScript methods like Array.prototype.flat or Array.from.
In other words, this plugin does not support detection for Build-in Object or DOM API yet.
These features are duplicate works to eslint-plugin-compat. So I re-think about the area of ​​responsibility of eslint-plugin-typescript-compat

loganvolkers added a commit to saasquatch/bunshi that referenced this issue May 15, 2024
## Description of the change
This PR adds eslint configuration for fixing browser compatibility
errors.

However this doesn't detect array methods such as `toSorted` #53
amilajack/eslint-plugin-compat#258 (comment).
I've also tried to add
https://github.com/azu/eslint-plugin-typescript-compat for detecting the
methods. But no luck. 😩

- Add eslint config for the project
- Add `eslint-plugin-compat` for browser compatibilities
- Add to `package.json`
```
 "browserslist": [
    "chrome 64",
    "edge 79",
    "firefox 67",
    "opera 51",
    "safari 12"
  ]
```
I've disabled the recommended rules as there quite a lot of error and we
can tackle them in another PR.
<img width="461" alt="Screenshot 2024-02-28 at 17 09 56"
src="https://github.com/saasquatch/bunshi/assets/17547035/9be59f4c-f58b-4552-a868-532f579d3466">

---------

Co-authored-by: Logan Volkers <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants