Skip to content

Commit 181e32b

Browse files
committed
Prettier formatting fixes
1 parent adcc5dd commit 181e32b

9 files changed

+82
-87
lines changed

babel.config.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1+
/** @format */
2+
13
module.exports = function( api ) {
24
api.cache( true );
35
return {
4-
presets: [
5-
'module:metro-react-native-babel-preset',
6-
],
6+
presets: [ 'module:metro-react-native-babel-preset' ],
77
plugins: [
88
'@babel/plugin-proposal-async-generator-functions',
99
'@babel/plugin-transform-runtime',
1010
[
1111
'react-native-platform-specific-extensions',
1212
{
13-
extensions: [
14-
'css',
15-
'scss',
16-
'sass',
17-
],
13+
extensions: [ 'css', 'scss', 'sass' ],
1814
},
1915
],
2016
],
2117
overrides: [
22-
{ // Transforms JSX into JS function calls and use `createElement` instead of the default `React.createElement`
18+
{
19+
// Transforms JSX into JS function calls and use `createElement` instead of the default `React.createElement`
2320
plugins: [
2421
[
2522
'@babel/plugin-transform-react-jsx',
@@ -31,7 +28,8 @@ module.exports = function( api ) {
3128
],
3229
exclude: /node_modules\/react-native/,
3330
},
34-
{ // Auto-add `import { createElement } from '@wordpress/element';` when JSX is found
31+
{
32+
// Auto-add `import { createElement } from '@wordpress/element';` when JSX is found
3533
plugins: [
3634
[
3735
'./gutenberg/packages/babel-plugin-import-jsx-pragma',
@@ -48,9 +46,7 @@ module.exports = function( api ) {
4846
],
4947
env: {
5048
development: {
51-
plugins: [
52-
'@babel/transform-react-jsx-source',
53-
],
49+
plugins: [ '@babel/transform-react-jsx-source' ],
5450
},
5551
},
5652
};

jest.config.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,20 @@ module.exports = {
3333
'/__device-tests__/',
3434
],
3535
testURL: 'http://localhost/',
36-
modulePathIgnorePatterns: [ '<rootDir>/gutenberg/gutenberg-mobile', 'react-native-aztec-old-submodule' ],
36+
modulePathIgnorePatterns: [
37+
'<rootDir>/gutenberg/gutenberg-mobile',
38+
'react-native-aztec-old-submodule',
39+
],
3740
moduleDirectories: [ 'node_modules', 'symlinked-packages' ],
3841
moduleNameMapper: {
3942
// Mock the CSS modules. See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets
4043
'\\.(scss)$': '<rootDir>/gutenberg/test/native/__mocks__/styleMock.js',
4144
},
4245
haste: {
4346
defaultPlatform: rnPlatform,
44-
platforms: [
45-
'android',
46-
'ios',
47-
'native',
48-
],
47+
platforms: [ 'android', 'ios', 'native' ],
4948
hasteImplModulePath: '<rootDir>/node_modules/react-native/jest/hasteImpl.js',
50-
providesModuleNodeModules: [
51-
'react-native',
52-
'react-native-svg',
53-
],
49+
providesModuleNodeModules: [ 'react-native', 'react-native-svg' ],
5450
},
5551
transformIgnorePatterns: [
5652
// This is required for now to have jest transform some of our modules
@@ -59,8 +55,6 @@ module.exports = {
5955
// https://github.com/facebook/react-native/blob/master/jest-preset.json#L20
6056
'node_modules/(?!(simple-html-tokenizer|(jest-)?react-native|react-clone-referenced-element))',
6157
],
62-
snapshotSerializers: [
63-
'enzyme-to-json/serializer',
64-
],
58+
snapshotSerializers: [ 'enzyme-to-json/serializer' ],
6559
reporters: [ 'default', 'jest-junit' ],
6660
};

libdefs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ declare module 'react-native' {
88
}
99

1010
declare module 'react-native/lib/TextInputState' {
11-
declare module.exports: any;
11+
declare module.exports: any;
1212
}

rn-cli-inside-gb.config.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ const path = require( 'path' );
33
const blacklist = require( 'metro-config/src/defaults/blacklist' );
44
// Blacklist the nested GB filetree so modules are not resolved in duplicates,
55
// both in the nested directory and the parent directory.
6-
const blacklistElements = blacklist( [ new RegExp( path.basename( __dirname ) + '/gutenberg/.*' ) ] );
6+
const blacklistElements = blacklist( [
7+
new RegExp( path.basename( __dirname ) + '/gutenberg/.*' ),
8+
] );
79

810
const enm = require( './extra-node-modules.config.js' );
911

@@ -19,7 +21,9 @@ const mapper = function( accu, v ) {
1921
};
2022

2123
const wppackages = wppackagenames.reduce( mapper, {} );
22-
const alternateRoots = [ path.resolve( __dirname, '../node_modules' ) ].concat( Object.values( wppackages ) );
24+
const alternateRoots = [ path.resolve( __dirname, '../node_modules' ) ].concat(
25+
Object.values( wppackages )
26+
);
2327

2428
module.exports = {
2529
extraNodeModules: Object.assign( enm, wppackages ),

sass-transformer-inside-gb.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ if ( reactNativeMinorVersion >= 56 ) {
6262
}
6363

6464
// TODO: need to find a way to pass the include paths and the default asset files via some config
65-
const autoImportIncludePaths = [
66-
path.join( path.dirname( __filename ), '../assets/stylesheets' ),
67-
];
65+
const autoImportIncludePaths = [ path.join( path.dirname( __filename ), '../assets/stylesheets' ) ];
6866
const autoImportAssets = [
6967
'_colors.scss',
7068
'_breakpoints.scss',

src/_colors.scss

+11-11
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,22 @@ $blue-500: #016087;
9494

9595
// Grays
9696
$gray: #87a6bc;
97-
$gray-light: lighten( $gray, 33% ); //#f3f6f8
98-
$gray-dark: darken( $gray, 38% ); //#2e4453
99-
$gray-900: #1A1A1A;
97+
$gray-light: lighten($gray, 33%); //#f3f6f8
98+
$gray-dark: darken($gray, 38%); //#2e4453
99+
$gray-900: #1a1a1a;
100100

101101
// $gray-text: ideal for standard, non placeholder text
102102
// $gray-text-min: minimum contrast needed for WCAG 2.0 AA on white background
103103
$gray-text: $gray-dark;
104-
$gray-text-min: darken( $gray, 18% ); //#537994
104+
$gray-text-min: darken($gray, 18%); //#537994
105105

106106
// Shades of gray
107-
$gray-lighten-10: lighten( $gray, 10% ); // #a8bece
108-
$gray-lighten-20: lighten( $gray, 20% ); // #c8d7e1
109-
$gray-lighten-30: lighten( $gray, 30% ); // #e9eff3
110-
$gray-darken-10: darken( $gray, 10% ); // #668eaa
111-
$gray-darken-20: darken( $gray, 20% ); // #4f748e
112-
$gray-darken-30: darken( $gray, 30% ); // #3d596d
107+
$gray-lighten-10: lighten($gray, 10%); // #a8bece
108+
$gray-lighten-20: lighten($gray, 20%); // #c8d7e1
109+
$gray-lighten-30: lighten($gray, 30%); // #e9eff3
110+
$gray-darken-10: darken($gray, 10%); // #668eaa
111+
$gray-darken-20: darken($gray, 20%); // #4f748e
112+
$gray-darken-30: darken($gray, 30%); // #3d596d
113113

114114
//
115115
// See wordpress.com/design-handbook/colors/ for more info.
@@ -126,4 +126,4 @@ $alert-purple: #855da6;
126126

127127
// Custom
128128
$toolbar-button: #7b9ab1;
129-
$toolbar-button-disabled: $gray-lighten-30;
129+
$toolbar-button-disabled: $gray-lighten-30;

src/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* External dependencies
3+
*
4+
* @format
5+
*/
6+
17
/**
28
* External dependencies
39
*/

src/index.test.js

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/** @format */
32

43
/**
@@ -45,32 +44,32 @@ describe( 'RootComponent', () => {
4544
it( 'Code block is a TextInput', () => {
4645
const app = renderer.create( <RootComponent /> );
4746

48-
app.root.findAllByType( BlockListBlock )
49-
.forEach( ( blockHolder ) => {
50-
if ( 'core/code' === blockHolder.props.name ) {
51-
// TODO: hardcoded indices are ugly and error prone. Can we do better here?
52-
const blockHolderContainer = blockHolder.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ];
53-
const contentComponent = blockHolderContainer.children[ 0 ];
54-
const inputComponent =
55-
contentComponent.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ]
56-
.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ];
47+
app.root.findAllByType( BlockListBlock ).forEach( ( blockHolder ) => {
48+
if ( 'core/code' === blockHolder.props.name ) {
49+
// TODO: hardcoded indices are ugly and error prone. Can we do better here?
50+
const blockHolderContainer =
51+
blockHolder.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ];
52+
const contentComponent = blockHolderContainer.children[ 0 ];
53+
const inputComponent =
54+
contentComponent.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ]
55+
.children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ].children[ 0 ]
56+
.children[ 0 ];
5757

58-
expect( inputComponent.type ).toBe( 'TextInput' );
59-
}
60-
} );
58+
expect( inputComponent.type ).toBe( 'TextInput' );
59+
}
60+
} );
6161

6262
app.unmount();
6363
} );
6464

6565
it( 'Heading block test', () => {
6666
const app = renderer.create( <RootComponent /> );
67-
app.root.findAllByType( BlockListBlock )
68-
.forEach( ( blockHolder ) => {
69-
if ( 'core/heading' === blockHolder.props.name ) {
70-
const aztec = blockHolder.findByType( 'RCTAztecView' );
71-
expect( aztec.props.text.text ).toBe( '<h2>What is Gutenberg?</h2>' );
72-
}
73-
} );
67+
app.root.findAllByType( BlockListBlock ).forEach( ( blockHolder ) => {
68+
if ( 'core/heading' === blockHolder.props.name ) {
69+
const aztec = blockHolder.findByType( 'RCTAztecView' );
70+
expect( aztec.props.text.text ).toBe( '<h2>What is Gutenberg?</h2>' );
71+
}
72+
} );
7473
app.unmount();
7574
} );
7675
} );

src/jsdom-patches.js

+22-24
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
* @format */
33

44
/**
5-
* This file is used in src/globals.js to patch jsdom-jscore.
6-
*
7-
* Node.prototype.contains is implemented as a simple recursive function.
8-
*
9-
* Node.prototype.insertBefore is re-implemented (code copied) with the
10-
* WrongDocumentError exception disabled.
11-
*
12-
* Element.prototype.matches is aliased to Element.prototype.matchesSelector.
13-
*
14-
* Getters are defined on the Node.prototype for the following properties:
15-
* parentElement, previousElementSibling, nextElementSibling.
16-
*/
5+
* This file is used in src/globals.js to patch jsdom-jscore.
6+
*
7+
* Node.prototype.contains is implemented as a simple recursive function.
8+
*
9+
* Node.prototype.insertBefore is re-implemented (code copied) with the
10+
* WrongDocumentError exception disabled.
11+
*
12+
* Element.prototype.matches is aliased to Element.prototype.matchesSelector.
13+
*
14+
* Getters are defined on the Node.prototype for the following properties:
15+
* parentElement, previousElementSibling, nextElementSibling.
16+
*/
1717

1818
/**
1919
* External dependencies
@@ -28,17 +28,10 @@ const { core } = jsdomLevel1Core.dom.level1;
2828
const { Node, Element, CharacterData } = core;
2929

3030
// Exception codes
31-
const {
32-
NO_MODIFICATION_ALLOWED_ERR,
33-
HIERARCHY_REQUEST_ERR,
34-
NOT_FOUND_ERR,
35-
} = core;
31+
const { NO_MODIFICATION_ALLOWED_ERR, HIERARCHY_REQUEST_ERR, NOT_FOUND_ERR } = core;
3632

3733
// Node types
38-
const {
39-
ATTRIBUTE_NODE,
40-
DOCUMENT_FRAGMENT_NODE,
41-
} = Node;
34+
const { ATTRIBUTE_NODE, DOCUMENT_FRAGMENT_NODE } = Node;
4235

4336
/**
4437
* Simple recursive implementation of Node.contains method
@@ -51,10 +44,12 @@ const {
5144
* expectation that this is implemented (as it is in the browser environment).
5245
*/
5346
Node.prototype.contains = function( otherNode ) {
54-
return this === otherNode ||
47+
return (
48+
this === otherNode ||
5549
Array.prototype.some.call( this._childNodes, ( childNode ) => {
5650
return childNode.contains( otherNode );
57-
} );
51+
} )
52+
);
5853
};
5954

6055
/**
@@ -71,7 +66,10 @@ Node.prototype.contains = function( otherNode ) {
7166
*/
7267
Node.prototype.insertBefore = function( /* Node */ newChild, /* Node*/ refChild ) {
7368
if ( this._readonly === true ) {
74-
throw new core.DOMException( NO_MODIFICATION_ALLOWED_ERR, 'Attempting to modify a read-only node' );
69+
throw new core.DOMException(
70+
NO_MODIFICATION_ALLOWED_ERR,
71+
'Attempting to modify a read-only node'
72+
);
7573
}
7674

7775
// Adopt unowned children, for weird nodes like DocumentType

0 commit comments

Comments
 (0)