chore: 使用 f2elint

This commit is contained in:
lihao.ylh 2021-12-09 20:55:26 +08:00
parent 327d4a3656
commit 1aeef60d03
16 changed files with 27 additions and 29 deletions

View File

@ -28,6 +28,8 @@ module.exports = {
'eol-last': 0,
'react/no-find-dom-node': 0,
'no-case-declarations': 0,
'@typescript-eslint/indent': 0
'@typescript-eslint/indent': 0,
'import/no-cycle': 0,
'@typescript-eslint/no-shadow': 0,
}
};

View File

@ -25,23 +25,20 @@
"test": "lerna run test --stream",
"test:snapshot": "lerna run test:snapshot",
"watchdog:build": "node ./scripts/watchdog.js",
"xima:fix": "xima fix",
"xima:scan": "xima scan --quiet"
"f2elint:scan": "f2elint scan -q -i ./packages/*/src",
"f2elint:fix": "f2elint fix -i ./packages/*/src"
},
"husky": {
"hooks": {
"pre-commit": "xima exec lint-staged",
"commit-msg": "xima exec commitlint -E HUSKY_GIT_PARAMS"
"pre-commit": "f2elint commit-file-scan",
"commit-msg": "f2elint commit-msg-scan"
}
},
"lint-staged": {
"**/*.{css,scss,less}": "xima exec stylelint",
"**/*.{js,jsx,ts,tsx}": "xima exec eslint"
},
"devDependencies": {
"@ali/lerna": "^1",
"typescript": "^3.2.2",
"xima": "^0.3.0"
"f2elint": "^2.0.1",
"husky": "^7.0.4",
"typescript": "^3.2.2"
},
"engines": {
"node": ">=14.0.0"

View File

@ -1,4 +0,0 @@
编排模块
simulator/renderer 发 CDN

View File

@ -47,9 +47,9 @@ function getTitle(title: string | I18nData | ReactElement) {
@observer
export class BorderContainer extends Component<{
host: BuiltinSimulatorHost,
host: BuiltinSimulatorHost;
}, {
target?: ParentalNode,
target?: ParentalNode;
}> {
state = {} as any;

View File

@ -1004,7 +1004,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
if (!domNode) return;
if (isElementNode(domNode) && !isDOMNodeVisible(domNode, this.viewport)) {
const { left, top } = domNode.getBoundingClientRect();
const { scrollTop = 0, scrollLeft = 0 } = this.contentDocument?.documentElement!;
const { scrollTop = 0, scrollLeft = 0 } = this.contentDocument?.documentElement || {};
opt.left = left + scrollLeft;
opt.top = top + scrollTop;
scroll = true;

View File

@ -62,7 +62,7 @@ export class LiveEditing {
let setterPropElement = getSetterPropElement(targetElement, rootElement);
let propTarget = setterPropElement?.dataset.setterProp;
let matched: (LiveTextEditingConfig & { propElement?: HTMLElement; }) | undefined | null;
let matched: (LiveTextEditingConfig & { propElement?: HTMLElement }) | undefined | null;
if (liveTextEditing) {
if (propTarget) {
// 已埋点命中 data-setter-prop="proptarget", 从 liveTextEditing 读取配置mode|onSaveContent
@ -196,7 +196,8 @@ export interface SaveHandler {
}
function setCaret(event: MouseEvent) {
const doc = event.view?.document!;
const doc = event.view?.document;
if (!doc) return;
const range = doc.caretRangeFromPoint(event.clientX, event.clientY);
if (range) {
selectRange(doc, range);

View File

@ -14,6 +14,7 @@ export const getClosestClickableNode = (
while (node) {
// 判断当前节点是否可点击
let canClick = canClickNode(node, event);
// eslint-disable-next-line no-loop-func
const lockedNode = getClosestNode(node!, (n) => {
// 假如当前节点就是 locked 状态,要从当前节点的父节点开始查找
return !!(node?.isLocked ? n.parent?.isLocked : n.isLocked);

View File

@ -179,7 +179,7 @@ hotkey.bind(['command+z', 'ctrl+z'], (e) => {
e.preventDefault();
const selection = focusing.focusDesigner?.currentSelection;
const curSelected = Array.from(selection?.selected!);
const curSelected = Array.from(selection?.selected || []);
his.back();
selection?.selectAll(curSelected);
});
@ -193,7 +193,7 @@ hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e) => {
}
e.preventDefault();
const selection = focusing.focusDesigner?.currentSelection;
const curSelected = Array.from(selection?.selected!);
const curSelected = Array.from(selection?.selected || []);
his.forward();
selection?.selectAll(curSelected);
});

View File

@ -8,7 +8,6 @@
align-items: center;
pointer-events: none;
background-color: rgba(0, 0, 0, 0.4);
//opacity: 0.9;
box-shadow: 0 0 6px grey;
transform: translate(-10%, -50%);
.lc-ghost {

View File

@ -98,7 +98,7 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
return this._config;
}
private initItems(items: Array<FieldConfig | CustomView>, settingFieldCollector?: { (name: string | number, field: SettingField): void; (name: string, field: SettingField): void; }) {
private initItems(items: Array<FieldConfig | CustomView>, settingFieldCollector?: { (name: string | number, field: SettingField): void; (name: string, field: SettingField): void }) {
this._items = items.map((item) => {
if (isCustomView(item)) {
return item;

View File

@ -292,7 +292,7 @@ export class SettingPropEntry implements SettingEntry {
}
}
notifyValueChange(oldValue: any, newValue:any) {
notifyValueChange(oldValue: any, newValue: any) {
this.editor.emit(GlobalEvent.Node.Prop.Change, { node: this.getNode(), prop: this, oldValue, newValue });
}

View File

@ -72,7 +72,7 @@ export class DocumentModel {
/**
* @deprecated
*/
private _addons: Array<{ name: string, exportData: any }> = [];
private _addons: Array<{ name: string; exportData: any }> = [];
/**
*
@ -634,7 +634,7 @@ export class DocumentModel {
) {
let visitorResult = {};
if (!visitorName) {
/* tslint:disable no-console */
/* eslint-disable-next-line no-console */
console.warn('Invalid or empty RootNodeVisitor name.');
}
try {

View File

@ -933,7 +933,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return this.props;
}
onChildrenChange(fn: (param?: { type: string, node: Node }) => void): (() => void) | undefined {
onChildrenChange(fn: (param?: { type: string; node: Node }) => void): (() => void) | undefined {
const wrappedFunc = wrapWithEventSwitch(fn);
return this.children?.onChange(wrappedFunc);
}

View File

@ -8,6 +8,7 @@ import { TransformStage } from '../transform-stage';
const { set: mobxSet, isObservableArray } = mobx;
export const UNSET = Symbol.for('unset');
// eslint-disable-next-line no-redeclare
export type UNSET = typeof UNSET;
export interface IPropParent {

View File

@ -5,6 +5,7 @@ import { BuiltinSimulatorRenderer } from './builtin-simulator/renderer';
import { Node, ParentalNode } from './document';
export type AutoFit = '100%';
// eslint-disable-next-line no-redeclare
export const AutoFit = '100%';
export interface IViewport extends IScrollable {

View File

@ -2,6 +2,6 @@ import Logger, { Level } from 'zen-logger';
export { Logger };
export function getLogger(config: { level: Level, bizName: string }): Logger {
export function getLogger(config: { level: Level; bizName: string }): Logger {
return new Logger(config);
}