Dev: allow unused destructured variables in lint rules (#33548)

Allow unused destructured variables in lint rules

- there were exceptions to the rule being added everywhere and it seems to be a reasonable allowance
This commit is contained in:
RJ 2022-06-29 16:56:31 +08:00 committed by GitHub
parent feb3ab0581
commit 04bef970ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 14 deletions

View File

@ -129,10 +129,6 @@ export function searchItemsByString< T extends ItemType >(
* @return {string} Resource name for item totals. * @return {string} Resource name for item totals.
*/ */
export function getTotalCountResourceName( itemType: string, query: Query ) { export function getTotalCountResourceName( itemType: string, query: Query ) {
// Disable eslint rule because we're using this spread to omit properties
// that don't affect item totals count results.
// eslint-disable-next-line no-unused-vars, camelcase
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { _fields, page, per_page, ...totalsQuery } = query; const { _fields, page, per_page, ...totalsQuery } = query;
return getResourceName( 'total-' + itemType, { ...totalsQuery } ); return getResourceName( 'total-' + itemType, { ...totalsQuery } );

View File

@ -100,8 +100,6 @@ describe( 'orders reducer', () => {
totalCount, totalCount,
} ); } );
const resourceName = getOrderResourceName( query );
expect( state.data[ 1 ].total ).toEqual( initialState.data[ 1 ].total ); expect( state.data[ 1 ].total ).toEqual( initialState.data[ 1 ].total );
expect( state.data[ 2 ] ).toEqual( orders[ 1 ] ); expect( state.data[ 2 ] ).toEqual( orders[ 1 ] );
} ); } );

View File

@ -28,9 +28,6 @@ export function getOrderResourceName( query: Partial< OrdersQuery > ) {
export function getTotalOrderCountResourceName( export function getTotalOrderCountResourceName(
query: Partial< OrdersQuery > query: Partial< OrdersQuery >
) { ) {
// Disable eslint rule because we're using this spread to omit properties
// that don't affect item totals count results.
// eslint-disable-next-line no-unused-vars, camelcase
const { _fields, page, per_page, ...totalsQuery } = query; const { _fields, page, per_page, ...totalsQuery } = query;
return getOrderResourceName( totalsQuery ); return getOrderResourceName( totalsQuery );

View File

@ -28,10 +28,6 @@ export function getProductResourceName( query: Partial< ProductQuery > ) {
export function getTotalProductCountResourceName( export function getTotalProductCountResourceName(
query: Partial< ProductQuery > query: Partial< ProductQuery >
) { ) {
// Disable eslint rule because we're using this spread to omit properties
// that don't affect item totals count results.
// eslint-disable-next-line no-unused-vars, camelcase
const { _fields, page, per_page, ...totalsQuery } = query; const { _fields, page, per_page, ...totalsQuery } = query;
return getProductResourceName( totalsQuery ); return getProductResourceName( totalsQuery );
} }

View File

@ -0,0 +1,4 @@
Significance: minor
Type: dev
Allow unused destructured variables in lint rules #35548

View File

@ -35,10 +35,11 @@ module.exports = {
], ],
}, },
], ],
'no-unused-vars': [ '@typescript-eslint/no-unused-vars': [
'error', 'error',
{ {
varsIgnorePattern: 'createElement', varsIgnorePattern: 'createElement',
ignoreRestSiblings: true,
}, },
], ],
'react/react-in-jsx-scope': 'error', 'react/react-in-jsx-scope': 'error',