Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
4 changes: 3 additions & 1 deletion packages/website/src/components/RulesTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ function parseFiltersState(str: string): FiltersState {
const exclude = part.startsWith(NEGATION_SYMBOL);
const key = exclude ? part.slice(1) : part;
if (Object.hasOwn(neutralFiltersState, key)) {
res[key] = exclude ? 'exclude' : 'include';
res[key as keyof typeof neutralFiltersState] = exclude
? 'exclude'
: 'include';
}
}

Expand Down
15 changes: 7 additions & 8 deletions packages/website/src/components/ast/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import type { ParentNodeType } from './types';

import { tsEnumFlagToString, tsEnumToString } from './tsUtils';

export function objType(obj: unknown): string {
const type = Object.prototype.toString.call(obj).slice(8, -1);
if (type === 'Object' && obj && typeof obj[Symbol.iterator] === 'function') {
return 'Iterable';
}

return type;
}
export const objType = (obj: unknown): string =>
typeof obj === 'object' &&
obj &&
Symbol.iterator in obj &&
typeof obj[Symbol.iterator] === 'function'
? 'Iterable'
: Object.prototype.toString.call(obj).slice(8, -1);

export function isRecord(value: unknown): value is Record<string, unknown> {
return objType(value) === 'Object';
Expand Down
50 changes: 24 additions & 26 deletions packages/website/src/components/lib/jsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,33 +177,31 @@ export function getTypescriptOptions(): DescribedOptionDeclaration[] {
*/
export function getTypescriptJsonSchema(): JSONSchema4 {
const properties = Object.fromEntries(
getTypescriptOptions()
.map(item => {
let value;
if (item.type === 'boolean') {
value = {
description: item.description.message,
type: 'boolean',
};
} else if (item.type === 'list' && item.element?.type instanceof Map) {
value = {
description: item.description.message,
items: {
enum: [...item.element.type.keys()],
type: 'string',
},
type: 'array',
};
} else if (item.type instanceof Map) {
value = {
description: item.description.message,
enum: [...item.type.keys()],
getTypescriptOptions().flatMap(item => {
let value: JSONSchema4 | undefined;
if (item.type === 'boolean') {
value = {
description: item.description.message,
type: 'boolean',
};
} else if (item.type === 'list' && item.element?.type instanceof Map) {
value = {
description: item.description.message,
items: {
enum: [...item.element.type.keys()],
type: 'string',
};
}
return [item.name, value] as const;
})
.filter(([, value]) => value),
},
type: 'array',
};
} else if (item.type instanceof Map) {
value = {
description: item.description.message,
enum: [...item.type.keys()],
type: 'string',
};
}
return value ? [[item.name, value] as const] : [];
}),
);

return {
Expand Down
6 changes: 3 additions & 3 deletions packages/website/src/components/lib/shallowEqual.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Shallowly compare two objects.
*/
export function shallowEqual(
object1: object | null | undefined,
object2: object | null | undefined,
export function shallowEqual<T extends Record<PropertyKey, unknown>>(
object1: T | null | undefined,
object2: T | null | undefined,
): boolean {
if (object1 === object2) {
return true;
Expand Down
1 change: 0 additions & 1 deletion packages/website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"jsx": "react",
"lib": ["DOM", "ES2023"],
"noEmit": true,
"noImplicitAny": false,
"resolveJsonModule": true,
"baseUrl": ".",
"paths": {
Expand Down
Loading