Skip to content
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; ignore the submodules
gutenberg
symlinked-packages
symlinked-packages-in-parent
react-native-aztec
bundle
Expand Down
31 changes: 0 additions & 31 deletions .eslintrc

This file was deleted.

74 changes: 74 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* External dependencies
*/
const { map } = require( 'lodash' );

module.exports = {
parser: "babel-eslint",
env: {
browser: true,
"jest/globals": true
},
globals: {
__DEV__: true
},
plugins: [
"react",
"react-native",
"jest",
"flowtype"
],
extends: [
"plugin:@wordpress/eslint-plugin/recommended",
"plugin:flowtype/recommended",
],
settings: {
flowtype: {
onlyFilesWithFlowAnnotation: true,
},
react: {
pragma: "React",
version: "16.8.3",
flowVersion: "0.92.0",
},
},
rules: {
'no-restricted-syntax': [
'error',
// NOTE: We can't include the forward slash in our regex or
// we'll get a `SyntaxError` (Invalid regular expression: \ at end of pattern)
// here. That's why we use \\u002F in the regexes below.
{
selector: 'ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]',
message: 'Path access on WordPress dependencies is not allowed.',
},
{
selector: 'CallExpression[callee.name=/^(__|_x|_n|_nx)$/] Literal[value=/\\.{3}/]',
message: 'Use ellipsis character (…) in place of three dots',
},
{
selector: 'ImportDeclaration[source.value="lodash"] Identifier.imported[name="memoize"]',
message: 'Use memize instead of Lodash’s memoize',
},
{
selector: 'CallExpression[callee.object.name="page"][callee.property.name="waitFor"]',
message: 'Prefer page.waitForSelector instead.',
},
{
selector: 'JSXAttribute[name.name="id"][value.type="Literal"]',
message: 'Do not use string literals for IDs; use withInstanceId instead.',
},
{
// Discourage the usage of `Math.random()` as it's a code smell
// for UUID generation, for which we already have a higher-order
// component: `withInstanceId`.
selector: 'CallExpression[callee.object.name="Math"][callee.property.name="random"]',
message: 'Do not use Math.random() to generate unique IDs; use withInstanceId instead. (If you’re not generating unique IDs: ignore this message.)',
},
{
selector: 'CallExpression[callee.name="withDispatch"] > :function > BlockStatement > :not(VariableDeclaration,ReturnStatement)',
message: 'withDispatch must return an object with consistent keys. Avoid performing logic in `mapDispatchToProps`.',
},
],
},
}
5 changes: 3 additions & 2 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ module.exports = {
blockCode: {
fontFamily: 'serif',
},
'editor-rich-text': {
'block-editor-rich-text': {
fontFamily: 'serif',
minHeight: 30,
},
'editor-plain-text': {
'block-editor-plain-text': {
fontFamily: 'serif',
},
blockHolderFocused: {
Expand Down
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 397 files
3 changes: 2 additions & 1 deletion i18n-cache/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ const fetchTranslations = () => {
const translationFilePromises = fetchedTranslations.map( ( languageResult ) => {
return new Promise( ( resolve, reject ) => {
const translationRelativePath = getTranslationFilePath( languageResult.locale );
const translationAbsolutePath = path.resolve( __dirname, translationRelativePath );

if ( languageResult.inCache ) {
languageResult.path = translationRelativePath;
resolve( translationRelativePath );
return;
}

const translationAbsolutePath = path.resolve( __dirname, translationRelativePath );

fs.writeFile( translationAbsolutePath, JSON.stringify( languageResult.response ), 'utf8', ( err ) => {
if ( err ) {
reject( err );
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @flow
* @format */

/**
* Internal dependencies
*/
import { registerApp } from './src';

registerApp();
2 changes: 1 addition & 1 deletion jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock( 'react-native-safe-area', () => {
accept( { safeAreaInsets: { bottom: 34 } } );
} );
},
addEventListener: addEventListener,
addEventListener,
removeEventListener: jest.fn(),
};
} );
Expand Down
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
},
"devDependencies": {
"@babel/core": "^7.3.3",
"@wordpress/babel-plugin-import-jsx-pragma": "^1.1.2",
"@wordpress/babel-preset-default": "^3.0.1",
"@wordpress/eslint-plugin": "^1.0.0",
"@wordpress/jest-preset-default": "^3.0.2",
"@wordpress/babel-preset-default": "^4.0.0",
"@wordpress/eslint-plugin": "^2.0.0",
"@wordpress/jest-preset-default": "^4.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^8.2.2",
"babel-jest": "^24.1.0",
Expand All @@ -24,13 +23,11 @@
"cross-env": "^5.1.4",
"empty": "^0.10.1",
"equivalent-key-map": "^0.2.0",
"eslint": "^4.19.1",
"eslint-plugin-flowtype": "^2.46.1",
"eslint": "^5.12.1",
"eslint-plugin-flowtype": "^3.4.2",
"eslint-plugin-jest": "^21.15.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"eslint-plugin-react-native": "^3.2.1",
"eslint-plugin-wordpress": "git+https://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress.git#1774343f6226052a46b081e01db3fca8793cc9f1",
"eslint-plugin-react-native": "^3.6.0",
"eslint-plugin-wordpress": "git://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress.git#552af1454d175e15f6d25aadc2ccde30a1922d4f",
"flow-bin": "0.92.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.1.0",
Expand Down
3 changes: 3 additions & 0 deletions react-native-gutenberg-bridge/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @format */

/**
* External dependencies
*/
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';

const { RNReactNativeGutenbergBridge } = NativeModules;
Expand Down
2 changes: 1 addition & 1 deletion sass-transformer-inside-gb.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function transform( src, filename, options ) {
const result = sass.renderSync( {
data: src,
includePaths: [ path.dirname( filename ), ...autoImportIncludePaths ],
importer: function( url /*, prev, done */ ) {
importer( url /*, prev, done */ ) {
// url is the path in import as is, which LibSass encountered.
// prev is the previously resolved path.
// done is an optional callback, either consume it or return value synchronously.
Expand Down
2 changes: 1 addition & 1 deletion sass-transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function transform( src, filename, options ) {
const result = sass.renderSync( {
data: src,
includePaths: [ path.dirname( filename ), ...autoImportIncludePaths ],
importer: function( url /*, prev, done */ ) {
importer( url /*, prev, done */ ) {
// url is the path in import as is, which LibSass encountered.
// prev is the previously resolved path.
// done is an optional callback, either consume it or return value synchronously.
Expand Down
6 changes: 6 additions & 0 deletions src/app/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/** @flow
* @format */

/**
* External dependencies
*/
import React from 'react';

/**
* Internal dependencies
*/
import AppContainer from './AppContainer';
import initialHtml from './initial-html';

Expand Down
12 changes: 11 additions & 1 deletion src/app/App.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
/** @format */

/**
* External dependencies
*/
import renderer from 'react-test-renderer';

/**
* WordPress dependencies
*/
import { dispatch, select } from '@wordpress/data';

/**
* Internal dependencies
*/
import { bootstrapEditor } from '..';
import App from './App';
import BlockHolder from '../block-management/block-holder';
import { dispatch, select } from '@wordpress/data';

describe( 'App', () => {
beforeAll( bootstrapEditor );
Expand Down
10 changes: 9 additions & 1 deletion src/app/AppContainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @flow
* @format */

/**
* External dependencies
*/
import React from 'react';
import type { EmitterSubscription } from 'react-native';
import RNReactNativeGutenbergBridge, {
Expand All @@ -11,14 +14,19 @@ import RNReactNativeGutenbergBridge, {
} from 'react-native-gutenberg-bridge';
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
import { parse, serialize } from '@wordpress/blocks';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { BlockEditorProvider } from '@wordpress/block-editor';
import { UnsupportedBlock } from '@wordpress/editor';

/**
* Internal dependencies
*/
import type { BlockType } from '../store/types';

import BlockManager from '../block-management/block-manager';

type PropsType = {
Expand Down
18 changes: 10 additions & 8 deletions src/block-management/block-holder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* @flow
*/

/**
* External dependencies
*/
import React from 'react';
import {
View,
Expand All @@ -11,7 +14,7 @@ import {
NativeSyntheticEvent,
NativeTouchEvent,
} from 'react-native';
import InlineToolbar, { InlineToolbarActions } from './inline-toolbar';
import TextInputState from 'react-native/lib/TextInputState';
import {
requestImageUploadCancel,
} from 'react-native-gutenberg-bridge';
Expand All @@ -22,16 +25,15 @@ import {
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { addAction, removeAction, hasAction } from '@wordpress/hooks';

import type { BlockType } from '../store/types';

import styles from './block-holder.scss';

// Gutenberg imports
import { getBlockType } from '@wordpress/blocks';
import { BlockEdit } from '@wordpress/block-editor';

import TextInputState from 'react-native/lib/TextInputState';
/**
* Internal dependencies
*/
import type { BlockType } from '../store/types';
import styles from './block-holder.scss';
import InlineToolbar, { InlineToolbarActions } from './inline-toolbar';

type PropsType = BlockType & {
clientId: string,
Expand Down
28 changes: 16 additions & 12 deletions src/block-management/block-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@
*/

/**
* WordPress dependencies
* External dependencies
*/
import { __ } from '@wordpress/i18n';

import React from 'react';
import { identity } from 'lodash';

import { Text, View, Keyboard, LayoutChangeEvent, SafeAreaView, Dimensions, Platform } from 'react-native';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { createBlock, isUnmodifiedDefaultBlock } from '@wordpress/blocks';
import { PostTitle } from '@wordpress/editor';
import { DefaultBlockAppender } from '@wordpress/block-editor';
import { sendNativeEditorDidLayout, subscribeSetFocusOnTitle, subscribeMediaAppend } from 'react-native-gutenberg-bridge';

/**
* Internal dependencies
*/
import BlockHolder from './block-holder';
import type { BlockType } from '../store/types';
import styles from './block-manager.scss';
Expand All @@ -25,14 +37,6 @@ import KeyboardAvoidingView from '../components/keyboard-avoiding-view';
import { KeyboardAwareFlatList, handleCaretVerticalPositionChange } from '../components/keyboard-aware-flat-list';
import SafeArea from 'react-native-safe-area';

// Gutenberg imports
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { createBlock, isUnmodifiedDefaultBlock } from '@wordpress/blocks';
import { PostTitle } from '@wordpress/editor';
import { DefaultBlockAppender } from '@wordpress/block-editor';
import { sendNativeEditorDidLayout, subscribeSetFocusOnTitle, subscribeMediaAppend } from 'react-native-gutenberg-bridge';

type PropsType = {
rootClientId: ?string,
blockClientIds: Array<string>,
Expand Down
Loading