Skip to content

Commit

Permalink
Scripts: Fix default use of lint-js file patterns (#16079)
Browse files Browse the repository at this point in the history
* Scripts: Call hasFileInCliArgs as function

* Scripts: Apply default file arguments as spread array

* Fix lint issues found
  • Loading branch information
aduth authored and gziolo committed Jun 11, 2019
1 parent 1f3f794 commit 51d4434
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe( 'MediaUpload component', () => {
);
} } />
);
expect( wrapper.find( 'Picker' ).length ).toEqual( 1 );
expect( wrapper.find( 'Picker' ) ).toHaveLength( 1 );
} );

it( 'shows right media capture option for media type', () => {
Expand All @@ -68,7 +68,7 @@ describe( 'MediaUpload component', () => {
);
} } />
);
expect( wrapper.find( 'Picker' ).props().options.filter( ( item ) => item.label === expectedOption ).length ).toEqual( 1 );
expect( wrapper.find( 'Picker' ).props().options.filter( ( item ) => item.label === expectedOption ) ).toHaveLength( 1 );
};
expectOptionForMediaType( MEDIA_TYPE_IMAGE, OPTION_TAKE_PHOTO );
expectOptionForMediaType( MEDIA_TYPE_VIDEO, OPTION_TAKE_VIDEO );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ describe( 'RichText Native', () => {

describe( 'Adds new line on Enter', () => {
let newValue;
const wrapper = shallow( <RichText
const wrapper = shallow( <RichText
rootTagsToEliminate={ [ 'p' ] }
value={ "" }
value=""
onChange={ ( value ) => {
newValue = value
newValue = value;
} }
formatTypes={ [] }
onSelectionChange={ jest.fn() }
Expand All @@ -45,12 +45,12 @@ describe( 'RichText Native', () => {
const event = {
nativeEvent: {
eventCount: 0,
}
},
};
wrapper.instance().onEnter(event);
wrapper.instance().onEnter( event );

it( ' Adds <br> tag to content after pressing Enter key', () => {
expect( newValue ).toEqual( "<br>" );
});
expect( newValue ).toEqual( '<br>' );
} );
} );
} );
2 changes: 0 additions & 2 deletions packages/block-library/src/heading/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import { createBlock } from '@wordpress/blocks';

const HeadingEdit = ( {
attributes,
isSelected,
mergeBlocks,
onBlur,
onFocus,
onReplace,
setAttributes,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/video/video-player.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Video = ( props ) => {
// We are using built-in player controls becasue manually
// calling presentFullscreenPlayer() is not working for android
controls={ isSelected }
muted={ !isSelected }
muted={ ! isSelected }
/>
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/scripts/lint-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const {

const args = getCliArgs();

const defaultFilesArgs = ! hasFileInCliArgs ? [ '.' ] : [];
const defaultFilesArgs = hasFileInCliArgs() ? [] : [ '.' ];

// See: https://eslint.org/docs/user-guide/configuring#using-configuration-files-1.
const hasLintConfig = hasCliArg( '-c' ) ||
Expand Down
4 changes: 2 additions & 2 deletions packages/scripts/scripts/lint-pkg-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const {

const args = getCliArgs();

const defaultFilesArgs = ! hasFileInCliArgs ? [ '.' ] : [];
const defaultFilesArgs = hasFileInCliArgs() ? [] : [ '.' ];

// See: https://github.com/tclindner/npm-package-json-lint/wiki/configuration#configuration.
const hasLintConfig = hasCliArg( '-c' ) ||
Expand All @@ -41,7 +41,7 @@ const defaultIgnoreArgs = ! hasIgnoredFiles ?

const result = spawn(
resolveBin( 'npm-package-json-lint', { executable: 'npmPkgJsonLint' } ),
[ ...defaultConfigArgs, ...defaultIgnoreArgs, ...args, defaultFilesArgs ],
[ ...defaultConfigArgs, ...defaultIgnoreArgs, ...args, ...defaultFilesArgs ],
{ stdio: 'inherit' }
);

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/scripts/lint-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const {

const args = getCliArgs();

const defaultFilesArgs = ! hasFileInCliArgs ? [ '**/*.{css,scss}' ] : [];
const defaultFilesArgs = hasFileInCliArgs() ? [] : [ '**/*.{css,scss}' ];

// See: https://github.com/stylelint/stylelint/blob/master/docs/user-guide/configuration.md#loading-the-configuration-object.
const hasLintConfig = hasCliArg( '--config' ) ||
Expand Down

0 comments on commit 51d4434

Please sign in to comment.