Skip to content

Commit

Permalink
update Prettier, add styles to Prettier check, reformat files (facebo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Simek authored Dec 7, 2020
1 parent aa97a8f commit d9037b6
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 156 deletions.
15 changes: 12 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"jsxBracketSameLine": true,
"printWidth": 80,
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "es5",
"endOfLine": "auto"
}
},
{
Expand All @@ -18,9 +19,17 @@
"bracketSpacing": true,
"jsxBracketSameLine": true,
"printWidth": 66,
"proseWrap": "never",
"proseWrap": "preserve",
"singleQuote": true,
"trailingComma": "none"
"trailingComma": "none",
"endOfLine": "auto"
}
},
{
"files": ["*.scss", "*.css"],
"options": {
"printWidth": 80,
"endOfLine": "auto"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion docs/backhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The event subscriptions are called in reverse order (i.e. the last registered su
## Pattern

```jsx
BackHandler.addEventListener('hardwareBackPress', function() {
BackHandler.addEventListener('hardwareBackPress', function () {
/**
* this.onMainScreen and this.goBack are just examples,
* you need to use your own implementation here.
Expand Down
4 changes: 2 additions & 2 deletions docs/building-for-tv.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down Expand Up @@ -143,7 +143,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down
28 changes: 14 additions & 14 deletions docs/native-modules-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,21 @@ NativeCalendarModule.createCalendarEvent('foo', 'bar');

When a native module method is invoked in JavaScript, React Native converts the arguments from JS objects to their Objective-C/Swift object analogues. So for example, if your Objective-C Native Module method accepts a NSNumber, in JS you need to call the method with a number. React Native will handle the conversion for you. Below is a list of the argument types supported for native module methods and the JavaScript equivalents they map to.

| Objective-C | JavaScript |
| --- | --- |
| NSString | string |
| NSString | ?string |
| BOOL | boolean |
| NSNumber | ?boolean |
| double | number |
| NSNumber | ?number |
| NSArray | Array |
| NSArray | ?Array |
| NSDictionary | Object |
| NSDictionary | ?Object |
| RCTResponseSenderBlock | Function (success) |
| Objective-C | JavaScript |
| --------------------------------------------- | ------------------ |
| NSString | string |
| NSString | ?string |
| BOOL | boolean |
| NSNumber | ?boolean |
| double | number |
| NSNumber | ?number |
| NSArray | Array |
| NSArray | ?Array |
| NSDictionary | Object |
| NSDictionary | ?Object |
| RCTResponseSenderBlock | Function (success) |
| RCTResponseSenderBlock, RCTResponseErrorBlock | Function (failure) |
| RCTPromiseResolveBlock, RCTPromiseRejectBlock | Promise |
| RCTPromiseResolveBlock, RCTPromiseRejectBlock | Promise |

> The following types are currently supported but will not be supported in TurboModules. Please avoid using them.
>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"husky": "^4.2.5",
"prettier": "1.16.4",
"pretty-quick": "^1.11.1"
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0"
}
}
4 changes: 1 addition & 3 deletions plugins/remark-snackplayer/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ const SnackPlayer = () => {
});

// Wait for all promises to be resolved
Promise.all(nodesToProcess)
.then(resolve())
.catch(reject());
Promise.all(nodesToProcess).then(resolve()).catch(reject());
});
};

Expand Down
22 changes: 8 additions & 14 deletions sync-api-docs/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ function generateMethod(method, component) {

obj.map(item => {
if (item.description.trim() !== 'missing')
mdPoints += `- '${item.key}' (${item.value.name}) - ${
item.description
}`;
mdPoints += `- '${item.key}' (${item.value.name}) - ${item.description}`;
else mdPoints += `- '${item.key}' (${item.value.name})`;
});
}
Expand Down Expand Up @@ -203,7 +201,7 @@ function generateProps({props, composes}) {
Object.keys(props)
.sort((a, b) => a.localeCompare(b))
.sort((a, b) => props[b].required - props[a].required)
.map(function(propName) {
.map(function (propName) {
return generateProp(propName, props[propName]);
})
.join('\n\n---\n\n')
Expand All @@ -226,7 +224,7 @@ function generateMethods(component) {
b.name /* TODO @nocommit what's a neutral locale */
)
)
.map(function(method) {
.map(function (method) {
return generateMethod(method, component);
})
.join('\n\n---\n\n')
Expand Down Expand Up @@ -291,15 +289,11 @@ function preprocessDescription(desc) {
return (
desc.substr(0, desc.search('```SnackPlayer')) +
`\n## Example\n` +
`${playgroundTab}\n\n${functionalBlock}\n\n${'`' +
firstExample.substr(
0,
firstExample.search('```') + 3
)}\n\n${classBlock}\n\n${'`' +
secondExample.substr(
0,
secondExample.search('```') + 3
)}\n\n${endBlock}` +
`${playgroundTab}\n\n${functionalBlock}\n\n${
'`' + firstExample.substr(0, firstExample.search('```') + 3)
}\n\n${classBlock}\n\n${
'`' + secondExample.substr(0, secondExample.search('```') + 3)
}\n\n${endBlock}` +
secondExample.substr(secondExample.search('```') + 3)
);
} else {
Expand Down
12 changes: 7 additions & 5 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
"clean": "docusaurus clean",
"publish-gh-pages": "yarn deploy",
"ci-check": "yarn prettier:diff && node image-check.js",
"format:source": "prettier --write \"{core/**/*.js,src/**/*.js,static/js/**/*.js}\"",
"format:markdown": "prettier --write \"{../docs/*.md,versioned_docs/**/*.md,blog/**/*.md}\"",
"nit:source": "prettier --list-different \"{core/**/*.js,src/**/*.js,static/js/**/*.js}\"",
"nit:markdown": "prettier --list-different \"{../docs/*.md,versioned_docs/**/*.md,blog/**/*.md}\"",
"prettier": "yarn format:source && yarn format:markdown",
"format:source": "prettier --write {{core,src}/**/*.js,*.js}",
"format:markdown": "prettier --write ../docs/*.md && prettier --write {{versioned_docs,src}/**/*.md,blog/*.md}",
"format:style": "prettier --write src/**/*.{scss,css}",
"nit:source": "prettier --list-different {{core,src}/**/*.js,*.js}",
"nit:markdown": "prettier --list-different ../docs/*.md && prettier --list-different {{versioned_docs,src}/**/*.md,blog/*.md}",
"nit:style": "&& prettier --write src/**/*.{scss,css}",
"prettier": "yarn format:source && yarn format:markdown && yarn format:style",
"prettier:diff": "yarn nit:source",
"test": "yarn build",
"lint": "cd ../ && alex .",
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.60/backhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The event subscriptions are called in reverse order (i.e. last registered subscr
Example:

```jsx
BackHandler.addEventListener('hardwareBackPress', function() {
BackHandler.addEventListener('hardwareBackPress', function () {
// this.onMainScreen and this.goBack are just examples, you need to use your own implementation here
// Typically you would use the navigator here to go to the last state.

Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-0.60/building-for-tv.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down Expand Up @@ -139,7 +139,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.60/listview.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Exports some data, e.g. for perf investigations or analytics.
### `scrollTo()`

```jsx
scrollTo(...args: Array)
scrollTo((...args: Array));
```

Scrolls to a given x, y offset, either immediately or with a smooth animation.
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.60/webview.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Function that is invoked when the `WebView` loading starts or ends.

### `originWhitelist`

List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are "http://*" and "https://*".
List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are `"http://*"` and `"https://*"`.

| Type | Required |
| ---------------- | -------- |
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.61/backhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The event subscriptions are called in reverse order (i.e. last registered subscr
Example:

```jsx
BackHandler.addEventListener('hardwareBackPress', function() {
BackHandler.addEventListener('hardwareBackPress', function () {
// this.onMainScreen and this.goBack are just examples, you need to use your own implementation here
// Typically you would use the navigator here to go to the last state.

Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-0.61/building-for-tv.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down Expand Up @@ -139,7 +139,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.61/listview.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Exports some data, e.g. for perf investigations or analytics.
### `scrollTo()`

```jsx
scrollTo(...args: Array)
scrollTo((...args: Array));
```

Scrolls to a given x, y offset, either immediately or with a smooth animation.
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.61/webview.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Function that is invoked when the `WebView` loading starts or ends.

### `originWhitelist`

List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are "http://*" and "https://*".
List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are `"http://*"` and `"https://*"`.

| Type | Required |
| ---------------- | -------- |
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.62/backhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The event subscriptions are called in reverse order (i.e. the last registered su
## Pattern

```jsx
BackHandler.addEventListener('hardwareBackPress', function() {
BackHandler.addEventListener('hardwareBackPress', function () {
/**
* this.onMainScreen and this.goBack are just examples,
* you need to use your own implementation here.
Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-0.62/building-for-tv.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down Expand Up @@ -143,7 +143,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.62/listview.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Exports some data, e.g. for perf investigations or analytics.
### `scrollTo()`

```jsx
scrollTo(...args: Array)
scrollTo((...args: Array));
```

Scrolls to a given x, y offset, either immediately or with a smooth animation.
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.62/webview.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Function that is invoked when the `WebView` loading starts or ends.

### `originWhitelist`

List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are "http://*" and "https://*".
List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are `"http://*"` and `"https://*"`.

| Type | Required |
| ---------------- | -------- |
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.63/backhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The event subscriptions are called in reverse order (i.e. the last registered su
## Pattern

```jsx
BackHandler.addEventListener('hardwareBackPress', function() {
BackHandler.addEventListener('hardwareBackPress', function () {
/**
* this.onMainScreen and this.goBack are just examples,
* you need to use your own implementation here.
Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-0.63/building-for-tv.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down Expand Up @@ -139,7 +139,7 @@ class Game2048 extends React.Component {

_enableTVEventHandler() {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
this._tvEventHandler.enable(this, function (cmp, evt) {
if (evt && evt.eventType === 'right') {
cmp.setState({ board: cmp.state.board.move(2) });
} else if (evt && evt.eventType === 'up') {
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.63/listview.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Exports some data, e.g. for perf investigations or analytics.
### `scrollTo()`

```jsx
scrollTo(...args: Array)
scrollTo((...args: Array));
```

Scrolls to a given x, y offset, either immediately or with a smooth animation.
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.63/webview.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Function that is invoked when the `WebView` loading starts or ends.

### `originWhitelist`

List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are "http://*" and "https://*".
List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _only_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this safelist, the URL will be handled by the OS. The default safelistlisted origins are `"http://*"` and `"https://*"`.

| Type | Required |
| ---------------- | -------- |
Expand Down
Loading

0 comments on commit d9037b6

Please sign in to comment.