Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ESLint latest rules and database query name checks #3

Open
wants to merge 7 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from 'react';
import type { ReactNode } from 'react';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import all types using type-only import

import styles from './ErrorMessage.module.scss';

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion app/animals/dashboard/AnimalsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { gql, useMutation, useSuspenseQuery } from '@apollo/client';
import { useState } from 'react';
import ErrorMessage from '../../../ErrorMessage';
import { Animal } from '../../../migrations/00000-createTableAnimals';
import type { Animal } from '../../../migrations/00000-createTableAnimals';
import styles from './AnimalsForm.module.scss';

const createAnimalMutation = gql`
Expand Down
2 changes: 1 addition & 1 deletion app/api/graphql/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
getUserInsecure,
getUserWithPasswordHashInsecure,
} from '../../../database/users';
import { Animal, Resolvers } from '../../../graphql/graphqlGeneratedTypes';
import type { Animal, Resolvers } from '../../../graphql/graphqlGeneratedTypes';

export type Context = {
sessionTokenCookie?: { value: string };
Expand Down
2 changes: 1 addition & 1 deletion app/notes/NotesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import ErrorMessage from '../../ErrorMessage';
import { Note } from '../../migrations/00004-createTableNotes';
import type { Note } from '../../migrations/00004-createTableNotes';
import styles from './NotesForm.module.scss';

type Props = {
Expand Down
3 changes: 2 additions & 1 deletion codegen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodegenConfig } from '@graphql-codegen/cli';
import type { CodegenConfig } from '@graphql-codegen/cli';

const codegenConfig: CodegenConfig = {
overwrite: true,
Expand All @@ -11,6 +11,7 @@ const codegenConfig: CodegenConfig = {

config: {
contextType: '../app/api/graphql/route#Context',
useTypeImports: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make codegen use type-only import for types

},
};
export default codegenConfig;
2 changes: 1 addition & 1 deletion database/animals.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cache } from 'react';
import { postgresToGraphql } from '../graphql/transform';
import { Animal } from '../migrations/00000-createTableAnimals';
import type { Animal } from '../migrations/00000-createTableAnimals';
import { sql } from './connect';

export const createAnimal = cache(
Expand Down
4 changes: 2 additions & 2 deletions database/connect.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'server-only';
import postgres, { Sql } from 'postgres';
import postgres, { type Sql } from 'postgres';
import { postgresConfig, setEnvironmentVariables } from '../util/config';

// This loads all environment variables from a .env file
// for all code after this line
setEnvironmentVariables();

// Type needed for the connection function below
declare module globalThis {
declare namespace globalThis {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module is now called namespace
Screenshot 2024-10-17 at 14 26 22

let postgresSqlClient: Sql;
}

Expand Down
2 changes: 1 addition & 1 deletion database/notes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cache } from 'react';
import { postgresToGraphql } from '../graphql/transform';
import { Note } from '../migrations/00004-createTableNotes';
import type { Note } from '../migrations/00004-createTableNotes';
import { sql } from './connect';

export const getNotes = cache(async (sessionToken: string) => {
Expand Down
2 changes: 1 addition & 1 deletion database/sessions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cache } from 'react';
import { Session } from '../migrations/00005-createTableSessions';
import type { Session } from '../migrations/00005-createTableSessions';
import { sql } from './connect';

export const getValidSession = cache(async (sessionToken: string) => {
Expand Down
2 changes: 1 addition & 1 deletion database/users.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cache } from 'react';
import { User } from '../migrations/00002-createTableUsers';
import type { User } from '../migrations/00002-createTableUsers';
import { sql } from './connect';

type UserWithPasswordHash = User & {
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import u from 'eslint-config-upleveled';const c=u.filter(d=>d.name!=='upleveled:database-auth');export default c;
export { default } from 'eslint-config-upleveled';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the ESLint disable for database function name auth

2 changes: 1 addition & 1 deletion migrations/00000-createTableAnimals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sql } from 'postgres';
import type { Sql } from 'postgres';

export type Animal = {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion migrations/00001-insertAnimals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sql } from 'postgres';
import type { Sql } from 'postgres';

const animals = [
{
Expand Down
2 changes: 1 addition & 1 deletion migrations/00002-createTableUsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sql } from 'postgres';
import type { Sql } from 'postgres';

export type User = {
id: number;
Expand Down
6 changes: 3 additions & 3 deletions migrations/00004-createTableNotes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sql } from 'postgres';
import type { Sql } from 'postgres';

export type Note = {
id: number;
Expand All @@ -12,8 +12,8 @@ export async function up(sql: Sql) {
CREATE TABLE notes (
id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
title varchar(100) NOT NULL,
text_content TEXT NOT NULL,
user_id integer NOT NULL REFERENCES users (id) ON DELETE CASCADE
text_content text NOT NULL,
user_id integer NOT NULL REFERENCES users (id) ON DELETE cascade
);
`;
}
Expand Down
2 changes: 1 addition & 1 deletion migrations/00005-createTableSessions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sql } from 'postgres';
import type { Sql } from 'postgres';

export type Session = {
id: number;
Expand Down
8 changes: 0 additions & 8 deletions next.config.js

This file was deleted.

16 changes: 16 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
experimental: {
dynamicIO: true,
typedRoutes: true,
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
};

export default nextConfig;
Comment on lines +1 to +16
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the latest next. config setting

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@apollo/experimental-nextjs-app-support": "^0.11.3",
"@apollo/server": "^4.11.0",
"@as-integrations/next": "^3.1.0",
"@graphql-tools/schema": "^10.0.6",
"@graphql-tools/schema": "^10.0.7",
"@upleveled/ley": "^0.9.2",
"bcrypt": "^5.1.1",
"dotenv-safe": "^9.1.0",
Expand All @@ -25,31 +25,31 @@
"postgres": "^3.4.4",
"react": "19.0.0-rc.0",
"react-dom": "19.0.0-rc.0",
"sass": "^1.79.4",
"sass": "^1.80.1",
"server-only": "^0.0.1",
"tsx": "^4.19.1",
"zod": "^3.23.8"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/typescript": "^4.0.9",
"@graphql-codegen/typescript-resolvers": "^4.2.1",
"@graphql-codegen/cli": "^5.0.3",
"@graphql-codegen/typescript": "^4.1.0",
"@graphql-codegen/typescript-resolvers": "^4.3.0",
"@parcel/watcher": "^2.4.1",
"@ts-safeql/eslint-plugin": "^3.4.7",
"@types/bcrypt": "^5.0.2",
"@types/node": "^22.7.4",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@types/node": "^22.7.6",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"concurrently": "^9.0.1",
"eslint": "^9.11.1",
"eslint-config-upleveled": "^8.7.1",
"eslint": "^9.12.0",
"eslint-config-upleveled": "^8.8.0",
"libpg-query": "^16.2.0",
"prettier": "^3.3.3",
"prettier-plugin-embed": "^0.4.15",
"prettier-plugin-sql": "^0.18.1",
"stylelint": "^16.9.0",
"stylelint-config-upleveled": "^1.1.4",
"typescript": "^5.6.2"
"stylelint": "^16.10.0",
"stylelint-config-upleveled": "^1.1.5",
"typescript": "^5.6.3"
},
"packageManager": "[email protected]+sha512.ee7b93e0c2bd11409c6424f92b866f31d3ea1bef5fbe47d3c7500cdc3c9668833d2e55681ad66df5b640c61fa9dc25d546efa54d76d7f8bf54b13614ac293631"
}
Loading