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

Add AMP validation checking for Gutenberg blocks #1019

Merged
merged 49 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8413457
Add source comments around each Gutenberg block to track validation i…
westonruter Mar 13, 2018
07aeee2
Defer mustache tag replacements to right before serialization and onl…
westonruter Mar 14, 2018
01691e5
Eliminate needless use of PEG parser for adding block source comments
westonruter Mar 17, 2018
27e8bec
Revert commit that removed REST API logic.
Mar 18, 2018
590cd76
Prototype asynchronous notices for blocks.
Mar 18, 2018
8218919
Rever commit 27e8b, which added REST API endpoint.
Mar 19, 2018
9c3568d
Add amp_validation field to REST API response.
Mar 19, 2018
ab82e8d
Output validation errors in REST API response.
Mar 19, 2018
ea1c37a
Remove jQuery dependency and ES6 class.
Mar 20, 2018
96297fc
Change which post types have the added field.
Mar 20, 2018
ed4b03b
In REST API response, validate front-end if no errors exist.
Mar 21, 2018
561af32
Skip Gutenberg-based tests for WP version < 4.9.
Mar 21, 2018
f64ab2e
Begin to add notices to blocks based on errors.
Mar 21, 2018
b9bd206
Address Travis error by aligning array values vertically.
Mar 21, 2018
bcdff5f
Get the block types with errors from the REST API response.
Mar 22, 2018
049e482
Update test to reflect change in text.
Mar 22, 2018
fe34e8e
Store the block validation errors, avoiding lookup in every edit().
Mar 22, 2018
49b66ae
Get validation errors for specific blocks, not only for block names.
Mar 22, 2018
743cca4
Address Travis errors by raising variable declaration.
Mar 22, 2018
4676777
Add 'block_attrs' to blocksWithErrors.
Mar 22, 2018
b9aa16c
Correct the variable for block_attrs.
Mar 22, 2018
e2fc9a7
Use the new blockAttrs to find a match with errors.
Mar 23, 2018
6cd996a
Move the notice from below to above the block.
Mar 23, 2018
339f69f
Add a 'More details' link to the notice.
Mar 23, 2018
a02d029
Enable showing multiple validation errors.
Mar 23, 2018
15f0abe
Enable outputting several error codes, and their counts.
Mar 23, 2018
2b03c6a
Address a Travis error regarding complexity.
Mar 23, 2018
d366da3
Remove the counts from after the error codes.
Mar 23, 2018
80d32de
Add keys to the components and edit block.
Mar 23, 2018
16388c2
Make the notice expandable.
Mar 26, 2018
f9d8575
Merge in develop, resolve conflicts.
kienstra Apr 6, 2018
9aa6704
Address Travis error by removing extra comma.
kienstra Apr 6, 2018
dcb1e77
Force re-validation of post on frontend for amp_validation_errors fie…
westonruter Apr 8, 2018
eb00bcf
Prevent re-validating posts that have just been validated
westonruter Apr 8, 2018
9ecc24c
Fix: Each child in an array or iterator should have a unique "key" prop
westonruter Apr 8, 2018
354fdcd
Remove block error summary while waiting for design to formulate
westonruter Apr 8, 2018
0bada73
Fix delay between save and update of validation error notice
westonruter Apr 9, 2018
34024cc
Use eslint-config-wordpress and fix eslint issues
westonruter Apr 9, 2018
8e78904
Prevent reporting validation errors for blocks that are not in the cu…
westonruter Apr 9, 2018
277da63
Use eslint config adapted from Gutenberg
westonruter Apr 10, 2018
ca3ff60
Use block content index to match blocks with corresponding validation…
westonruter Apr 10, 2018
01a21a8
Only update block validation errors when editor state is clean
westonruter Apr 10, 2018
3e032d4
Handle showing validation errors for nested blocks
westonruter Apr 11, 2018
6a4cbcc
Add initial overall warning notice when there are validation errors
westonruter Apr 11, 2018
4d7dc19
Improve organization of Gutenberg extension code; improve warning not…
westonruter Apr 11, 2018
21e60f0
Show details with each block's validation errors; improve styling
westonruter Apr 11, 2018
ca6c96c
Add link to validation error details in Gutenberg notice
westonruter Apr 12, 2018
7a60509
Use wp.element.Fragment instead of wrangling arrays with key props
westonruter Apr 12, 2018
5bf12da
Merge branch 'develop' of https://github.com/Automattic/amp-wp into a…
westonruter Apr 13, 2018
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
1 change: 1 addition & 0 deletions .dev-lib
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ SKIP_ECHO_PATHS_SCOPE=1
function after_wp_install {
echo "Installing REST API..."
svn export -q https://plugins.svn.wordpress.org/jetpack/trunk/ "$WP_CORE_DIR/src/wp-content/plugins/jetpack"
svn export -q https://plugins.svn.wordpress.org/gutenberg/trunk/ "$WP_CORE_DIR/src/wp-content/plugins/gutenberg"
}
1 change: 0 additions & 1 deletion .eslintrc

