Merge pull request #8 from alibaba/test/setup-action

chore: 修改 code style 以及配置 lint & test action
This commit is contained in:
JackLian 2022-02-17 16:59:18 +08:00 committed by GitHub
commit d16fed25a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 52 additions and 17 deletions

36
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: lint & test
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: install
run: npm i && npm run setup:skip-build
- name: lint
run: npm run lint
test-designer:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: install
run: npm i && npm run setup:skip-build
- name: lint
run: cd packages/designer && npm test

View File

@ -53,7 +53,6 @@ export function flattenResult(dir: ResultDir, cwd = ''): FlattenFile[] {
),
].concat(
...dir.dirs.map((subDir) =>
flattenResult(subDir, [cwd, subDir.name].filter((x) => x !== '' && x !== '.').join('/')),
),
flattenResult(subDir, [cwd, subDir.name].filter((x) => x !== '' && x !== '.').join('/'))),
);
}

View File

@ -50,6 +50,7 @@ export function resolveToImport(initialPath) {
}
pathBuffer.unshift(...paths);
}
// eslint-disable-next-line no-fallthrough
case 'Identifier':
case 'JSXIdentifier': {
const valuePath = resolveToValue(path);

View File

@ -25,6 +25,7 @@ export default function getComposedPropTypesPath(documentation, propName, p) {
const ast = parser.parse(fileContent);
visit(ast, {
// eslint-disable-next-line no-loop-func
visitAssignmentExpression(path: any) {
// Ignore anything that is not `exports.X = ...;` or
// `module.exports = ...;`

View File

@ -299,8 +299,7 @@ function getDocgenTypeHelper(
name: 'union',
// @ts-ignore
value: type.types.map((t) =>
getDocgenTypeHelper(checker, t, true, getNextParentIds(parentIds, type)),
),
getDocgenTypeHelper(checker, t, true, getNextParentIds(parentIds, type))),
});
} else if (isComplexType(type)) {
return makeResult({
@ -494,8 +493,7 @@ export default function parseTS(filePath: string, args: IParseArgs): ComponentDo
log('ts config path is', tsConfigPath);
const { config, error } = ts.readConfigFile(tsConfigPath, (filename) =>
readFileSync(filename, 'utf8'),
);
readFileSync(filename, 'utf8'));
if (error !== undefined) {
const errorText = `Cannot load custom tsconfig.json from provided path: ${tsConfigPath}, with error code: ${error.code}, message: ${error.messageText}`;

View File

@ -24,7 +24,6 @@
"setup:test": "./scripts/setup-for-test.sh",
"setup:skip-build": "./scripts/setup-skip-build.sh",
"start": "./scripts/start.sh",
"start:demo": "./scripts/start.sh @ali/lowcode-demo",
"test": "lerna run test --stream",
"test:snapshot": "lerna run test:snapshot",
"watchdog:build": "node ./scripts/watchdog.js",

View File

@ -37,6 +37,7 @@ export declare interface Editor extends StrictEventEmitter<EventEmitter, GlobalE
getPreference(): Preference;
}
// eslint-disable-next-line no-redeclare
export class Editor extends (EventEmitter as any) implements IEditor {
/**
* Ioc Container

View File

@ -28,11 +28,11 @@ window.__newFunc = (funContext: string): ((...args: any[]) => any) => {
};
// 关闭浏览器前提醒,只有产生过交互才会生效
window.onbeforeunload = function (e: Event): string | void {
window.onbeforeunload = function (e: Event): string {
const ev = e || window.event;
// 本地调试不生效
if (location.href.indexOf('localhost') > 0) {
return;
return '';
}
const msg = '您确定要离开此页面吗?';
ev.cancelBubble = true;

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);
}

View File

@ -16,7 +16,7 @@ export default class Preference {
return `${STORAGE_KEY_PREFIX}_${moduleKey}.${key}`;
}
set(key: string, value:any, module?: string) {
set(key: string, value: any, module?: string) {
if (!key || typeof key !== 'string' || key.length === 0) {
logger.error('Invalid key when setting preference', key);
return;
@ -26,7 +26,7 @@ export default class Preference {
store.set(storageKey, value);
}
get(key: string, module: string) : any {
get(key: string, module: string): any {
if (!key || typeof key !== 'string' || key.length === 0) {
logger.error('Invalid key when getting from preference', key);
return;
@ -44,7 +44,7 @@ export default class Preference {
* @returns {boolean}
* @memberof Preference
*/
contains(key: string, module: string) : boolean {
contains(key: string, module: string): boolean {
if (!key || typeof key !== 'string' || key.length === 0) {
logger.error('Invalid key when getting from preference', key);
return false;

View File

@ -7,7 +7,7 @@ interface UtilsMetadata {
subName?: string;
destructuring?: boolean;
main?: string;
}
};
}
interface LibrayMap {

View File

@ -126,7 +126,8 @@ function toCss(runtime) {
css.push(
`:root${pseudo === 'default' ? '' : `${prefix}${pseudo}`} {
${runtimeToCss(normalizeStyle(runtime[pseudo]))}
}\n`);
}\n`,
);
});
return css.join('\n');
}

View File

@ -1,7 +1,6 @@
export function setPrototypeOf(target: any, proto: any) {
// tslint:disable-next-line
if (typeof Object.setPrototypeOf !== 'undefined') {
Object.setPrototypeOf(target, proto); // tslint:disable-line
Object.setPrototypeOf(target, proto);
} else {
// eslint-disable-next-line no-proto
target.__proto__ = proto;