Enable additional TypeScript ESLint rules (#39640)
Enables some rules that are useful and already pass currently. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
This commit is contained in:
parent
3d3938b793
commit
6876bb4c44
5 changed files with 36 additions and 32 deletions
|
@ -93,7 +93,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"no-useless-constructor": "off",
|
"no-useless-constructor": "off",
|
||||||
"@typescript-eslint/no-useless-constructor": "warn"
|
"@typescript-eslint/no-useless-constructor": "warn",
|
||||||
|
"@typescript-eslint/prefer-literal-enum-member": "error",
|
||||||
|
"@typescript-eslint/prefer-namespace-keyword": "error"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -326,6 +328,8 @@
|
||||||
"react/react-in-jsx-scope": "error",
|
"react/react-in-jsx-scope": "error",
|
||||||
"react/require-render-return": "error",
|
"react/require-render-return": "error",
|
||||||
"react/style-prop-object": "warn",
|
"react/style-prop-object": "warn",
|
||||||
"react-hooks/rules-of-hooks": "error"
|
"react-hooks/rules-of-hooks": "error",
|
||||||
|
// "@typescript-eslint/non-nullable-type-assertion-style": "warn",
|
||||||
|
"@typescript-eslint/prefer-as-const": "warn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
* @module
|
* @module
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AnyDataModel } from "convex/server";
|
import { AnyDataModel } from 'convex/server'
|
||||||
import { GenericId } from "convex/values";
|
import { GenericId } from 'convex/values'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No `schema.ts` file found!
|
* No `schema.ts` file found!
|
||||||
|
@ -26,12 +26,12 @@ import { GenericId } from "convex/values";
|
||||||
/**
|
/**
|
||||||
* The names of all of your Convex tables.
|
* The names of all of your Convex tables.
|
||||||
*/
|
*/
|
||||||
export type TableNames = string;
|
export type TableNames = string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of a document stored in Convex.
|
* The type of a document stored in Convex.
|
||||||
*/
|
*/
|
||||||
export type Document = any;
|
export type Document = any
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An identifier for a document in Convex.
|
* An identifier for a document in Convex.
|
||||||
|
@ -45,8 +45,8 @@ export type Document = any;
|
||||||
* Using `===` will not work because two different instances of `Id` can refer
|
* Using `===` will not work because two different instances of `Id` can refer
|
||||||
* to the same document.
|
* to the same document.
|
||||||
*/
|
*/
|
||||||
export type Id = GenericId<string>;
|
export type Id = GenericId<string>
|
||||||
export const Id = GenericId;
|
export const Id = GenericId
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type describing your Convex data model.
|
* A type describing your Convex data model.
|
||||||
|
@ -57,4 +57,4 @@ export const Id = GenericId;
|
||||||
* This type is used to parameterize methods like `queryGeneric` and
|
* This type is used to parameterize methods like `queryGeneric` and
|
||||||
* `mutationGeneric` to make them type-safe.
|
* `mutationGeneric` to make them type-safe.
|
||||||
*/
|
*/
|
||||||
export type DataModel = AnyDataModel;
|
export type DataModel = AnyDataModel
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
* @module
|
* @module
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type getCounter from "../getCounter";
|
import type getCounter from '../getCounter'
|
||||||
import type incrementCounter from "../incrementCounter";
|
import type incrementCounter from '../incrementCounter'
|
||||||
import type { OptimisticLocalStore as GenericOptimisticLocalStore } from "convex/browser";
|
import type { OptimisticLocalStore as GenericOptimisticLocalStore } from 'convex/browser'
|
||||||
import type { ClientMutation, ClientQuery } from "convex/server";
|
import type { ClientMutation, ClientQuery } from 'convex/server'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type describing your app's public Convex API.
|
* A type describing your app's public Convex API.
|
||||||
|
@ -25,14 +25,14 @@ import type { ClientMutation, ClientQuery } from "convex/server";
|
||||||
*/
|
*/
|
||||||
export type ConvexAPI = {
|
export type ConvexAPI = {
|
||||||
queries: {
|
queries: {
|
||||||
getCounter: ClientQuery<typeof getCounter>;
|
getCounter: ClientQuery<typeof getCounter>
|
||||||
};
|
}
|
||||||
mutations: {
|
mutations: {
|
||||||
incrementCounter: ClientMutation<typeof incrementCounter>;
|
incrementCounter: ClientMutation<typeof incrementCounter>
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
import { makeUseQuery, makeUseMutation, makeUseConvex } from "convex/react";
|
import { makeUseQuery, makeUseMutation, makeUseConvex } from 'convex/react'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a reactive query within a React component.
|
* Load a reactive query within a React component.
|
||||||
|
@ -46,7 +46,7 @@ import { makeUseQuery, makeUseMutation, makeUseConvex } from "convex/react";
|
||||||
* @param args - The arguments to the query function.
|
* @param args - The arguments to the query function.
|
||||||
* @returns `undefined` if loading and the query's return value otherwise.
|
* @returns `undefined` if loading and the query's return value otherwise.
|
||||||
*/
|
*/
|
||||||
export const useQuery = makeUseQuery<ConvexAPI>();
|
export const useQuery = makeUseQuery<ConvexAPI>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new {@link ReactMutation}.
|
* Construct a new {@link ReactMutation}.
|
||||||
|
@ -64,7 +64,7 @@ export const useQuery = makeUseQuery<ConvexAPI>();
|
||||||
* @param name - The name of the mutation.
|
* @param name - The name of the mutation.
|
||||||
* @returns The {@link ReactMutation} object with that name.
|
* @returns The {@link ReactMutation} object with that name.
|
||||||
*/
|
*/
|
||||||
export const useMutation = makeUseMutation<ConvexAPI>();
|
export const useMutation = makeUseMutation<ConvexAPI>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link ConvexReactClient} within a React component.
|
* Get the {@link ConvexReactClient} within a React component.
|
||||||
|
@ -73,10 +73,10 @@ export const useMutation = makeUseMutation<ConvexAPI>();
|
||||||
*
|
*
|
||||||
* @returns The active {@link ConvexReactClient} object, or `undefined`.
|
* @returns The active {@link ConvexReactClient} object, or `undefined`.
|
||||||
*/
|
*/
|
||||||
export const useConvex = makeUseConvex<ConvexAPI>();
|
export const useConvex = makeUseConvex<ConvexAPI>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A view of the query results currently in the Convex client for use within
|
* A view of the query results currently in the Convex client for use within
|
||||||
* optimistic updates.
|
* optimistic updates.
|
||||||
*/
|
*/
|
||||||
export type OptimisticLocalStore = GenericOptimisticLocalStore<ConvexAPI>;
|
export type OptimisticLocalStore = GenericOptimisticLocalStore<ConvexAPI>
|
||||||
|
|
|
@ -16,8 +16,8 @@ import {
|
||||||
MutationCtx as GenericMutationCtx,
|
MutationCtx as GenericMutationCtx,
|
||||||
DatabaseReader as GenericDatabaseReader,
|
DatabaseReader as GenericDatabaseReader,
|
||||||
DatabaseWriter as GenericDatabaseWriter,
|
DatabaseWriter as GenericDatabaseWriter,
|
||||||
} from "convex/server";
|
} from 'convex/server'
|
||||||
import { DataModel } from "./dataModel.js";
|
import { DataModel } from './dataModel.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a query in this Convex app's public API.
|
* Define a query in this Convex app's public API.
|
||||||
|
@ -27,7 +27,7 @@ import { DataModel } from "./dataModel.js";
|
||||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||||
*/
|
*/
|
||||||
export const query = makeQuery<DataModel>();
|
export const query = makeQuery<DataModel>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a mutation in this Convex app's public API.
|
* Define a mutation in this Convex app's public API.
|
||||||
|
@ -37,7 +37,7 @@ export const query = makeQuery<DataModel>();
|
||||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||||
*/
|
*/
|
||||||
export const mutation = makeMutation<DataModel>();
|
export const mutation = makeMutation<DataModel>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of services for use within Convex query functions.
|
* A set of services for use within Convex query functions.
|
||||||
|
@ -48,7 +48,7 @@ export const mutation = makeMutation<DataModel>();
|
||||||
* This differs from the {@link MutationCtx} because all of the services are
|
* This differs from the {@link MutationCtx} because all of the services are
|
||||||
* read-only.
|
* read-only.
|
||||||
*/
|
*/
|
||||||
export type QueryCtx = GenericQueryCtx<DataModel>;
|
export type QueryCtx = GenericQueryCtx<DataModel>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of services for use within Convex mutation functions.
|
* A set of services for use within Convex mutation functions.
|
||||||
|
@ -56,7 +56,7 @@ export type QueryCtx = GenericQueryCtx<DataModel>;
|
||||||
* The mutation context is passed as the first argument to any Convex mutation
|
* The mutation context is passed as the first argument to any Convex mutation
|
||||||
* function run on the server.
|
* function run on the server.
|
||||||
*/
|
*/
|
||||||
export type MutationCtx = GenericMutationCtx<DataModel>;
|
export type MutationCtx = GenericMutationCtx<DataModel>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface to read from the database within Convex query functions.
|
* An interface to read from the database within Convex query functions.
|
||||||
|
@ -65,7 +65,7 @@ export type MutationCtx = GenericMutationCtx<DataModel>;
|
||||||
* document by its {@link Id}, or {@link DatabaseReader.table}, which starts
|
* document by its {@link Id}, or {@link DatabaseReader.table}, which starts
|
||||||
* building a query.
|
* building a query.
|
||||||
*/
|
*/
|
||||||
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
export type DatabaseReader = GenericDatabaseReader<DataModel>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface to read from and write to the database within Convex mutation
|
* An interface to read from and write to the database within Convex mutation
|
||||||
|
@ -76,4 +76,4 @@ export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
||||||
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
||||||
* for the guarantees Convex provides your functions.
|
* for the guarantees Convex provides your functions.
|
||||||
*/
|
*/
|
||||||
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
export type DatabaseWriter = GenericDatabaseWriter<DataModel>
|
||||||
|
|
2
packages/next/types/misc.d.ts
vendored
2
packages/next/types/misc.d.ts
vendored
|
@ -335,7 +335,7 @@ declare module 'next/dist/compiled/@segment/ajv-human-errors' {
|
||||||
export = m
|
export = m
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module NodeJS {
|
declare namespace NodeJS {
|
||||||
interface ProcessVersions {
|
interface ProcessVersions {
|
||||||
pnp?: string
|
pnp?: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue