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

chore: Use ESLint comma-dangle with always-multiline #615

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"rules": {
"array-bracket-spacing": [ "error", "always" ],
"brace-style": [ "error", "1tbs" ],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": [ "error", "always" ],
Expand Down
2 changes: 1 addition & 1 deletion blocks/api/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @var {Array} categories
*/
const categories = [
{ slug: 'common', title: 'Common' }
{ slug: 'common', title: 'Common' },
];

/**
Expand Down
4 changes: 2 additions & 2 deletions blocks/api/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function createBlock( blockType, attributes = {} ) {
return {
uid: uuid(),
blockType,
attributes
attributes,
};
}

Expand Down Expand Up @@ -48,6 +48,6 @@ export function switchToBlockType( block, blockType ) {
return Object.assign( {
uid: block.uid,
attributes: transformation.transform( block.attributes ),
blockType
blockType,
} );
}
2 changes: 1 addition & 1 deletion blocks/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export {
setUnknownTypeHandler,
getUnknownTypeHandler,
getBlockSettings,
getBlocks
getBlocks,
} from './registration';
40 changes: 20 additions & 20 deletions blocks/api/test/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ describe( 'block factory', () => {
describe( 'createBlock()', () => {
it( 'should create a block given its blockType and attributes', () => {
const block = createBlock( 'core/test-block', {
align: 'left'
align: 'left',
} );

expect( block.blockType ).to.eql( 'core/test-block' );
expect( block.attributes ).to.eql( {
align: 'left'
align: 'left',
} );
expect( block.uid ).to.be.a( 'string' );
} );
Expand All @@ -39,20 +39,20 @@ describe( 'block factory', () => {
blocks: [ 'core/text-block' ],
transform: ( { value } ) => {
return {
value: 'chicken ' + value
value: 'chicken ' + value,
};
}
} ]
}
},
} ],
},
} );
registerBlock( 'core/text-block', {} );

const block = {
uid: 1,
blockType: 'core/text-block',
attributes: {
value: 'ribs'
}
value: 'ribs',
},
};

const updateBlock = switchToBlockType( block, 'core/updated-text-block' );
Expand All @@ -61,8 +61,8 @@ describe( 'block factory', () => {
uid: 1,
blockType: 'core/updated-text-block',
attributes: {
value: 'chicken ribs'
}
value: 'chicken ribs',
},
} );
} );

Expand All @@ -74,19 +74,19 @@ describe( 'block factory', () => {
blocks: [ 'core/updated-text-block' ],
transform: ( { value } ) => {
return {
value: 'chicken ' + value
value: 'chicken ' + value,
};
}
} ]
}
},
} ],
},
} );

const block = {
uid: 1,
blockType: 'core/text-block',
attributes: {
value: 'ribs'
}
value: 'ribs',
},
};

const updateBlock = switchToBlockType( block, 'core/updated-text-block' );
Expand All @@ -95,8 +95,8 @@ describe( 'block factory', () => {
uid: 1,
blockType: 'core/updated-text-block',
attributes: {
value: 'chicken ribs'
}
value: 'chicken ribs',
},
} );
} );

Expand All @@ -108,8 +108,8 @@ describe( 'block factory', () => {
uid: 1,
blockType: 'core/text-block',
attributes: {
value: 'ribs'
}
value: 'ribs',
},
};

const updateBlock = switchToBlockType( block, 'core/updated-text-block' );
Expand Down
30 changes: 15 additions & 15 deletions blocks/api/test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ describe( 'block parser', () => {
const blockSettings = {
attributes: function( rawContent ) {
return {
content: rawContent + ' & Chicken'
content: rawContent + ' & Chicken',
};
}
},
};

expect( parseBlockAttributes( 'Ribs', blockSettings ) ).to.eql( {
content: 'Ribs & Chicken'
content: 'Ribs & Chicken',
} );
} );

it( 'should use the query object implementation', () => {
const blockSettings = {
attributes: {
emphasis: text( 'strong' )
}
emphasis: text( 'strong' ),
},
};

const rawContent = '<span>Ribs <strong>& Chicken</strong></span>';

expect( parseBlockAttributes( rawContent, blockSettings ) ).to.eql( {
emphasis: '& Chicken'
emphasis: '& Chicken',
} );
} );

Expand All @@ -70,12 +70,12 @@ describe( 'block parser', () => {
const blockSettings = {
attributes: function( rawContent ) {
return {
content: rawContent + ' & Chicken'
content: rawContent + ' & Chicken',
};
},
defaultAttributes: {
topic: 'none'
}
topic: 'none',
},
};

const rawContent = 'Ribs';
Expand All @@ -84,7 +84,7 @@ describe( 'block parser', () => {
expect( getBlockAttributes( blockSettings, rawContent, attrs ) ).to.eql( {
align: 'left',
topic: 'none',
content: 'Ribs & Chicken'
content: 'Ribs & Chicken',
} );
} );
} );
Expand Down Expand Up @@ -146,7 +146,7 @@ describe( 'block parser', () => {
return {
content: rawContent,
};
}
},
} );

const parsed = parse(
Expand All @@ -168,9 +168,9 @@ describe( 'block parser', () => {
registerBlock( 'core/test-block', {
attributes: function( rawContent ) {
return {
content: rawContent + ' & Chicken'
content: rawContent + ' & Chicken',
};
}
},
} );

const parsed = parse(
Expand All @@ -182,7 +182,7 @@ describe( 'block parser', () => {
expect( parsed ).to.have.lengthOf( 1 );
expect( parsed[ 0 ].blockType ).to.equal( 'core/test-block' );
expect( parsed[ 0 ].attributes ).to.eql( {
content: 'Ribs & Chicken'
content: 'Ribs & Chicken',
} );
expect( parsed[ 0 ].uid ).to.be.a( 'string' );
} );
Expand Down Expand Up @@ -215,7 +215,7 @@ describe( 'block parser', () => {
return {
content: rawContent,
};
}
},
} );

setUnknownTypeHandler( 'core/unknown-block' );
Expand Down
2 changes: 1 addition & 1 deletion blocks/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
setUnknownTypeHandler,
getUnknownTypeHandler,
getBlockSettings,
getBlocks
getBlocks,
} from '../registration';

describe( 'blocks', () => {
Expand Down
18 changes: 9 additions & 9 deletions blocks/api/test/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ describe( 'block serializer', () => {
const attributes = getCommentAttributes( {
fruit: 'bananas',
category: 'food',
ripeness: 'ripe'
ripeness: 'ripe',
}, {
fruit: 'bananas'
fruit: 'bananas',
} );

expect( attributes ).to.equal( 'category:food ripeness:ripe ' );
Expand All @@ -78,9 +78,9 @@ describe( 'block serializer', () => {
const attributes = getCommentAttributes( {
fruit: 'bananas',
category: 'food',
ripeness: undefined
ripeness: undefined,
}, {
fruit: 'bananas'
fruit: 'bananas',
} );

expect( attributes ).to.equal( 'category:food ' );
Expand All @@ -92,22 +92,22 @@ describe( 'block serializer', () => {
const blockSettings = {
attributes: ( rawContent ) => {
return {
content: rawContent
content: rawContent,
};
},
save( { attributes } ) {
return <p dangerouslySetInnerHTML={ { __html: attributes.content } } />;
}
},
};
registerBlock( 'core/test-block', blockSettings );
const blockList = [
{
blockType: 'core/test-block',
attributes: {
content: 'Ribs & Chicken',
align: 'left'
}
}
align: 'left',
},
},
];
const expectedPostContent = '<!-- wp:core/test-block align:left --><p>Ribs & Chicken</p><!-- /wp:core/test-block -->';

Expand Down
24 changes: 12 additions & 12 deletions blocks/components/editable/format-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ const FORMATTING_CONTROLS = [
{
icon: 'editor-bold',
title: wp.i18n.__( 'Bold' ),
format: 'bold'
format: 'bold',
},
{
icon: 'editor-italic',
title: wp.i18n.__( 'Italic' ),
format: 'italic'
format: 'italic',
},
{
icon: 'editor-strikethrough',
title: wp.i18n.__( 'Strikethrough' ),
format: 'strikethrough'
}
format: 'strikethrough',
},
];

class FormatToolbar extends wp.element.Component {
constructor( props ) {
super( ...arguments );
this.state = {
linkValue: props.formats.link ? props.formats.link.value : '',
isEditingLink: false
isEditingLink: false,
};
this.addLink = this.addLink.bind( this );
this.editLink = this.editLink.bind( this );
Expand All @@ -46,7 +46,7 @@ class FormatToolbar extends wp.element.Component {

componentWillReceiveProps( nextProps ) {
const newState = {
linkValue: nextProps.formats.link ? nextProps.formats.link.value : ''
linkValue: nextProps.formats.link ? nextProps.formats.link.value : '',
};
if (
! this.props.formats.link ||
Expand All @@ -61,7 +61,7 @@ class FormatToolbar extends wp.element.Component {
toggleFormat( format ) {
return () => {
this.props.onChange( {
[ format ]: ! this.props.formats[ format ]
[ format ]: ! this.props.formats[ format ],
} );
};
}
Expand All @@ -82,21 +82,21 @@ class FormatToolbar extends wp.element.Component {
editLink( event ) {
event.preventDefault();
this.setState( {
isEditingLink: true
isEditingLink: true,
} );
}

submitLink( event ) {
event.preventDefault();
this.props.onChange( { link: { value: this.state.linkValue } } );
this.setState( {
isEditingLink: false
isEditingLink: false,
} );
}

updateLinkValue( event ) {
this.setState( {
linkValue: event.target.value
linkValue: event.target.value,
} );
}

Expand All @@ -114,13 +114,13 @@ class FormatToolbar extends wp.element.Component {
.map( ( control ) => ( {
...control,
onClick: this.toggleFormat( control.format ),
isActive: !! formats[ control.format ]
isActive: !! formats[ control.format ],
} ) )
.concat( [ {
icon: 'admin-links',
title: wp.i18n.__( 'Link' ),
onClick: this.addLink,
isActive: !! formats.link
isActive: !! formats.link,
} ] )
}
/>
Expand Down