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

eslint-plugin: Enforce object-shorthand #13400

Merged
merged 4 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions docs/tool/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ function generateRootManifestFromTOCItems( items, parent = null ) {
}

pageItems.push( {
title: title,
slug: slug,
title,
slug,
markdown_source: `${ baseRepoUrl }\/${ fileName }`,
parent: parent,
parent,
} );
if ( Array.isArray( children ) && children.length ) {
pageItems = pageItems.concat( generateRootManifestFromTOCItems( children, slug ) );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/classic/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class ClassicEdit extends Component {
editor.addButton( 'kitchensink', {
tooltip: _x( 'More', 'button to expand options' ),
icon: 'dashicon dashicons-editor-kitchensink',
onClick: function() {
onClick() {
const button = this;
const active = ! button.active();

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const settings = {
],
},

edit: edit,
edit,

save( { attributes } ) {
return <RawHTML>{ attributes.content }</RawHTML>;
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ export const settings = {
'has-drop-cap': dropCap,
} );
const styles = {
backgroundColor: backgroundColor,
backgroundColor,
color: textColor,
fontSize: fontSize,
fontSize,
textAlign: align,
};

Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/verse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const settings = {
content: nextContent,
} );
} }
style={ { textAlign: textAlign } }
style={ { textAlign } }
placeholder={ __( 'Write…' ) }
wrapperClassName={ className }
onMerge={ mergeBlocks }
Expand All @@ -91,7 +91,7 @@ export const settings = {
return (
<RichText.Content
tagName="pre"
style={ { textAlign: textAlign } }
style={ { textAlign } }
value={ content }
/>
);
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/button/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ const styles = StyleSheet.create( {
fontWeight: 'bold',
fontSize: 13,
alignSelf: 'flex-end',
marginLeft: marginLeft,
marginBottom: marginBottom,
marginLeft,
marginBottom,
},
subscriptActive: {
color: 'white',
fontWeight: 'bold',
fontSize: 13,
alignSelf: 'flex-end',
marginLeft: marginLeft,
marginBottom: marginBottom,
marginLeft,
marginBottom,
},
} );

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/color-palette/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function ColorPalette( { colors, disableCustomColors = false, val
return (
<div className={ classes }>
{ map( colors, ( { color, name } ) => {
const style = { color: color };
const style = { color };
const itemClasses = classnames( 'components-color-palette__item', { 'is-active': value === color } );

return (
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/form-token-field/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe( 'FormTokenField', function() {
TestUtils.Simulate.keyDown(
wrapperElement(),
{
keyCode: keyCode,
keyCode,
shiftKey: ! ! shiftKey,
}
);
Expand All @@ -58,7 +58,7 @@ describe( 'FormTokenField', function() {
function sendKeyPress( charCode ) {
TestUtils.Simulate.keyPress(
wrapperElement(),
{ charCode: charCode }
{ charCode }
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default compose(

return {
openGeneralSidebar: () => openGeneralSidebar( getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document' ),
closeGeneralSidebar: closeGeneralSidebar,
closeGeneralSidebar,
};
} ),
)( Header );
4 changes: 2 additions & 2 deletions packages/editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const BlockDraggable = ( { children, clientId, rootClientId, blockElementId, ind
{
( { onDraggableStart, onDraggableEnd } ) => {
return children( {
onDraggableStart: onDraggableStart,
onDraggableEnd: onDraggableEnd,
onDraggableStart,
onDraggableEnd,
} );
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/inserter/test/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const items = [

const DEFAULT_PROPS = {
position: 'top center',
items: items,
items,
debouncedSpeak: noop,
fetchReusableBlocks: noop,
setTimeout: noop,
Expand Down
14 changes: 7 additions & 7 deletions packages/editor/src/editor-styles/ast/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function( css, options ) {
*/

function position() {
const start = { line: lineno, column: column };
const start = { line: lineno, column };
return function( node ) {
node.position = new Position( start );
whitespace();
Expand All @@ -50,7 +50,7 @@ export default function( css, options ) {

function Position( start ) {
this.start = start;
this.end = { line: lineno, column: column };
this.end = { line: lineno, column };
this.source = options.source;
}

Expand Down Expand Up @@ -351,8 +351,8 @@ export default function( css, options ) {

return pos( {
type: 'keyframes',
name: name,
vendor: vendor,
name,
vendor,
keyframes: frames,
} );
}
Expand Down Expand Up @@ -382,7 +382,7 @@ export default function( css, options ) {

return pos( {
type: 'supports',
supports: supports,
supports,
rules: style,
} );
}
Expand Down Expand Up @@ -440,7 +440,7 @@ export default function( css, options ) {

return pos( {
type: 'media',
media: media,
media,
rules: style,
} );
}
Expand Down Expand Up @@ -527,7 +527,7 @@ export default function( css, options ) {
return pos( {
type: 'document',
document: doc,
vendor: vendor,
vendor,
rules: style,
} );
}
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.0.0 (Unreleased)

### Breaking Changes

- The `esnext` and `recommended` rulesets now enforce [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand)

## 1.0.0 (2018-12-12)

### New Features
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/configs/esnext.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-const': 'error',
quotes: [ 'error', 'single', { allowTemplateLiterals: true, avoidEscape: true } ],
'space-unary-ops': [ 'error', {
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/src/createHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function createHooks() {
doingFilter: createDoingHook( filters ),
didAction: createDidHook( actions ),
didFilter: createDidHook( filters ),
actions: actions,
filters: filters,
actions,
filters,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rich-text/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function create( {
if ( typeof text === 'string' && text.length > 0 ) {
return {
formats: Array( text.length ),
text: text,
text,
};
}

Expand Down