Skip to content

Commit

Permalink
ESLint: Enable ignoreRestSiblings option for no-unused-vars rule (#…
Browse files Browse the repository at this point in the history
…41897)

* ESLint: Enable ignoreRestSiblings option for no-unused-vars rule

* Remove unnecessary ESLint ignores

* Add changelog
  • Loading branch information
tyxla authored Jun 27, 2022
1 parent 0f23f61 commit fa24765
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 26 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/block-library/src/comments-title/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ export default [
},
supports,
migrate: ( oldAttributes ) => {
/* eslint-disable no-unused-vars */
const {
singleCommentLabel,
multipleCommentsLabel,
...newAttributes
} = oldAttributes;
/* eslint-enable no-unused-vars */
return newAttributes;
},
isEligible: ( { multipleCommentsLabel, singleCommentLabel } ) =>
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/custom-gradient-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const GradientTypePicker = ( { gradientAST, hasGradient, onChange } ) => {
};

const onSetRadialGradient = () => {
// eslint-disable-next-line no-unused-vars
const { orientation, ...restGradientAST } = gradientAST;
onChange(
serializeGradient( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,8 @@ class KeyboardAvoidingView extends Component {
}

render() {
const {
children,
enabled,
keyboardVerticalOffset, // eslint-disable-line no-unused-vars
style,
...props
} = this.props;
const { children, enabled, keyboardVerticalOffset, style, ...props } =
this.props;

let finalStyle = style;
if ( Platform.OS === 'ios' ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const useNavigationTreeNodes = () => {
const getNode = ( key ) => nodes[ key ];

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

const removeNode = ( key ) => {
return setNodes( ( original ) => {
// eslint-disable-next-line no-unused-vars
const { [ key ]: removedNode, ...remainingNodes } = original;
return remainingNodes;
} );
Expand Down
8 changes: 1 addition & 7 deletions packages/editor/src/components/provider/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,7 @@ class NativeEditorProvider extends Component {
}

render() {
const {
children,
post, // eslint-disable-line no-unused-vars
capabilities,
settings,
...props
} = this.props;
const { children, post, capabilities, settings, ...props } = this.props;
const editorSettings = this.getEditorSettings( settings, capabilities );

return (
Expand Down
1 change: 0 additions & 1 deletion packages/element/src/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ export function renderNativeComponent(
// place of children. Ensure to omit so it is not assigned as attribute
// as well.
content = renderChildren( props.value, context, legacyContext );
// eslint-disable-next-line no-unused-vars
const { value, ...restProps } = props;
props = restProps;
} else if (
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Enable `no-unused-vars`'s setting `ignoreRestSiblings` to allow unused variables when destructuring with rest properties ([#41897](https://github.com/WordPress/gutenberg/pull/41897)).

## 12.2.0 (2022-05-04)

### Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/configs/es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = {
'no-unreachable': 'error',
'no-unsafe-negation': 'error',
'no-unused-expressions': 'error',
'no-unused-vars': 'error',
'no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
'no-useless-return': 'error',
'no-whitespace-before-property': 'error',
'no-with': 'error',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/configs/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-unused-expressions': 'error',
'no-unused-vars': 'error',
'no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
'one-var': [ 'error', 'always' ],
quotes: [ 'error', 'single' ],
'wrap-iife': [ 'error', 'any' ],
Expand Down
1 change: 0 additions & 1 deletion packages/react-native-aztec/src/AztecView.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ class AztecView extends Component {
}

render() {
// eslint-disable-next-line no-unused-vars
const { onActiveFormatsChange, ...otherProps } = this.props;
// `style` has to be destructured separately, without `otherProps`, because of:
// https://github.com/WordPress/gutenberg/issues/23611
Expand Down
1 change: 0 additions & 1 deletion packages/react-native-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const registerGutenberg = ( {
constructor( props ) {
super( props );

// eslint-disable-next-line no-unused-vars
const { rootTag, ...parentProps } = this.props;

// Setup locale.
Expand Down

0 comments on commit fa24765

Please sign in to comment.