Skip to content

Commit

Permalink
Merge branch 'develop' into update/template-head
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Sep 3, 2019
2 parents 820fbda + 7ba548d commit a2554a4
Show file tree
Hide file tree
Showing 58 changed files with 2,963 additions and 2,526 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[{.babelrc,.eslintrc,.jshintrc,*.json,*.yml}]
[{.babelrc,.eslintrc,.rtlcssrc,*.json,*.yml}]
indent_style = space
indent_size = 2

Expand Down
69 changes: 40 additions & 29 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@
"root": true,
"extends": [
"plugin:@wordpress/eslint-plugin/recommended",
"plugin:jest/all",
"plugin:import/recommended",
"plugin:eslint-comments/recommended"
],
"settings": {
"react": {
"pragma": "wp",
"version": "16.6"
}
},
"globals": {
"browser": true,
"wp": true,
"Set": true
},
"rules": {
"block-scoped-var": "error",
"complexity": ["error", { "max": 20 } ],
Expand Down Expand Up @@ -51,30 +39,53 @@
"radix": [ "error", "as-needed" ],
"require-await": "error",
"rest-spread-spacing": [ "error", "never" ],
"jest/lowercase-name": [
"error",
{
"ignore": [ "describe" ]
}
],
"jest/no-hooks": "off",
"jest/prefer-expect-assertions": "off",
"jest/prefer-inline-snapshots": "off",
"react/prop-types": "error",
"import/no-unresolved": [ "error", {
"ignore": [ "jquery", "amp-block-editor-data" ]
} ]
} ],
"jsdoc/check-indentation": "error",
"@wordpress/dependency-group": "error",
"@wordpress/react-no-unsafe-timeout": "error"
},
"overrides": [
{
"files":[
"**/__tests__/**/*.js",
"**/test/*.js",
"**/?(*.)test.js",
"tests/js/**/*.js"
],
"extends": [
"plugin:jest/all"
],
"rules": {
"jest/lowercase-name": [
"error",
{
"ignore": [ "describe" ]
}
],
"jest/no-hooks": "off",
"jest/prefer-expect-assertions": "off",
"jest/prefer-inline-snapshots": "off",
}
},
{
"files": [ "tests/e2e/**/*.js" ],
"env": {
"browser": true
},
"globals": {
"browser": true,
"page": true,
"wp": true
"extends": [
"plugin:@wordpress/eslint-plugin/test-e2e",
"plugin:jest/all"
],
"rules": {
"jest/lowercase-name": [
"error",
{
"ignore": [ "describe" ]
}
],
"jest/no-hooks": "off",
"jest/prefer-expect-assertions": "off",
"jest/prefer-inline-snapshots": "off",
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const { ampValidation } = window;
/**
* The id for the 'Showing x of y errors' notice.
*
* @var {string}
* @member {string}
*/
const idNumberErrors = 'number-errors';

/**
* The id for the 'Show all' button.
*
* @var {string}
* @member {string}
*/
const showAllId = 'show-all-errors';

Expand Down
11 changes: 6 additions & 5 deletions assets/src/block-editor/components/layout-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import PropTypes from 'prop-types';
import { ReactElement } from 'react';

/**
* WordPress dependencies
Expand All @@ -12,12 +13,12 @@ import { __, sprintf } from '@wordpress/i18n';
/**
* Layout controls for AMP blocks' attributes: layout, width, height.
*
* @param {Object} attributes Block attributes.
* @param {string} attributes.ampLayout AMP layout option.
* @param {Function} setAttributes Callback to update block attributes.
* @param {Array} ampLayoutOptions Layout options.
* @param {Object} props Component props.
* @param {Object} props.attributes Block attributes.
* @param {Function} props.setAttributes Callback to update block attributes.
* @param {Array} props.ampLayoutOptions Layout options.
*
* @return {Component} Controls.
* @return {ReactElement} Controls.
*/
const LayoutControls = ( { attributes, setAttributes, ampLayoutOptions } ) => {
const { ampLayout, height, width } = attributes;
Expand Down
8 changes: 5 additions & 3 deletions assets/src/block-editor/components/media-placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import PropTypes from 'prop-types';
import { ReactElement } from 'react';

/**
* WordPress dependencies
Expand All @@ -12,10 +13,11 @@ import { __ } from '@wordpress/i18n';
/**
* Display media placeholder.
*
* @param {string} name Block's name.
* @param {string} url URL.
* @param {Object} props Component props.
* @param {string} props.name Block's name.
* @param {string} props.url URL.
*
* @return {Component} Placeholder.
* @return {ReactElement} Placeholder.
*/
const MediaPlaceholder = ( { name, url } ) => {
return (
Expand Down
13 changes: 7 additions & 6 deletions assets/src/block-editor/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import PropTypes from 'prop-types';
import { ReactElement } from 'react';

/**
* WordPress dependencies
Expand Down Expand Up @@ -464,7 +465,7 @@ export const setImageBlockLayoutAttributes = ( props, layout ) => {
*
* @param {Object} props Props.
*
* @return {Component} Inspector Controls.
* @return {ReactElement} Inspector Controls.
*/
export const setUpInspectorControls = ( props ) => {
const { isSelected } = props;
Expand Down Expand Up @@ -492,7 +493,7 @@ setUpInspectorControls.propTypes = {
*
* @param {Object} props Props.
*
* @return {Component} Element.
* @return {ReactElement} Element.
*/
const AmpLayoutControl = ( props ) => {
const { name, attributes: { ampLayout }, setAttributes } = props;
Expand Down Expand Up @@ -531,7 +532,7 @@ AmpLayoutControl.propTypes = {
*
* @param {Object} props Props.
*
* @return {Component} Element.
* @return {ReactElement} Element.
*/
const AmpNoloadingToggle = ( props ) => {
const { attributes: { ampNoLoading }, setAttributes } = props;
Expand Down Expand Up @@ -562,7 +563,7 @@ AmpNoloadingToggle.propTypes = {
*
* @param {Object} props Props.
*
* @return {Component} Inspector Controls.
* @return {ReactElement} Inspector Controls.
*/
const setUpTextBlocksInspectorControls = ( props ) => {
const { isSelected, attributes, setAttributes } = props;
Expand Down Expand Up @@ -698,7 +699,7 @@ setUpTextBlocksInspectorControls.propTypes = {
*
* @param {Object} props Props.
*
* @return {Component} Inspector controls.
* @return {ReactElement} Inspector controls.
*/
const setUpShortcodeInspectorControls = ( props ) => {
const { isSelected } = props;
Expand Down Expand Up @@ -729,7 +730,7 @@ setUpShortcodeInspectorControls.propTypes = {
*
* @param {Object} props Props.
*
* @return {Component} Element.
* @return {ReactElement} Element.
*/
const AmpLightboxToggle = ( props ) => {
const { attributes: { ampLightbox, linkTo, ampLayout }, setAttributes } = props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import PropTypes from 'prop-types';
import { ReactElement } from 'react';

/**
* WordPress dependencies
Expand All @@ -11,12 +12,13 @@ import { __, sprintf } from '@wordpress/i18n';
/**
* Get message for validation error.
*
* @param {?string} code Error code.
* @param {?string} nodeName Node name.
* @param {?string} parentName Parent node name.
* @param {?string} message Error message.
* @param {Object} props Component props.
* @param {?string} props.code Error code.
* @param {?string} props.node_name Node name.
* @param {?string} props.parent_name Parent node name.
* @param {?string} props.message Error message.
*
* @return {Component} Validation error message.
* @return {ReactElement} Validation error message.
*/
const ValidationErrorMessage = ( { message, code, node_name: nodeName, parent_name: parentName } ) => {
if ( message ) {
Expand Down
3 changes: 2 additions & 1 deletion assets/src/block-validation/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ export const maybeResetValidationErrors = () => {
*/
export const updateValidationErrors = () => {
const { getBlockCount, getClientIdsWithDescendants, getBlock } = select( 'core/block-editor' );
const { getCurrentPost } = select( 'core/editor' );
const { resetValidationErrors, addValidationError, updateReviewLink } = dispatch( 'amp/block-validation' );

if ( 0 === getBlockCount() ) {
return;
}

const { getCurrentPost } = select( 'core/editor' );

const currentPost = getCurrentPost();

/**
Expand Down
3 changes: 1 addition & 2 deletions assets/src/common/components/featured-image-cropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ const { wp } = window;
* A state for cropping a featured image.
*
* @constructs FeaturedImageCropper
* @inheritDoc
*/
const FeaturedImageCropper = wp.media.controller.Cropper.extend( {
/**
* Creates an object with the image attachment and crop properties.
*
* @param {wp.media.model.Attachment} attachment The attachment to crop.
* @return {jQuery.promise} A jQuery promise that represents the crop image request.
* @return {Promise} A jQuery promise (not a native one!) that represents the crop image request.
*/
doCrop( attachment ) {
const cropDetails = attachment.get( 'cropDetails' );
Expand Down
7 changes: 4 additions & 3 deletions assets/src/common/components/pre-publish-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import { validateFeaturedImage } from '../helpers';
/**
* Conditionally adds a notice to the pre-publish panel for the featured image.
*
* @param {Object} featuredMedia Media object.
* @param {Array} dimensions Required image dimensions.
* @param {boolean} required Whether selecting a featured image is required.
* @param {Object} props Component props.
* @param {Object} props.featuredMedia Media object.
* @param {Array} props.dimensions Required image dimensions.
* @param {boolean} props.required Whether selecting a featured image is required.
*
* @return {Function} Either a plain pre-publish panel, or the panel with a featured image notice.
*/
Expand Down
13 changes: 2 additions & 11 deletions assets/src/common/components/select-media-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const NOTICE_CLASSNAME = 'notice notice-warning notice-alt inline';
/**
* FeaturedImageSelectionError
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
Expand All @@ -47,7 +46,6 @@ const FeaturedImageSelectionError = wp.media.View.extend( {
* Applies if the featured image has the wrong file type, like .mov or .txt.
* Very similar to the FeaturedImageSelectionError class.
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
Expand All @@ -71,7 +69,6 @@ export const SelectionFileTypeError = wp.media.View.extend( {
* Applies when the video size is more than a certain amount of MB per second.
* Very similar to the FeaturedImageSelectionError class.
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
Expand All @@ -96,13 +93,11 @@ export const SelectionFileSizeError = wp.media.View.extend( {
* Prevent selection of an image that does not meet the minimum requirements.
* Also enforces the file type, ensuring that it was in the allowedTypes prop.
*
* @class
* @augments wp.media.view.Toolbar.Select
* @augments wp.media.view.Toolbar
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
* @inheritDoc
*/
export const FeaturedImageToolbarSelect = wp.media.view.Toolbar.Select.extend( {
/**
Expand Down Expand Up @@ -146,13 +141,11 @@ export const FeaturedImageToolbarSelect = wp.media.view.Toolbar.Select.extend( {
*
* Prevents selecting an attachment that has the wrong file type, like .mov or .txt.
*
* @class
* @augments wp.media.view.Toolbar.Select
* @augments wp.media.view.Toolbar
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
* @inheritDoc
*/
export const EnforcedFileToolbarSelect = wp.media.view.Toolbar.Select.extend( {
/**
Expand All @@ -179,22 +172,20 @@ export const EnforcedFileToolbarSelect = wp.media.view.Toolbar.Select.extend( {
/**
* Gets the select media frame, which displays in the bottom of the Media Library.
*
* @param {Class} ToolbarSelect The select toolbar that display at the bottom of the Media Library.
* @return {Class} ToolbarSelect A wp.media Class that creates a Media Library toolbar.
* @param {Object} ToolbarSelect The select toolbar that display at the bottom of the Media Library.
* @return {Object} ToolbarSelect A wp.media Class that creates a Media Library toolbar.
*/
export const getSelectMediaFrame = ( ToolbarSelect ) => {
/**
* Selects a featured image from the media library.
*
* @class
* @augments wp.media.view.MediaFrame.Select
* @augments wp.media.view.MediaFrame
* @augments wp.media.view.Frame
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
* @mixes wp.media.controller.StateMachine
* @inheritDoc
*/
return wp.media.view.MediaFrame.Select.extend( {
/**
Expand Down
2 changes: 2 additions & 0 deletions assets/src/common/components/with-cropped-featured-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default ( InitialMediaUpload, minImageDimensions, alternateMinImageDimens
return class FeaturedImageMediaUpload extends InitialMediaUpload {
/**
* Constructs the class.
*
* @param {*} args Constructor arguments.
*/
constructor( ...args ) {
super( ...args );
Expand Down
2 changes: 2 additions & 0 deletions assets/src/common/components/with-enforced-file-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export default ( InitialMediaUpload ) => {
return class EnforcedFileTypeMediaUpload extends InitialMediaUpload {
/**
* Constructs the class.
*
* @param {*} args Constructor arguments.
*/
constructor( ...args ) {
super( ...args );
Expand Down
Loading

0 comments on commit a2554a4

Please sign in to comment.