Skip to content

Commit 565fb24

Browse files
committed
Prettify library and examples and enable format check in ci
1 parent 9859866 commit 565fb24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+388
-347
lines changed

.eslintrc.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@ extends:
1010
- plugin:react-hooks/recommended
1111
- plugin:jest/recommended
1212
- plugin:jest-dom/recommended
13-
parser: "@babel/eslint-parser"
13+
parser: '@babel/eslint-parser'
1414
plugins:
15-
- "@babel"
15+
- '@babel'
1616
- jest
1717
- react
1818
- react-hooks
1919
- testing-library
2020
overrides:
2121
- files:
22-
- "**/__tests__/**/*.[jt]s?(x)"
23-
- "**/?(*.)+(spec|test).[jt]s?(x)"
22+
- '**/__tests__/**/*.[jt]s?(x)'
23+
- '**/?(*.)+(spec|test).[jt]s?(x)'
2424
extends:
25-
- "plugin:testing-library/react"
25+
- 'plugin:testing-library/react'
2626
- files:
27-
- "**/*.ts?(x)"
28-
parser: "@typescript-eslint/parser"
27+
- '**/*.ts?(x)'
28+
parser: '@typescript-eslint/parser'
2929
parserOptions:
30-
tsconfigRootDir: .
31-
project: ['./tsconfig.json']
30+
tsconfigRootDir: .
31+
project: ['./tsconfig.json']
3232
extends:
3333
- eslint:recommended
3434
- plugin:@typescript-eslint/eslint-recommended
3535
- plugin:@typescript-eslint/recommended
3636
- plugin:@typescript-eslint/recommended-requiring-type-checking
3737
rules:
38-
"@typescript-eslint/no-unused-vars":
38+
'@typescript-eslint/no-unused-vars':
3939
- error
40-
- varsIgnorePattern: "^_"
41-
argsIgnorePattern: "^_"
40+
- varsIgnorePattern: '^_'
41+
argsIgnorePattern: '^_'
4242
# For compat with jest: https://typescript-eslint.io/rules/unbound-method/
43-
"@typescript-eslint/unbound-method": "off"
44-
"jest/unbound-method": "error"
43+
'@typescript-eslint/unbound-method': 'off'
44+
'jest/unbound-method': 'error'
4545
rules:
4646
quotes:
4747
- error

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
uses: wearerequired/lint-action@v2
4949
with:
5050
github_token: ${{ secrets.GITHUB_TOKEN }}
51-
prettier: false
51+
prettier: true
5252
eslint: false
5353
eslint_args: '--max-warnings 0'
5454
eslint_extensions: js,jsx,ts,tsx

.github/workflows/publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
# Setup .npmrc file to publish to GitHub Packages
1111
- uses: actions/setup-node@v2
1212
with:
13-
node-version: "14.x"
14-
registry-url: "https://registry.npmjs.org"
13+
node-version: '14.x'
14+
registry-url: 'https://registry.npmjs.org'
1515
# Defaults to the user or organization that owns the workflow file
1616
# scope: '@rollbar'
1717
- run: npm install

README.md

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010

1111
---
1212

13-
1413
React features to enhance using Rollbar.js in React Applications.
1514

1615
This SDK provides a wrapper around the base [Rollbar.js] SDK in order to provide an
1716
SDK that matches the intention of how to build React Apps with a declarative API, features for the latest React API like
1817
hooks and ErrorBoundaries, as well as simplify using Rollbar within a React SPA.
1918

2019
## Key benefits of using Rollbar React are:
20+
2121
- **Telemetry:** The telemetry timeline provides a list of “breadcrumbs” events that can help developers understand and fix problems in their client-side javascript. <a href="https://docs.rollbar.com/docs/rollbarjs-telemetry">Learn more about telemetry</a>.
2222
- **Automatic error grouping:** Rollbar aggregates Occurrences caused by the same error into Items that represent application issues. <a href="https://docs.rollbar.com/docs/grouping-occurrences">Learn more about reducing log noise</a>.
2323
- **Advanced search:** Filter items by many different properties. <a href="https://docs.rollbar.com/docs/search-items">Learn more about search</a>.
2424
- **Customizable notifications:** Rollbar supports several messaging and incident management tools where your team can get notified about errors and important events by real-time alerts. <a href="https://docs.rollbar.com/docs/notifications">Learn more about Rollbar notifications</a>.
2525

26-
2726
### In Beta
2827

2928
It is currently in a public Beta release right now as we push towards a 1.0 release that will have all of the features
@@ -153,11 +152,7 @@ const rollbarConfig = {
153152
};
154153

