Repository navigation
Effects: Restore new post setup as non-dirtying change #4836
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
Changes from all commits
32fbe7b
a4fff32
8b1d6f1
2566c71
88f922e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| // For the most part, this file mirrors the same configuration from the root | ||
| // `.eslintrc.json`, the exceptions being that since Cypress is preconfigured | ||
| // with Mocha & Chai, we need to broadly disable the Jest rules, which is | ||
| // otherwise difficult to do. This file could be made more minimal once all of | ||
| // the Gutenberg-specific rules are migrated to a common WordPress config. | ||
|
|
||
| module.exports = { | ||
| "root": true, | ||
| "parser": "babel-eslint", | ||
| "extends": [ | ||
| "wordpress" | ||
| ], | ||
| "env": { | ||
| "browser": false, | ||
| "es6": true, | ||
| "node": true, | ||
| "mocha": true | ||
| }, | ||
| "parserOptions": { | ||
| "sourceType": "module" | ||
| }, | ||
| "globals": { | ||
| "cy": true, | ||
| "Cypress": true, | ||
| "expect": true | ||
| }, | ||
| "plugins": [ | ||
| "wordpress" | ||
| ], | ||
| "rules": { | ||
| "array-bracket-spacing": [ "error", "always" ], | ||
| "brace-style": [ "error", "1tbs" ], | ||
| "camelcase": [ "error", { "properties": "never" } ], | ||
| "comma-dangle": [ "error", "always-multiline" ], | ||
| "comma-spacing": "error", | ||
| "comma-style": "error", | ||
| "computed-property-spacing": [ "error", "always" ], | ||
| "constructor-super": "error", | ||
| "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-const-assign": "error", | ||
| "no-debugger": "error", | ||
| "no-dupe-args": "error", | ||
| "no-dupe-class-members": "error", | ||
| "no-dupe-keys": "error", | ||
| "no-duplicate-case": "error", | ||
| "no-duplicate-imports": "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": "ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]", | ||
| "message": "Path access on WordPress dependencies is not allowed." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^blocks$/]", | ||
| "message": "Use @wordpress/blocks as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^components$/]", | ||
| "message": "Use @wordpress/components as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^date$/]", | ||
| "message": "Use @wordpress/date as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^editor$/]", | ||
| "message": "Use @wordpress/editor as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^element$/]", | ||
| "message": "Use @wordpress/element as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^i18n$/]", | ||
| "message": "Use @wordpress/i18n as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^data$/]", | ||
| "message": "Use @wordpress/data as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^utils$/]", | ||
| "message": "Use @wordpress/utils as import path instead." | ||
| }, | ||
| { | ||
| "selector": "ImportDeclaration[source.value=/^edit-poost$/]", | ||
| "message": "Use @wordpress/edit-post as import path instead." | ||
| }, | ||
| { | ||
| "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-computed-key": "error", | ||
| "no-useless-constructor": "error", | ||
| "no-useless-return": "error", | ||
| "no-var": "error", | ||
| "no-whitespace-before-property": "error", | ||
| "object-curly-spacing": [ "error", "always" ], | ||
| "padded-blocks": [ "error", "never" ], | ||
| "prefer-const": "error", | ||
| "quote-props": [ "error", "as-needed" ], | ||
| "semi": "error", | ||
| "semi-spacing": "error", | ||
| "space-before-blocks": [ "error", "always" ], | ||
| "space-before-function-paren": [ "error", "never" ], | ||
| "space-in-parens": [ "error", "always" ], | ||
| "space-infix-ops": [ "error", { "int32Hint": false } ], | ||
| "space-unary-ops": [ "error", { | ||
| "overrides": { | ||
| "!": true | ||
| } | ||
| } ], | ||
| "template-curly-spacing": [ "error", "always" ], | ||
| "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" | ||
| } | ||
| }; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,30 @@ describe( 'Hello Gutenberg', () => { | |
| cy.url().should( 'include', 'post-new.php' ); | ||
| cy.get( '[placeholder="Add title"]' ).should( 'exist' ); | ||
| } ); | ||
|
|
||
| it( 'Should have no history', () => { | ||
| cy.get( '.editor-history__undo:not( :disabled )' ).should( 'not.exist' ); | ||
| cy.get( '.editor-history__redo:not( :disabled )' ).should( 'not.exist' ); | ||
| } ); | ||
|
|
||
| it( 'Should not prompt to confirm unsaved changes', ( done ) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was afraid this was a false positive because I thought Cypress would remove all popovers but confirmed it's breaking correctly when needed. |
||
| const timeout = setTimeout( () => { | ||
| done( new Error( 'Expected page reload' ) ); | ||
| }, 5000 ); | ||
|
|
||
| cy.window().then( ( window ) => { | ||
| function verify( event ) { | ||
| expect( event.returnValue ).to.equal( '' ); | ||
|
|
||
| window.removeEventListener( 'beforeunload', verify ); | ||
| clearTimeout( timeout ); | ||
|
|
||
| done(); | ||
| } | ||
|
|
||
| window.addEventListener( 'beforeunload', verify ); | ||
|
|
||
| cy.reload(); | ||
| } ); | ||
| } ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ Nice test |
||
| } ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a way to override the root config instead of copying it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, that would be the best solution. I would leave it as it is. We are going to tackle it together with @ntwb as part of
@wordpress/packagessoon.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous iteration of the configuration file is how to override the root config (i.e. ESLint will look in all parent directories until it finds a config with
root: true). The problem is that by opting into many Jest presets, there are many rules andenvvalues we'd need to disable individually.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more complicated than I would expect.