Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: Fix default use of lint-js file patterns #16079

Merged
merged 3 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ? [ '.' ] : [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple asides:

  • I changed the logic of this expression since if I personally find that "if not x, else" is generally more confusing to follow in than "if x, else". Seems like a good general rule of thumb, but open to counter-points, since maybe it could be argued that as assigning a default value, the most relevant logic path is the absence of the CLI argument. Admittedly I probably shouldn't have made the refactor here vs. getting the fix in place.
  • This function is technically not named correctly in accordance with naming guidelines. It should be hasFileInCLIArgs ("CLI" is an acronym).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This function is technically not named correctly in accordance with naming guidelines. It should be hasFileInCLIArgs ("CLI" is an acronym).

I will fix it in a follow-up PR, I bet there are more functions to update 😅

I'm fine with "if x, else" it reads better in general. PR was small enough to include it and The Boy Scout Rule always applies 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it in a follow-up PR, I bet there are more functions to update 😅

Ready: #16091.

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