Browse Source

dev: 增加eslint

master
Cmen 3 years ago
parent
commit
c45f365cee
  1. 7
      .editorconfig
  2. 27
      package.json
  3. 5
      src/app/index.tsx
  4. 4
      src/editor/Catalog/index.tsx
  5. 4
      src/editor/Menu/index.tsx
  6. 8
      src/editor/Plot/Tools/index.tsx
  7. 2
      src/editor/Plot/index.less
  8. 1
      src/editor/Plot/index.tsx
  9. 4
      src/editor/Property/index.tsx
  10. 5
      src/editor/index.less
  11. 2
      src/editor/index.tsx
  12. 49
      src/icon.less
  13. 3
      src/index.less
  14. 16
      src/index.tsx
  15. 5
      src/store/index.ts
  16. 7
      src/store/initState.ts
  17. 2
      src/store/reducers.ts
  18. 4
      src/store/type.ts
  19. 1
      src/types/index.d.ts
  20. 9
      vite.config.js
  21. 2954
      yarn.lock

7
.editorconfig

@ -0,0 +1,7 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8

27
package.json

@ -4,7 +4,8 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"preview": "vite preview" "preview": "vite preview",
"lint": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,less,md}\""
}, },
"dependencies": { "dependencies": {
"antd": "^4.16.13", "antd": "^4.16.13",
@ -20,9 +21,33 @@
"@types/react": "^17.0.33", "@types/react": "^17.0.33",
"@types/react-dom": "^17.0.10", "@types/react-dom": "^17.0.10",
"@vitejs/plugin-react": "^1.0.7", "@vitejs/plugin-react": "^1.0.7",
"eslint": "^8.7.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-react-app": "^7.0.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"lint-staged": "^12.2.2",
"ncp": "^2.0.0", "ncp": "^2.0.0",
"prettier": "^2.5.1",
"typescript": "^4.4.4", "typescript": "^4.4.4",
"vite": "^2.6.4", "vite": "^2.6.4",
"vitepress": "^0.20.0" "vitepress": "^0.20.0"
},
"eslintConfig": {
"extends": [
"react-app",
"plugin:prettier/recommended"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json,less,md}": [
"prettier --write"
],
"src/**/*.{js, ts}": "eslint"
} }
} }

5
src/app/index.tsx

@ -1,6 +1,5 @@
const App = () => { const App = () => {
return <h1></h1> return <h1></h1>;
} };
export default App; export default App;

4
src/editor/Catalog/index.tsx

@ -1,7 +1,5 @@
const Catalog = () => { const Catalog = () => {
return <h1></h1>; return <h1></h1>;
} };
export default Catalog; export default Catalog;

4
src/editor/Menu/index.tsx

@ -1,7 +1,5 @@
const Menu = () => { const Menu = () => {
return <h1></h1>; return <h1></h1>;
} };
export default Menu; export default Menu;

8
src/editor/Plot/Tools/index.tsx

@ -1,9 +1,9 @@
import { Tooltip } from "antd"; import { Tooltip } from "antd";
type IconWithTipProps = { type IconWithTipProps = {
type: string, type: string;
text: string, text: string;
placement?: "top" | "right", placement?: "top" | "right";
}; };
const IconWithTip = ({ type, text, placement = "top" }: IconWithTipProps) => { const IconWithTip = ({ type, text, placement = "top" }: IconWithTipProps) => {
@ -31,6 +31,6 @@ const Tools = () => {
</div> </div>
</> </>
); );
} };
export default Tools; export default Tools;

2
src/editor/Plot/index.less

@ -37,7 +37,7 @@
display: inline-block; display: inline-block;
border-radius: 4px; border-radius: 4px;
margin-top: 4px; margin-top: 4px;
box-shadow: 1px 1px 4px rgba(0, 0, 0, .3); box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.3);
} }
} }
} }

1
src/editor/Plot/index.tsx

