Skip to content

Latest commit

 

History

History
1431 lines (1039 loc) · 27.5 KB

prefer-at.mjs.md

File metadata and controls

1431 lines (1039 loc) · 27.5 KB

Snapshot report for test/prefer-at.mjs

The actual snapshot is saved in prefer-at.mjs.snap.

Generated by AVA.

Invalid #1

  1 | array[array.length - 1];

Output

`␊
  1 | array.at(-1);␊
`

Error 1/1

`␊
> 1 | array[array.length - 1];␊
    |       ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #2

  1 | array[array.length -1];

Output

`␊
  1 | array.at(-1);␊
`

Error 1/1

`␊
> 1 | array[array.length -1];␊
    |       ^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #3

  1 | array[array.length - /* comment */ 1];

Output

`␊
  1 | array.at(- /* comment */ 1);␊
`

Error 1/1

`␊
> 1 | array[array.length - /* comment */ 1];␊
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #4

  1 | array[array.length - 1.];

Output

`␊
  1 | array.at(- 1.);␊
`

Error 1/1

`␊
> 1 | array[array.length - 1.];␊
    |       ^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #5

  1 | array[array.length - 0b1];

Output

`␊
  1 | array.at(- 0b1);␊
`

Error 1/1

`␊
> 1 | array[array.length - 0b1];␊
    |       ^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #6

  1 | array[array.length - 9];

Output

`␊
  1 | array.at(-9);␊
`

Error 1/1

`␊
> 1 | array[array.length - 9];␊
    |       ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #7

  1 | array[0][array[0].length - 1];

Output

`␊
  1 | array[0].at(-1);␊
`

Error 1/1

`␊
> 1 | array[0][array[0].length - 1];␊
    |          ^^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #8

  1 | array[(( array.length )) - 1];

Output

`␊
  1 | array.at(-1);␊
`

Error 1/1

`␊
> 1 | array[(( array.length )) - 1];␊
    |       ^^^^^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #9

  1 | array[array.length - (( 1 ))];

Output

`␊
  1 | array.at(- (( 1 )));␊
`

Error 1/1

`␊
> 1 | array[array.length - (( 1 ))];␊
    |       ^^^^^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #10

  1 | array[(( array.length - 1 ))];

Output

`␊
  1 | array.at((( -1 )));␊
`

Error 1/1

`␊
> 1 | array[(( array.length - 1 ))];␊
    |          ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #11

  1 | (( array ))[array.length - 1];

Output

`␊
  1 | (( array )).at(-1);␊
`

Error 1/1

`␊
> 1 | (( array ))[array.length - 1];␊
    |             ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #12

  1 | (( array[array.length - 1] ));

Output

`␊
  1 | (( array.at(-1) ));␊
`

Error 1/1

`␊
> 1 | (( array[array.length - 1] ));␊
    |          ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #13

  1 | array[array.length - 1].pop().shift()[0];

Output

`␊
  1 | array.at(-1).pop().shift()[0];␊
`

Error 1/1

`␊
> 1 | array[array.length - 1].pop().shift()[0];␊
    |       ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #14

  1 | a = array[array.length - 1]

Output

`␊
  1 | a = array.at(-1)␊
`

Error 1/1

`␊
> 1 | a = array[array.length - 1]␊
    |           ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #15

  1 | const a = array[array.length - 1]

Output

`␊
  1 | const a = array.at(-1)␊
`

Error 1/1

`␊
> 1 | const a = array[array.length - 1]␊
    |                 ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #16

  1 | const {a = array[array.length - 1]} = {}

Output

`␊
  1 | const {a = array.at(-1)} = {}␊
`

Error 1/1

`␊
> 1 | const {a = array[array.length - 1]} = {}␊
    |                  ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #17

  1 | typeof array[array.length - 1]

Output

`␊
  1 | typeof array.at(-1)␊
`

Error 1/1

`␊
> 1 | typeof array[array.length - 1]␊
    |              ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #18

  1 | function foo() {return arguments[arguments.length - 1]}

Error 1/1

`␊
> 1 | function foo() {return arguments[arguments.length - 1]}␊
    |                                  ^^^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #19

  1 | class Foo {bar; baz() {return this.bar[this.bar.length - 1]}}

Output

`␊
  1 | class Foo {bar; baz() {return this.bar.at(-1)}}␊
`

Error 1/1

