feat: Migrate ESLint to flat config and resolve initial linting errors
Migrated the ESLint configuration to the new flat config format () and addressed several initial linting errors. Key changes include: - Updated ESLint configuration to treat as warnings instead of errors. - Fixed errors in by declaring and . - Corrected error in by using instead of an out-of-scope . - Resolved error in by replacing the undefined directive with the component. - Addressed errors in by replacing with and with . - Fixed errors in by importing necessary modules (, , ) and adding missing props (, , , , ).
This commit is contained in:
@@ -8,11 +8,11 @@ Svelte 5 introduces "runes" as a new way to manage reactivity. This is a major c
|
||||
|
||||
### Key Breaking Changes
|
||||
|
||||
* **`let` is no longer reactive:** In Svelte 4, any `let` variable declared in the top-level scope of a component was automatically reactive. In Svelte 5, you must explicitly declare reactive state using the `$state` rune.
|
||||
* **`$:` is replaced by `$derived` and `$effect`:** The `$` label is no longer used for reactive statements. Instead, you should use the `$derived` rune for computed values and the `$effect` rune for side effects.
|
||||
* **`export let` is replaced by `$props`:** Component props are now declared using the `$props` rune, which provides a more flexible and explicit way to define component APIs.
|
||||
* **Event handling:** The `on:` directive is replaced by event attributes (e.g., `onclick`). Component events are now handled using callback props instead of `createEventDispatcher`.
|
||||
* **Slots are replaced by snippets:** The `<slot>` element is replaced by the `{#snippet ...}` block, which provides a more powerful and flexible way to pass content to components.
|
||||
- **`let` is no longer reactive:** In Svelte 4, any `let` variable declared in the top-level scope of a component was automatically reactive. In Svelte 5, you must explicitly declare reactive state using the `$state` rune.
|
||||
- **`$:` is replaced by `$derived` and `$effect`:** The `$` label is no longer used for reactive statements. Instead, you should use the `$derived` rune for computed values and the `$effect` rune for side effects.
|
||||
- **`export let` is replaced by `$props`:** Component props are now declared using the `$props` rune, which provides a more flexible and explicit way to define component APIs.
|
||||
- **Event handling:** The `on:` directive is replaced by event attributes (e.g., `onclick`). Component events are now handled using callback props instead of `createEventDispatcher`.
|
||||
- **Slots are replaced by snippets:** The `<slot>` element is replaced by the `{#snippet ...}` block, which provides a more powerful and flexible way to pass content to components.
|
||||
|
||||
For a complete list of breaking changes, refer to the [Svelte 5 migration guide](https://svelte.dev/docs/svelte/v5-migration-guide).
|
||||
|
||||
@@ -22,24 +22,24 @@ Dexie.js is a lightweight, minimalistic wrapper for IndexedDB that makes it easi
|
||||
|
||||
### Key Classes and Methods
|
||||
|
||||
* **`Dexie`:** The main class for creating and managing IndexedDB databases.
|
||||
* `new Dexie(databaseName)`: Creates a new database instance.
|
||||
* `version(versionNumber).stores({ ... })`: Defines the database schema.
|
||||
* **`Table`:** Represents an object store (table) in the database.
|
||||
* `add(item)`: Adds a new item to the table.
|
||||
* `put(item)`: Adds or updates an item in the table.
|
||||
* `update(key, changes)`: Updates an existing item.
|
||||
* `delete(key)`: Deletes an item by its primary key.
|
||||
* `get(key)`: Retrieves an item by its primary key.
|
||||
* `where(index)`: Starts a query using an index.
|
||||
* `toArray()`: Retrieves all items from the table as an array.
|
||||
* **`Collection`:** Represents a collection of items resulting from a query.
|
||||
* `toArray()`: Retrieves all items in the collection as an array.
|
||||
* `first()`: Retrieves the first item in the collection.
|
||||
* `last()`: Retrieves the last item in the collection.
|
||||
* `each(callback)`: Iterates over each item in the collection.
|
||||
* `modify(changes)`: Updates all items in the collection.
|
||||
* `delete()`: Deletes all items in the collection.
|
||||
- **`Dexie`:** The main class for creating and managing IndexedDB databases.
|
||||
- `new Dexie(databaseName)`: Creates a new database instance.
|
||||
- `version(versionNumber).stores({ ... })`: Defines the database schema.
|
||||
- **`Table`:** Represents an object store (table) in the database.
|
||||
- `add(item)`: Adds a new item to the table.
|
||||
- `put(item)`: Adds or updates an item in the table.
|
||||
- `update(key, changes)`: Updates an existing item.
|
||||
- `delete(key)`: Deletes an item by its primary key.
|
||||
- `get(key)`: Retrieves an item by its primary key.
|
||||
- `where(index)`: Starts a query using an index.
|
||||
- `toArray()`: Retrieves all items from the table as an array.
|
||||
- **`Collection`:** Represents a collection of items resulting from a query.
|
||||
- `toArray()`: Retrieves all items in the collection as an array.
|
||||
- `first()`: Retrieves the first item in the collection.
|
||||
- `last()`: Retrieves the last item in the collection.
|
||||
- `each(callback)`: Iterates over each item in the collection.
|
||||
- `modify(changes)`: Updates all items in the collection.
|
||||
- `delete()`: Deletes all items in the collection.
|
||||
|
||||
For a complete list of API methods, refer to the [Dexie.js API Reference](https://dexie.org/docs/API-Reference).
|
||||
|
||||
@@ -63,13 +63,13 @@ import { readable } from 'svelte/store';
|
||||
import { db } from './db'; // Your Dexie database instance
|
||||
|
||||
export function createLiveQueryStore<T>(query: () => T | Promise<T>) {
|
||||
return readable<T | undefined>(undefined, (set) => {
|
||||
const subscription = liveQuery(query).subscribe({
|
||||
next: (result) => set(result),
|
||||
error: (error) => console.error(error),
|
||||
});
|
||||
return () => subscription.unsubscribe();
|
||||
});
|
||||
return readable<T | undefined>(undefined, (set) => {
|
||||
const subscription = liveQuery(query).subscribe({
|
||||
next: (result) => set(result),
|
||||
error: (error) => console.error(error)
|
||||
});
|
||||
return () => subscription.unsubscribe();
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
@@ -77,18 +77,16 @@ export function createLiveQueryStore<T>(query: () => T | Promise<T>) {
|
||||
|
||||
```html
|
||||
<script>
|
||||
import { createLiveQueryStore } from './stores';
|
||||
import { db } from './db';
|
||||
import { createLiveQueryStore } from './stores';
|
||||
import { db } from './db';
|
||||
|
||||
const friends = createLiveQueryStore(() => db.friends.toArray());
|
||||
const friends = createLiveQueryStore(() => db.friends.toArray());
|
||||
</script>
|
||||
|
||||
<ul>
|
||||
{#if $friends}
|
||||
{#each $friends as friend}
|
||||
<li>{friend.name}</li>
|
||||
{/each}
|
||||
{/if}
|
||||
{#if $friends} {#each $friends as friend}
|
||||
<li>{friend.name}</li>
|
||||
{/each} {/if}
|
||||
</ul>
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user