Skip to content

Commit

Permalink
refactor: upgrade tools and implement svelte store for item list
Browse files Browse the repository at this point in the history
- restructure src folder and component organization
- implement items store for better state management
- upgrade to Bun and add lint/typecheck to GitHub actions
- replace Prettier with ESLint for formatting and linting
- add Iconify with Tabler icon pack
- simplify component logic and fix Item tests
  • Loading branch information
Rettend authored Jul 7, 2024
1 parent 44c762a commit 45ac2e6
Show file tree
Hide file tree
Showing 36 changed files with 1,081 additions and 7,048 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy to GitHub Pages
on:
push:
branches: 'main'
branches: main

jobs:
build_site:
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/upload-pages-artifact@v3
with:
# this should match the `pages` option in your adapter-static options
path: 'build/'
path: build/

deploy:
needs: build_site
Expand Down
41 changes: 32 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,44 @@ on:
branches: [main]

jobs:
run-tests:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: npm install
run: bun i

- name: Run Tests
run: npm run test
run: bun run test

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun i

- name: Run Lint
run: bun run lint

typecheck:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun i

- name: Run Typecheck
run: bun run typecheck
4 changes: 0 additions & 4 deletions .prettierignore

This file was deleted.

8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

50 changes: 50 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "warn" },
{ "rule": "format/*", "severity": "warn" },
{ "rule": "*-indent", "severity": "warn" },
{ "rule": "*-spacing", "severity": "warn" },
{ "rule": "*-spaces", "severity": "warn" },
{ "rule": "*-order", "severity": "warn" },
{ "rule": "*-dangle", "severity": "warn" },
{ "rule": "*-newline", "severity": "warn" },
{ "rule": "*quotes", "severity": "warn" },
{ "rule": "*semi", "severity": "warn" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"less",
"scss",
"pcss",
"postcss",
"svelte"
]
}
70 changes: 52 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,72 @@
# create-svelte
# Bun bun bun

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
More info: [Bun Docs](https://bun.sh/docs)

## Creating a project
>[!TIP]
> just `bun` can be used as shorthand for pretty much all of its commands.
If you're seeing this, you've probably already done this step. Congrats!
## Install

### Install all dependencies

```bash
# create a new project in the current directory
npm create svelte@latest
bun i
```

### Install a specific package

# create a new project in my-app
npm create svelte@latest my-app
```bash
bun i <package>
```

## Developing
#### Flags

- `-g` to install globally
- `-D` to install as a dev dependency

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
## Development

```bash
npm run dev
bun dev
```

# or start the server and open the app in a new browser tab
npm run dev -- --open
## Build

```bash
bun build
```

## Building
## Running

To create a production version of your app:
### Scripts

```bash
npm run build
bun run <script>
```

You can preview the production build with `npm run preview`.
Example: `bun lint`

### Binaries

```bash
bunx <binary>
```

`bun run` also works

Example: `bun eslint`

>[!NOTE]
> To use the Bun runtime (instead of Node.js), pass `--bun` to the command: `bunx --bun vite dev`
### Files

```bash
bun run <file>
```

Example: `bun src/index.ts`

## `ni`

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
To forget about package managers: [antfu/ni](https://github.com/antfu-collective/ni?tab=readme-ov-file#ni)
Binary file added bun.lockb
Binary file not shown.
42 changes: 10 additions & 32 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
import antfu from '@antfu/eslint-config'

/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
];
export default antfu({
svelte: true,
rules: {
'svelte/valid-compile': 'off',
'no-console': 'off',
'svelte/html-quotes': ['warn', { prefer: 'double' }],
'curly': ['warn', 'multi-or-nest', 'consistent'],
},
})
Loading

0 comments on commit 45ac2e6

Please sign in to comment.