diff --git a/.dependabot/config.yml b/.dependabot/config.yml index 241aeef4..846ddcaa 100644 --- a/.dependabot/config.yml +++ b/.dependabot/config.yml @@ -5,4 +5,4 @@ update_configs: directory: "/" update_schedule: "weekly" default_assignees: - - "kwypchlo" \ No newline at end of file + - "kwypchlo" diff --git a/.eslintrc.json b/.eslintrc.json index 8414ede6..58d80ffb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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" - ] -} \ No newline at end of file + "ecmaVersion": 2018, + "sourceType": "module" + }, + "plugins": ["react", "cypress"] +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10cddb01..66f0cfcf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 - - - name: Install dependencies - run: yarn + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: 12.x - - name: Build production bundle - run: yarn build - env: - GATSBY_API_URL: "https://siasky.net" + - name: Install dependencies + run: yarn - - 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: Static code analysis + run: yarn prettier --check . + + - 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" diff --git a/.prettierrc b/.prettierrc index 9efb91d2..963354f2 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,3 @@ { - "arrowParens": "always", "printWidth": 120 } diff --git a/cypress/fixtures/check.json b/cypress/fixtures/check.json index 47971aa3..0287aedd 100644 --- a/cypress/fixtures/check.json +++ b/cypress/fixtures/check.json @@ -1,3 +1,3 @@ { "ok": true -} \ No newline at end of file +} diff --git a/cypress/integration/intergration.spec.js b/cypress/integration/intergration.spec.js index 487d1176..ab94bdec 100644 --- a/cypress/integration/intergration.spec.js +++ b/cypress/integration/intergration.spec.js @@ -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"); diff --git a/gatsby-config.js b/gatsby-config.js index d0a10f3c..7947ec05 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -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`, + ], }; diff --git a/package.json b/package.json index e5e87256..410c4177 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "eslint-plugin-react": "^7.19.0", "husky": "^4.2.3", "lint-staged": "^10.0.8", - "prettier": "^1.19.1" + "prettier": "^2.0.1" }, "keywords": [ "sia", @@ -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" diff --git a/src/components/CircleIcon/CircleIcon.js b/src/components/CircleIcon/CircleIcon.js index 9280047e..a032c62e 100644 --- a/src/components/CircleIcon/CircleIcon.js +++ b/src/components/CircleIcon/CircleIcon.js @@ -7,5 +7,5 @@ export default function CircleIcon({ children }) { } CircleIcon.propTypes = { - children: PropTypes.node + children: PropTypes.node, }; diff --git a/src/components/CodeExamples/Colors.js b/src/components/CodeExamples/Colors.js index b54fbc43..e8d5a353 100644 --- a/src/components/CodeExamples/Colors.js +++ b/src/components/CodeExamples/Colors.js @@ -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", + }, }; diff --git a/src/components/FAQ/FAQ.js b/src/components/FAQ/FAQ.js index 066dbef6..d3ce4b57 100644 --- a/src/components/FAQ/FAQ.js +++ b/src/components/FAQ/FAQ.js @@ -16,5 +16,5 @@ export default function FAQ({ title, children }) { FAQ.propTypes = { title: PropTypes.string, - children: PropTypes.node + children: PropTypes.node, }; diff --git a/src/components/HomeNetwork/HomeNetwork.js b/src/components/HomeNetwork/HomeNetwork.js index 2d53bb20..ea7a1d74 100644 --- a/src/components/HomeNetwork/HomeNetwork.js +++ b/src/components/HomeNetwork/HomeNetwork.js @@ -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, }; diff --git a/src/components/HomeNetwork/useStats.js b/src/components/HomeNetwork/useStats.js index ee292ecb..9ebc2fc9 100644 --- a/src/components/HomeNetwork/useStats.js +++ b/src/components/HomeNetwork/useStats.js @@ -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, }; } diff --git a/src/components/HomeSamples/HomeSamples.js b/src/components/HomeSamples/HomeSamples.js index cb360108..e24d2dee 100644 --- a/src/components/HomeSamples/HomeSamples.js +++ b/src/components/HomeSamples/HomeSamples.js @@ -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() { diff --git a/src/components/HomeUpload/HomeUpload.js b/src/components/HomeUpload/HomeUpload.js index e96d5a56..924f6c6c 100644 --- a/src/components/HomeUpload/HomeUpload.js +++ b/src/components/HomeUpload/HomeUpload.js @@ -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() {