155154
export function App(props) {
156-
return (
157-
<Provider config={rollbarConfig}>
158-
159-
</Provider>
160-
);
155+
return <Provider config={rollbarConfig}></Provider>;
161156
}
162157
```
163158

@@ -180,11 +175,7 @@ const rollbarConfig = {
180175
const rollbar = new Rollbar(rollbarConfig);
181176

182177
export function App(props) {
183-
return (
184-
<Provider instance={rollbar}>
185-
186-
</Provider>
187-
);
178+
return <Provider instance={rollbar}></Provider>;
188179
}
189180
```
190181

@@ -206,11 +197,7 @@ import { Provider } from '@rollbar/react';
206197
const rollbarClient = new Client('POST_CLIENT_ITEM_ACCESS_TOKEN');
207198

208199
export function App(props) {
209-
return (
210-
<Provider instance={rollbarClient.rollbar}>
211-
212-
</Provider>
213-
);
200+
return <Provider instance={rollbarClient.rollbar}></Provider>;
214201
}
215202
```
216203

@@ -243,9 +230,7 @@ const rollbarConfig = {
243230
export function App(props) {
244231
return (
245232
<Provider config={rollbarConfig}>
246-
<ErrorBoundary>
247-
248-
</ErrorBoundary>
233+
<ErrorBoundary></ErrorBoundary>
249234
</Provider>
250235
);
251236
}
@@ -272,7 +257,15 @@ const rollbarConfig = {
272257
export function App(props) {
273258
return (
274259
<Provider config={rollbarConfig}>
275-
<ErrorBoundary level={LEVEL_WARN} errorMessage="Error in React render" extra={(error, info) => info.componentStack.includes('Experimental') ? { experiment: true } : {} }>
260+
<ErrorBoundary
261+
level={LEVEL_WARN}
262+
errorMessage="Error in React render"
263+
extra={(error, info) =>
264+
info.componentStack.includes('Experimental')
265+
? { experiment: true }
266+
: {}
267+
}
268+
>
276269
277270
</ErrorBoundary>
278271
</Provider>
@@ -297,7 +290,9 @@ const rollbarConfig = {
297290
environment: 'production',
298291
};
299292

300-
const ErrorDisplay = ({ error, resetError }) => ( // <-- props passed to fallbackUI component
293+
const ErrorDisplay = (
294+
{ error, resetError }, // <-- props passed to fallbackUI component
295+
) => (
301296
<div>
302297
<h1>A following error has occured:</h1>
303298
<p>{error.toString()}</p>
@@ -335,11 +330,7 @@ import React from 'react';
335330
import { RollbarContext } from '@rollbar/react';
336331

337332
function HomePage() {
338-
return (
339-
<RollbarContext context="home">
340-
341-
</RollbarContext>
342-
)
333+
return <RollbarContext context="home"></RollbarContext>;
343334
}
344335
```
345336

@@ -377,7 +368,7 @@ const Routes = () => (
377368
</Route>
378369
</Switch>
379370
</Router>
380-
)
371+
);
381372

382373
export default Routes;
383374
```
@@ -392,11 +383,9 @@ import { RollbarContext } from '@rollbar/react';
392383
export default function About(props) {
393384
return (
394385
<Route path="/about">
395-
<RollbarContext context="/about">
396-
397-
</RollbarContext>
386+
<RollbarContext context="/about"></RollbarContext>
398387
</Route>
399-
)
388+
);
400389
}
401390
```
402391

@@ -474,7 +463,8 @@ const ROUTE_PARAMS_RE = /\/\d+/g;
474463

475464
const historyListener = historyContext(rollbar, {
476465
// optional: default uses location.pathname
477-
formatter: (location, action) => location.pathname.replace(ROUTE_PARAMS_RE, ''),
466+
formatter: (location, action) =>
467+
location.pathname.replace(ROUTE_PARAMS_RE, ''),
478468
// optional: true return sets Rollbar context
479469
filter: (location, action) => !location.pathname.includes('admin'),
480470
});
@@ -513,11 +503,7 @@ function ContactDetails({ contactId }) {
513503
}
514504
}, [contactId]);
515505