`␊
> 1 | class Foo {bar; baz() {return this.bar[this.bar.length - 1]}}␊
    |                                        ^^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #20

  1 | class Foo {#bar; baz() {return this.#bar[this.#bar.length - 1]}}

Output

`␊
  1 | class Foo {#bar; baz() {return this.#bar.at(-1)}}␊
`

Error 1/1

`␊
> 1 | class Foo {#bar; baz() {return this.#bar[this.#bar.length - 1]}}␊
    |                                          ^^^^^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #1

  1 | string.charAt(string.length - 1);

Error 1/1

`␊
> 1 | string.charAt(string.length - 1);␊
    |               ^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(- 1);␊
`

Invalid #2

  1 | string.charAt(string.length - 0o11);

Error 1/1

`␊
> 1 | string.charAt(string.length - 0o11);␊
    |               ^^^^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(- 0o11);␊
`

Invalid #3

  1 | some.string.charAt(some.string.length - 1);

Error 1/1

`␊
> 1 | some.string.charAt(some.string.length - 1);␊
    |                    ^^^^^^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | some.string.at(- 1);␊
`

Invalid #4

  1 | string.charAt((( string.length )) - 0xFF);

Error 1/1

`␊
> 1 | string.charAt((( string.length )) - 0xFF);␊
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(- 0xFF);␊
`

Invalid #5

  1 | string.charAt(string.length - (( 1 )));

Error 1/1

`␊
> 1 | string.charAt(string.length - (( 1 )));␊
    |               ^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(- (( 1 )));␊
`

Invalid #6

  1 | string.charAt((( string.length - 1 )));

Error 1/1

`␊
> 1 | string.charAt((( string.length - 1 )));␊
    |                  ^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at((( - 1 )));␊
`

Invalid #7

  1 | (( string )).charAt(string.length - 1);

Error 1/1

`␊
> 1 | (( string )).charAt(string.length - 1);␊
    |                     ^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | (( string )).at(- 1);␊
`

Invalid #8

  1 | (( string.charAt ))(string.length - 1);

Error 1/1

`␊
> 1 | (( string.charAt ))(string.length - 1);␊
    |                     ^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | (( string.at ))(- 1);␊
`

Invalid #9

  1 | (( string.charAt(string.length - 1) ));

Error 1/1

`␊
> 1 | (( string.charAt(string.length - 1) ));␊
    |                  ^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | (( string.at(- 1) ));␊
`

Invalid #1

  1 | array.slice(-1)[0]

Output

`␊
  1 | array.at(-1)␊
`

Error 1/1

`␊
> 1 | array.slice(-1)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #2

  1 | array.slice(-1).pop()

Output

`␊
  1 | array.at(-1)␊
`

Error 1/1

`␊
> 1 | array.slice(-1).pop()␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #3

  1 | array.slice(-1.0).shift()

Output

`␊
  1 | array.at(-1.0)␊
`

Error 1/1

`␊
> 1 | array.slice(-1.0).shift()␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #4

  1 | array.slice(-9)[0]

Output

`␊
  1 | array.at(-9)␊
`

Error 1/1

`␊
> 1 | array.slice(-9)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #5

  1 | array.slice(-0xA)[0b000]

Output

`␊
  1 | array.at(-0xA)␊
`

Error 1/1

`␊
> 1 | array.slice(-0xA)[0b000]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #6

  1 | array.slice(-9).shift()

Output

`␊
  1 | array.at(-9)␊
`

Error 1/1

`␊
> 1 | array.slice(-9).shift()␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #7

  1 | array.slice(-1)[(( 0 ))];

Output

`␊
  1 | array.at(-1);␊
`

Error 1/1

`␊
> 1 | array.slice(-1)[(( 0 ))];␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #8

  1 | array.slice(-(( 1 )))[0];

Output

`␊
  1 | array.at(-(( 1 )));␊
`

Error 1/1

`␊
> 1 | array.slice(-(( 1 )))[0];␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #9

  1 | array.slice((( -1 )))[0];

Output

`␊
  1 | array.at((( -1 )));␊
`

Error 1/1

`␊
> 1 | array.slice((( -1 )))[0];␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #10

  1 | (( array.slice(-1) ))[0];

Output

`␊
  1 | (( array.at(-1) ));␊
`

Error 1/1

`␊
> 1 | (( array.slice(-1) ))[0];␊
    |          ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #11

  1 | (( array )).slice(-1)[0];

Output

`␊
  1 | (( array )).at(-1);␊
`

Error 1/1

`␊
> 1 | (( array )).slice(-1)[0];␊
    |             ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #12

  1 | (( array.slice(-1)[0] ));

Output

`␊
  1 | (( array.at(-1) ));␊
`

Error 1/1

`␊
> 1 | (( array.slice(-1)[0] ));␊
    |          ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #13

  1 | (( array.slice(-1) )).pop();

Output

`␊
  1 | (( array.at(-1) ));␊
`

Error 1/1

`␊
> 1 | (( array.slice(-1) )).pop();␊
    |          ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #14

  1 | (( array.slice(-1).pop ))();

Output

`␊
  1 | (( array.at(-1) ));␊
`

Error 1/1

`␊
> 1 | (( array.slice(-1).pop ))();␊
    |          ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #15

  1 | (( array.slice(-1).pop() ));

Output

`␊
  1 | (( array.at(-1) ));␊
`

Error 1/1

`␊
> 1 | (( array.slice(-1).pop() ));␊
    |          ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #16

  1 | array.slice(-1)[0].pop().shift().slice(-1)

Output

`␊
  1 | array.at(-1).pop().shift().slice(-1)␊
`

Error 1/1

`␊
> 1 | array.slice(-1)[0].pop().shift().slice(-1)␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #1

  1 | array.slice(-9, -8)[0]

Output

`␊
  1 | array.at(-9)␊
`

Error 1/1

`␊
> 1 | array.slice(-9, -8)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #2

  1 | array.slice(-9, -0o10)[0]

Output

`␊
  1 | array.at(-9)␊
`

Error 1/1

`␊
> 1 | array.slice(-9, -0o10)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #3

  1 | array.slice(-9, -8).pop()

Output

`␊
  1 | array.at(-9)␊
`

Error 1/1

`␊
> 1 | array.slice(-9, -8).pop()␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #4

  1 | array.slice(-9, -8).shift()

Output

`␊
  1 | array.at(-9)␊
`

Error 1/1

`␊
> 1 | array.slice(-9, -8).shift()␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #5

  1 | array.slice((( -9 )), (( -8 )), ).shift()

Output

`␊
  1 | array.at((( -9 )))␊
`

Error 1/1

`␊
> 1 | array.slice((( -9 )), (( -8 )), ).shift()␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #6

  1 | (( array.slice(-9, -8).shift ))()

Output

`␊
  1 | (( array.at(-9) ))␊
`

Error 1/1

`␊
> 1 | (( array.slice(-9, -8).shift ))()␊
    |          ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊
`

Invalid #1

  1 | array.slice(-9, unknown)[0]

Error 1/1

`␊
> 1 | array.slice(-9, unknown)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | array.at(-9)␊
`

Invalid #2

  1 | array.slice(-0o11, -7)[0]

Error 1/1

`␊
> 1 | array.slice(-0o11, -7)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | array.at(-0o11)␊
`

Invalid #3

  1 | array.slice(-9, unknown).shift()

Error 1/1

`␊
> 1 | array.slice(-9, unknown).shift()␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | array.at(-9)␊
`

Invalid #4

  1 | const KNOWN = -8; array.slice(-9, KNOWN).shift()

Error 1/1

`␊
> 1 | const KNOWN = -8; array.slice(-9, KNOWN).shift()␊
    |                         ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | const KNOWN = -8; array.at(-9)␊
`

Invalid #5

  1 | array.slice(-9, 0)[0]

Error 1/1

`␊
> 1 | array.slice(-9, 0)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | array.at(-9)␊
`

Invalid #6

  1 | (( (( array.slice( ((-9)), ((unknown)), ).shift ))() ));

Error 1/1

`␊
> 1 | (( (( array.slice( ((-9)), ((unknown)), ).shift ))() ));␊
    |             ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | (( (( array.at( ((-9))) )) ));␊
`

Invalid #7

  1 | array.slice(-9, (a, really, _really, complicated, second) => argument)[0]

Error 1/1

`␊
> 1 | array.slice(-9, (a, really, _really, complicated, second) => argument)[0]␊
    |       ^^^^^ Prefer \`.at(…)\` over the first element from \`.slice(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | array.at(-9)␊
`

Invalid #1

  1 | _.last(array)

Output

`␊
  1 | array.at(-1)␊
`

Error 1/1

`␊
> 1 | _.last(array)␊
    | ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Invalid #2

  1 | lodash.last(array)

Output

`␊
  1 | array.at(-1)␊
`

Error 1/1

`␊
> 1 | lodash.last(array)␊
    | ^^^^^^^^^^^ Prefer \`.at(-1)\` over \`lodash.last(…)\` to get the last element.␊
`

Invalid #3

  1 | underscore.last(array)

Output

`␊
  1 | array.at(-1)␊
`

Error 1/1

`␊
> 1 | underscore.last(array)␊
    | ^^^^^^^^^^^^^^^ Prefer \`.at(-1)\` over \`underscore.last(…)\` to get the last element.␊
`

Invalid #4

  1 | _.last(new Array)

Output

`␊
  1 | (new Array).at(-1)␊
`

Error 1/1

`␊
> 1 | _.last(new Array)␊
    | ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Invalid #5

  1 | const foo = []
  2 | _.last([bar])

Output

`␊
  1 | const foo = []␊
  2 | ;[bar].at(-1)␊
`

Error 1/1

`␊
  1 | const foo = []␊
> 2 | _.last([bar])␊
    | ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Invalid #6

  1 | const foo = []
  2 | _.last( new Array )

Output

`␊
  1 | const foo = []␊
  2 | ;(new Array).at(-1)␊
`

Error 1/1

`␊
  1 | const foo = []␊
> 2 | _.last( new Array )␊
    | ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Invalid #7

  1 | const foo = []
  2 | _.last( (( new Array )) )

Output

`␊
  1 | const foo = []␊
  2 | ;(( new Array )).at(-1)␊
`

Error 1/1

`␊
  1 | const foo = []␊
> 2 | _.last( (( new Array )) )␊
    | ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Invalid #8

  1 | if (foo) _.last([bar])

Output

`␊
  1 | if (foo) [bar].at(-1)␊
`

Error 1/1

`␊
> 1 | if (foo) _.last([bar])␊
    |          ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Invalid #9

  1 | _.last(getLast(utils.lastOne(array)))

Options

`␊
[␊
  {␊
    "getLastElementFunctions": [␊
      "getLast",␊
      "  utils.lastOne  "␊
    ]␊
  }␊
]␊
`

Output

`␊
  1 | array.at(-1).at(-1).at(-1)␊
`

Error 1/3

`␊
> 1 | _.last(getLast(utils.lastOne(array)))␊
    | ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Error 2/3

`␊
> 1 | _.last(getLast(utils.lastOne(array)))␊
    |        ^^^^^^^ Prefer \`.at(-1)\` over \`getLast(…)\` to get the last element.␊
`

Error 3/3

`␊
> 1 | _.last(getLast(utils.lastOne(array)))␊
    |                ^^^^^^^^^^^^^ Prefer \`.at(-1)\` over \`utils.lastOne(…)\` to get the last element.␊
`

Invalid #10

  1 | function foo() {return _.last(arguments)}

Error 1/1

`␊
> 1 | function foo() {return _.last(arguments)}␊
    |                        ^^^^^^ Prefer \`.at(-1)\` over \`_.last(…)\` to get the last element.␊
`

Invalid #1

  1 | array[0]

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Output

`␊
  1 | array.at(0)␊
`

Error 1/1

`␊
> 1 | array[0]␊
    |       ^ Prefer \`.at(…)\` over index access.␊
`

Invalid #2

  1 | array[1]

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Output

`␊
  1 | array.at(1)␊
`

Error 1/1

`␊
> 1 | array[1]␊
    |       ^ Prefer \`.at(…)\` over index access.␊
`

Invalid #3

  1 | array[5 + 9]

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Output

`␊
  1 | array.at(5 + 9)␊
`

Error 1/1

`␊
> 1 | array[5 + 9]␊
    |       ^^^^^ Prefer \`.at(…)\` over index access.␊
`

Invalid #4

  1 | const offset = 5;array[offset + 9]

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Output

`␊
  1 | const offset = 5;array.at(offset + 9)␊
`

Error 1/1

`␊
> 1 | const offset = 5;array[offset + 9]␊
    |                        ^^^^^^^^^^ Prefer \`.at(…)\` over index access.␊
`

Invalid #5

  1 | array[array.length - 1]

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Output

`␊
  1 | array.at(-1)␊
`

Error 1/1

`␊
> 1 | array[array.length - 1]␊
    |       ^^^^^^^^^^^^^^^^ Prefer \`.at(…)\` over \`[….length - index]\`.␊
`

Invalid #6

  1 | string.charAt(9)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | string.charAt(9)␊
    |               ^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(9)␊
`

Invalid #7

  1 | string.charAt(5 + 9)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | string.charAt(5 + 9)␊
    |               ^^^^^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(5 + 9)␊
`

Invalid #8

  1 | const offset = 5;string.charAt(offset + 9)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | const offset = 5;string.charAt(offset + 9)␊
    |                                ^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | const offset = 5;string.at(offset + 9)␊
`

Invalid #9

  1 | string.charAt(unknown)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | string.charAt(unknown)␊
    |               ^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(unknown)␊
`

Invalid #10

  1 | string.charAt(-1)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | string.charAt(-1)␊
    |               ^^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(-1)␊
`

Invalid #11

  1 | string.charAt(1.5)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | string.charAt(1.5)␊
    |               ^^^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(1.5)␊
`

Invalid #12

  1 | string.charAt(1n)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | string.charAt(1n)␊
    |               ^^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(1n)␊
`

Invalid #13

  1 | string.charAt(string.length - 1)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | string.charAt(string.length - 1)␊
    |               ^^^^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(….length - index)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | string.at(- 1)␊
`

Invalid #14

  1 | foo.charAt(bar.length - 1)

Options

`␊
[␊
  {␊
    "checkAllIndexAccess": true␊
  }␊
]␊
`

Error 1/1

`␊
> 1 | foo.charAt(bar.length - 1)␊
    |            ^^^^^^^^^^^^^^ Prefer \`String#at(…)\` over \`String#charAt(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Use \`.at(…)\`.␊
  1 | foo.at(bar.length - 1)␊
`