Merge pull request #4 from webzard-io/refactor/add-eslint

add eslint
This commit is contained in:
tanbowensg 2022-01-17 16:45:37 +08:00 committed by Bowen Tan
parent 5ac40e0785
commit 02baff5b32
7 changed files with 1627 additions and 34 deletions

View File

@ -0,0 +1,34 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint"],
"rules": {
"linebreak-style": ["error", "unix"],
"react/prop-types": "off",
"no-case-declarations": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"react/display-name": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
},
"ignorePatterns": ["node_modules", "*.d.ts", "*.js", "package.json", "*.html"]
}

View File

@ -0,0 +1,30 @@
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}
readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."
if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi
if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi
export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"
if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
exit $exitCode
fi
exit 0
fi

View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged

View File

@ -6,23 +6,45 @@
"build": "tsc && vite build",
"serve": "vite preview",
"lk": "yarn link @sunmao-ui/runtime @sunmao-ui/editor @sunmao-ui/core",
"unlk": "yarn unlink @sunmao-ui/runtime @sunmao-ui/editor @sunmao-ui/core"
"unlk": "yarn unlink @sunmao-ui/runtime @sunmao-ui/editor @sunmao-ui/core",
"lint": "eslint ./src --ext .ts --ext .tsx",
"fix-lint": "eslint --fix ./src --ext .ts --ext .tsx"
},
"dependencies": {
"@arco-design/web-react": "^2.26.1",
"@emotion/css": "^11.5.0",
"@sinclair/typebox": "^0.23.1",
"@sunmao-ui/core": "^0.3.3",
"@sunmao-ui/runtime": "^0.3.7",
"@sunmao-ui/core": "^0.3.5",
"@sunmao-ui/runtime": "^0.3.9",
"eslint-plugin-react-hooks": "^4.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@sunmao-ui/editor": "^0.3.7",
"@sunmao-ui/editor": "^0.3.9",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@vitejs/plugin-react": "^1.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.25.1",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"typescript": "^4.3.2",
"vite": "^2.6.4"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,tsx,html}": [
"prettier --write",
"eslint --fix",
"git add"
]
}
}

View File

@ -18,7 +18,7 @@ type CascaderOptions = {
children?: CascaderOptions[];
};
const convertArrToTree = (arr: Array<Array<string>>) => {
let map: MapItem = {};
const map: MapItem = {};
let node = map;
// convert array to object, use the uniqueness of the object key

View File

@ -20,7 +20,7 @@ const LayoutStateSchema = Type.Object({});
const LayoutImpl: ComponentImpl<Static<typeof LayoutPropsSchema>> = (props) => {
const { slotsElements, customStyle } = props;
const cProps = getComponentProps(props);
console.log('layout', slotsElements)
return (
<BaseLayout className={css(customStyle?.content)} {...cProps}>
{slotsElements.content}

File diff suppressed because it is too large Load Diff