Skip to content

Instantly share code, notes, and snippets.

@getify
Last active March 14, 2019 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/0011e437a80905cf1321846af00999bf to your computer and use it in GitHub Desktop.
Save getify/0011e437a80905cf1321846af00999bf to your computer and use it in GitHub Desktop.
ESLint: test cases for determining if a function parameter is unused
// these `xx` parameters are all used, so no "unused parameter" errors should be reported
var f;
f = (xx) => xx;
f = (xx) => () => xx;
f = (xx) => { xx; };
f = (xx, yy = xx) => { yy; };
f = (xx, yy = xx) => { var xx; xx = yy; };
f = (xx, yy = xx) => { var xx = yy; };
f = (xx, yy = () => xx) => { yy; };
f = (xx, yy = () => { xx = 3; }) => { yy; };
f = (xx, yy = (zz = xx) => zz) => { yy; };
// the first parameter of each of these `f()` functions is unused:
// xx, yy, zz, ww, rr, kk, aa, ss, dd, gg
// so "unused parameter" errors should be reported for all of them
var f;
f = (xx) => 3;
f = (yy = 3) => { var yy; };
f = (zz = 3) => { var zz = 3; };
f = (ww = 3) => { var ww; ww = 3; };
f = (rr) => { var rr = 3; };
f = (kk, mm = (kk) => kk) => mm;
f = (aa, bb = (kk = 3) => { kk = 3; }) => bb;
f = (ss, tt = () => { var ss; }) => tt;
f = (dd, ee = () => { var dd = 3; }) => ee;
f = (gg, hh = () => { var gg; gg = 3; }) => hh;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment