Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Update versions in package.json, use @wordpress/scripts for build process #492

Merged
merged 17 commits into from
Jan 13, 2020
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
18 changes: 17 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
},
"rules": {
"@wordpress/dependency-group": "error",
"@wordpress/react-no-unsafe-timeout": "error"
"@wordpress/react-no-unsafe-timeout": "error",
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
Copy link
Collaborator Author

@kienstra kienstra Dec 19, 2019

Choose a reason for hiding this comment

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

This requires the trailing comma after 'bar' here:

const foo = {
    one: 'baz',
    two: 'bar',
};

...but doesn't allow a trailing comma after 'bar' here:

const foo = { one: 'baz', two: 'bar' };

"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
Copy link
Collaborator Author

@kienstra kienstra Dec 19, 2019

Choose a reason for hiding this comment

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

A trailing comma after the last argument looks strange to me: doThis( 'arg1', 'arg2', )

...and it doesn't have great browser support. This .eslintrc is also used for a non-compiled file: admin.block-post.js.

Ideally, soon that file will be ported to the React logic in the refactoring.

}
],
"no-unused-vars": [
"error",
{
"ignoreRestSiblings": true
}
]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file could probably use more rules, but that's not in scope for this PR.

}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ tmp/
#######
.npmignore
node_modules
package-lock.json

# Always-ignore extensions #
########################
Expand All @@ -88,6 +87,7 @@ package-lock.json
*.swp
*.tmp
*.bak
*.map
Copy link
Collaborator Author

@kienstra kienstra Dec 18, 2019

Choose a reason for hiding this comment

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

The new build process creates .map files, like block-lab/css/blocks.editor.css.map.


# Sass #
#######
Expand Down Expand Up @@ -117,3 +117,4 @@ js/editor.blocks.js
js/scripts.js
css/blocks.editor.css
package/
*.asset.php
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ gulp.task( 'clean:bundle', function () {
'package/trunk/coverage',
'package/trunk/js/blocks',
'package/trunk/js/src',
'package/trunk/js/*.map',
'package/trunk/css/*.map',
'package/trunk/bin',
'package/trunk/node_modules',
'package/trunk/vendor',
Expand All @@ -103,4 +105,4 @@ gulp.task( 'default', gulp.series(
'wporg:trunk',
'version',
'clean:bundle'
) );
) );
38 changes: 0 additions & 38 deletions js/blocks/components/advanced-controls.js

This file was deleted.

6 changes: 3 additions & 3 deletions js/blocks/components/block-lab-inspector.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* WordPress dependencies
*/
const { PanelBody } = wp.components;
const { InspectorControls } = wp.editor;
const { applyFilters } = wp.hooks;
import { PanelBody } from '@wordpress/components';
import { InspectorControls } from '@wordpress/block-editor';
import { applyFilters } from '@wordpress/hooks';

/**
* Internal dependencies
Expand Down
10 changes: 4 additions & 6 deletions js/blocks/components/edit.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/**
* WordPress dependencies
*/
const { ServerSideRender } = wp.editor;
const { Fragment } = wp.element;
import ServerSideRender from '@wordpress/server-side-render';

/**
* Internal dependencies
*/
import { AdvancedControls, BlockLabInspector, FormControls } from './';
import { BlockLabInspector, FormControls } from './';
import icons from '../../../assets/icons.json';

/**
Expand All @@ -26,9 +25,8 @@ const Edit = ( { blockProps, block } ) => {
}

return (
<Fragment>
<>
<BlockLabInspector blockProps={ blockProps } block={ block } />
<AdvancedControls block={ block } />
<div className={ className } key={ `form-controls-${ block.name }` } >
{ isSelected ? (
<div className="block-form">
Expand All @@ -43,7 +41,7 @@ const Edit = ( { blockProps, block } ) => {
/>
) }
</div>
</Fragment>
</>
);
};

Expand Down
16 changes: 8 additions & 8 deletions js/blocks/components/fetch-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import classNames from 'classnames';
/**
* WordPress dependencies
*/
const { __, sprintf, _n } = wp.i18n;
const { Component, createRef } = wp.element;
const { decodeEntities } = wp.htmlEntities;
const { UP, DOWN, ENTER } = wp.keycodes;
const { BaseControl, Spinner, withSpokenMessages, Popover } = wp.components;
const { withInstanceId } = wp.compose;
const apiFetch = wp.apiFetch;
const { addQueryArgs } = wp.url;
import { __, sprintf, _n } from '@wordpress/i18n';
import { Component, createRef } from '@wordpress/element';
import { decodeEntities } from '@wordpress/html-entities';
import { UP, DOWN, ENTER } from '@wordpress/keycodes';
import { BaseControl, Spinner, withSpokenMessages, Popover } from '@wordpress/components';
import { withInstanceId } from '@wordpress/compose';
import { addQueryArgs } from '@wordpress/url';
const { apiFetch } = wp;

// Since FetchInput is rendered in the context of other inputs, but should be
// considered a separate modal node, prevent keyboard events from propagating
Expand Down
4 changes: 2 additions & 2 deletions js/blocks/components/fields.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* WordPress dependencies
*/
const { applyFilters } = wp.hooks;
const { select } = wp.data;
import { applyFilters } from '@wordpress/hooks';
Copy link
Collaborator Author

@kienstra kienstra Jan 12, 2020

Choose a reason for hiding this comment

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

The reason for importing these as modules instead of using something like wp.hooks is so that we can control the module versions.

For example, InspectorControls and InspectorAdvancedControls were moved from wp.editor to wp.block-editor. And wp.nux was deprecated entirely.

If we control the versions of the modules, we should be less dependent on the version of Core and Gutenberg users have.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A user reported an error from wp.nux.DotTips being deprecated in Gutenberg. I probably would have seen that if we imported that deprecated module.

import { select } from '@wordpress/data';

/**
* Internal dependencies
Expand Down
19 changes: 11 additions & 8 deletions js/blocks/components/image.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const { BaseControl, Button, Placeholder, DropZone, FormFileUpload, Spinner } = wp.components;
const { withState } = wp.compose;
const { withSelect } = wp.data;
const { mediaUpload, MediaUpload, MediaUploadCheck } = wp.editor;
const { Fragment } = wp.element;
const { __, sprintf } = wp.i18n;
/**
* WordPress dependencies
*/
import { BaseControl, Button, Placeholder, DropZone, FormFileUpload, Spinner } from '@wordpress/components';
import { withState } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
import { mediaUpload } from '@wordpress/editor';
import { __, sprintf } from '@wordpress/i18n';

const ALLOWED_TYPES = [ 'image' ];
const DEFAULT_IMG_ID = 0;
Expand Down Expand Up @@ -96,7 +99,7 @@ const Image = withSelect( ( select, ownProps ) => {
<Spinner />
) }
{ ! isUploading && (
<Fragment>
<>
<FormFileUpload
isLarge
disabled={ !! isUploading }
Expand Down Expand Up @@ -129,7 +132,7 @@ const Image = withSelect( ( select, ownProps ) => {
</div>
) }
/>
</Fragment>
</>
) }
</MediaUploadCheck>
</Placeholder>
Expand Down
1 change: 0 additions & 1 deletion js/blocks/components/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as AdvancedControls } from './advanced-controls';
export { default as BlockLabInspector } from './block-lab-inspector';
export { default as ContentControl } from './content-control';
export { default as Edit } from './edit';
Expand Down
10 changes: 5 additions & 5 deletions js/blocks/components/repeater-rows.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* WordPress dependencies
*/
const { BaseControl, IconButton } = wp.components;
const { Component, Fragment, createRef } = wp.element;
const { __ } = wp.i18n;
import { BaseControl, IconButton } from '@wordpress/components';
import { Component, createRef } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
const { getScrollContainer } = wp.dom;