This file was deleted.

187 changes: 187 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"root": true,
"extends": [
"wordpress"
],
"env": {
"browser": true
},
"globals": {
"wp": true,
"window": true,
"document": true
},
"settings": {
"react": {
"pragma": "wp"
}
},
"rules": {
"no-magic-numbers": [2, { "ignoreArrayIndexes": true, "ignore": [ -1, 0, 1 ] }],
"array-bracket-spacing": [
"error",
"always"
],
"brace-style": [
"error",
"1tbs"
],
"camelcase": [
"error",
{
"properties": "never"
}
],
"comma-dangle": [
"error",
"never"
],
"comma-spacing": "error",
"comma-style": "error",
"computed-property-spacing": [
"error",
"always"
],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"key-spacing": "error",
"keyword-spacing": "error",
"lines-around-comment": "off",
"no-alert": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-console": "error",
"no-debugger": "error",
"no-dupe-args": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-else-return": "error",
"no-eval": "error",
"no-extra-semi": "error",
"no-fallthrough": "error",
"no-lonely-if": "error",
"no-mixed-operators": "error",
"no-mixed-spaces-and-tabs": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-multi-spaces": "error",
"no-multi-str": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-redeclare": "error",
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.name=/^__|_n|_x$/]:not([arguments.0.type=/^Literal|BinaryExpression$/])",
"message": "Translate function arguments must be string literals."
},
{
"selector": "CallExpression[callee.name=/^_n|_x$/]:not([arguments.1.type=/^Literal|BinaryExpression$/])",
"message": "Translate function arguments must be string literals."
},
{
"selector": "CallExpression[callee.name=_nx]:not([arguments.2.type=/^Literal|BinaryExpression$/])",
"message": "Translate function arguments must be string literals."
}
],
"no-shadow": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unreachable": "error",
"no-unsafe-negation": "error",
"no-unused-expressions": "error",
"no-unused-vars": "error",
"no-useless-return": "error",
"no-whitespace-before-property": "error",
"object-curly-spacing": [
"error",
"always"
],
"padded-blocks": [
"error",
"never"
],
"quote-props": [
"error",
"as-needed"
],
"react/display-name": "off",
"react/no-children-prop": "off",
"react/prop-types": "off",
"semi": "error",
"semi-spacing": "error",
"space-before-blocks": [
"error",
"always"
],
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"space-in-parens": [
"error",
"always"
],
"space-infix-ops": [
"error",
{
"int32Hint": false
}
],
"space-unary-ops": [
"error",
{
"overrides": {
"!": true,
"yield": true
}
}
],
"valid-jsdoc": [
"error",
{
"prefer": {
"arg": "param",
"argument": "param",
"extends": "augments",
"returns": "return"
},
"preferType": {
"array": "Array",
"bool": "boolean",
"Boolean": "boolean",
"float": "number",
"Float": "number",
"int": "number",
"integer": "number",
"Integer": "number",
"Number": "number",
"object": "Object",
"String": "string",
"Void": "void"
},
"requireParamDescription": false,
"requireReturn": false
}
],
"valid-typeof": "error",
"yoda": "off"
}
}
1 change: 0 additions & 1 deletion .jscsrc

This file was deleted.

1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env node */
/* jshint node:true */
/* eslint-disable camelcase */

module.exports = function( grunt ) {
'use strict';
Expand Down
13 changes: 13 additions & 0 deletions assets/css/amp-post-meta-box.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@
line-height: 280%;
}
}

.amp-block-validation-errors {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 13px;
line-height: 1.5;
}
.amp-block-validation-errors .amp-block-validation-errors__summary {
margin: 0.5em 0;
padding: 2px;
}
.amp-block-validation-errors .amp-block-validation-errors__list {
padding-left: 2.5em;
}
Loading