Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 06254d2

Browse files
style(js): Use sentry's prettier config (#793)
1 parent 1e11d8d commit 06254d2

Some content is hidden

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

51 files changed

+598
-771
lines changed

.babelrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ if (process.env.NODE_ENV !== `test`) {
88

99
module.exports = {
1010
sourceMaps: true,
11-
presets: ["babel-preset-gatsby-package"],
11+
presets: ['babel-preset-gatsby-package'],
1212
ignore,
1313
};

.prettierrc

-14
This file was deleted.

gatsby-browser.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react";
2-
import PageContext from "~src/components/pageContext";
1+
import React from 'react';
2+
import PageContext from '~src/components/pageContext';
33

4-
export const wrapPageElement = ({ element, props: { pageContext } }) => (
4+
export const wrapPageElement = ({element, props: {pageContext}}) => (
55
<PageContext.Provider value={pageContext}>{element}</PageContext.Provider>
66
);
77

gatsby-config.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
require("ts-node").register({
1+
require('ts-node').register({
22
files: true, // to that TS node hooks have access to local typings too
33
});
44

5-
const activeEnv =
6-
process.env.GATSBY_ENV || process.env.NODE_ENV || "development";
5+
const activeEnv = process.env.GATSBY_ENV || process.env.NODE_ENV || 'development';
76

87
console.log(`Using environment config: '${activeEnv}'`);
98

10-
require("dotenv").config({
9+
require('dotenv').config({
1110
path: `.env.${activeEnv}`,
1211
});
1312

14-
if (
15-
process.env.VERCEL_GITHUB_COMMIT_REF === "master" &&
16-
process.env.ALGOLIA_ADMIN_KEY
17-
) {
18-
process.env.ALGOLIA_INDEX = "1";
13+
if (process.env.VERCEL_GITHUB_COMMIT_REF === 'master' && process.env.ALGOLIA_ADMIN_KEY) {
14+
process.env.ALGOLIA_INDEX = '1';
1915
}
2016

21-
module.exports = require("./src/gatsby/config");
17+
module.exports = require('./src/gatsby/config');

gatsby-node.js

+21-25
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
const Sentry = require("@sentry/node");
2-
require("@sentry/tracing");
3-
const Profiling = require("@sentry/profiling-node");
1+
const Sentry = require('@sentry/node');
2+
require('@sentry/tracing');
3+
const Profiling = require('@sentry/profiling-node');
44

5-
const activeEnv =
6-
process.env.GATSBY_ENV || process.env.NODE_ENV || "development";
5+
const activeEnv = process.env.GATSBY_ENV || process.env.NODE_ENV || 'development';
76

87
Sentry.init({
98
dsn:
109
process.env.SENTRY_DSN ||
11-
"https://[email protected]/5266138",
10+
'https://[email protected]/5266138',
1211
environment: activeEnv,
13-
tracesSampleRate: activeEnv === "development" ? 0 : 1,
14-
profilesSampleRate: activeEnv === "development" ? 0 : 1, // Set profiling sampling rate.
12+
tracesSampleRate: activeEnv === 'development' ? 0 : 1,
13+
profilesSampleRate: activeEnv === 'development' ? 0 : 1, // Set profiling sampling rate.
1514
integrations: [new Profiling.ProfilingIntegration()],
1615
});
1716

18-
exports.onCreateNode = require("./src/gatsby/onCreateNode").default;
19-
exports.onCreateWebpackConfig = require("./src/gatsby/onCreateWebpackConfig").default;
20-
exports.createPages = require("./src/gatsby/createPages").default;
21-
exports.createSchemaCustomization = require("./src/gatsby/createSchemaCustomization").default;
17+
exports.onCreateNode = require('./src/gatsby/onCreateNode').default;
18+
exports.onCreateWebpackConfig = require('./src/gatsby/onCreateWebpackConfig').default;
19+
exports.createPages = require('./src/gatsby/createPages').default;
20+
exports.createSchemaCustomization =
21+
require('./src/gatsby/createSchemaCustomization').default;
2222

2323
Sentry.configureScope(scope => {
2424
const id = process.env.GITHUB_RUN_ID;
2525
if (id) {
26-
scope.setUser({ id });
26+
scope.setUser({id});
2727
}
2828
});
2929

3030
function startFromPrevTransaction(newTransactionContext) {
31-
const oldTransaction = Sentry.getCurrentHub()
32-
?.getScope()
33-
?.getTransaction();
31+
const oldTransaction = Sentry.getCurrentHub()?.getScope()?.getTransaction();
3432

3533
let oldTransactionTraceParent;
3634
if (oldTransaction) {
@@ -59,29 +57,27 @@ function startFromPrevTransaction(newTransactionContext) {
5957

6058
exports.onPreInit = () => {
6159
startFromPrevTransaction({
62-
op: "build",
63-
name: "Init",
60+
op: 'build',
61+
name: 'Init',
6462
});
6563
};
6664

6765
exports.onPreBootstrap = () => {
6866
startFromPrevTransaction({
69-
op: "build",
70-
name: "Bootstrap",
67+
op: 'build',
68+
name: 'Bootstrap',
7169
});
7270
};
7371

7472
exports.onPreBuild = () => {
7573
startFromPrevTransaction({
76-
op: "build",
77-
name: "Build",
74+
op: 'build',
75+
name: 'Build',
7876
});
7977
};
8078

8179
exports.onPostBuild = () => {
82-
const transaction = Sentry.getCurrentHub()
83-
?.getScope()
84-
?.getTransaction();
80+
const transaction = Sentry.getCurrentHub()?.getScope()?.getTransaction();
8581
if (transaction) {
8682
transaction.finish();
8783
}

gatsby-ssr.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from "react";
2-
import PageContext from "~src/components/pageContext";
1+
import React from 'react';
2+
import PageContext from '~src/components/pageContext';
33

4-
export const wrapPageElement = ({ element, props: { pageContext } }) => (
4+
export const wrapPageElement = ({element, props: {pageContext}}) => (
55
<PageContext.Provider value={pageContext}>{element}</PageContext.Provider>
66
);

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
transform: {
3-
"^.+\\.[jt]sx?$": `<rootDir>/jest-transformer.js`,
3+
'^.+\\.[jt]sx?$': `<rootDir>/jest-transformer.js`,
44
},
55
testEnvironment: `jest-environment-jsdom-fourteen`,
66
testPathIgnorePatterns: [`node_modules`, `\\.cache`, `<rootDir>.*/public`],

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"init": "cp .env.example .env.development && yarn install",
6565
"prestart": "gatsby clean",
6666
"start": "yarn run develop",
67-
"format": "prettier --ignore-path .gitignore --write \"**/*.js\"",
67+
"format": "prettier --ignore-path .gitignore --write \"**/*.{js,ts,jsx,tsx}\"",
6868
"test": "GATSBY_ENV=test gatsby build"
6969
},
7070
"devDependencies": {
@@ -75,7 +75,7 @@
7575
"identity-obj-proxy": "^3.0.0",
7676
"jest": "^26.0.1",
7777
"jest-environment-jsdom-fourteen": "^1.0.1",
78-
"prettier": "^1.19.1",
78+
"prettier": "2.7.1",
7979
"react-test-renderer": "^16.13.1"
8080
},
8181
"volta": {

prettier.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-env node */
2+
module.exports = {
3+
bracketSpacing: false,
4+
bracketSameLine: false,
5+
printWidth: 90,
6+
semi: true,
7+
singleQuote: true,
8+
tabWidth: 2,
9+
trailingComma: 'es5',
10+
useTabs: false,
11+
arrowParens: 'avoid',
12+
};

src/components/alert.tsx

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React from 'react';
22

33
type Props = {
44
title?: string;
@@ -15,22 +15,17 @@ export default ({
1515
deepLink,
1616
dismiss = false,
1717
}: Props): JSX.Element => {
18-
let className = "alert";
18+
let className = 'alert';
1919
if (level) {
2020
className += ` alert-${level}`;
2121
}
22-
if (children.props && typeof children.props.children === "string") {
23-
className += " markdown-text-only";
22+
if (children.props && typeof children.props.children === 'string') {
23+
className += ' markdown-text-only';
2424
}
2525
return (
2626
<div className={className} role="alert" id={deepLink}>
2727
{dismiss && (
28-
<button
29-
type="button"
30-
className="close"
31-
data-dismiss="alert"
32-
aria-label="Close"
33-
>
28+
<button type="button" className="close" data-dismiss="alert" aria-label="Close">
3429
<span aria-hidden="true">&times;</span>
3530
</button>
3631
)}

src/components/basePage.tsx

+20-29
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
import React, { useRef } from "react";
1+
import React, {useRef} from 'react';
22

3-
import CodeContext, { useCodeContextState } from "./codeContext";
4-
import SEO from "./seo";
5-
import Layout from "./layout";
6-
import SmartLink from "./smartLink";
7-
import TableOfContents from "./tableOfContents";
8-
import * as Sentry from "@sentry/gatsby";
3+
import CodeContext, {useCodeContextState} from './codeContext';
4+
import SEO from './seo';
5+
import Layout from './layout';
6+
import SmartLink from './smartLink';
7+
import TableOfContents from './tableOfContents';
8+
import * as Sentry from '@sentry/gatsby';
99

1010
type GitHubCTAProps = {
1111
sourceInstanceName: string;
1212
relativePath: string;
1313
};
1414

15-
const GitHubCTA = ({
16-
sourceInstanceName,
17-
relativePath,
18-
}: GitHubCTAProps): JSX.Element => (
15+
const GitHubCTA = ({sourceInstanceName, relativePath}: GitHubCTAProps): JSX.Element => (
1916
<div className="github-cta">
2017
<small>
21-
You can{" "}
18+
You can{' '}
2219
<SmartLink
2320
to={`https://github.com/getsentry/develop/edit/master/src/${sourceInstanceName}/${relativePath}`}
2421
>
2522
edit this page
26-
</SmartLink>{" "}
23+
</SmartLink>{' '}
2724
on GitHub.
2825
</small>
2926
</div>
3027
);
3128

32-
const WrappedTOC = React.forwardRef(
33-
(props, ref: React.RefObject<HTMLDivElement>) => {
34-
return <TableOfContents {...props} contentRef={ref} />;
35-
}
36-
);
29+
const WrappedTOC = React.forwardRef((props, ref: React.RefObject<HTMLDivElement>) => {
30+
return <TableOfContents {...props} contentRef={ref} />;
31+
});
3732

3833
type Props = {
3934
data?: {
@@ -55,29 +50,27 @@ type Props = {
5550
};
5651

5752
export default ({
58-
data: { file } = {},
53+
data: {file} = {},
5954
pageContext = {},
6055
seoTitle,
6156
sidebar,
6257
children,
6358
prependToc,
6459
}: Props): JSX.Element => {
65-
const tx = Sentry.getCurrentHub()
66-
.getScope()
67-
.getTransaction();
60+
const tx = Sentry.getCurrentHub().getScope().getTransaction();
6861
if (tx) {
69-
tx.setStatus("ok");
62+
tx.setStatus('ok');
7063
}
7164

72-
const { title, excerpt, description } = pageContext;
65+
const {title, excerpt, description} = pageContext;
7366
const hasToc = !pageContext.notoc;
7467

7568
const contentRef = useRef<HTMLDivElement>(null);
7669

77-
const pageDescription = description || (excerpt ? excerpt.slice(0, 160) : "");
70+
const pageDescription = description || (excerpt ? excerpt.slice(0, 160) : '');
7871

7972
return (
80-
<Layout {...{ sidebar, pageContext }}>
73+
<Layout {...{sidebar, pageContext}}>
8174
<SEO
8275
title={seoTitle || title}
8376
description={pageDescription}
@@ -87,9 +80,7 @@ export default ({
8780
<div className="row">
8881
<div
8982
className={
90-
hasToc || prependToc
91-
? "col-sm-8 col-md-12 col-lg-8 col-xl-9"
92-
: "col-12"
83+
hasToc || prependToc ? 'col-sm-8 col-md-12 col-lg-8 col-xl-9' : 'col-12'
9384
}
9485
>
9586
<h1 className="mb-3">{title}</h1>

src/components/breadcrumbs.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react";
2-
import { useLocation } from "@reach/router";
3-
import { StaticQuery, graphql } from "gatsby";
4-
import SmartLink from "./smartLink";
1+
import React from 'react';
2+
import {useLocation} from '@reach/router';
3+
import {StaticQuery, graphql} from 'gatsby';
4+
import SmartLink from './smartLink';
55

66
const query = graphql`
77
query BreadcrumbsQuery {
@@ -35,19 +35,19 @@ type Props = {
3535

3636
const getTitle = node => {
3737
// TODO(dcramer): support frontmatter somehow from js files
38-
if (node.path === "/") return "Home";
38+
if (node.path === '/') return 'Home';
3939
return node.context.title;
4040
};
4141

4242
export const Breadcrumbs = ({
4343
data: {
44-
allSitePage: { nodes },
44+
allSitePage: {nodes},
4545
},
4646
}: Props) => {
4747
const location = useLocation();
4848
let currentPath = location.pathname;
49-
if (currentPath.substr(currentPath.length - 1) !== "/")
50-
currentPath = currentPath += "/";
49+
if (currentPath.substr(currentPath.length - 1) !== '/')
50+
currentPath = currentPath += '/';
5151
const rootNode = nodes.find(n => n.path === currentPath);
5252
if (!rootNode) {
5353
console.warn(`Cant find root node for breadcrumbs: ${currentPath}`);
@@ -56,7 +56,7 @@ export const Breadcrumbs = ({
5656
const trailNodes = nodes.filter(n => rootNode.path.indexOf(n.path) === 0);
5757

5858
return (
59-
<ul className="breadcrumb" style={{ margin: 0 }}>
59+
<ul className="breadcrumb" style={{margin: 0}}>
6060
{trailNodes
6161
.sort((a, b) => a.path.localeCompare(b.path))
6262
.map(n => {

0 commit comments

Comments
 (0)