build: prevent tsconfig includes sources outside (#2643)

This commit is contained in:
LongYinan
2023-06-01 17:08:14 +08:00
committed by Himself65
parent 2a31af0973
commit 4ab5457a44
25 changed files with 160 additions and 107 deletions

View File

@@ -12,12 +12,13 @@ import { Condition } from '../filter/condition';
import { tBoolean, tDate } from '../filter/logical/custom-type';
import type {
Filter,
FilterMatcherDataType,
LiteralValue,
Ref,
VariableMap,
} from '../filter/vars';
import { filterMatcher, toLiteral } from '../filter/vars';
} from '../filter/shared-types';
import { toLiteral } from '../filter/shared-types';
import type { FilterMatcherDataType } from '../filter/vars';
import { filterMatcher } from '../filter/vars';
import { filterByFilterList } from '../use-all-page-setting';
const ref = (name: keyof VariableMap): Ref => {

View File

@@ -5,7 +5,7 @@ import { Menu, MenuItem } from '../../../ui/menu';
import * as styles from './index.css';
import { literalMatcher } from './literal-matcher';
import type { TFunction, TType } from './logical/typesystem';
import type { Filter, Literal } from './vars';
import type { Filter, Literal } from './shared-types';
import { filterMatcher, VariableSelect, vars } from './vars';
export const Condition = ({

View File

@@ -1,5 +1,4 @@
import type { Filter, Literal, Ref } from './vars';
import type { VariableMap } from './vars';
import type { Filter, Literal, Ref, VariableMap } from './shared-types';
import { filterMatcher } from './vars';
const evalRef = (ref: Ref, variableMap: VariableMap) => {

View File

@@ -3,7 +3,7 @@ import { CloseIcon, PlusIcon } from '@blocksuite/icons';
import { Menu } from '../../..';
import { Condition } from './condition';
import * as styles from './index.css';
import type { Filter } from './vars';
import type { Filter } from './shared-types';
import { CreateFilterMenu } from './vars';
export const FilterList = ({
value,

View File

@@ -6,7 +6,7 @@ import { tBoolean, tDate } from './logical/custom-type';
import { Matcher } from './logical/matcher';
import type { TType } from './logical/typesystem';
import { typesystem } from './logical/typesystem';
import type { Literal } from './vars';
import type { Literal } from './shared-types';
export const literalMatcher = new Matcher<{
render: (props: {

View File

@@ -0,0 +1,66 @@
import { DateTimeIcon, FavoritedIcon } from '@blocksuite/icons';
import type { ReactElement } from 'react';
import { tBoolean, tDate } from './logical/custom-type';
import type { TType } from './logical/typesystem';
export type Ref = {
type: 'ref';
name: keyof VariableMap;
};
export type Filter = {
type: 'filter';
left: Ref;
funcName: string;
args: Literal[];
};
export type LiteralValue =
| number
| string
| boolean
| { [K: string]: LiteralValue }
| Array<LiteralValue>;
export const toLiteral = (value: LiteralValue): Literal => ({
type: 'literal',
value,
});
export type Literal = {
type: 'literal';
value: LiteralValue;
};
export type FilterVariable = {
name: keyof VariableMap;
type: TType;
icon: ReactElement;
};
export const variableDefineMap = {
Created: {
type: tDate.create(),
icon: <DateTimeIcon />,
},
Updated: {
type: tDate.create(),
icon: <DateTimeIcon />,
},
'Is Favourited': {
type: tBoolean.create(),
icon: <FavoritedIcon />,
},
// Imported: {
// type: tBoolean.create(),
// },
// 'Daily Note': {
// type: tBoolean.create(),
// },
} as const;
export type VariableMap = {
[K in keyof typeof variableDefineMap]: LiteralValue;
};
export type View = {
id: string;
name: string;
filterList: Filter[];
};

View File

@@ -1,68 +1,20 @@
import { DateTimeIcon, FavoritedIcon } from '@blocksuite/icons';
import dayjs from 'dayjs';
import type { ReactElement, ReactNode } from 'react';
import type { ReactNode } from 'react';
import { MenuItem } from '../../../ui/menu';
import * as styles from './index.css';
import { tBoolean, tDate } from './logical/custom-type';
import { Matcher } from './logical/matcher';
import type { TFunction, TType } from './logical/typesystem';
import type { TFunction } from './logical/typesystem';
import { tFunction, typesystem } from './logical/typesystem';
import type {
Filter,
FilterVariable,
LiteralValue,
VariableMap,
} from './shared-types';
import { variableDefineMap } from './shared-types';
export type Ref = {
type: 'ref';
name: keyof VariableMap;
};
export type Filter = {
type: 'filter';
left: Ref;
funcName: string;
args: Literal[];
};
export type LiteralValue =
| number
| string
| boolean
| { [K: string]: LiteralValue }
| Array<LiteralValue>;
export const toLiteral = (value: LiteralValue): Literal => ({
type: 'literal',
value,
});
export type Literal = {
type: 'literal';
value: LiteralValue;
};
export type FilterVariable = {
name: keyof VariableMap;
type: TType;
icon: ReactElement;
};
export const variableDefineMap = {
Created: {
type: tDate.create(),
icon: <DateTimeIcon />,
},
Updated: {
type: tDate.create(),
icon: <DateTimeIcon />,
},
'Is Favourited': {
type: tBoolean.create(),
icon: <FavoritedIcon />,
},
// Imported: {
// type: tBoolean.create(),
// },
// 'Daily Note': {
// type: tBoolean.create(),
// },
} as const;
export type VariableMap = {
[K in keyof typeof variableDefineMap]: LiteralValue;
};
export const vars: FilterVariable[] = Object.entries(variableDefineMap).map(
([key, value]) => ({
name: key as keyof VariableMap,

View File

@@ -8,13 +8,7 @@ import useSWRImmutable from 'swr/immutable';
import { NIL } from 'uuid';
import { evalFilterList } from './filter';
import type { Filter, VariableMap } from './filter/vars';
export type View = {
id: string;
name: string;
filterList: Filter[];
};
import type { Filter, VariableMap, View } from './filter/shared-types';
type PersistenceView = View;

View File

@@ -4,8 +4,7 @@ import { useState } from 'react';
import { Button, Input, Modal, ModalWrapper } from '../../..';
import { FilterList } from '../filter';
import type { Filter } from '../filter/vars';
import type { View } from '../use-all-page-setting';
import type { Filter, View } from '../filter/shared-types';
import * as styles from './view-list.css';
type CreateViewProps = {

View File

@@ -1,3 +1,6 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../../../apps/electron/layers/preload/preload.d.ts" />
export * from './components/list-skeleton';
export * from './styles';
export * from './ui/breadcrumbs';

View File

@@ -1,18 +1,18 @@
{
"extends": "../../tsconfig.json",
"include": [
"./src/**/*.ts",
"./src/**/*.tsx",
"./src/**/*.json",
"../workspace/src",
"../../apps/electron/layers/**/src"
"exclude": [
"lib",
"./src/components/page-list/filter/shared-types.tsx",
"./src/components/page-list/filter/logic/custom-type.ts",
"./src/components/page-list/filter/logic/matcher.ts",
"./src/components/page-list/filter/logic/typesystem.ts"
],
"include": ["./src/**/*", "./src/**/*.json"],
"compilerOptions": {
"composite": true,
"noEmit": false,
"outDir": "lib"
},
"exclude": ["lib"],
"references": [
{
"path": "../debug"
@@ -26,9 +26,14 @@
{
"path": "../hooks"
},
{ "path": "../workspace" },
{
"path": "../../apps/electron"
},
{
"path": "./tsconfig.node.json"
},
{ "path": "./tsconfig.workspace.json" },
{ "path": "../../tests/fixtures" }
]
}

View File

@@ -0,0 +1,18 @@
// to prevent the `@affine/components` contains circular references with `@affine/workspace`
// the include files should be excluded in `./tsconfig.json`
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"noEmit": false,
"outDir": "lib"
},
"include": [
"./src/components/page-list/filter/shared-types.tsx",
"./src/components/page-list/filter/logical/custom-type.ts",
"./src/components/page-list/filter/logical/matcher.ts",
"./src/components/page-list/filter/logical/typesystem.ts"
],
"references": [{ "path": "../env" }],
"exclude": ["lib"]
}