@ -8,7 +8,6 @@ import "./index.less";
const { Header, Footer, Sider, Content } = Layout; const { Header, Footer, Sider, Content } = Layout;
const Plot = () => { const Plot = () => {
const mapStageRef = useRef<HTMLDivElement>(null); const mapStageRef = useRef<HTMLDivElement>(null);
useEffect(() => { useEffect(() => {

4
src/editor/Property/index.tsx

@ -1,7 +1,5 @@
const Property = () => { const Property = () => {
return <h1></h1>; return <h1></h1>;
} };
export default Property; export default Property;

5
src/editor/index.less

@ -1,4 +1,3 @@
.editor-main { .editor-main {
height: 100%; height: 100%;
} }
@ -11,7 +10,9 @@
.editor-body-center { .editor-body-center {
position: relative; position: relative;
} }
.editor-header, .editor-body-left, .editor-body-right{ .editor-header,
.editor-body-left,
.editor-body-right {
background-color: #fff; background-color: #fff;
} }

2
src/editor/index.tsx

@ -19,4 +19,4 @@ export const Editor = () => {
</Layout> </Layout>
</Layout> </Layout>
); );
} };

49
src/icon.less

@ -1,11 +1,14 @@
@font-face { @font-face {
font-family: 'iconfont'; /* Project id 2872894 */ font-family: "iconfont"; /* Project id 2872894 */
src: url('//at.alicdn.com/t/font_2872894_c6wq9g1vj1v.woff2?t=1642594908994') format('woff2'), src: url("//at.alicdn.com/t/font_2872894_c6wq9g1vj1v.woff2?t=1642594908994")
url('//at.alicdn.com/t/font_2872894_c6wq9g1vj1v.woff?t=1642594908994') format('woff'), format("woff2"),
url('//at.alicdn.com/t/font_2872894_c6wq9g1vj1v.ttf?t=1642594908994') format('truetype'); url("//at.alicdn.com/t/font_2872894_c6wq9g1vj1v.woff?t=1642594908994")
format("woff"),
url("//at.alicdn.com/t/font_2872894_c6wq9g1vj1v.ttf?t=1642594908994")
format("truetype");
} }
.icon { .icon {
font-family: 'iconfont'; font-family: "iconfont";
font-size: 14px; font-size: 14px;
line-height: 20px; line-height: 20px;
cursor: pointer; cursor: pointer;
@ -16,58 +19,58 @@
display: inline-block; display: inline-block;
} }
.icon-boundary:after { .icon-boundary:after {
content: '\e7a9'; content: "\e7a9";
} }
.icon-confirm:after { .icon-confirm:after {
content: '\e618'; content: "\e618";
} }
.icon-export:after { .icon-export:after {
content: '\e791'; content: "\e791";
} }
.icon-polygon:after { .icon-polygon:after {
content: '\e67b'; content: "\e67b";
} }
.icon-ellipse:after { .icon-ellipse:after {
content: '\e610'; content: "\e610";
} }
.icon-polyline:after { .icon-polyline:after {
content: '\e68f'; content: "\e68f";
} }
.icon-edit:after { .icon-edit:after {
content: '\e609'; content: "\e609";
} }
.icon-delete:after { .icon-delete:after {
content: '\e61c'; content: "\e61c";
} }
.icon-search:after { .icon-search:after {
content: '\e600'; content: "\e600";
} }
.icon-select:after { .icon-select:after {
content: '\e607'; content: "\e607";
} }
.icon-help:after { .icon-help:after {
content: '\e752'; content: "\e752";
} }
.icon-import:after { .icon-import:after {
content: '\e792'; content: "\e792";
} }
.icon-open:after { .icon-open:after {
content: '\eddb' content: "\eddb";
} }
.icon-save:after { .icon-save:after {
content: '\eddc'; content: "\eddc";
} }
.icon-setting:after { .icon-setting:after {
content: '\e78e'; content: "\e78e";
} }
.icon-location:after { .icon-location:after {
content: '\e793'; content: "\e793";
} }
.icon-rect:after { .icon-rect:after {
content: '\e604'; content: "\e604";
} }
.icon-circle:after { .icon-circle:after {
content: '\edf8'; content: "\edf8";
} }
.icon-selected { .icon-selected {
color: rgb(31, 107, 206); color: rgb(31, 107, 206);

3
src/index.less

@ -1,6 +1,7 @@
@import "./icon.less"; @import "./icon.less";
html, body{ html,
body {
margin: 0; margin: 0;
padding: 0; padding: 0;
height: 100%; height: 100%;

16
src/index.tsx

@ -1,15 +1,15 @@
import React from 'react'; import React from "react";
import ReactDOM from 'react-dom'; import ReactDOM from "react-dom";
import 'antd/dist/antd.css'; import "antd/dist/antd.css";
import { store, StoreContext } from './store'; import { store, StoreContext } from "./store";
import { Editor } from './editor'; import { Editor } from "./editor";
import './index.less'; import "./index.less";
ReactDOM.render( ReactDOM.render(
<StoreContext.Provider value={store}> <StoreContext.Provider value={store}>
<Editor /> <Editor />
</StoreContext.Provider>, </StoreContext.Provider>,
document.getElementById('app') document.getElementById("app")
) );

5
src/store/index.ts

@ -24,8 +24,9 @@ export { store };
// } // }
// } // }
export const StoreContext = createContext<IStore | null>(
export const StoreContext = createContext<IStore | null>(null) as Context<IStore>; null
) as Context<IStore>;
export const useStore = () => { export const useStore = () => {
const store = useContext(StoreContext); const store = useContext(StoreContext);

7
src/store/initState.ts

@ -1,8 +1,7 @@
import { IEditorState } from "./type"; import { IEditorState } from "./type";
export const initState: IEditorState = { export const initState: IEditorState = {
map: { map: {
polygons: [] polygons: [],
} },
} };

2
src/store/reducers.ts

@ -4,7 +4,7 @@ import { initState } from "./initState";
export type Action = { export type Action = {
type: string; type: string;
payload: any; payload: any;
} };
export function reducer(state = initState, action: Action) { export function reducer(state = initState, action: Action) {
return state; return state;

4
src/store/type.ts

@ -1,5 +1,3 @@
export interface IPolygon { export interface IPolygon {
id: string; id: string;
name: string; name: string;
@ -10,5 +8,5 @@ export interface IMapState {
} }
export interface IEditorState { export interface IEditorState {
map: IMapState, map: IMapState;
} }

1
src/types/index.d.ts vendored

@ -1,4 +1,3 @@
declare global { declare global {
namespace AMapLoader { namespace AMapLoader {
const load: (config: any) => Promise<AMap.Map>; const load: (config: any) => Promise<AMap.Map>;

9
vite.config.js

@ -1,9 +1,18 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import path from "path";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
resolve: {
alias: {
"@store": path.resolve(__dirname, "src/store"),
"@editor": path.resolve(__dirname, "src/editor"),
"@app": path.resolve(__dirname, "src/app"),
"@types": path.resolve(__dirname, "src/types"),
},
},
server: { server: {
port: 8080 port: 8080
}, },

2954
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save