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

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

View File

@ -4,30 +4,32 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: yarn
- name: Install dependencies
run: yarn
- name: Build production bundle
run: yarn build
env:
GATSBY_API_URL: "https://siasky.net"
- name: Static code analysis
run: yarn prettier --check .
- 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"
- name: Build production bundle
run: yarn build
env:
GATSBY_API_URL: "https://siasky.net"
- 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
}

View File

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

View File

@ -3,7 +3,7 @@ module.exports = {
title: `Skynet`,
description: `Skynet is a decentralized file sharing and content distribution protocol.`,
author: `Nebulous`,
siteUrl: `https://siasky.net`
siteUrl: `https://siasky.net`,
},
plugins: [
`gatsby-plugin-sass`,
@ -12,8 +12,8 @@ module.exports = {
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`
}
path: `${__dirname}/src/images`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
@ -27,17 +27,17 @@ module.exports = {
background_color: `#f1f7f2`,
theme_color: `#f1f7f2`,
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",
options: {
siteId: 3,
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",
"scripts": {
"build": "gatsby build",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,md,html,css,scss}\"",
"start": "gatsby develop",
"serve": "gatsby serve",
"clean": "gatsby clean"

View File

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

View File

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

View File

@ -16,5 +16,5 @@ export default function FAQ({ title, children }) {
FAQ.propTypes = {
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: "Hosts", key: AVAILABLE_STATS.ONLINE_HOSTS_COUNT },
{ 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() {
@ -193,7 +193,7 @@ StatValue.propTypes = {
stat: PropTypes.shape({
key: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
currency: PropTypes.bool
currency: PropTypes.bool,
}).isRequired,
value: PropTypes.number.isRequired
value: PropTypes.number.isRequired,
};

View File

@ -6,7 +6,7 @@ export const AVAILABLE_STATS = {
STORAGE_USED_TB: "storageUsedTB",
NETWORK_CAPACITY_TB: "networkCapacityTB",
STORAGE_COST_USD: "storageCostUSD",
BANDWIDTH_DOWN_COST_USD: "bandwidthDownCostUSD"
BANDWIDTH_DOWN_COST_USD: "bandwidthDownCostUSD",
};
export default function useStats() {
@ -15,7 +15,7 @@ export default function useStats() {
[AVAILABLE_STATS.STORAGE_USED_TB]: null,
[AVAILABLE_STATS.NETWORK_CAPACITY_TB]: null,
[AVAILABLE_STATS.STORAGE_COST_USD]: null,
[AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD]: null
[AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD]: null,
});
useEffect(() => {
@ -38,7 +38,7 @@ async function getBandwidthStats() {
const current = data.reverse().find((entry) => "downusd" in entry);
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);
return {
[AVAILABLE_STATS.STORAGE_COST_USD]: current.usd
[AVAILABLE_STATS.STORAGE_COST_USD]: current.usd,
};
}
@ -63,6 +63,6 @@ async function getStorageStats() {
return {
[AVAILABLE_STATS.ONLINE_HOSTS_COUNT]: data.online_hosts,
[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: "Video", url: "/CABAB_1Dt0FJsxqsu_J4TodNCbCGvtFf1Uys_3EgzOlTcg" },
{ type: "JSON", url: "/AAC0uO43g64ULpyrW0zO3bjEknSFbAhm8c-RFP21EQlmSQ" },
{ type: "Dapp", url: "/EAC5HJr5Pu086EAZG4fP_r6Pnd7Ft366vt6t2AnjkoFb9Q/index.html" }
{ type: "Dapp", url: "/EAC5HJr5Pu086EAZG4fP_r6Pnd7Ft366vt6t2AnjkoFb9Q/index.html" },
];
export default function HomeSamples() {

View File

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

View File

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

View File

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

View File

@ -29,5 +29,5 @@ SocialLink.propTypes = {
icon: PropTypes.string,
title: PropTypes.node,
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 = {
file: PropTypes.shape({
name: PropTypes.string.isRequired
name: PropTypes.string.isRequired,
}),
status: PropTypes.string.isRequired,
url: PropTypes.string,
progress: PropTypes.number
progress: PropTypes.number,
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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