Skip to content

Commit f8ca10e

Browse files
authored
ESLintify the library and its examples, enable linting in CI (#112)
1 parent d8d3be8 commit f8ca10e

File tree

10 files changed

+1367
-2840
lines changed

10 files changed

+1367
-2840
lines changed

.github/workflows/ci.yaml

+23-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
node: [14, 16, 18, 20]
17+
include:
18+
- node: 14
19+
npm: 8
20+
- node: 16
21+
npm: 8
22+
- node: 18
23+
npm: 9
24+
- node: 20
25+
npm: 10
1826

1927
steps:
2028
- name: Checkout
@@ -25,7 +33,10 @@ jobs:
2533
with:
2634
node-version: ${{ matrix.node }}
2735

28-
- name: Cache
36+
- name: Update npm
37+
run: npm install -g npm@^${{ matrix.npm }}
38+
39+
- name: Set up cache
2940
uses: actions/cache@v4
3041
with:
3142
path: ~/.npm
@@ -49,9 +60,18 @@ jobs:
4960
with:
5061
github_token: ${{ secrets.GITHUB_TOKEN }}
5162
prettier: true
52-
eslint: false
63+
eslint: true
5364
eslint_args: '--max-warnings 0'
5465
eslint_extensions: js,jsx,ts,tsx
5566

67+
- name: Build library
68+
run: npm run build
69+
- name: Build examples/create-react-app
70+
run: cd examples/create-react-app && npm run build
71+
- name: Build examples/nextjs
72+
run: cd examples/nextjs && npm run build
73+
- name: Build examples/typescript
74+
run: cd examples/typescript && npm run build
75+
5676
- name: Test
5777
run: npm run test

examples/index.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* @file examples/index.js
3+
* @fileoverview This is a repertoire of snippets exploring Rollbar's usage.
4+
*/
5+
6+
/* eslint-disable no-unused-vars, react/jsx-no-undef, react/prop-types */
7+
18
import React, { useEffect, useState } from 'react';
29
import Rollbar from 'rollbar';
310
import { Router, Switch, Route } from 'react-router-dom';
@@ -33,11 +40,11 @@ const rollbarConfig = {
3340
environment: 'production',
3441
};
3542

36-
const rollbar = new Client('POST_CLIENT_ITEM_ACCESS_TOKEN');
43+
const rollbar_client = new Client('POST_CLIENT_ITEM_ACCESS_TOKEN');
3744

3845
const ROUTE_PARAMS_RE = /\/\d+/g;
3946

40-
const historyListener = historyContext(rollbar, {
47+
const historyListener = historyContext(rollbar_client, {
4148
// optional: default uses location.pathname
4249
formatter: (location, action) =>
4350
location.pathname.replace(ROUTE_PARAMS_RE, ''),
@@ -96,14 +103,15 @@ function Contacts(props) {
96103
);
97104
}
98105

106+
/* eslint-disable react-hooks/exhaustive-deps, no-undef */
107+
99108
function Home() {
100109
const [currentUser, setCurrentUser] = useState();
101110

111+
useRollbarPerson(currentUser);
112+
102113
useEffect(async () => {
103114
const user = await Auth.getCurrentUser();
104-
if (user) {
105-
useRollbarPerson(user);
106-
}
107115
setCurrentUser(user);
108116
});
109117

@@ -132,14 +140,16 @@ function ContactDetails({ contactId }) {
132140
return <div></div>;
133141
}
134142

143+
/* eslint-enable react-hooks/exhaustive-deps, no-undef */
144+
135145
function App(props) {
136146
return (
137147
<Provider rollbar={rollbar}>
138148
<Router></Router>
139149
<RollbarContext name="">
140150
<ErrorBoundary fallbackUI={ErrorDisplay}>
141151
<div>
142-
<h1>I'm Here</h1>
152+
<h1>I&apos;m Here</h1>
143153
<MyInput>
144154
<ErrorBoundary
145155
level
@@ -173,6 +183,7 @@ function MyInput(props) {
173183

174184
useEffect(() => {
175185
try {
186+
throw new Error('no data to fetch');
176187
} catch (err) {
177188
rollbar.error('error fetching data', err);
178189
}

examples/nextjs/babel.config.js

-1
This file was deleted.

examples/nextjs/eslint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
module.exports = {
33
root: true,
44
extends: 'next/core-web-vitals',
5-
ignorePatterns: ['node_modules'],
5+
ignorePatterns: ['node_modules', '.next'],
66
};

0 commit comments

Comments
 (0)