Skip to content

Commit

Permalink
example: stylecheck and format.
Browse files Browse the repository at this point in the history
  • Loading branch information
thruflo committed Nov 22, 2024
1 parent 7472cf0 commit e731ecb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
36 changes: 18 additions & 18 deletions examples/write-patterns/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@ module.exports = {
node: true,
},
extends: [
`eslint:recommended`,
`plugin:@typescript-eslint/recommended`,
`plugin:prettier/recommended`,
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2022,
requireConfigFile: false,
sourceType: `module`,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
parser: `@typescript-eslint/parser`,
plugins: [`prettier`],
parser: '@typescript-eslint/parser',
plugins: ['prettier'],
rules: {
quotes: [`error`, `backtick`],
"no-unused-vars": `off`,
"@typescript-eslint/no-unused-vars": [
`error`,
quotes: ['error', 'single'],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: `^_`,
varsIgnorePattern: `^_`,
caughtErrorsIgnorePattern: `^_`,
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
ignorePatterns: [
`**/node_modules/**`,
`**/dist/**`,
`tsup.config.ts`,
`vitest.config.ts`,
`.eslintrc.js`,
'**/node_modules/**',
'**/dist/**',
'tsup.config.ts',
'vitest.config.ts',
'.eslintrc.js',
],
}
4 changes: 2 additions & 2 deletions examples/write-patterns/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"tabWidth": 2
"tabWidth": 2,
"trailingComma": "es5"
}
1 change: 1 addition & 0 deletions examples/write-patterns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"db:migrate": "dotenv -e ../../.env.dev -- pnpm exec pg-migrations apply --directory ./shared/migrations",
"dev": "concurrently \"vite\" \"node shared/backend/api.js\"",
"build": "vite build",
"format": "eslint . --ext ts,tsx --fix",
"stylecheck": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"typecheck": "tsc --noEmit"
Expand Down
11 changes: 4 additions & 7 deletions examples/write-patterns/patterns/1-online-writes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ export default function OnlineWrites() {
})

if (isLoading) {
return (
<div className="loading">Loading &hellip;</div>
)
return <div className="loading">Loading &hellip;</div>
}

const todos = data
? data.sort((a, b) => a.created_at - b.created_at)
: []
const todos = data ? data.sort((a, b) => a.created_at - b.created_at) : []

async function handleChange(id: string, completed: boolean) {
await client.updateTodo(id, {completed: !completed})
await client.updateTodo(id, { completed: !completed })
}

async function handleDelete(event: React.MouseEvent, id: string) {
Expand All @@ -50,6 +46,7 @@ export default function OnlineWrites() {
form.reset()
}

// prettier-ignore
return (
<div id="online-writes" className="example">
<h3>Online writes</h3>
Expand Down
6 changes: 3 additions & 3 deletions examples/write-patterns/shared/app/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ async function request(url: string, method: string, data?: object) {
const options: RequestOptions = {
method: method,
headers: {
'Content-Type': `application/json`
}
'Content-Type': 'application/json',
},
}

if (data) {
Expand All @@ -27,7 +27,7 @@ export async function createTodo(title: string) {
const url = `${API_URL}/todos`
const data = {
id: uuidv4(),
title: title
title: title,
}

return await request(url, 'POST', data)
Expand Down

0 comments on commit e731ecb

Please sign in to comment.