516-
return (
517-
<div>
518-
519-
</div>
520-
);
506+
return <div></div>;
521507
}
522508
```
523509

@@ -535,11 +521,7 @@ import { useRollbarContext } from '@rollbar/react';
535521
function HomePage(props) {
536522
useRollbarContext('home#index');
537523

538-
return (
539-
<div>
540-
541-
</div>
542-
);
524+
return <div></div>;
543525
}
544526

545527
// src/pages/UsersPage.js
@@ -549,9 +531,7 @@ import UserTable from '../components/users/UserTable';
549531
function UsersPage(props) {
550532
useRollbarContext('users#list');
551533

552-
return (
553-
<UserTable data={props.users} />
554-
);
534+
return <UserTable data={props.users} />;
555535
}
556536

557537
// src/pages/UserDetailsPage.js
@@ -561,9 +541,7 @@ import UserDetails from '../components/users/UserDetails';
561541
function UserDetailsPage(props) {
562542
useRollbarContext('users#details');
563543

564-
return (
565-
<UserDetails user={props.user} />
566-
);
544+
return <UserDetails user={props.user} />;
567545
}
568546
```
569547

@@ -585,7 +563,7 @@ Here is a simple example of using it once the current user has been determined:
585563
```javascript
586564
import { useState } from 'react';
587565
import { useRollbarPerson } from '@rollbar/react';
588-
import LoggedInHome from './LoggedInHome';
566+
import LoggedInHome from './LoggedInHome';
589567
import LoggedOutHome from './LoggedOutHome';
590568

591569
function Home() {
@@ -596,7 +574,7 @@ function Home() {
596574
(async () => {
597575
const user = await Auth.getCurrentUser();
598576
setCurrentUser(user);
599-
})()
577+
})();
600578
});
601579

602580
if (currentUser != null) {
@@ -642,28 +620,23 @@ function BookDetails({ bookId }) {
642620

643621
useRollbarCaptureEvent(book, LEVEL_INFO); // <-- only fires when book changes
644622

645-
return (
646-
<div>
647-
648-
</div>
649-
)
623+
return <div></div>;
650624
}
651625
```
652626

653-
654-
[Rollbar]: https://rollbar.com
655-
[Rollbar Docs]: https://docs.rollbar.com
656-
[Rollbar.js]: https://github.com/rollbar/rollbar.js
657-
[Rollbar.js Setup Instructions]: https://github.com/rollbar/rollbar.js/#setup-instructions
658-
[React Native SDK]: https://github.com/rollbar/rollbar-react-native
659-
[Telemetry]: https://docs.rollbar.com/docs/rollbarjs-telemetry
660-
[`Provider`]: #provider-component
661-
[`ErrorBoundary`]: #errorboundary-component
662-
[`RollbarContext`]: #rollbarcontext-component
663-
[Functional Components]: https://reactjs.org/docs/components-and-props.html#function-and-class-components
664-
[React Context]: https://reactjs.org/docs/context.html
665-
[Error Boundaries]: https://reactjs.org/docs/error-boundaries.html
666-
[React Hooks API]: https://reactjs.org/docs/hooks-intro.html
627+
[rollbar]: https://rollbar.com
628+
[rollbar docs]: https://docs.rollbar.com
629+
[rollbar.js]: https://github.com/rollbar/rollbar.js
630+
[rollbar.js setup instructions]: https://github.com/rollbar/rollbar.js/#setup-instructions
631+
[react native sdk]: https://github.com/rollbar/rollbar-react-native
632+
[telemetry]: https://docs.rollbar.com/docs/rollbarjs-telemetry
633+
[`provider`]: #provider-component
634+
[`errorboundary`]: #errorboundary-component
635+
[`rollbarcontext`]: #rollbarcontext-component
636+
[functional components]: https://reactjs.org/docs/components-and-props.html#function-and-class-components
637+
[react context]: https://reactjs.org/docs/context.html
638+
[error boundaries]: https://reactjs.org/docs/error-boundaries.html
639+
[react hooks api]: https://reactjs.org/docs/hooks-intro.html
667640
[history]: https://www.npmjs.com/package/history
668641
[history.location]: https://github.com/ReactTraining/history/blob/master/docs/api-reference.md#location
669642
[history.action]: https://github.com/ReactTraining/history/blob/master/docs/api-reference.md#action

babel.config.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
module.exports = {
2-
presets: [
3-
'@babel/preset-env',
4-
'@babel/preset-react'
5-
],
2+
presets: ['@babel/preset-env', '@babel/preset-react'],
63
plugins: [
74
'@babel/plugin-proposal-class-properties',
8-
'@babel/plugin-syntax-class-properties'
5+
'@babel/plugin-syntax-class-properties',
96
],
107
env: {
118
test: {
129
plugins: [
1310
'@babel/plugin-transform-modules-commonjs',
14-
'babel-plugin-istanbul'
15-
]
16-
}
17-
}
18-
}
11+
'babel-plugin-istanbul',
12+
],
13+
},
14+
},
15+
};

0 commit comments

Comments
 (0)