Skip to content

Commit

Permalink
chore: lint fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
1ncounter committed Apr 10, 2024
1 parent 6b8d0c1 commit 764e841
Show file tree
Hide file tree
Showing 207 changed files with 2,700 additions and 660 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ typings/
codealike.json
.node

.must.config.js
.must.config.js
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git-checks=false
29 changes: 13 additions & 16 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint'
import tseslint from 'typescript-eslint';
import js from '@eslint/js';
import react from 'eslint-plugin-react'
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals'
import globals from 'globals';

export default tseslint.config({
files: ['packages/*/src/**/*.{ts?(x),js?(x)}'],
ignores: ["**/*.test.ts"],
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
],
files: ['packages/*/{src,__tests__}/**/*.{ts?(x),js?(x)}'],
ignores: ['**/*.test.ts'],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
plugins: {
'@stylistic': stylistic,
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh
},
languageOptions: {
parserOptions: {
Expand All @@ -28,18 +23,22 @@ export default tseslint.config({
globals: {
...globals.browser,
...globals.nodeBuiltin,
...globals.jest
...globals.jest,
},
},
rules: {
'@stylistic/indent': ['error', 2],
'@stylistic/indent-binary-ops': ['error', 2],
'@stylistic/max-len': ['error', { tabWidth: 2, "ignoreStrings": true }],
'@stylistic/max-len': ['error', { code: 100, tabWidth: 2, ignoreStrings: true, ignoreComments: true }],
'@stylistic/no-tabs': 'error',
'@stylistic/quotes': ['error', 'single'],
'@stylistic/jsx-pascal-case': [2],
'@stylistic/jsx-indent': [2, 2, { checkAttributes: true, indentLogicalExpressions: true }],
'@stylistic/semi': ['error', 'always'],
'@stylistic/eol-last': ['error', 'always'],
'@stylistic/jsx-quotes': ['error', 'prefer-double'],

"@typescript-eslint/ban-ts-comment": ["error", { 'ts-expect-error': 'allow-with-description' }],

'react/jsx-no-undef': 'error',
'react/jsx-uses-vars': 'error',
Expand All @@ -50,7 +49,5 @@ export default tseslint.config({

'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies

'react-refresh/only-export-components': 'warn',
},
})
});
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"type": "module",
"scripts": {
"playground": "pnpm --filter playground dev",
"test": "pnpm -r test",
"build": "node ./scripts/build.js",
"test": "vitest",
"clean": "rimraf ./packages/*/dist",
"clean:lib": "rimraf ./node_modules ./packages/*/node_modules",
"lint": "eslint . --cache",
Expand Down Expand Up @@ -35,7 +35,6 @@
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"globals": "^15.0.0",
"husky": "^9.0.11",
"less": "^4.2.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/designer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"import": "./dist/low-code-designer.js",
"require": "./dist/low-code-designer.cjs",
"types": "./dist/index.d.ts"
},
"./dist/": {
"import": "./dist/",
"require": "./dist/"
}
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function getTitle(title: string | IPublicTypeI18nData | ReactElement) {
export class BorderContainer extends Component<{
host: BuiltinSimulatorHost;
}, {
target?: INode;
}> {
target?: INode;
}> {
state = {} as any;

@computed get scale() {
Expand All @@ -70,7 +70,7 @@ export class BorderContainer extends Component<{
const { host } = this.props;

host.designer.editor.eventBus.on('designer.dropLocation.change', (loc: DropLocation) => {
let { target } = this.state;
const { target } = this.state;
if (target === loc?.target) return;
this.setState({
target: loc?.target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ export class BemTools extends Component<{ host: BuiltinSimulatorHost }> {
</div>
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ export class BemToolsManager {
getAllBemTools() {
return this.toolsContainer;
}
}
}
12 changes: 6 additions & 6 deletions packages/designer/src/builtin-simulator/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1225,9 +1225,9 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
const childrenCanMove =
onChildMoveHook && parentContainerNode && typeof onChildMoveHook === 'function'
? onChildMoveHook(
node!.internalToShellNode(),
(parentContainerNode as any).internalToShellNode(),
)
node!.internalToShellNode(),
(parentContainerNode as any).internalToShellNode(),
)
: true;

return canMove && childrenCanMove;
Expand Down Expand Up @@ -1313,9 +1313,9 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
const inst = instances
? instances.length > 1
? instances.find(
(_inst) =>
this.getClosestNodeInstance(_inst, container.id)?.instance === containerInstance,
)
(_inst) =>
this.getClosestNodeInstance(_inst, container.id)?.instance === containerInstance,
)
: instances[0]
: null;
const rect = inst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export class LiveEditing {

export type SpecificRule = (target: EditingTarget) =>
| (IPublicTypeLiveTextEditingConfig & {
propElement?: HTMLElement;
})
propElement?: HTMLElement;
})
| null;

export interface SaveHandler {
Expand Down
20 changes: 10 additions & 10 deletions packages/designer/src/builtin-simulator/node-selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ export default class InstanceNodeSelector extends React.Component<IProps, IState

onMouseOver =
(node: INode) =>
(_: any, flag = true) => {
if (node && typeof node.hover === 'function') {
node.hover(flag);
}
};
(_: any, flag = true) => {
if (node && typeof node.hover === 'function') {
node.hover(flag);
}
};

onMouseOut =
(node: INode) =>
(_: any, flag = false) => {
if (node && typeof node.hover === 'function') {
node.hover(flag);
}
};
(_: any, flag = false) => {
if (node && typeof node.hover === 'function') {
node.hover(flag);
}
};

renderNodes = () => {
const nodes = this.state.parentNodes;
Expand Down
2 changes: 1 addition & 1 deletion packages/designer/src/component-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ export class ComponentActions {
getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[] {
return this.metadataTransducers;
}
}
}
8 changes: 4 additions & 4 deletions packages/designer/src/component-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ export class ComponentMeta implements IComponentMeta {
this._title =
typeof title === 'string'
? {
type: 'i18n',
'en-US': this.componentName,
'zh-CN': title,
}
type: 'i18n',
'en-US': this.componentName,
'zh-CN': title,
}
: title;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/designer/src/context-menu-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class GlobalContextMenuActions {
event.preventDefault();

const actions: IPublicTypeContextMenuAction[] = [];
let contextMenu: ContextMenuActions = this.contextMenuActionsMap.values().next().value;
const contextMenu: ContextMenuActions = this.contextMenuActionsMap.values().next().value;
this.contextMenuActionsMap.forEach((contextMenu) => {
actions.push(...contextMenu.actions);
});
Expand Down
10 changes: 5 additions & 5 deletions packages/designer/src/designer/designer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export interface DesignerProps {
onDragstart?: (e: IPublicModelLocateEvent) => void;
onDrag?: (e: IPublicModelLocateEvent) => void;
onDragend?: (
e: { dragObject: IPublicModelDragObject; copy: boolean },
loc?: DropLocation,
) => void;
e: { dragObject: IPublicModelDragObject; copy: boolean },
loc?: DropLocation,
) => void;
}

export class Designer {
Expand Down Expand Up @@ -406,8 +406,8 @@ export class Designer {

if (components) {
// 合并 assets
let assets = this.editor.get('assets') || {};
let newAssets = mergeAssets(assets, incrementalAssets);
const assets = this.editor.get('assets') || {};
const newAssets = mergeAssets(assets, incrementalAssets);
// 对于 assets 存在需要二次网络下载的过程,必须 await 等待结束之后,再进行事件触发
await this.editor.set('assets', newAssets);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/designer/src/designer/setting/setting-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ function getSettingFieldCollectorKey(
// @ts-ignore
export interface ISettingField
extends ISettingPropEntry,
Omit<
IBaseModelSettingField<ISettingTopEntry, ISettingField, IComponentMeta, INode>,
Omit<
IBaseModelSettingField<ISettingTopEntry, ISettingField, IComponentMeta, INode>,
'setValue' | 'key' | 'node'
> {
> {
readonly isSettingField: true;

readonly isRequired: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function generateSessionId(nodes: INode[]) {

export interface ISettingTopEntry
extends ISettingEntry,
IPublicModelSettingTopEntry<INode, ISettingField> {
IPublicModelSettingTopEntry<INode, ISettingField> {
readonly top: ISettingTopEntry;

readonly parent: ISettingTopEntry;
Expand Down
6 changes: 3 additions & 3 deletions packages/designer/src/designer/setting/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ function getHotterFromSetter(setter: any) {
function getTransducerFromSetter(setter: any) {
return (
(setter &&
(setter.transducer ||
setter.Transducer ||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
(setter.transducer ||
setter.Transducer ||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
null
); // eslint-disable-line
}
Expand Down
6 changes: 3 additions & 3 deletions packages/designer/src/document/document-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ import { EDITOR_EVENT } from '../types';

export type GetDataType<T, NodeType> = T extends undefined
? NodeType extends {
schema: infer R;
}
schema: infer R;
}
? R
: any
: T;

export class DocumentModel
implements
implements
Omit<
IPublicModelDocumentModel<
ISelection,
Expand Down
8 changes: 4 additions & 4 deletions packages/designer/src/document/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export class History<T = IPublicTypeNodeSchema> implements IHistory {
private timeGap: number = 1000;

constructor(
dataFn: () => T | null,
private redoer: (data: T) => void,
private document?: IDocumentModel,
) {
dataFn: () => T | null,
private redoer: (data: T) => void,
private document?: IDocumentModel,
) {
this.session = new Session(0, null, this.timeGap);
this.records = [this.session];

Expand Down
16 changes: 8 additions & 8 deletions packages/designer/src/document/node/node-children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export interface IOnChangeOptions {
}

export class NodeChildren implements Omit<IPublicModelNodeChildren<INode>,
'importSchema' |
'exportSchema' |
'isEmpty' |
'notEmpty'
'importSchema' |
'exportSchema' |
'isEmpty' |
'notEmpty'
> {
@obx.shallow children: INode[];

Expand Down Expand Up @@ -46,9 +46,9 @@ export class NodeChildren implements Omit<IPublicModelNodeChildren<INode>,
}

constructor(
readonly owner: INode,
data: IPublicTypeNodeData | IPublicTypeNodeData[],
) {
readonly owner: INode,
data: IPublicTypeNodeData | IPublicTypeNodeData[],
) {
makeObservable(this);
this.children = (Array.isArray(data) ? data : [data]).filter(child => !!child).map((child) => {
return this.owner.document?.createNode(child);
Expand Down Expand Up @@ -469,4 +469,4 @@ export class NodeChildren implements Omit<IPublicModelNodeChildren<INode>,
}
}

export interface INodeChildren extends NodeChildren {}
export interface INodeChildren extends NodeChildren {}
Loading

0 comments on commit 764e841

Please sign in to comment.