upgrade to prettier 2.0

This commit is contained in:
Karol Wypchlo 2020-03-23 15:02:47 +01:00
parent 76a57d9390
commit 222317b600
34 changed files with 139 additions and 155 deletions

View File

@ -5,4 +5,4 @@ update_configs:
directory: "/" directory: "/"
update_schedule: "weekly" update_schedule: "weekly"
default_assignees: default_assignees:
- "kwypchlo" - "kwypchlo"

View File

@ -1,29 +1,22 @@
{ {
"env": { "env": {
"browser": true, "browser": true,
"es6": true, "es6": true,
"cypress/globals": true, "cypress/globals": true,
"node": true "node": true
},
"extends": ["prettier", "eslint:recommended", "plugin:react/recommended"],
"settings": {
"react": {
"version": "detect"
}
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}, },
"extends": [ "ecmaVersion": 2018,
"prettier", "sourceType": "module"
"eslint:recommended", },
"plugin:react/recommended" "plugins": ["react", "cypress"]
], }
"settings": {
"react": {
"version": "detect"
}
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react",
"cypress"
]
}

View File

@ -4,30 +4,32 @@ on: [push]
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Use Node.js - name: Use Node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12.x node-version: 12.x
- name: Install dependencies
run: yarn
- name: Build production bundle - name: Install dependencies
run: yarn build run: yarn
env:
GATSBY_API_URL: "https://siasky.net"
- name: Cypress run - name: Static code analysis
uses: cypress-io/github-action@v1 run: yarn prettier --check .
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - name: Build production bundle
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: yarn build
with: env:
record: true GATSBY_API_URL: "https://siasky.net"
start: npx http-server public --port 8000
wait-on: "http://localhost:8000" - name: Cypress run
uses: cypress-io/github-action@v1
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
record: true
start: npx http-server public --port 8000
wait-on: "http://localhost:8000"

View File

@ -1,4 +1,3 @@
{ {
"arrowParens": "always",
"printWidth": 120 "printWidth": 120
} }

View File

@ -1,3 +1,3 @@
{ {
"ok": true "ok": true
} }

View File

@ -21,9 +21,7 @@ context("Skynet", () => {
cy.get('.home-upload input[type="file"]').upload({ fileContent, fileName, mimeType: "application/json" }); cy.get('.home-upload input[type="file"]').upload({ fileContent, fileName, mimeType: "application/json" });
}); });
cy.get(".home-uploaded-files") cy.get(".home-uploaded-files").children().should("have.length", 1);
.children()
.should("have.length", 1);
cy.wait("@upload"); cy.wait("@upload");

View File

@ -3,7 +3,7 @@ module.exports = {
title: `Skynet`, title: `Skynet`,
description: `Skynet is a decentralized file sharing and content distribution protocol.`, description: `Skynet is a decentralized file sharing and content distribution protocol.`,
author: `Nebulous`, author: `Nebulous`,
siteUrl: `https://siasky.net` siteUrl: `https://siasky.net`,
}, },
plugins: [ plugins: [
`gatsby-plugin-sass`, `gatsby-plugin-sass`,
@ -12,8 +12,8 @@ module.exports = {
resolve: `gatsby-source-filesystem`, resolve: `gatsby-source-filesystem`,
options: { options: {
name: `images`, name: `images`,
path: `${__dirname}/src/images` path: `${__dirname}/src/images`,
} },
}, },
`gatsby-transformer-sharp`, `gatsby-transformer-sharp`,
`gatsby-plugin-sharp`, `gatsby-plugin-sharp`,
@ -27,17 +27,17 @@ module.exports = {
background_color: `#f1f7f2`, background_color: `#f1f7f2`,
theme_color: `#f1f7f2`, theme_color: `#f1f7f2`,
display: `minimal-ui`, display: `minimal-ui`,
icon: `src/images/logo.svg` // This path is relative to the root of the site. icon: `src/images/logo.svg`, // This path is relative to the root of the site.
} },
}, },
{ {
resolve: "gatsby-plugin-matomo", resolve: "gatsby-plugin-matomo",
options: { options: {
siteId: 3, siteId: 3,
matomoUrl: "https://surveillance.sia.tech", matomoUrl: "https://surveillance.sia.tech",
siteUrl: "https://siasky.net" siteUrl: "https://siasky.net",
} },
}, },
`gatsby-plugin-remove-serviceworker` `gatsby-plugin-remove-serviceworker`,
] ],
}; };

View File

@ -54,7 +54,6 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "gatsby build", "build": "gatsby build",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,md,html,css,scss}\"",
"start": "gatsby develop", "start": "gatsby develop",
"serve": "gatsby serve", "serve": "gatsby serve",
"clean": "gatsby clean" "clean": "gatsby clean"