/**
Expand Down Expand Up @@ -166,7 +166,7 @@ class RepeaterRows extends Component {
const { rows, field, subFields, parentBlockProps, parentBlock } = this.props;

return (
<Fragment>
<>
<div className="block-lab-repeater__rows" ref={ this.repeaterRows }>
{
rows.map( ( row, rowIndex ) => {
Expand Down Expand Up @@ -214,7 +214,7 @@ class RepeaterRows extends Component {
} )
}
</div>
</Fragment>
</>
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions js/blocks/components/tiny-mce.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* WordPress dependencies
*/
const { Component } = wp.element;
const { __ } = wp.i18n;
const { F10 } = wp.keycodes;
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { F10 } from '@wordpress/keycodes';

/**
* Forked from the Core Classic Editor's Edit component.
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/checkbox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { CheckboxControl } = wp.components;
/**
* WordPress dependencies
*/
import { CheckboxControl } from '@wordpress/components';

const BlockLabCheckboxControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
2 changes: 1 addition & 1 deletion js/blocks/controls/classic-text.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
const { BaseControl } = wp.components;
import { BaseControl } from '@wordpress/components';

/**
* Internal dependencies
Expand Down
7 changes: 5 additions & 2 deletions js/blocks/controls/color.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const { BaseControl, TextControl, Popover, ColorIndicator, ColorPicker } = wp.components;
const { withState } = wp.compose;
/**
* WordPress dependencies
*/
import { BaseControl, TextControl, Popover, ColorIndicator, ColorPicker } from '@wordpress/components';
import { withState } from '@wordpress/compose';

const BlockLabColorPopover = withState( {
} )( ( { isVisible, color, onUpdate, setState } ) => {
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*/
import classNames from 'classnames';

const { TextControl } = wp.components;
/**
* WordPress dependencies
*/
import { TextControl } from '@wordpress/components';

const BlockLabEmailControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/multiselect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { SelectControl } = wp.components;
/**
* WordPress dependencies
*/
import { SelectControl } from '@wordpress/components';

const BlockLabMultiselectControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*/
import classNames from 'classnames';

const { TextControl } = wp.components;
/**
* WordPress dependencies
*/
import { TextControl } from '@wordpress/components';

const BlockLabNumberControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/radio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { RadioControl } = wp.components;
/**
* WordPress dependencies
*/
import { RadioControl } from '@wordpress/components';

const BlockLabRadioControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/range.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { RangeControl } = wp.components;
/**
* WordPress dependencies
*/
import { RangeControl } from '@wordpress/components';

const BlockLabRangeControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
7 changes: 3 additions & 4 deletions js/blocks/controls/repeater.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* WordPress dependendies
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { BaseControl, IconButton } = wp.components;

import { __ } from '@wordpress/i18n';
import { BaseControl, IconButton } from '@wordpress/components';
/**
* Internal dependencies
*/
Expand Down
4 changes: 2 additions & 2 deletions js/blocks/controls/rich-text.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* WordPress dependencies
*/
const { BaseControl } = wp.components;
const { RichText } = wp.blockEditor;
import { BaseControl } from '@wordpress/components';
import { RichText } from '@wordpress/block-editor';

const BlockLabRichTextControl = ( props ) => {
const { field, getValue, instanceId, onChange } = props;
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/select.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { SelectControl } = wp.components;
/**
* WordPress dependencies
*/
import { SelectControl } from '@wordpress/components';

const BlockLabSelectControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/text.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { TextControl } = wp.components;
/**
* WordPress dependencies
*/
import { TextControl } from '@wordpress/components';

const BlockLabTextControl = ( props ) => {
const { field, getValue, onChange } = props;
Expand Down
5 changes: 4 additions & 1 deletion js/blocks/controls/textarea.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { TextareaControl } = wp.components;
/**
* WordPress dependencies
*/
import { TextareaControl } from '@wordpress/components';

const BlockLabTextareaControl = ( props ) => {
const { getValue, field, onChange } = props;
Expand Down
Loading