# RFC: drop legacy browsers, allow modern syntax
A proposal to seize a timely opportunity to make Sinon codebases easier and more enjoyable to work in.
**Drop**
* Internet Explorer
* Edge Legacy (non-Chromium based)
* Safari 9 (doesn't have ES6 syntax)
**Allow**
* modern JavaScript syntax
* modern built-ins (like [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) and [`Reflect`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect))
**Adopt**
* [`eslint-plugin-compat`](https://github.com/amilajack/eslint-plugin-compat#eslint-plugin-compat)
* [`prettier` default options](https://prettier.io/docs/en/options.html)
The proposal is only about **allowing** authors to make use of modern JavaScript, and putting assistive tools in place to better support that.
The proposal **is not** about rewriting all the libraries in newer syntax. That would be foolish.
## Background
Microsoft are finally removing support for IE11 and Edge Legacy in their own products, this will effectively be the end of IE11.
https://techcommunity.microsoft.com/t5/microsoft-365-blog/microsoft-365-apps-say-farewell-to-internet-explorer-11-and/ba-p/1591666
We should take this opportunity to also remove support for IE11 and Edge Legacy from Sinon libraries.
## Proposal
We drop support for legacy runtimes and only support last two versions of evergreen (desktop) browsers and NodeJS LTS versions.
This will allow us to adopt newer JavaScript syntax and built-ins, while still avoiding transpilers and polyfills.
Library users that need to support legacy runtimes can use their own transpilers and polyfills.
### Suggestion for supported runtimes
Looking at https://kangax.github.io/compat-table/es2016plus/, here is a suggestion for supported runtimes to configure in `eslint-plugin-compat`.
* Firefox: Last two major versions (currently 81, 82) and ESR 78
* Chrome: Last two major versions (currently 84, 85)
* Edge: Last two major versions (currently 83, 84)
* Safari: Last two major versions (currently 13.1, 14)
* NodeJS LTS versions (currently 10, 12, 14)
Historically, we've not explicitly supported mobile browsers, meaning we don't run tests in them. That might be something to consider.
## Solution
1. Adopt `prettier` default options
1. Adjust ESLint config
### Adopt `prettier` default options
The default options in `prettier@2` include traling commas, which are considered syntax errors in IE11. If we don't need to support IE11 anymore, we can adopt `prettier` default options.
Having no configuration for `prettier` makes is a lot easier to make a shared configuration for ESLint, and will also make it easier for people to configure their editors and IDEs to do the right thing with `prettier`.
Once we adopt this in a library, we have effectively dropped IE11 and Edge Legacy, and should release a new `MAJOR` version of that library.
**Impact**
* Indentation is two spaces, not four
* Trailing commas
* 80 characters per line
* Removal of `.prettierrc` in each library
### Adjust ESLint config
For our new evergreen future, we will need to adjust the ESLint config to make the most of supported syntax and built-ins available natively in our supported runtimes.
We can make use of [`eslint-plugin-compat`](https://github.com/amilajack/eslint-plugin-compat#readme) to catch the few scenarios where our supported runtimes haven't implemented the spec.
#### JavaScript version
Assuming the supported runtimes proposed above, looking at https://kangax.github.io/compat-table/es2016plus/, it seems like we can allow all of `ES2017` with no problems and `ES2018` with a few exceptions. The exceptions can be managed by `eslint-plugin-compat`
#### Context
`@mroderick` is working towards simplifying `eslint-config-sinon` to include all the necessary dependencies, making it much easier for the Sinon libraries to use it. Drop it in, create an `.eslintignore` and you're done. As part of that [`eslint-plugin-no-prototype-methods`](https://github.com/sinonjs/eslint-plugin-no-prototype-methods) was extracted from the libraries by `@khamiltonuk`, unit tests for that plugin are underway.
## Next steps
1. Implement `prettier` defaults across libraries, release major version of each
2. Get the [Saucelabs badge for Sinon working in the README.md again](https://github.com/sinonjs/sinon#------------------------sinonjs)
3. Adjust the Saucelabs setup to test in the supported runtimes
4. Finish the ESLint config with the new syntax and `eslint-plugin-compat`.
5. Adopt the new ESLint config across libraries, release major version of each