chore: lint tool

This commit is contained in:
1ncounter 2024-03-29 12:58:27 +08:00
parent 0014b6aae8
commit 1874a4b3e1
33 changed files with 89 additions and 108 deletions

View File

@ -1,59 +0,0 @@
module.exports = {
extends: 'eslint-config-ali/typescript/react',
parserOptions: {
project: [], // for lint performance
createDefaultProgram: false, // for lint performance
},
rules: {
'react/no-multi-comp': 0,
'no-unused-expressions': 0,
'implicit-arrow-linebreak': 1,
'no-nested-ternary': 1,
'no-mixed-operators': 1,
'@typescript-eslint/ban-types': 1,
'no-shadow': 1,
'no-prototype-builtins': 1,
'no-useless-constructor': 1,
'no-empty-function': 1,
'lines-between-class-members': 0,
'no-await-in-loop': 0,
'no-plusplus': 0,
'@typescript-eslint/no-parameter-properties': 0,
'no-restricted-exports': ['error'],
'no-multi-assign': 1,
'no-dupe-class-members': 1,
'react/no-deprecated': 1,
'no-useless-escape': 1,
'brace-style': 1,
'@typescript-eslint/no-inferrable-types': 0,
'no-proto': 0,
'prefer-const': 0,
'eol-last': 0,
'react/no-find-dom-node': 0,
'no-case-declarations': 0,
'@typescript-eslint/indent': 0,
'import/no-cycle': 0,
'@typescript-eslint/no-shadow': 0,
'@typescript-eslint/method-signature-style': 0,
'@typescript-eslint/consistent-type-assertions': 0,
'@typescript-eslint/no-useless-constructor': 0,
'@typescript-eslint/dot-notation': 0, // for lint performance
'@typescript-eslint/restrict-plus-operands': 0, // for lint performance
'no-unexpected-multiline': 1,
'no-multiple-empty-lines': ['error', { max: 1 }],
'lines-around-comment': ['error', {
beforeBlockComment: true,
afterBlockComment: false,
afterLineComment: false,
allowBlockStart: true,
}],
'comma-dangle': ['error', 'always-multiline'],
'@typescript-eslint/member-ordering': [
'error',
{ default: ['signature', 'field', 'constructor', 'method'] }
],
'@typescript-eslint/no-unused-vars': ['error'],
'no-redeclare': 0,
'@typescript-eslint/no-redeclare': 1,
},
};

1
.husky/commit-msg Normal file
View File

@ -0,0 +1 @@
pnpm commitlint --edit $1

1
.husky/pre-commit Normal file
View File

@ -0,0 +1 @@
# pnpm lint-staged

View File

@ -1,7 +0,0 @@
module.exports = {
printWidth: 100,
tabWidth: 2,
semi: true,
singleQuote: true,
trailingComma: 'all',
};

View File

@ -1,9 +0,0 @@
# 忽略目录
node_modules/
build/
dist/
# 忽略文件
**/*.min.css
**/*-min.css
**/*.bundle.css

View File

@ -1,6 +0,0 @@
module.exports = {
extends: 'stylelint-config-ali',
rules: {
"selector-max-id": 2
}
};

View File

@ -1,3 +1,21 @@
module.exports = {
extends: ['ali'],
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat',
'fix',
'docs',
'chore',
'style',
'refactor',
'ci',
'test',
'revert',
'perf',
],
],
}
};

40
eslint.config.js Normal file
View File

@ -0,0 +1,40 @@
import stylistic from '@stylistic/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import js from '@eslint/js';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
export default [
js.configs.recommended,
{
files: ['**/src/**/*.{ts?(x),js?(x)}'],
plugins: {
'@stylistic': stylistic,
'react-hooks': reactHooks,
},
languageOptions: {
parser: tsParser,
},
rules: {
'@stylistic/indent': ['error', 2],
"@stylistic/indent-binary-ops": ["error", 2],
'@stylistic/max-len': ["error", { "tabWidth": 2 }],
'@stylistic/no-tabs': "error",
'@stylistic/quotes': ["error", "single"],
"@stylistic/jsx-pascal-case": [2],
"@stylistic/jsx-indent": [2, 2, { checkAttributes: true, indentLogicalExpressions: true }],
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
},
},
{
files: ['**/src/**/*.{tsx,jsx}'],
plugins: {
'react-refresh': reactRefresh,
},
rules: {
'react-refresh/only-export-components': 'warn',
},
},
];

