You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documents the enforced but currently undocumented `no-unused-vars` rule with a brief description, examples, and noting the `"ignoreRestSiblings": true` option.
> Why? Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers.
1749
+
1750
+
```javascript
1751
+
// bad
1752
+
1753
+
var some_unused_var =42;
1754
+
1755
+
// Write-only variables are not considered as used.
1756
+
var y =10;
1757
+
y =5;
1758
+
1759
+
// A read for a modification of itself is not considered as used.
1760
+
var z =0;
1761
+
z = z +1;
1762
+
1763
+
// Unused function arguments.
1764
+
functiongetX(x, y) {
1765
+
return x;
1766
+
}
1767
+
1768
+
// good
1769
+
1770
+
functiongetXPlusY(x, y) {
1771
+
return x + y;
1772
+
}
1773
+
1774
+
var x =1;
1775
+
var y = a +2;
1776
+
1777
+
alert(getXPlusY(x, y));
1778
+
1779
+
// 'type' is ignored even if unused because it has a rest property sibling.
1780
+
// This is a form of extracting an object that omits the specified keys.
1781
+
var { type, ...coords } = data;
1782
+
// 'coords' is now the 'data' object without its 'type' property.
0 commit comments