From e4111ee4e9b941ed921df8ca2981e84fd619fabb Mon Sep 17 00:00:00 2001 From: sevonj <100710152+sevonj@users.noreply.github.com> Date: Mon, 9 Jun 2025 14:18:23 +0300 Subject: [PATCH] ci: build & lint --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ README.md | 2 ++ eslint.config.js | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 8 +++++++- 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 eslint.config.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..aed0666e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: CI +on: + - push + - pull_request +jobs: + ci: + runs-on: ubuntu-latest + name: CI + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: install + run: npm install + - name: deps + run: npm ci + - name: build + run: npm run build + - name: lint + run: npm run lint diff --git a/README.md b/README.md index 085b519a..76eb59e5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Photon +[![CI](https://github.com/sevonj/photon/actions/workflows/ci.yml/badge.svg)](https://github.com/sevonj/photon/actions/workflows/ci.yml) + Photon is a Svelte-based opinionated Lemmy client designed for the best UI and UX. Every feature is carefully considered and placed. - `🌟` A stunning UI diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..16523718 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,39 @@ +import js from '@eslint/js'; +import { includeIgnoreFile } from '@eslint/compat'; +import svelte from 'eslint-plugin-svelte'; +import globals from 'globals'; +import { fileURLToPath } from 'node:url'; +import ts from 'typescript-eslint'; +import svelteConfig from './svelte.config.js'; + +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); + +export default ts.config( + includeIgnoreFile(gitignorePath), + js.configs.recommended, + ...ts.configs.recommended, + ...svelte.configs.recommended, + { + languageOptions: { + globals: { ...globals.browser, ...globals.node } + }, + rules: { // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects. + // see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + "no-undef": 'off' } + }, + { + files: [ + '**/*.svelte', + '**/*.svelte.ts', + '**/*.svelte.js' + ], + languageOptions: { + parserOptions: { + projectService: true, + extraFileExtensions: ['.svelte'], + parser: ts.parser, + svelteConfig + } + } + } +); diff --git a/package.json b/package.json index 057b0fdd..7a29b868 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "devDependencies": { "@dicebear/core": "^8.0.1", "@dicebear/initials": "^8.0.1", + "@eslint/compat": "^1.2.9", + "@eslint/js": "^9.28.0", "@svelte-put/qr": "^2.0.0", "@sveltejs/adapter-auto": "^3.3.1", "@sveltejs/adapter-node": "^5.2.9", @@ -14,6 +16,8 @@ "@tailwindcss/postcss": "^4.1.8", "@types/nprogress": "^0.2.0", "@types/ua-parser-js": "^0.7.39", + "eslint": "^9.28.0", + "eslint-plugin-svelte": "^3.9.1", "jsdom": "^22.1.0", "lemmy-js-client": "^0.19.6-beta.1", "linkify-it": "^5.0.0", @@ -36,6 +40,7 @@ "tailwindcss": "^4.1.8", "tslib": "^2.4.1", "typescript": "^5.5.0", + "typescript-eslint": "^8.33.1", "ua-parser-js": "^1.0.38", "vite": "^5.4.14", "vitest": "^1.0.0" @@ -54,7 +59,8 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "format": "prettier --write .", - "format:specific": "prettier --write" + "format:specific": "prettier --write", + "lint": "eslint ." }, "type": "module", "dependencies": {