eslintrc: Disallow calling String/Array/Object methods introduced in ES6 or later
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 28 Sep 2018 12:36:04 +0000 (14:36 +0200)
committerJames D. Forrester <jforrester@wikimedia.org>
Wed, 7 Nov 2018 15:32:40 +0000 (07:32 -0800)
commit6ad73362f376a0399bd1568fe7bbf40425737311
tree79d601745851b3db816371b97fa08ca958d3bfcf
parentf77b1ed3c48ffbbee7639d343b5e1bfc182432f9
eslintrc: Disallow calling String/Array/Object methods introduced in ES6 or later

This aims to disallow using the methods listed below, which are
supported by Chromium 69 but not supported by Internet Explorer 11.
Most of them were introduced in ECMAScript 6, but some are more recent
or experimental.

We keep breaking IE 11 support by using them. Recent examples include:
* mediawiki/core:
  Ic85063dfbbcf26a99d343845c9fb801f1888d750
* mediawiki/extensions/MultimediaViewer:
  I0954c42a37668b0eb46c3e864a2e13152a6dc68a
* mediawiki/extensions/UploadWizard:
  I70d37a8f0abcc96b5e39fa71a93cda6f3421c87c
* VisualEditor/VisualEditor:
  Ic1971549da37091c41a847229d18e95aff5c9952

This will unfortunately almost certainly cause false positives, but
hopefully not too many of them. Common false positives can be
disallowed more precisely using 'no-restricted-syntax' rather than
'no-restricted-properties'.

Disallowed methods:
    String.prototype:
        codePointAt
        endsWith
        includes
        normalize
        padEnd                    (ES 2017)
        padStart                  (ES 2017)
        repeat
        startsWith
        trimEnd                   (experimental/proposed)
        trimLeft                  (experimental/proposed)
        trimRight                 (experimental/proposed)
        trimStart                 (experimental/proposed)
    Array.prototype:
        copyWithin
        entries
        fill
        find
        findIndex
        flat                      (experimental/proposed)
        flatMap                   (experimental/proposed)
        includes                  (ES 2016)
        keys
        values
    String:
        fromCodePoint
        raw
    Array:
        from
        of
    Object:
        assign
        entries                   (ES 2017)
        getOwnPropertyDescriptors (ES 2017)
        getOwnPropertySymbols
        is
        values                    (ES 2017)

I compiled the list based on running the following code in each
browser's console, since there doesn't seem to be an authoritative
list anywhere on the Internet:

    console.log( Object.getOwnPropertyNames( String.prototype ) )
    console.log( Object.getOwnPropertyNames( Array.prototype ) )
    console.log( Object.getOwnPropertyNames( Object.prototype ) )
    console.log( Object.getOwnPropertyNames( String ) )
    console.log( Object.getOwnPropertyNames( Array ) )
    console.log( Object.getOwnPropertyNames( Object ) )

Change-Id: Ic44c79834f99c52863fbc544ad657787f70fb9bb
.eslintrc.json
tests/selenium/.eslintrc.json