Skip to content

Commit fa24765

Browse files
authored
ESLint: Enable ignoreRestSiblings option for no-unused-vars rule (#41897)
* ESLint: Enable ignoreRestSiblings option for no-unused-vars rule * Remove unnecessary ESLint ignores * Add changelog
1 parent 0f23f61 commit fa24765

File tree

12 files changed

+9
-26
lines changed

12 files changed

+9
-26
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/block-library/src/comments-title/deprecated.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ export default [
1818
},
1919
supports,
2020
migrate: ( oldAttributes ) => {
21-
/* eslint-disable no-unused-vars */
2221
const {
2322
singleCommentLabel,
2423
multipleCommentsLabel,
2524
...newAttributes
2625
} = oldAttributes;
27-
/* eslint-enable no-unused-vars */
2826
return newAttributes;
2927
},
3028
isEligible: ( { multipleCommentsLabel, singleCommentLabel } ) =>

packages/components/src/custom-gradient-picker/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const GradientTypePicker = ( { gradientAST, hasGradient, onChange } ) => {
6666
};
6767

6868
const onSetRadialGradient = () => {
69-
// eslint-disable-next-line no-unused-vars
7069
const { orientation, ...restGradientAST } = gradientAST;
7170
onChange(
7271
serializeGradient( {

packages/components/src/mobile/bottom-sheet/keyboard-avoiding-view.native.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,8 @@ class KeyboardAvoidingView extends Component {
9898
}
9999

100100
render() {
101-
const {
102-
children,
103-
enabled,
104-
keyboardVerticalOffset, // eslint-disable-line no-unused-vars
105-
style,
106-
...props
107-
} = this.props;
101+
const { children, enabled, keyboardVerticalOffset, style, ...props } =
102+
this.props;
108103

109104
let finalStyle = style;
110105
if ( Platform.OS === 'ios' ) {

packages/components/src/navigation/use-navigation-tree-nodes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const useNavigationTreeNodes = () => {
99
const getNode = ( key ) => nodes[ key ];
1010

1111
const addNode = ( key, value ) => {
12-
// eslint-disable-next-line no-unused-vars
1312
const { children, ...newNode } = value;
1413
return setNodes( ( original ) => ( {
1514
...original,
@@ -19,7 +18,6 @@ export const useNavigationTreeNodes = () => {
1918

2019
const removeNode = ( key ) => {
2120
return setNodes( ( original ) => {
22-
// eslint-disable-next-line no-unused-vars
2321
const { [ key ]: removedNode, ...remainingNodes } = original;
2422
return remainingNodes;
2523
} );

packages/editor/src/components/provider/index.native.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,7 @@ class NativeEditorProvider extends Component {
319319
}
320320

321321
render() {
322-
const {
323-
children,
324-
post, // eslint-disable-line no-unused-vars
325-
capabilities,
326-
settings,
327-
...props
328-
} = this.props;
322+
const { children, post, capabilities, settings, ...props } = this.props;
329323
const editorSettings = this.getEditorSettings( settings, capabilities );
330324

331325
return (

packages/element/src/serialize.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ export function renderNativeComponent(
646646
// place of children. Ensure to omit so it is not assigned as attribute
647647
// as well.
648648
content = renderChildren( props.value, context, legacyContext );
649-
// eslint-disable-next-line no-unused-vars
650649
const { value, ...restProps } = props;
651650
props = restProps;
652651
} else if (

packages/eslint-plugin/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Enable `no-unused-vars`'s setting `ignoreRestSiblings` to allow unused variables when destructuring with rest properties ([#41897](https://github.com/WordPress/gutenberg/pull/41897)).
6+
57
## 12.2.0 (2022-05-04)
68

79
### Bug Fix

packages/eslint-plugin/configs/es5.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = {
5252
'no-unreachable': 'error',
5353
'no-unsafe-negation': 'error',
5454
'no-unused-expressions': 'error',
55-
'no-unused-vars': 'error',
55+
'no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
5656
'no-useless-return': 'error',
5757
'no-whitespace-before-property': 'error',
5858
'no-with': 'error',

packages/eslint-plugin/configs/jshint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
'no-trailing-spaces': 'error',
1010
'no-undef': 'error',
1111
'no-unused-expressions': 'error',
12-
'no-unused-vars': 'error',
12+
'no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
1313
'one-var': [ 'error', 'always' ],
1414
quotes: [ 'error', 'single' ],
1515
'wrap-iife': [ 'error', 'any' ],

0 commit comments

Comments
 (0)