Skip to content

Commit

Permalink
OPHJOD-1037: Initialize project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sauanto committed Nov 22, 2024
1 parent f8c90f4 commit 876664d
Show file tree
Hide file tree
Showing 73 changed files with 14,608 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.github/ @Opetushallitus/jod-kehittajat
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Have you ran tests and they pass?
Did builds complete successfully?
Remembered to run linters?
-->

## Description

<!-- Give some description about the PR.
- What was done and why? Give some context to help the reviewer.
- Where to focus especially?
-->

## Related JIRA ticket

<!-- Remember to add link to the JIRA issue
https://jira.eduuni.fi/browse/OPHJOD-XXX
-->

https://jira.eduuni.fi/browse/OPHJOD-
2 changes: 2 additions & 0 deletions .github/snyk_pull_request_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: 'OPHJOD-851: Upgrade {{ package_name }} from {{ package_from }} to {{ package_to }}'
commitMessage: 'OPHJOD-851: Upgrade {{ package_name }} from {{ package_from }} to {{ package_to }}'
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and deploy JOD Ohjaaja UI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
id-token: write # Needed to interact with GitHub's OIDC Token endpoint
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- uses: actions/setup-node@v4
with:
node-version: lts/iron
cache: npm

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npx eslint . --report-unused-disable-directives --max-warnings 0

- name: Run Prettier
run: npx prettier . --check

- name: Run Vitest unit tests
run: npx vitest --coverage.enabled true

- name: Upload Vitest report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage
path: coverage/
retention-days: 30

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.JOD_UTIL_AWS_ACCOUNT_ID }}:role/${{ secrets.JOD_UTIL_AWS_GITHUB_ROLE_NAME}}
aws-region: eu-west-1

- name: Copy third party assets from S3
run: aws s3 sync --quiet s3://${{ secrets.JOD_UI_ASSETS }} ./assets

- name: Run build
run: npm run build

# SonarCloud analysis
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@v2
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
/public/assets
/assets
coverage
/test-results/
/blob-report/
*.local


# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/launch.json
!.vscode/settings.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged || (echo '\n (⊙_⊙) Your forgot to use prettier and fix eslint errors!\n'; false)
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run test:unit || (echo '\n (⊙_⊙) Your forgot to run unit tests!\n'; false)
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*": ["prettier --check"],
"*.{ts,tsx}": ["eslint --report-unused-disable-directives --max-warnings 0"]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/iron
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"singleQuote": true,
"plugins": ["prettier-plugin-tailwindcss", "prettier-plugin-organize-imports"]
}
12 changes: 12 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"deque-systems.vscode-axe-linter",
"Lokalise.i18n-ally",
"vitest.explorer",
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"bradlc.vscode-tailwindcss"
]
}
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src"
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"i18n-ally.localesPaths": ["src/i18n"],
"i18n-ally.keystyle": "nested",
"i18n-ally.sourceLanguage": "fi"
}
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
# JOD Ohjaaja UI
# React + TypeScript + Vite

This repository is the UI for JOD Ohjaaja. JOD Ohjaaja is part of the Digital Service Ecosystem for Continuous Learning (JOD) project.
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
});
```

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
import react from 'eslint-plugin-react';

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
});
```
34 changes: 34 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import js from '@eslint/js';
import singlestoreReactHooksDisableImport from '@singlestore/eslint-plugin-react-hooks-disable-import';
import eslintConfigPrettier from 'eslint-config-prettier';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import sonarjs from 'eslint-plugin-sonarjs';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ ignores: ['dist'] },
{ files: ['**/*.{ts,tsx}'] },
{ languageOptions: { ecmaVersion: 2020, globals: globals.browser } },
sonarjs.configs.recommended,
jsxA11y.flatConfigs.recommended,
js.configs.recommended,
...tseslint.configs.recommended,
{
plugins: {
react: react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
'@singlestore/react-hooks-disable-import': singlestoreReactHooksDisableImport,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'@singlestore/react-hooks-disable-import/react-hooks-disable-import': 'error',
},
},
eslintConfigPrettier,
);
Loading

0 comments on commit 876664d

Please sign in to comment.