0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

chore: upgrade configs and eslint (#294)

* chore: upgrade configs and eslint

* chore: update lockfile

* fix(ui): stylelint
This commit is contained in:
Gao Sun 2022-02-28 15:21:48 +08:00 committed by GitHub
parent fb6a1dc236
commit f7925d9332
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 766 additions and 378 deletions

View file

@ -10,10 +10,10 @@
"dev": "lerna run --stream prepack && lerna --scope=@logto/{core,ui} exec -- pnpm dev" "dev": "lerna run --stream prepack && lerna --scope=@logto/{core,ui} exec -- pnpm dev"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^13.1.0", "@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.1.0", "@commitlint/config-conventional": "^13.2.0",
"@commitlint/types": "^13.1.0", "@commitlint/types": "^13.2.0",
"husky": "^7.0.1", "husky": "^7.0.4",
"lerna": "^4.0.0", "lerna": "^4.0.0",
"typescript": "^4.5.5" "typescript": "^4.5.5"
}, },

View file

@ -23,13 +23,13 @@
"devDependencies": { "devDependencies": {
"@parcel/core": "^2.3.1", "@parcel/core": "^2.3.1",
"@parcel/transformer-sass": "^2.3.1", "@parcel/transformer-sass": "^2.3.1",
"@silverhand/eslint-config": "^0.8.1", "@silverhand/eslint-config": "^0.9.1",
"@silverhand/eslint-config-react": "^0.8.1", "@silverhand/eslint-config-react": "^0.9.2",
"@silverhand/ts-config": "^0.8.1", "@silverhand/ts-config": "^0.9.1",
"@silverhand/ts-config-react": "^0.8.1", "@silverhand/ts-config-react": "^0.9.2",
"@types/react": "^17.0.14", "@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9", "@types/react-dom": "^17.0.9",
"eslint": "^8.1.0", "eslint": "^8.10.0",
"lint-staged": "^11.1.1", "lint-staged": "^11.1.1",
"parcel": "^2.3.1", "parcel": "^2.3.1",
"postcss": "^8.4.6", "postcss": "^8.4.6",

View file

@ -48,8 +48,8 @@
}, },
"devDependencies": { "devDependencies": {
"@shopify/jest-koa-mocks": "^3.0.8", "@shopify/jest-koa-mocks": "^3.0.8",
"@silverhand/eslint-config": "^0.8.1", "@silverhand/eslint-config": "^0.9.1",
"@silverhand/ts-config": "^0.8.1", "@silverhand/ts-config": "^0.9.1",
"@types/jest": "^27.0.1", "@types/jest": "^27.0.1",
"@types/koa": "^2.13.3", "@types/koa": "^2.13.3",
"@types/koa-logger": "^3.1.1", "@types/koa-logger": "^3.1.1",
@ -60,7 +60,7 @@
"@types/oidc-provider": "^7.8.0", "@types/oidc-provider": "^7.8.0",
"@types/supertest": "^2.0.11", "@types/supertest": "^2.0.11",
"codecov": "^3.8.3", "codecov": "^3.8.3",
"eslint": "^8.1.0", "eslint": "^8.10.0",
"jest": "^27.0.6", "jest": "^27.0.6",
"jest-matcher-specific-error": "^1.0.0", "jest-matcher-specific-error": "^1.0.0",
"lint-staged": "^11.1.1", "lint-staged": "^11.1.1",

View file

@ -51,6 +51,8 @@ describe('validateConfig', () => {
).resolves.not.toThrow(); ).resolves.not.toThrow();
}); });
it('should throw on empty config', async () => { it('should throw on empty config', async () => {
// FIXME: @sijie
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error // @ts-expect-error
await expect(validateConfig()).rejects.toThrowError(); await expect(validateConfig()).rejects.toThrowError();
}); });

View file

@ -12,8 +12,6 @@ export const conditionalSql = <T>(
) => (notFalsy(value) ? buildSql(value) : sql``); ) => (notFalsy(value) ? buildSql(value) : sql``);
export const autoSetFields = Object.freeze(['createdAt', 'updatedAt'] as const); export const autoSetFields = Object.freeze(['createdAt', 'updatedAt'] as const);
// `Except` type will require omit fields to be the key of given type
// eslint-disable-next-line @typescript-eslint/ban-types
export type OmitAutoSetFields<T> = Omit<T, typeof autoSetFields[number]>; export type OmitAutoSetFields<T> = Omit<T, typeof autoSetFields[number]>;
export type ExcludeAutoSetFields<T> = Exclude<T, typeof autoSetFields[number]>; export type ExcludeAutoSetFields<T> = Exclude<T, typeof autoSetFields[number]>;
export const excludeAutoSetFields = <T extends string>(fields: readonly T[]) => export const excludeAutoSetFields = <T extends string>(fields: readonly T[]) =>
@ -34,7 +32,9 @@ export const excludeAutoSetFields = <T extends string>(fields: readonly T[]) =>
*/ */
export const convertToPrimitiveOrSql = ( export const convertToPrimitiveOrSql = (
key: string, key: string,
// eslint-disable-next-line @typescript-eslint/ban-types
value: NonNullable<SchemaValue> | null value: NonNullable<SchemaValue> | null
// eslint-disable-next-line @typescript-eslint/ban-types
): NonNullable<SchemaValuePrimitive> | SqlTokenType | null => { ): NonNullable<SchemaValuePrimitive> | SqlTokenType | null => {
if (value === null) { if (value === null) {
return null; return null;

View file

@ -76,6 +76,8 @@ export const getUserInfoFromInteractionResult = async (
*/ */
export const findSocialRelatedUser = async ( export const findSocialRelatedUser = async (
info: SocialUserInfo info: SocialUserInfo
// FIXME:
// eslint-disable-next-line @typescript-eslint/ban-types
): Promise<null | [string, User]> => { ): Promise<null | [string, User]> => {
if (info.phone && (await hasUserWithPhone(info.phone))) { if (info.phone && (await hasUserWithPhone(info.phone))) {
const user = await findUserByPhone(info.phone); const user = await findUserByPhone(info.phone);

View file

@ -16,11 +16,13 @@ export type QueryResult = Pick<OidcModelInstance, 'payload' | 'consumedAt'>;
const { table, fields } = convertToIdentifiers(OidcModelInstances); const { table, fields } = convertToIdentifiers(OidcModelInstances);
// eslint-disable-next-line @typescript-eslint/ban-types
const withConsumed = <T>(data: T, consumedAt?: number | null): WithConsumed<T> => ({ const withConsumed = <T>(data: T, consumedAt?: number | null): WithConsumed<T> => ({
...data, ...data,
...(consumedAt ? { consumed: true } : undefined), ...(consumedAt ? { consumed: true } : undefined),
}); });
// eslint-disable-next-line @typescript-eslint/ban-types
const convertResult = (result: QueryResult | null) => const convertResult = (result: QueryResult | null) =>
conditional(result && withConsumed(result.payload, result.consumedAt)); conditional(result && withConsumed(result.payload, result.consumedAt));

View file

@ -29,9 +29,9 @@
"@silverhand/essentials": "^1.1.4" "@silverhand/essentials": "^1.1.4"
}, },
"devDependencies": { "devDependencies": {
"@silverhand/eslint-config": "^0.8.1", "@silverhand/eslint-config": "^0.9.1",
"@silverhand/ts-config": "^0.8.1", "@silverhand/ts-config": "^0.9.1",
"eslint": "^8.1.0", "eslint": "^8.10.0",
"lint-staged": "^11.1.1", "lint-staged": "^11.1.1",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"typescript": "^4.5.5" "typescript": "^4.5.5"

View file

@ -21,14 +21,14 @@
"node": ">=14.15.0" "node": ">=14.15.0"
}, },
"devDependencies": { "devDependencies": {
"@silverhand/eslint-config": "^0.8.1", "@silverhand/eslint-config": "^0.9.1",
"@silverhand/essentials": "^1.1.0", "@silverhand/essentials": "^1.1.0",
"@silverhand/ts-config": "^0.8.1", "@silverhand/ts-config": "^0.9.1",
"@types/lodash.uniq": "^4.5.6", "@types/lodash.uniq": "^4.5.6",
"@types/node": "14", "@types/node": "14",
"@types/pluralize": "^0.0.29", "@types/pluralize": "^0.0.29",
"camelcase": "^6.2.0", "camelcase": "^6.2.0",
"eslint": "^8.1.0", "eslint": "^8.10.0",
"lint-staged": "^11.1.1", "lint-staged": "^11.1.1",
"lodash.uniq": "^4.5.0", "lodash.uniq": "^4.5.0",
"pluralize": "^8.0.0", "pluralize": "^8.0.0",
@ -37,7 +37,10 @@
"typescript": "^4.5.5" "typescript": "^4.5.5"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "@silverhand" "extends": "@silverhand",
"rules": {
"@typescript-eslint/ban-types": "off"
}
}, },
"prettier": "@silverhand/eslint-config/.prettierrc", "prettier": "@silverhand/eslint-config/.prettierrc",
"dependencies": { "dependencies": {

View file

@ -8,7 +8,6 @@ export type Field = {
isArray: boolean; isArray: boolean;
}; };
// eslint-disable-next-line @typescript-eslint/ban-types
export type FieldWithType = Omit<Field, 'type' | 'customType'> & { type: string; isEnum: boolean }; export type FieldWithType = Omit<Field, 'type' | 'customType'> & { type: string; isEnum: boolean };
export type Type = { export type Type = {

View file

@ -30,16 +30,16 @@
"@jest/types": "^27.5.1", "@jest/types": "^27.5.1",
"@parcel/core": "^2.3.1", "@parcel/core": "^2.3.1",
"@parcel/transformer-sass": "^2.3.1", "@parcel/transformer-sass": "^2.3.1",
"@silverhand/eslint-config": "^0.8.1", "@silverhand/eslint-config": "^0.9.1",
"@silverhand/eslint-config-react": "^0.8.1", "@silverhand/eslint-config-react": "^0.9.2",
"@silverhand/ts-config": "^0.8.1", "@silverhand/ts-config": "^0.9.1",
"@silverhand/ts-config-react": "^0.8.1", "@silverhand/ts-config-react": "^0.9.2",
"@testing-library/react": "^12.0.0", "@testing-library/react": "^12.0.0",
"@types/jest": "^27.4.0", "@types/jest": "^27.4.0",
"@types/react": "^17.0.14", "@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9", "@types/react-dom": "^17.0.9",
"@types/react-router-dom": "^5.3.2", "@types/react-router-dom": "^5.3.2",
"eslint": "^8.1.0", "eslint": "^8.10.0",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"lint-staged": "^11.1.1", "lint-staged": "^11.1.1",

View file

@ -21,7 +21,7 @@
--color-error-border: #{rgba(#ff6b66, 0.35)}; --color-error-border: #{rgba(#ff6b66, 0.35)};
/* Shadow */ /* Shadow */
--shadow-button: 2px 2px 8px rgb(60 76 227 / 25%); --shadow-button: 2px 2px 8px rgb(60, 76, 227, 25%);
/* Transition */ /* Transition */
--transition-default-function: 0.2s ease-in-out; --transition-default-function: 0.2s ease-in-out;
@ -39,8 +39,8 @@
--color-background: #101419; --color-background: #101419;
/* Shadow */ /* Shadow */
--shadow-card: 2px 2px 24px rgb(59 61 63 / 25%); --shadow-card: 2px 2px 24px rgb(59, 61, 63, 25%);
--shadow-control: 1px 1px 2px rgb(221 221 221 / 25%); --shadow-control: 1px 1px 2px rgb(221, 221, 221, 25%);
} }
.light { .light {
@ -54,8 +54,8 @@
--color-background: #fdfdff; --color-background: #fdfdff;
/* Shadow */ /* Shadow */
--shadow-card: 2px 2px 24px rgb(187 189 191 / 20%); --shadow-card: 2px 2px 24px rgb(187, 189, 191, 20%);
--shadow-control: 1px 1px 2px rgb(221 221 221 / 25%); --shadow-control: 1px 1px 2px rgb(221, 221, 221, 25%);
} }
$font-family: 'PingFang SC', 'SF Pro Text', sans-serif; $font-family: 'PingFang SC', 'SF Pro Text', sans-serif;

View file

@ -5,6 +5,8 @@ import { useState, useCallback } from 'react';
type UseApi<T extends any[], U> = { type UseApi<T extends any[], U> = {
result?: U; result?: U;
loading: boolean; loading: boolean;
// FIXME:
// eslint-disable-next-line @typescript-eslint/ban-types
error: RequestErrorBody | null; error: RequestErrorBody | null;
run: (...args: T) => Promise<void>; run: (...args: T) => Promise<void>;
}; };
@ -13,6 +15,8 @@ function useApi<Args extends any[], Response>(
api: (...args: Args) => Promise<Response> api: (...args: Args) => Promise<Response>
): UseApi<Args, Response> { ): UseApi<Args, Response> {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
// FIXME:
// eslint-disable-next-line @typescript-eslint/ban-types
const [error, setError] = useState<RequestErrorBody | null>(null); const [error, setError] = useState<RequestErrorBody | null>(null);
const [result, setResult] = useState<Response>(); const [result, setResult] = useState<Response>();

File diff suppressed because it is too large Load diff