Skip to content

Commit

Permalink
chore: use eslint old config
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jan 20, 2024
1 parent b33614c commit 678f1da
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 81 deletions.
38 changes: 38 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/strict-type-checked",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./playground/tsconfig.json"],
},
root: true,
ignorePatterns: ["*.js", "*.cjs", "*.mjs", "dist"],
reportUnusedDisableDirectives: true,
settings: {
next: {
rootDir: "playground",
},
},
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],

"@typescript-eslint/no-non-null-assertion": "off",

"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/no-import-type-side-effects": "error",

"no-console": ["warn", { allow: ["warn", "error", "table"] }],
},
}
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.experimental.useFlatConfig": true
"editor.formatOnSave": true
}
70 changes: 0 additions & 70 deletions eslint.config.js

This file was deleted.

6 changes: 4 additions & 2 deletions playground/src/app/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import {
} from "@/components/ui/table"
import { kv } from "@/lib/storage"
import { cn } from "@/lib/utils"
import { getDependents, ParseResult } from "izon"
import { getDependents } from "izon"
import { Suspense } from "react"

import type { ParseResult } from "izon"

const cachePrefix = "dependents-"

function DependentTable({
Expand Down Expand Up @@ -90,7 +92,7 @@ async function DependentsRealtime({
const dependents = await getDependents(packageName, {
resume: cached,
})
kv.setItem(`${cachePrefix}${packageName}`, dependents)
await kv.setItem(`${cachePrefix}${packageName}`, dependents)
return (
<DependentTable
parseResult={{
Expand Down
125 changes: 122 additions & 3 deletions playground/src/app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use server"

import { RepositoryList } from "@/components/github-repository-selector"
import { env } from "@/env.mjs"
import { kv } from "@/lib/storage"

import type { RepositoryList } from "@/components/github-repository-selector"

export async function queryRepositoryList(
query?: string,
): Promise<RepositoryList> {
Expand All @@ -29,12 +30,130 @@ export async function queryRepositoryList(
},
},
)
.then((res) => res.json())
.then((res) => res.json() as Promise<GitHubQueryResult>)
.then((res) => {
return res.items.map((item: any) => ({
return res.items.map((item) => ({
name: item.full_name,
avatarUrl: item.owner.avatar_url,
}))
})
return repositoryList
}

interface GitHubQueryResult {
total_count: number
incomplete_results: boolean
items: Item[]
}

interface Item {
id: number
node_id: string
name: string
full_name: string
private: boolean
owner: Owner
html_url: string
description: string
fork: boolean
url: string
forks_url: string
keys_url: string
collaborators_url: string
teams_url: string
hooks_url: string
issue_events_url: string
events_url: string
assignees_url: string
branches_url: string
tags_url: string
blobs_url: string
git_tags_url: string
git_refs_url: string
trees_url: string
statuses_url: string
languages_url: string
stargazers_url: string
contributors_url: string
subscribers_url: string
subscription_url: string
commits_url: string
git_commits_url: string
comments_url: string
issue_comment_url: string
contents_url: string
compare_url: string
merges_url: string
archive_url: string
downloads_url: string
issues_url: string
pulls_url: string
milestones_url: string
notifications_url: string
labels_url: string
releases_url: string
deployments_url: string
created_at: string
updated_at: string
pushed_at: string
git_url: string
ssh_url: string
clone_url: string
svn_url: string
homepage: string
size: number
stargazers_count: number
watchers_count: number
language: string
has_issues: boolean
has_projects: boolean
has_downloads: boolean
has_wiki: boolean
has_pages: boolean
has_discussions: boolean
forks_count: number
mirror_url: unknown
archived: boolean
disabled: boolean
open_issues_count: number
license: License
allow_forking: boolean
is_template: boolean
web_commit_signoff_required: boolean
topics: string[]
visibility: string
forks: number
open_issues: number
watchers: number
default_branch: string
score: number
}

interface Owner {
login: string
id: number
node_id: string
avatar_url: string
gravatar_id: string
url: string
html_url: string
followers_url: string
following_url: string
gists_url: string
starred_url: string
subscriptions_url: string
organizations_url: string
repos_url: string
events_url: string
received_events_url: string
type: string
site_admin: boolean
}

interface License {
key: string
name: string
spdx_id: string
url: string
node_id: string
}
6 changes: 3 additions & 3 deletions playground/src/components/github-repository-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function GitHubRepositorySelector() {
>
{currentRepository ? (
<RepositoryInfo repository={currentRepository} />
) : !!value ? (
) : value ? (
value
) : (
"Select GitHub repository"
Expand All @@ -89,9 +89,9 @@ export function GitHubRepositorySelector() {
value={search}
onValueChange={setSearch}
/>
{repositoryList && repositoryList?.length > 0 && (
{repositoryList && repositoryList.length > 0 && (
<CommandGroup>
{repositoryList?.map((repo) => (
{repositoryList.map((repo) => (
<CommandItem
key={repo.name}
value={repo.name}
Expand Down
3 changes: 2 additions & 1 deletion playground/src/components/ui/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import { Dialog, DialogContent } from "@/components/ui/dialog"
import { cn } from "@/lib/utils"
import { type DialogProps } from "@radix-ui/react-dialog"
import { Command as CommandPrimitive } from "cmdk"
import { Search } from "lucide-react"
import * as React from "react"

import type { DialogProps } from "@radix-ui/react-dialog"

const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
Expand Down
1 change: 1 addition & 0 deletions playground/src/lib/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createStorage } from "unstorage"
import cloudflareKVHTTPDriver from "unstorage/drivers/cloudflare-kv-http"

export const kv = createStorage({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
driver: cloudflareKVHTTPDriver({
accountId: env.CF_ACCOUNT_ID,
namespaceId: env.CF_NAMESPACE_ID,
Expand Down

0 comments on commit 678f1da

Please sign in to comment.