Skip to content

Commit

Permalink
ci: add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
1ncounter committed Apr 9, 2024
1 parent cdb9445 commit cbf57e3
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 29 deletions.
24 changes: 23 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint'
import js from '@eslint/js';
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals'

export default tseslint.config({
files: ['packages/*/src/**/*.{ts?(x),js?(x)}'],
Expand All @@ -13,19 +15,39 @@ export default tseslint.config({
],
plugins: {
'@stylistic': stylistic,
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.nodeBuiltin,
...globals.jest
},
},
rules: {
'@stylistic/indent': ['error', 2],
'@stylistic/indent-binary-ops': ['error', 2],
'@stylistic/max-len': ['error', { tabWidth: 2 }],
'@stylistic/max-len': ['error', { tabWidth: 2, "ignoreStrings": 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'],

'react/jsx-no-undef': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
'react/no-this-in-sfc': 'error',
'react/require-render-return': 'warn',
'react/no-children-prop': 'warn',

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

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"clean": "rimraf ./packages/*/dist",
"clean:lib": "rimraf ./node_modules ./packages/*/node_modules",
"lint": "eslint . --cache",
"docs": "pnpm --filter @alilc/lowcode-engine-docs run start",
"pub": "npm run watchdog:build && lerna publish patch --yes --force-publish --exact --no-changelog",
"pub:minor": "npm run watchdog:build && lerna publish minor --yes --force-publish --exact --no-changelog",
"pub:major": "npm run watchdog:build && lerna publish major --yes --force-publish --exact --no-changelog",
Expand All @@ -32,13 +33,13 @@
"@types/react-router": "5.1.18",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"execa": "^8.0.1",
"globals": "^15.0.0",
"husky": "^9.0.11",
"less": "^4.2.0",
"lint-staged": "^15.2.2",
"minimist": "^1.2.8",
"rimraf": "^5.0.2",
"rollup": "^4.13.0",
"typescript": "^5.4.2",
Expand Down
1 change: 1 addition & 0 deletions packages/designer/src/icons/hidden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export function IconHidden(props: IconProps) {
</SVGIcon>
);
}

IconHidden.displayName = 'Hidden';
1 change: 0 additions & 1 deletion packages/designer/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from './plugin-types';
import { filterValidOptions, isLowCodeRegisterOptions } from './plugin-utils';
import { LowCodePluginRuntime } from './plugin';
// eslint-disable-next-line import/no-named-as-default
import LowCodePluginContext from './plugin-context';
import { invariant } from '../utils';
import sequencify from './sequencify';
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-core/src/di/setter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function registerSetter(
function getInitialFromSetter(setter: any) {
return setter && (
setter.initial || setter.Initial
|| (setter.type && (setter.type.initial || setter.type.Initial))
|| (setter.type && (setter.type.initial || setter.type.Initial))
) || null; // eslint-disable-line
}

Expand Down
24 changes: 12 additions & 12 deletions packages/engine/src/shell/api/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class SkeletonCabin implements IPublicApiCommonSkeletonCabin {
/**
* @deprecated
*/
get PopupPipe(): any {
get PopupPipe(): any {
return InnerPopupPipe;
}
}
Expand All @@ -233,9 +233,9 @@ class Utils implements IPublicApiCommonUtils {
}

getNodeSchemaById(
schema: IPublicTypeNodeSchema,
nodeId: string,
): IPublicTypeNodeSchema | undefined {
schema: IPublicTypeNodeSchema,
nodeId: string,
): IPublicTypeNodeSchema | undefined {
return innerGetNodeSchemaById(schema, nodeId);
}

Expand All @@ -248,18 +248,18 @@ class Utils implements IPublicApiCommonUtils {
}

executeTransaction(
fn: () => void,
type: IPublicEnumTransitionType = IPublicEnumTransitionType.REPAINT,
): void {
fn: () => void,
type: IPublicEnumTransitionType = IPublicEnumTransitionType.REPAINT,
): void {
transactionManager.executeTransaction(fn, type);
}

createIntl(instance: string | object): {
intlNode(id: string, params?: object): ReactNode;
intl(id: string, params?: object): string;
getLocale(): string;
setLocale(locale: string): void;
} {
intlNode(id: string, params?: object): ReactNode;
intl(id: string, params?: object): string;
getLocale(): string;
setLocale(locale: string): void;
} {
return innerCreateIntl(instance);
}

Expand Down
1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ packages:
- 'packages/*'
- 'playground'
- 'docs'
- 'scripts'
20 changes: 10 additions & 10 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { resolve } from 'node:path';
import { existsSync } from 'node:fs';
import { readdir } from 'node:fs/promises';
import { argv } from 'node:process';
import { URL } from 'node:url'
import { argv, cwd } from 'node:process';
import minimist from 'minimist';
import { execa } from 'execa';
import { findWorkspacePackages } from '@pnpm/workspace.find-packages'

const args = minimist(argv.slice(2));
const targets = args['_'][0].split(',');
const formatArgs = args['format'];
const targets = args['_'][0];
const formatArgs = args['formats'];
const prod = args['prod'] || args['p'];

const packagesUrl = new URL('../packages', import.meta.url);

async function run() {
const packageDirs = await readdir(packagesUrl.pathname);
const targetPackages = packageDirs
.filter((dir) => targets.includes(dir))
const packages = await findWorkspacePackages(cwd());
const targetPackageName = `@alilc/lowcode-${targets[0]}`

const finalName = packages
.filter((item) => item.manifest.name.includes(targetPackageName))
.filter((dir) => existsSync(resolve(packagesUrl.pathname, dir)));

await execa('pnpm', ['--filter', `@alilc/lowcode-${targetPackages[0]}`, 'build:target'], {
await execa('pnpm', ['--filter', finalName, 'build:target'], {
stdio: 'inherit',
env: {
FORMATS: !prod ? formatArgs : undefined,
Expand Down
10 changes: 10 additions & 0 deletions scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "scripts",
"private": true,
"type": "module",
"devDependencies": {
"@pnpm/workspace.find-packages": "^1.1.12",
"execa": "^8.0.1",
"minimist": "^1.2.8"
}
}
2 changes: 1 addition & 1 deletion scripts/rollup-dts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'node:path';
import { existsSync, readdirSync } from 'node:fs';
import { env, exit } from 'node:process'
import * as console from 'node:console'
import console from 'node:console'
import { Extractor, ExtractorConfig } from '@microsoft/api-extractor';
import { rimraf } from 'rimraf';

Expand Down
2 changes: 1 addition & 1 deletion scripts/sync-oss.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import { request } from 'node:http';
import packageJson from '../packages/engine/package.json';
import * as console from 'node:console';
import console from 'node:console';
import { Buffer } from 'node:buffer'

const { version, name } = packageJson;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"removeComments": false,
"baseUrl": ".",
"rootDir": ".",
// provide type friendly tips
"paths": {
"@alilc/lowcode-*": ["packages/*/src"]
}
Expand Down

0 comments on commit cbf57e3

Please sign in to comment.