-
-
Save getify/0011e437a80905cf1321846af00999bf to your computer and use it in GitHub Desktop.
ESLint: test cases for determining if a function parameter is unused
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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