diff --git a/.babelrc b/.babelrc index 05d8a77..cc9799d 100644 --- a/.babelrc +++ b/.babelrc @@ -1,16 +1,16 @@ { "presets": [ - "next/babel" + "next/babel" ], "plugins": [ - [ - "babel-plugin-styled-components", - { - "ssr": true, - "displayName": true, - "preprocess": false, - "pure": true - } - ] + [ + "babel-plugin-styled-components", + { + "ssr": true, + "displayName": true, + "preprocess": false, + "pure": true + } + ] ] -} \ No newline at end of file +} diff --git a/.eslintrc.json b/.eslintrc.json index ad3c072..91b8abe 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,61 +1,61 @@ { - "root": true, - "env": { - "browser": true, - "commonjs": true, - "es6": true, - "node": true + "root": true, + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:import/errors", + "plugin:import/warnings", + "plugin:jsx-a11y/recommended", + "plugin:react-hooks/recommended", + "plugin:@typescript-eslint/recommended", + "airbnb-typescript" + ], + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaFeatures": { + "jsx": true }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:import/errors", - "plugin:import/warnings", - "plugin:jsx-a11y/recommended", - "plugin:react-hooks/recommended", - "plugin:@typescript-eslint/recommended", - "airbnb-typescript" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 2018, - "sourceType": "module", - "project": "./tsconfig.json" - }, - "plugins": [], - "settings": { - "react": { - "version": "detect" - } - }, - "rules": { - "@typescript-eslint/naming-convention": "off", - "max-len": [ - "warn", - 240 - ], - "@typescript-eslint/quotes": [ - "error", - "double" - ], - "import/prefer-default-export": "warn", - "react/jsx-props-no-spreading": "off", - "react/prop-types": "off", - // Temp - "react/jsx-one-expression-per-line": "off", - "react/no-array-index-key": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "jsx-a11y/label-has-associated-control": "off", - "jsx-a11y/click-events-have-key-events": "off", - "jsx-a11y/no-noninteractive-element-interactions": "off", - "jsx-a11y/no-static-element-interactions": "off" + "ecmaVersion": 2018, + "sourceType": "module", + "project": "./tsconfig.json" + }, + "plugins": [], + "settings": { + "react": { + "version": "detect" } -} \ No newline at end of file + }, + "rules": { + "@typescript-eslint/naming-convention": "off", + "max-len": [ + "warn", + 240 + ], + "@typescript-eslint/quotes": [ + "error", + "double" + ], + "import/prefer-default-export": "warn", + "react/jsx-props-no-spreading": "off", + "react/prop-types": "off", + // Temp + "react/jsx-one-expression-per-line": "off", + "react/no-array-index-key": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "jsx-a11y/label-has-associated-control": "off", + "jsx-a11y/click-events-have-key-events": "off", + "jsx-a11y/no-noninteractive-element-interactions": "off", + "jsx-a11y/no-static-element-interactions": "off" + } +} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b49b3fa..2ee1980 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,42 +1,42 @@ stages: - - setup - - audit - - lint - - build - - test - - publish - - deploy + - setup + - audit + - lint + - build + - test + - publish + - deploy install: - image: node:14 - stage: setup - script: - - npm ci - artifacts: - paths: - - node_modules - expire_in: 1 week + image: node:14 + stage: setup + script: + - npm ci + artifacts: + paths: + - node_modules + expire_in: 1 week audit: - image: node:14 - needs: ["install"] - stage: audit - script: - - npm audit --audit-level=critical + image: node:14 + needs: ["install"] + stage: audit + script: + - npm audit --audit-level=critical es:lint: - image: node:14 - needs: ["install"] - stage: lint - script: - - npm run lint:es + image: node:14 + needs: ["install"] + stage: lint + script: + - npm run lint:es css:lint: - image: node:14 - needs: ["install"] - stage: lint - script: - - npm run lint:css + image: node:14 + needs: ["install"] + stage: lint + script: + - npm run lint:css # test:unit: # image: node:14 @@ -45,103 +45,103 @@ css:lint: # - npm run test:unit build: - image: node:14 - needs: ["install"] - stage: build - script: - - NODE_ENV=test npm run build - dependencies: - - install - artifacts: - paths: - - .next - expire_in: 1 week - cache: - key: ${CI_COMMIT_REF_SLUG} - paths: - - node_modules/ - - .next/cache/ + image: node:14 + needs: ["install"] + stage: build + script: + - NODE_ENV=test npm run build + dependencies: + - install + artifacts: + paths: + - .next + expire_in: 1 week + cache: + key: ${CI_COMMIT_REF_SLUG} + paths: + - node_modules/ + - .next/cache/ test:e2e: - image: circleci/node:14-browsers - needs: ["install", "build"] - stage: test - script: - - npm run test:e2e - artifacts: - paths: - - e2e-screenshots - expire_in: 1 week - when: on_failure + image: circleci/node:14-browsers + needs: ["install", "build"] + stage: test + script: + - npm run test:e2e + artifacts: + paths: + - e2e-screenshots + expire_in: 1 week + when: on_failure publish:dev: - stage: publish - image: docker:stable - needs: ["build", "test:e2e", "es:lint", "css:lint"] - services: - - docker:stable-dind - only: - - master - script: - - docker info - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker build . -t "$IMAGE_NAME":latest --build-arg NEXT_PUBLIC_API_URL=https://api.dev.sahkoinsinoorikilta.fi/api --build-arg NEXT_PUBLIC_SITE_URL=https://dev.sahkoinsinoorikilta.fi - - docker push "$IMAGE_NAME":latest + stage: publish + image: docker:stable + needs: ["build", "test:e2e", "es:lint", "css:lint"] + services: + - docker:stable-dind + only: + - master + script: + - docker info + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker build . -t "$IMAGE_NAME":latest --build-arg NEXT_PUBLIC_API_URL=https://api.dev.sahkoinsinoorikilta.fi/api --build-arg NEXT_PUBLIC_SITE_URL=https://dev.sahkoinsinoorikilta.fi + - docker push "$IMAGE_NAME":latest publish:prod: - stage: publish - image: docker:stable - services: - - docker:stable-dind - only: - - production - script: - - docker info - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker build . -t "$IMAGE_NAME":prod - - docker push "$IMAGE_NAME":prod + stage: publish + image: docker:stable + services: + - docker:stable-dind + only: + - production + script: + - docker info + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker build . -t "$IMAGE_NAME":prod + - docker push "$IMAGE_NAME":prod deploy:dev: - stage: deploy - image: docker:stable - only: - - master - environment: - name: dev - url: https://dev.sahkoinsinoorikilta.fi - variables: - DOCKER_HOST: $DEV_CI_DOCKER_HOST - DOCKER_TLS_VERIFY: 1 - before_script: - - mkdir -p ~/.docker - - echo "$DEV_TLSCACERT" > ~/.docker/ca.pem - - echo "$DEV_TLSCERT" > ~/.docker/cert.pem - - echo "$DEV_TLSKEY" > ~/.docker/key.pem - - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY" - script: - - docker stack deploy --with-registry-auth -c stack-compose-dev.yml "$SERVICE_NAME" - after_script: - - docker logout "$CI_REGISTRY" + stage: deploy + image: docker:stable + only: + - master + environment: + name: dev + url: https://dev.sahkoinsinoorikilta.fi + variables: + DOCKER_HOST: $DEV_CI_DOCKER_HOST + DOCKER_TLS_VERIFY: 1 + before_script: + - mkdir -p ~/.docker + - echo "$DEV_TLSCACERT" > ~/.docker/ca.pem + - echo "$DEV_TLSCERT" > ~/.docker/cert.pem + - echo "$DEV_TLSKEY" > ~/.docker/key.pem + - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY" + script: + - docker stack deploy --with-registry-auth -c stack-compose-dev.yml "$SERVICE_NAME" + after_script: + - docker logout "$CI_REGISTRY" deploy:prod: - stage: deploy - image: docker:stable - only: - - production - environment: - name: production - url: https://sahkoinsinoorikilta.fi - when: manual - variables: - DOCKER_HOST: $CI_DOCKER_HOST - DOCKER_TLS_VERIFY: 1 - before_script: - - mkdir -p ~/.docker - - echo "$TLSCACERT" > ~/.docker/ca.pem - - echo "$TLSCERT" > ~/.docker/cert.pem - - echo "$TLSKEY" > ~/.docker/key.pem - - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY" - script: - - docker stack deploy --with-registry-auth -c stack-compose.yml "$SERVICE_NAME" - after_script: - - docker logout "$CI_REGISTRY" + stage: deploy + image: docker:stable + only: + - production + environment: + name: production + url: https://sahkoinsinoorikilta.fi + when: manual + variables: + DOCKER_HOST: $CI_DOCKER_HOST + DOCKER_TLS_VERIFY: 1 + before_script: + - mkdir -p ~/.docker + - echo "$TLSCACERT" > ~/.docker/ca.pem + - echo "$TLSCERT" > ~/.docker/cert.pem + - echo "$TLSKEY" > ~/.docker/key.pem + - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY" + script: + - docker stack deploy --with-registry-auth -c stack-compose.yml "$SERVICE_NAME" + after_script: + - docker logout "$CI_REGISTRY" diff --git a/next-sitemap.js b/next-sitemap.js index 8e458bb..46e2888 100644 --- a/next-sitemap.js +++ b/next-sitemap.js @@ -1,5 +1,5 @@ module.exports = { siteUrl: process.env.NEXT_PUBLIC_SITE_URL || "https://sahkoinsinoorikilta.fi", generateRobotsTxt: true, - exclude: ["/events/*", "/feed/*", "/signup/*", "/admin/*"] -} \ No newline at end of file + exclude: ["/events/*", "/feed/*", "/signup/*", "/admin/*"], +}; diff --git a/next.config.js b/next.config.js index 5673955..be463ea 100644 --- a/next.config.js +++ b/next.config.js @@ -15,6 +15,6 @@ module.exports = withBundleAnalyzer({ ], }, future: { - webpack5: true + webpack5: true, }, }); diff --git a/stack-compose-dev.yml b/stack-compose-dev.yml index 661663f..3f0d881 100644 --- a/stack-compose-dev.yml +++ b/stack-compose-dev.yml @@ -1,4 +1,4 @@ -version: '3.4' +version: "3.4" services: frontend: diff --git a/stack-compose.yml b/stack-compose.yml index e36e87d..744ace3 100644 --- a/stack-compose.yml +++ b/stack-compose.yml @@ -1,4 +1,4 @@ -version: '3.4' +version: "3.4" services: frontend: diff --git a/tests/testcafe/404.test.ts b/tests/testcafe/404.test.ts index 90e78d1..28a5493 100644 --- a/tests/testcafe/404.test.ts +++ b/tests/testcafe/404.test.ts @@ -4,9 +4,6 @@ import { getSiteRoot } from "./utils"; fixture`404 page renders and functions correctly`.page(`${getSiteRoot()}/404`); test("Page contains the text 404", async (t) => { - /** - * Test if there is a favicon element on the page - */ const elem = Selector("#not-found"); await t.expect(elem.textContent).contains("404"); }); diff --git a/tsconfig.json b/tsconfig.json index 94a500f..91f6568 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,10 @@ "forceConsistentCasingInFileNames": true, "isolatedModules": true, "jsx": "preserve", - "lib": ["dom", "esnext"], + "lib": [ + "dom", + "esnext" + ], "module": "esnext", "moduleResolution": "node", "noEmit": true, @@ -19,7 +22,10 @@ "sourceMap": true, "strict": false, // TODO: switch true "target": "esnext", - "typeRoots": ["types", "node_modules/@types"], + "typeRoots": [ + "types", + "node_modules/@types" + ], "baseUrl": "./", "paths": { "@api/*": [