Skip to content

Commit

Permalink
Eslint refacto (#599)
Browse files Browse the repository at this point in the history
* adding option & lint

* cleanup

* add some docs ;)
  • Loading branch information
jycouet authored Jan 9, 2024
1 parent 7411161 commit 5a2f362
Show file tree
Hide file tree
Showing 31 changed files with 460 additions and 406 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-feet-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-plugin-kit-routes': patch
---

remove a warning log that is internal
5 changes: 5 additions & 0 deletions .changeset/rare-papayas-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kitql/eslint-config': patch
---

add option to format by file/dir/glob with arg `-g`
16 changes: 0 additions & 16 deletions packages/create-kitql/templates/sveltekit-remult/.eslintignore

This file was deleted.

35 changes: 3 additions & 32 deletions packages/create-kitql/templates/sveltekit-remult/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
/** @type { import("eslint").Linter.FlatConfig } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
rules: {
// Some specific rules ?
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};
extends: ['@kitql'],
rules: {},
}
6 changes: 3 additions & 3 deletions packages/create-kitql/templates/sveltekit-remult/.meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "SvelteKit Remult",
"hint": "Minimul setup for SvelteKit & Remult",
"order": 2
"label": "SvelteKit Remult",
"hint": "Minimul setup for SvelteKit & Remult",
"order": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ package-lock.json
yarn.lock

# Ignore files that are project specific
/db
/db
8 changes: 0 additions & 8 deletions packages/create-kitql/templates/sveltekit-remult/.prettierrc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = require('@kitql/eslint-config/.prettierrc.cjs')

module.exports = {
...config,
// Some custom things?
}
3 changes: 1 addition & 2 deletions packages/create-kitql/templates/sveltekit-remult/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ TODO...

## Info

xxx.spec.ts for unit test
xxx.e2e.ts for e2e test
xxx.spec.ts for unit test xxx.e2e.ts for e2e test
72 changes: 33 additions & 39 deletions packages/create-kitql/templates/sveltekit-remult/package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
{
"name": "create-kitql-sveltekit-remult",
"version": "0.0.1",
"type": "module",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:w": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"test": "vitest",
"test:e2e": "playwright test",
"test:ci": "npm run test:e2e && npm run test"
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.30.0",
"pg": "^8.11.3",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.0",
"remult": "^0.24.1",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.0",
"vite-plugin-kit-routes": "0.5.0",
"vite-plugin-striper": "0.3.1",
"vitest": "^1.0.0"
}
"name": "create-kitql-sveltekit-remult",
"version": "0.0.1",
"type": "module",
"private": true,
"scripts": {
"build": "vite build",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:w": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"dev": "vite dev",
"format": "kitql-lint --format",
"lint": "kitql-lint",
"preview": "vite preview",
"test": "vitest",
"test:ci": "npm run test:e2e && npm run test",
"test:e2e": "playwright test"
},
"devDependencies": {
"@kitql/eslint-config": "^0.1.0",
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"pg": "^8.11.3",
"remult": "^0.24.1",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.0",
"vite-plugin-kit-routes": "^0.5.0",
"vite-plugin-stripper": "^0.3.2",
"vitest": "^1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test'

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testMatch: /(.+\.)?(e2e)\.[jt]s/
};
webServer: {
command: 'npm run build && npm run preview',
port: 4173,
},
testMatch: /(.+\.)?(e2e)\.[jt]s/,
}

export default config;
export default config
14 changes: 7 additions & 7 deletions packages/create-kitql/templates/sveltekit-remult/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}

export {};
export {}
18 changes: 9 additions & 9 deletions packages/create-kitql/templates/sveltekit-remult/src/app.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sequence } from '@sveltejs/kit/hooks';
import { handleRemult } from './hooks/handleRemult';
import { sequence } from '@sveltejs/kit/hooks'

export const handle = sequence(handleRemult);
import { handleRemult } from './hooks/handleRemult'

export const handle = sequence(handleRemult)
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { remultSveltekit } from 'remult/remult-sveltekit';
import { remult } from 'remult'
import { remultSveltekit } from 'remult/remult-sveltekit'

// import { createPostgresDataProvider } from 'remult/postgres';
// import { DATABASE_URL } from '$env/static/private';
import { entities, controllers } from '../shared';
import { remult } from 'remult';
import { Task } from '../shared';
import { entities, controllers } from '../shared'
import { Task } from '../shared'

export const handleRemult = remultSveltekit({
// dataProvider: createPostgresDataProvider({ connectionString: DATABASE_URL })
entities,
controllers,
initApi: async () => {
try {
if ((await remult.repo(Task).count()) === 0) {
await remult.repo(Task).insert({ title: 'Well done!' });
await remult
.repo(Task)
.insert({ title: "You've successfully created a new KitQL remult project. 🚀" });
}
} catch (error) {
console.error(error);
}
}
});
// dataProvider: createPostgresDataProvider({ connectionString: DATABASE_URL })
entities,
controllers,
initApi: async () => {
try {
if ((await remult.repo(Task).count()) === 0) {
await remult.repo(Task).insert({ title: 'Well done!' })
await remult
.repo(Task)
.insert({ title: "You've successfully created a new KitQL remult project. 🚀" })
}
} catch (error) {
console.error(error)
}
},
})
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { describe, it, expect } from 'vitest';
import { route } from './ROUTES';
import { describe, it, expect } from 'vitest'

import { route } from './ROUTES'

describe('ROUTES', () => {
it('root path is /', () => {
expect(route('/')).toBe('/');
});
});
it('root path is /', () => {
expect(route('/')).toBe('/')
})
})
Loading

0 comments on commit 5a2f362

Please sign in to comment.