View File

@ -1,14 +1,14 @@
{
"name": "lowcode-engine-repo",
"name": "@alilc/lowcode-monorepo",
"private": true,
"type": "module",
"scripts": {
"playground": "pnpm --filter playground dev",
"test": "pnpm -r test",
"build": "pnpm -r build",
"clean": "rimraf ./packages/*/dist",
"clean:lib": "rimraf ./node_modules ./packages/*/node_modules",
"lint": "f2elint scan -q -i ./packages/*/src",
"lint:fix": "f2elint fix -i ./packages/*/src",
"lint": "eslint --cache --no-warn-ignored",
"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",
@ -16,37 +16,39 @@
"pub:preminor": "npm run watchdog:build && lerna publish preminor --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prepatch": "npm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prerelease": "npm run watchdog:build && lerna publish prerelease --yes --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"syncOss": "node ./scripts/sync-oss.js"
},
"husky": {
"hooks": {
"pre-commit": "f2elint commit-file-scan",
"commit-msg": "f2elint commit-msg-scan"
}
"syncOss": "node ./scripts/sync-oss.js",
"prepare": "husky"
},
"devDependencies": {
"@alilc/build-plugin-lce": "^0.0.5",
"@alilc/lowcode-test-mate": "^1.0.1",
"@changesets/cli": "^2.27.1",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@eslint/js": "^8.57.0",
"@microsoft/api-extractor": "^7.43.0",
"@stylistic/eslint-plugin": "^1.7.0",
"@types/node": "^20.11.30",
"@types/react-router": "5.1.18",
"@typescript-eslint/parser": "^7.4.0",
"@vitejs/plugin-react": "^4.2.1",
"babel-jest": "^26.5.2",
"del": "^6.1.1",
"execa": "^8.0.1",
"f2elint": "^4.2.1",
"gulp": "^4.0.2",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"husky": "^9.0.11",
"typescript": "^5.4.2",
"prettier": "^3.2.5",
"lint-staged": "^15.2.2",
"rimraf": "^5.0.2",
"rollup": "^4.13.0",
"typescript": "^5.4.2",
"vite": "^5.1.6",
"vitest": "^1.3.1"
},
"engines": {
"node": ">=18"
"node": "^18.18.0 || ^20.9.0 || >=21.1.0",
"pnpm": ">= 8"
},
"lint-staged": {
"*": "pnpm lint"
},
"repository": "git@github.com:alibaba/lowcode-engine.git"
}

View File

@ -1,18 +1,18 @@
{
"name": "@alilc/lowcode-renderer-react",
"name": "@alilc/lowcode-react-renderer",
"version": "2.0.0-beta.0",
"description": "react renderer for ali lowcode engine",
"type": "module",
"bugs": "https://github.com/alibaba/lowcode-engine/issues",
"homepage": "https://github.com/alibaba/lowcode-engine/#readme",
"license": "MIT",
"main": "dist/rendererReact.cjs",
"module": "dist/rendererReact.js",
"main": "dist/reactRenderer.cjs",
"module": "dist/reactRenderer.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/rendererReact.js",
"require": "./dist/rendererReact.cjs",
"import": "./dist/reactRenderer.js",
"require": "./dist/reactRenderer.cjs",
"types": "./dist/index.d.ts"
}
},

View File

@ -1,4 +1,4 @@
import EventEmitter from 'events';
import { EventEmitter } from 'events';
let instance: AppHelper | null = null;

View File

@ -1,6 +1,6 @@
import { IPublicEnumTransitionType } from '@alilc/lowcode-types';
import { runInAction } from 'mobx';
import EventEmitter from 'events';
import { EventEmitter } from 'events';
class TransactionManager {
emitter = new EventEmitter();