Skip to content

Commit

Permalink
Add github workflows
Browse files Browse the repository at this point in the history
- Remove unused things
- Fix issue with knip
- Update eslint flat config for compatibility with knip
  • Loading branch information
tnagorra committed Sep 6, 2024
1 parent ce6a2de commit 7aeeaf8
Show file tree
Hide file tree
Showing 29 changed files with 1,049 additions and 1,430 deletions.
26 changes: 2 additions & 24 deletions eslint.config.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import process from 'process';

const dirname = process.cwd();

const compat = new FlatCompat({
baseDirectory: dirname,
resolvePluginsRelativeTo: dirname,
});

const appConfigs = compat.config({
const config = {
env: {
node: true,
browser: true,
Expand Down Expand Up @@ -118,17 +107,6 @@ const appConfigs = compat.config({
}
}
]
}).map((conf) => ({
...conf,
files: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts', 'src/**/*.js', 'generated/**/*.ts'],
}));

const otherConfig = {
files: ['*.js', '*.ts', '*.cjs'],
...js.configs.recommended,
};

export default [
...appConfigs,
otherConfig,
];
module.exports = config;
134 changes: 134 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Lint & Build

on:
pull_request:
push:
branches:
- 'develop'

env:
APP_TITLE: ${{ vars.APP_TITLE }}
APP_ENVIRONMENT: ${{ vars.APP_ENVIRONMENT }}
APP_GRAPHQL_CODEGEN_ENDPOINT: ${{ vars.APP_GRAPHQL_CODEGEN_ENDPOINT }}
APP_GRAPHQL_API_ENDPOINT: ${{ vars.APP_GRAPHQL_API_ENDPOINT }}
APP_AUTH_URL: ${{ vars.APP_AUTH_URL }}
APP_ADMIN_URL: ${{ vars.APP_ADMIN_URL }}
APP_UMAMI_SRC: ${{ vars.APP_UMAMI_SRC }}
APP_UMAMI_ID: ${{ vars.APP_UMAMI_ID }}
GITHUB_WORKFLOW: true

jobs:
unused:
name: Find unused things
environment: 'test'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: pnpm/action-setup@v4
name: Install pnpm

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Run knip
run: pnpm lint:unused
lint-js:
name: Lint JS
environment: 'test'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: pnpm/action-setup@v4
name: Install pnpm

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Lint Javascript
run: pnpm generate:type && pnpm lint:js
css-lint:
name: Lint CSS
environment: 'test'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
name: Install pnpm

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Css Lint
run: pnpm lint:css
typecheck:
name: Typecheck
environment: 'test'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: pnpm/action-setup@v4
name: Install pnpm

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Lint Javascript
run: pnpm generate:type && pnpm typecheck
build:
name: Build
environment: 'test'
needs: [lint-js, css-lint, typecheck]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: pnpm/action-setup@v4
name: Install pnpm

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm generate:type && pnpm build
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ pnpm-debug.log*
# Custom
build/
generated/
coverage/
stats.html

2 changes: 1 addition & 1 deletion codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config: CodegenConfig = {
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
'./generated/types/': {
preset: 'client'
preset: 'client',
}
},
config: {
Expand Down
19 changes: 17 additions & 2 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"entry": ["src/index.tsx!"],
"project": ["src/**/*.tsx!", "src/**/*.ts!"]
"ignoreDependencies": [
"virtual:pwa-info",
"virtual:pwa-register"
],
"entry": [
"src/**/*.test.ts",
"src/**/*.test.tsx",
"generated/**/*.ts",
"src/index.tsx!"
],
"project": [
"src/**/*.d.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"src/**/*.tsx!",
"src/**/*.ts!"
]
}
20 changes: 8 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"build": "vite build",
"preview": "vite preview",
"generate-and-watch:type": "graphql-codegen --require dotenv/config --config codegen.ts --watch",
"generate:type": "graphql-codegen --require dotenv/config --config codegen.ts && eslint --fix generated/",
"generate:type": "graphql-codegen --require dotenv/config --config codegen.ts",
"typecheck": "tsc",
"lint": "pnpm lint:js && pnpm lint:css",
"lint:fix": "pnpm lint:js --fix && pnpm lint:css --fix",
"lint:js": "eslint src",
"lint:css": "stylelint \"./src/**/*.css\"",
"lint": "yarn lint:js && yarn lint:css",
"lint:unused": "knip",
"lint:fix": "yarn lint:js --fix && yarn lint:css --fix",
"lint:unused": "knip --tags=-knipignore",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"postinstall": "patch-package"
Expand All @@ -40,11 +40,8 @@
"urql": "^4.1.0"
},
"devDependencies": {
"@eslint/eslintrc": "^2.0.3",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/client-preset": "^4.3.3",
"@graphql-codegen/introspection": "^4.0.3",
"@graphql-codegen/typescript-operations": "^4.2.3",
"@graphql-typed-document-node/core": "^3.2.0",
"@julr/vite-plugin-validate-env": "^1.0.1",
"@types/node": "^20.11.6",
Expand All @@ -57,27 +54,26 @@
"@vitejs/plugin-react-swc": "^3.5.0",
"@vitest/coverage-v8": "^1.2.2",
"autoprefixer": "^10.4.14",
"core": "link:@types/dnd-kit/core",
"dotenv": "^16.4.5",
"eslint": "^8.40.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-import-exports-imports-resolver": "^1.0.1",
"eslint-plugin-import-newlines": "^1.3.4",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"eslint-plugin-simple-import-sort": "^10.0.0",
"knip": "^5.27.3",
"graphql": "^16.9.0",
"happy-dom": "^15.7.3",
"knip": "^5.29.2",
"patch-package": "^7.0.0",
"postcss": "^8.3.0",
"postcss-nested": "^6.0.1",
"postcss-normalize": "^10.0.1",
"postcss-preset-env": "^8.3.2",
"postinstall-postinstall": "^2.1.0",
"rollup-plugin-visualizer": "^5.9.0",
"sortable": "link:@types/dnd-kit/sortable",
"stylelint": "^16.7.0",
"stylelint-config-concentric": "^2.0.2",
"stylelint-config-recommended": "^14.0.1",
Expand Down
Loading

0 comments on commit 7aeeaf8

Please sign in to comment.