View File

@ -7,5 +7,5 @@ export default function CircleIcon({ children }) {
} }
CircleIcon.propTypes = { CircleIcon.propTypes = {
children: PropTypes.node children: PropTypes.node,
}; };

View File

@ -4,105 +4,105 @@ export default {
overflowX: "auto", overflowX: "auto",
padding: "0.5em", padding: "0.5em",
background: "#171917", background: "#171917",
color: "#e6e1dc" color: "#e6e1dc",
}, },
"hljs-comment": { "hljs-comment": {
color: "#bc9458", color: "#bc9458",
fontStyle: "italic" fontStyle: "italic",
}, },
"hljs-quote": { "hljs-quote": {
color: "#bc9458", color: "#bc9458",
fontStyle: "italic" fontStyle: "italic",
}, },
"hljs-keyword": { "hljs-keyword": {
color: "#c26230" color: "#c26230",
}, },
"hljs-selector-tag": { "hljs-selector-tag": {
color: "#c26230" color: "#c26230",
}, },
"hljs-string": { "hljs-string": {
color: "#a5c261" color: "#a5c261",
}, },
"hljs-number": { "hljs-number": {
color: "#a5c261" color: "#a5c261",
}, },
"hljs-regexp": { "hljs-regexp": {
color: "#a5c261" color: "#a5c261",
}, },
"hljs-variable": { "hljs-variable": {
color: "#a5c261" color: "#a5c261",
}, },
"hljs-template-variable": { "hljs-template-variable": {
color: "#a5c261" color: "#a5c261",
}, },
"hljs-subst": { "hljs-subst": {
color: "#519f50" color: "#519f50",
}, },
"hljs-tag": { "hljs-tag": {
color: "#e8bf6a" color: "#e8bf6a",
}, },
"hljs-name": { "hljs-name": {
color: "#e8bf6a" color: "#e8bf6a",
}, },
"hljs-type": { "hljs-type": {
color: "#da4939" color: "#da4939",
}, },
"hljs-symbol": { "hljs-symbol": {
color: "#6d9cbe" color: "#6d9cbe",
}, },
"hljs-bullet": { "hljs-bullet": {
color: "#6d9cbe" color: "#6d9cbe",
}, },
"hljs-built_in": { "hljs-built_in": {
color: "#6d9cbe" color: "#6d9cbe",
}, },
"hljs-builtin-name": { "hljs-builtin-name": {
color: "#6d9cbe" color: "#6d9cbe",
}, },
"hljs-attr": { "hljs-attr": {
color: "#6d9cbe" color: "#6d9cbe",
}, },
"hljs-link": { "hljs-link": {
color: "#6d9cbe", color: "#6d9cbe",
textDecoration: "underline" textDecoration: "underline",
}, },
"hljs-params": { "hljs-params": {
color: "#d0d0ff" color: "#d0d0ff",
}, },
"hljs-attribute": { "hljs-attribute": {
color: "#cda869" color: "#cda869",
}, },
"hljs-meta": { "hljs-meta": {
color: "#9b859d" color: "#9b859d",
}, },
"hljs-title": { "hljs-title": {
color: "#ffc66d" color: "#ffc66d",
}, },
"hljs-section": { "hljs-section": {
color: "#ffc66d" color: "#ffc66d",
}, },
"hljs-addition": { "hljs-addition": {
backgroundColor: "#144212", backgroundColor: "#144212",
color: "#e6e1dc", color: "#e6e1dc",
display: "inline-block", display: "inline-block",
width: "100%" width: "100%",
}, },
"hljs-deletion": { "hljs-deletion": {
backgroundColor: "#600", backgroundColor: "#600",
color: "#e6e1dc", color: "#e6e1dc",
display: "inline-block", display: "inline-block",
width: "100%" width: "100%",
}, },
"hljs-selector-class": { "hljs-selector-class": {
color: "#9b703f" color: "#9b703f",
}, },
"hljs-selector-id": { "hljs-selector-id": {
color: "#8b98ab" color: "#8b98ab",
}, },
"hljs-emphasis": { "hljs-emphasis": {
fontStyle: "italic" fontStyle: "italic",
}, },
"hljs-strong": { "hljs-strong": {
fontWeight: "bold" fontWeight: "bold",
} },
}; };

View File

