Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
setup eslint/prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
threepointone committed Nov 29, 2024
1 parent 48e5d08 commit b0ab510
Show file tree
Hide file tree
Showing 12 changed files with 3,412 additions and 476 deletions.
5 changes: 1 addition & 4 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "threepointone/durable-scheduler" }
],
"changelog": ["@changesets/changelog-github", { "repo": "threepointone/durable-scheduler" }],
"commit": false,
"fixed": [],
"linked": [],
Expand Down
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"printWidth": 100,
"tabWidth": 2,
"useTabs": false
}
72 changes: 72 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import js from '@eslint/js'
import tseslint from '@typescript-eslint/eslint-plugin'
import tsparser from '@typescript-eslint/parser'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import importPlugin from 'eslint-plugin-import'
import prettier from 'eslint-config-prettier'

export default [
js.configs.recommended,
{
linterOptions: {
reportUnusedDisableDirectives: true,
},
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
projectService: true,
},
},
plugins: {
'@typescript-eslint': tseslint,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
import: importPlugin,
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: true,
node: true,
},
},
rules: {
// TypeScript rules
...tseslint.configs.recommended.rules,
'no-undef': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],

// React rules
...reactPlugin.configs.recommended.rules,
'react/react-in-jsx-scope': 'off',
...reactHooksPlugin.configs.recommended.rules,

// Import rules
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling'], 'index'],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],

// General rules
'no-console': ['warn', { allow: ['warn', 'error'] }],
},
},
{
ignores: ['dist/**', 'node_modules/**', 'coverage/**', '.github/**'],
},
prettier,
]
1 change: 1 addition & 0 deletions example/src/client/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createRoot } from "react-dom/client";

import App from "./app";
import "./index.css";

Expand Down
18 changes: 7 additions & 11 deletions example/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Scheduler } from "../../../src";
import { z } from "zod";

import { Scheduler } from "../../../src";

type Env = {
AI: Ai;
SCHEDULER: DurableObjectNamespace<MyScheduler>;
Expand Down Expand Up @@ -38,10 +39,7 @@ export class MyScheduler extends Scheduler<Env> {
const url = new URL(request.url);

if (!url.pathname.startsWith("/api/")) {
return fetch(
request.url.replace("http://localhost:8787", "http://localhost:5173"),
request
);
return fetch(request.url.replace("http://localhost:8787", "http://localhost:5173"), request);
}

const route = `${request.method} ${url.pathname}`;
Expand Down Expand Up @@ -82,9 +80,10 @@ export class MyScheduler extends Scheduler<Env> {
`,
});

// @ts-expect-error
// @ts-expect-error - this is a string
// eslint-disable-next-line no-console
console.log(result.response);
// @ts-expect-error
// @ts-expect-error - this is a string
return new Response(result.response as string);
}

Expand All @@ -110,10 +109,7 @@ export default {
const url = new URL(request.url);

if (!url.pathname.startsWith("/api/")) {
return fetch(
request.url.replace("http://localhost:8787", "http://localhost:5173"),
request
);
return fetch(request.url.replace("http://localhost:8787", "http://localhost:5173"), request);
}

const id = env.SCHEDULER.idFromName("example");
Expand Down
2 changes: 1 addition & 1 deletion example/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

// https://vite.dev/config/
export default defineConfig({
Expand Down
Loading

0 comments on commit b0ab510

Please sign in to comment.