@ -16,5 +16,5 @@ export default function FAQ({ title, children }) {
FAQ.propTypes = { FAQ.propTypes = {
title: PropTypes.string, title: PropTypes.string,
children: PropTypes.node children: PropTypes.node,
}; };

View File

@ -14,7 +14,7 @@ const STATS_MAP = [
{ name: "TB Capacity", key: AVAILABLE_STATS.NETWORK_CAPACITY_TB }, { name: "TB Capacity", key: AVAILABLE_STATS.NETWORK_CAPACITY_TB },
{ name: "Hosts", key: AVAILABLE_STATS.ONLINE_HOSTS_COUNT }, { name: "Hosts", key: AVAILABLE_STATS.ONLINE_HOSTS_COUNT },
{ name: "Storage/TB", key: AVAILABLE_STATS.STORAGE_COST_USD, currency: true }, { name: "Storage/TB", key: AVAILABLE_STATS.STORAGE_COST_USD, currency: true },
{ name: "Bandwidth/TB", key: AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD, currency: true } { name: "Bandwidth/TB", key: AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD, currency: true },
]; ];
export default function HomeNetwork() { export default function HomeNetwork() {
@ -193,7 +193,7 @@ StatValue.propTypes = {
stat: PropTypes.shape({ stat: PropTypes.shape({
key: PropTypes.string.isRequired, key: PropTypes.string.isRequired,
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
currency: PropTypes.bool currency: PropTypes.bool,
}).isRequired, }).isRequired,
value: PropTypes.number.isRequired value: PropTypes.number.isRequired,
}; };

View File

@ -6,7 +6,7 @@ export const AVAILABLE_STATS = {
STORAGE_USED_TB: "storageUsedTB", STORAGE_USED_TB: "storageUsedTB",
NETWORK_CAPACITY_TB: "networkCapacityTB", NETWORK_CAPACITY_TB: "networkCapacityTB",
STORAGE_COST_USD: "storageCostUSD", STORAGE_COST_USD: "storageCostUSD",
BANDWIDTH_DOWN_COST_USD: "bandwidthDownCostUSD" BANDWIDTH_DOWN_COST_USD: "bandwidthDownCostUSD",
}; };
export default function useStats() { export default function useStats() {
@ -15,7 +15,7 @@ export default function useStats() {
[AVAILABLE_STATS.STORAGE_USED_TB]: null, [AVAILABLE_STATS.STORAGE_USED_TB]: null,
[AVAILABLE_STATS.NETWORK_CAPACITY_TB]: null, [AVAILABLE_STATS.NETWORK_CAPACITY_TB]: null,
[AVAILABLE_STATS.STORAGE_COST_USD]: null, [AVAILABLE_STATS.STORAGE_COST_USD]: null,
[AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD]: null [AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD]: null,
}); });
useEffect(() => { useEffect(() => {
@ -38,7 +38,7 @@ async function getBandwidthStats() {
const current = data.reverse().find((entry) => "downusd" in entry); const current = data.reverse().find((entry) => "downusd" in entry);
return { return {
[AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD]: current.downusd [AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD]: current.downusd,
}; };
} }
@ -49,7 +49,7 @@ async function getPriceStats() {
const current = data.reverse().find((entry) => "usd" in entry); const current = data.reverse().find((entry) => "usd" in entry);
return { return {
[AVAILABLE_STATS.STORAGE_COST_USD]: current.usd [AVAILABLE_STATS.STORAGE_COST_USD]: current.usd,
}; };
} }
@ -63,6 +63,6 @@ async function getStorageStats() {
return { return {
[AVAILABLE_STATS.ONLINE_HOSTS_COUNT]: data.online_hosts, [AVAILABLE_STATS.ONLINE_HOSTS_COUNT]: data.online_hosts,
[AVAILABLE_STATS.STORAGE_USED_TB]: data.used_storage_TB, [AVAILABLE_STATS.STORAGE_USED_TB]: data.used_storage_TB,
[AVAILABLE_STATS.NETWORK_CAPACITY_TB]: data.network_capacity_TB [AVAILABLE_STATS.NETWORK_CAPACITY_TB]: data.network_capacity_TB,
}; };
} }

View File

@ -12,7 +12,7 @@ const samples = [
{ type: "Audio", url: "/_A2zt5SKoqwnnZU4cBF8uBycSKULXMyeg1c5ZISBr2Q3dA" }, { type: "Audio", url: "/_A2zt5SKoqwnnZU4cBF8uBycSKULXMyeg1c5ZISBr2Q3dA" },
{ type: "Video", url: "/CABAB_1Dt0FJsxqsu_J4TodNCbCGvtFf1Uys_3EgzOlTcg" }, { type: "Video", url: "/CABAB_1Dt0FJsxqsu_J4TodNCbCGvtFf1Uys_3EgzOlTcg" },
{ type: "JSON", url: "/AAC0uO43g64ULpyrW0zO3bjEknSFbAhm8c-RFP21EQlmSQ" }, { type: "JSON", url: "/AAC0uO43g64ULpyrW0zO3bjEknSFbAhm8c-RFP21EQlmSQ" },
{ type: "Dapp", url: "/EAC5HJr5Pu086EAZG4fP_r6Pnd7Ft366vt6t2AnjkoFb9Q/index.html" } { type: "Dapp", url: "/EAC5HJr5Pu086EAZG4fP_r6Pnd7Ft366vt6t2AnjkoFb9Q/index.html" },
]; ];
export default function HomeSamples() { export default function HomeSamples() {

View File

@ -27,11 +27,7 @@ export default function HomeUpload() {
const getRelativeFilePath = (file) => { const getRelativeFilePath = (file) => {
const filePath = getFilePath(file); const filePath = getFilePath(file);
const { root, dir, base } = path.parse(filePath); const { root, dir, base } = path.parse(filePath);
const relative = path const relative = path.normalize(dir).slice(root.length).split(path.sep).slice(1);
.normalize(dir)
.slice(root.length)
.split(path.sep)
.slice(1);
return path.join(...relative, base); return path.join(...relative, base);
}; };
@ -40,10 +36,7 @@ export default function HomeUpload() {
const filePath = getFilePath(file); const filePath = getFilePath(file);
const { root, dir } = path.parse(filePath); const { root, dir } = path.parse(filePath);
return path return path.normalize(dir).slice(root.length).split(path.sep)[0];
.normalize(dir)
.slice(root.length)
.split(path.sep)[0];
}; };
const handleDrop = async (acceptedFiles) => { const handleDrop = async (acceptedFiles) => {
@ -63,9 +56,9 @@ export default function HomeUpload() {
...previousFiles.slice(0, index), ...previousFiles.slice(0, index),
{ {
...previousFiles[index], ...previousFiles[index],
...state ...state,
}, },
...previousFiles.slice(index + 1) ...previousFiles.slice(index + 1),
]; ];
}); });
}; };
@ -78,7 +71,7 @@ export default function HomeUpload() {
const status = progress === 1 ? "processing" : "uploading"; const status = progress === 1 ? "processing" : "uploading";
onFileStateChange(file, { status, progress }); onFileStateChange(file, { status, progress });
} },
}); });
return data; return data;
@ -127,7 +120,7 @@ export default function HomeUpload() {
<div className="home-upload-box "> <div className="home-upload-box ">
<div <div
className={classNames("home-upload-dropzone", { className={classNames("home-upload-dropzone", {
"drop-active": isDragActive "drop-active": isDragActive,
})} })}
{...getRootProps()} {...getRootProps()}
> >

View File

@ -16,7 +16,7 @@ const CustomForm = ({ status, message, onValidated, light, id }) => {
if ((email, user, email.value.indexOf("@") > -1)) { if ((email, user, email.value.indexOf("@") > -1)) {
onValidated({ onValidated({
EMAIL: email.value, EMAIL: email.value,
USER: user.checked ? "Yes" : "No" USER: user.checked ? "Yes" : "No",
}); });
} }
}; };
@ -50,7 +50,7 @@ CustomForm.propTypes = {
message: PropTypes.string, message: PropTypes.string,
onValidated: PropTypes.func, onValidated: PropTypes.func,
light: PropTypes.bool, light: PropTypes.bool,
id: PropTypes.string id: PropTypes.string,
}; };
export default function Mailing({ light, id }) { export default function Mailing({ light, id }) {
@ -72,5 +72,5 @@ export default function Mailing({ light, id }) {
Mailing.propTypes = { Mailing.propTypes = {
light: PropTypes.bool, light: PropTypes.bool,
id: PropTypes.string id: PropTypes.string,
}; };

View File

@ -21,5 +21,5 @@ export default function Sample({ type, url, className }) {
Sample.propTypes = { Sample.propTypes = {
type: PropTypes.string, type: PropTypes.string,
url: PropTypes.string, url: PropTypes.string,
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -29,5 +29,5 @@ SocialLink.propTypes = {
icon: PropTypes.string, icon: PropTypes.string,
title: PropTypes.node, title: PropTypes.node,
greenText: PropTypes.string, greenText: PropTypes.string,
url: PropTypes.string url: PropTypes.string,
}; };

View File

@ -75,9 +75,9 @@ export default function UploadFile({ file, url, status, progress }) {
UploadFile.propTypes = { UploadFile.propTypes = {
file: PropTypes.shape({ file: PropTypes.shape({
name: PropTypes.string.isRequired name: PropTypes.string.isRequired,
}), }),
status: PropTypes.string.isRequired, status: PropTypes.string.isRequired,
url: PropTypes.string, url: PropTypes.string,
progress: PropTypes.number progress: PropTypes.number,
}; };

View File

@ -34,5 +34,5 @@ export {
UploadFile, UploadFile,
LoadingSpinner, LoadingSpinner,
Footer, Footer,
Mailing Mailing,
}; };

View File

@ -28,42 +28,42 @@ function SEO({ lang, meta }) {
return ( return (
<Helmet <Helmet
htmlAttributes={{ htmlAttributes={{
lang lang,
}} }}
title={site.siteMetadata.title} title={site.siteMetadata.title}
meta={[ meta={[
{ {
name: `description`, name: `description`,
content: site.siteMetadata.description content: site.siteMetadata.description,
}, },
{ {
property: `og:title`, property: `og:title`,
content: site.siteMetadata.title content: site.siteMetadata.title,
}, },
{ {
property: `og:description`, property: `og:description`,
content: site.siteMetadata.description content: site.siteMetadata.description,
}, },
{ {
property: `og:type`, property: `og:type`,
content: `website` content: `website`,
}, },
{ {
name: `twitter:card`, name: `twitter:card`,
content: `summary` content: `summary`,
}, },
{ {
name: `twitter:creator`, name: `twitter:creator`,
content: site.siteMetadata.author content: site.siteMetadata.author,
}, },
{ {
name: `twitter:title`, name: `twitter:title`,
content: site.siteMetadata.title content: site.siteMetadata.title,
}, },
{ {
name: `twitter:description`, name: `twitter:description`,
content: site.siteMetadata.description content: site.siteMetadata.description,
} },
].concat(meta)} ].concat(meta)}
/> />
); );
@ -72,12 +72,12 @@ function SEO({ lang, meta }) {
SEO.defaultProps = { SEO.defaultProps = {
lang: `en`, lang: `en`,
meta: [], meta: [],
description: `` description: ``,
}; };
SEO.propTypes = { SEO.propTypes = {
lang: PropTypes.string, lang: PropTypes.string,
meta: PropTypes.arrayOf(PropTypes.object) meta: PropTypes.arrayOf(PropTypes.object),
}; };
export default SEO; export default SEO;

View File

@ -8,7 +8,7 @@ import AppContext from "../AppContext";
export default function IndexPage({ location }) { export default function IndexPage({ location }) {
const context = useMemo( const context = useMemo(
() => ({ () => ({
apiUrl: process.env.GATSBY_API_URL || location.origin apiUrl: process.env.GATSBY_API_URL || location.origin,
}), }),
[location.origin] [location.origin]
); );
@ -22,5 +22,5 @@ export default function IndexPage({ location }) {
} }
IndexPage.propTypes = { IndexPage.propTypes = {
location: PropTypes.object.isRequired location: PropTypes.object.isRequired,
}; };

View File

@ -10,5 +10,5 @@ export default function Arrow({ className }) {
} }
Arrow.propTypes = { Arrow.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -17,5 +17,5 @@ export default function Cylinder({ className }) {
} }
Cylinder.propTypes = { Cylinder.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -14,5 +14,5 @@ export default function Discord({ className }) {
} }
Discord.propTypes = { Discord.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -17,5 +17,5 @@ export default function DoubleRight({ className }) {
} }
DoubleRight.propTypes = { DoubleRight.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -24,5 +24,5 @@ export default function Download({ className }) {
} }
Download.propTypes = { Download.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -14,5 +14,5 @@ export default function Github({ className }) {
} }
Github.propTypes = { Github.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -16,5 +16,5 @@ export default function Logo({ className }) {
} }
Logo.propTypes = { Logo.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -14,5 +14,5 @@ export default function LogoSolid({ className }) {
} }
LogoSolid.propTypes = { LogoSolid.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -18,5 +18,5 @@ export default function Pyramid({ className }) {
} }
Pyramid.propTypes = { Pyramid.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -17,5 +17,5 @@ export default function SmallOrb({ className }) {
} }
SmallOrb.propTypes = { SmallOrb.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -14,5 +14,5 @@ export default function Twitter({ className }) {
} }
Twitter.propTypes = { Twitter.propTypes = {
className: PropTypes.string className: PropTypes.string,
}; };

View File

@ -60,5 +60,5 @@ export {
Deco5, Deco5,
Deco6, Deco6,
Deco7, Deco7,
Deco8 Deco8,
}; };