Ver código fonte

add eslint and fix tsconfig.json error config; init Editor Component

Roxas 5 anos atrás
pai
commit
d485735782

+ 17
- 0
.eslintrc.js Ver arquivo

@@ -0,0 +1,17 @@
1
+module.exports = {
2
+  parser: "@typescript-eslint/parser",
3
+  parserOptions: {
4
+    ecmaVersion: 6, //也就是ES6语法支持的意思
5
+    sourceType: "module",
6
+    ecmaFeatures: {
7
+      modules: true
8
+    }
9
+  },
10
+  plugins: ["@typescript-eslint"],
11
+  rules: {
12
+    // 禁止使用 var
13
+    "no-var": "error",
14
+    // 优先使用 interface 而不是 type
15
+    "@typescript-eslint/consistent-type-definitions": ["error", "interface"]
16
+  }
17
+};

+ 4
- 0
package.json Ver arquivo

@@ -14,6 +14,7 @@
14 14
     "@types/react-dom": "^16.9.0",
15 15
     "@types/react-intl": "^3.0.0",
16 16
     "classnames": "^2.2.6",
17
+    "draft-js": "^0.11.4",
17 18
     "kiwi-intl": "^1.2.4",
18 19
     "react-intl": "^3.9.2",
19 20
     "react-scripts": "3.3.0",
@@ -70,12 +71,15 @@
70 71
     "@storybook/react": "^5.2.8",
71 72
     "@types/storybook-readme": "^5.0.4",
72 73
     "@types/storybook__addon-info": "^5.2.1",
74
+    "@typescript-eslint/eslint-plugin": "^2.16.0",
75
+    "@typescript-eslint/parser": "^2.16.0",
73 76
     "antd": "^3.26.4",
74 77
     "autoprefixer": "^9.7.3",
75 78
     "babel-loader": "^8.0.6",
76 79
     "babel-plugin-import": "^1.13.0",
77 80
     "cross-env": "^6.0.3",
78 81
     "css-loader": "^3.2.1",
82
+    "eslint": "^6.8.0",
79 83
     "file-loader": "^5.0.2",
80 84
     "less": "^3.10.3",
81 85
     "less-loader": "^5.0.0",

+ 23
- 0
src/components/Editor/RichTextEditor/index.tsx Ver arquivo

@@ -0,0 +1,23 @@
1
+import React from 'react';
2
+import PropTypes from 'prop-types';
3
+import styles from './RichTextEditor.less';
4
+
5
+interface RichTextEditorProps {}
6
+interface RichTextEditorState {}
7
+
8
+class RichTextEditor extends React.Component<RichTextEditorProps, RichTextEditorState> {
9
+  constructor(props: RichTextEditorProps) {
10
+    super(props);
11
+    this.state = {};
12
+  }
13
+
14
+  render() {
15
+    return (
16
+      <div className={styles.wrapper}>
17
+        Component
18
+      </div>
19
+    )
20
+  }
21
+}
22
+
23
+export default RichTextEditor;

+ 5
- 5
src/components/Payment/Common/PayPlatformOptions/index.tsx Ver arquivo

@@ -17,23 +17,23 @@ type PAY_CHANNEL_VALUE =
17 17
   | "ALI_WAP"
18 18
   | "WX_WAP"
19 19
   | "WX_NATIVE";
20
-type PAY_CHANNEL_TYPE = {
20
+interface PAY_CHANNEL_TYPE {
21 21
   PAYPAL: PAY_CHANNEL_VALUE;
22 22
   ALI_WEB: PAY_CHANNEL_VALUE;
23 23
   ALI_WAP: PAY_CHANNEL_VALUE;
24 24
   WX_WAP: PAY_CHANNEL_VALUE;
25 25
   WX_NATIVE: PAY_CHANNEL_VALUE;
26
-};
26
+}
27 27
 
28
-type Props = {
28
+interface Props {
29 29
   payitem: PAY_CHANNEL_VALUE;
30 30
   onPayItemChange: (value: PAY_CHANNEL_VALUE) => void;
31 31
   isMobile: boolean;
32 32
   size: "small" | "normal" | "large";
33 33
   withTitle: boolean;
34
-  titleTxt: string;
34
+  titleTxt?: string;
35 35
   locale: "zh" | "en";
36
-};
36
+}
37 37
 
38 38
 export const PAY_CHANNEL: PAY_CHANNEL_TYPE = {
39 39
   PAYPAL: "PAYPAL_PAYPAL", // PAYPAL_LIVE

+ 0
- 3360
stats.html
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 1
- 1
stories/index.stories.tsx Ver arquivo

@@ -7,7 +7,7 @@ import { addReadme } from 'storybook-readme';
7 7
 
8 8
 import ConsumeListView from '@components/Payment/Common/ConsumeListView';
9 9
 import ConsumeListViewDoc from '@components/Payment/Common/ConsumeListView/README.md';
10
-import PayPlatFormOptions, { PAY_CHANNEL } from '@components/Payment/Common/PayPlatformOptions/index';
10
+import PayPlatFormOptions, { PAY_CHANNEL } from '@components/Payment/Common/PayPlatformOptions';
11 11
 import PayPlatFormOptionsDoc from '@components/Payment/Common/PayPlatformOptions/README.md';
12 12
 import PriceOptions from '@components/Payment/Common/PriceOptions';
13 13
 import PriceOptionsDoc from '@components/Payment/Common/PriceOptions/README.md';

+ 12
- 7
tsconfig.json Ver arquivo

@@ -13,23 +13,28 @@
13 13
     "allowJs": true,
14 14
     "skipLibCheck": true,
15 15
     "esModuleInterop": true,
16
+    "removeComments": true,
16 17
     "allowSyntheticDefaultImports": true,
17 18
     "strict": true,
18 19
     "forceConsistentCasingInFileNames": true,
19
-    "module": "esnext",
20 20
     "moduleResolution": "node",
21
+    "module": "esnext",
21 22
     "resolveJsonModule": true,
22 23
     "isolatedModules": true,
23 24
     "noEmit": true,
24
-    "jsx": "react"
25
-  },
26
-  "baseUrl": ".",
27
-  "paths": {
28
-    "@/*": ["src/*"],
29
-    "@components/*": [ "src/components/*" ]
25
+    "traceResolution": true,
26
+    "jsx": "react",
27
+    "baseUrl": ".",
28
+    "paths": {
29
+      "@/*": ["src/*"],
30
+      "@components/*": [ "src/components/*" ]
31
+    },
30 32
   },
31 33
   "include": [
32 34
     "src/**/*",
33 35
     "stories/**/*"
36
+  ],
37
+  "exclude": [
38
+    "node_modules"
34 39
   ]
35 40
 }

+ 73
- 2
yarn.lock Ver arquivo

@@ -2335,6 +2335,17 @@
2335 2335
   dependencies:
2336 2336
     "@types/yargs-parser" "*"
2337 2337
 
2338
+"@typescript-eslint/eslint-plugin@^2.16.0":
2339
+  version "2.16.0"
2340
+  resolved "https://registry.npm.taobao.org/@typescript-eslint/eslint-plugin/download/@typescript-eslint/eslint-plugin-2.16.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40typescript-eslint%2Feslint-plugin%2Fdownload%2F%40typescript-eslint%2Feslint-plugin-2.16.0.tgz#bf339b7db824c7cc3fd1ebedbc88dd17016471af"
2341
+  integrity sha1-vzObfbgkx8w/0evtvIjdFwFkca8=
2342
+  dependencies:
2343
+    "@typescript-eslint/experimental-utils" "2.16.0"
2344
+    eslint-utils "^1.4.3"
2345
+    functional-red-black-tree "^1.0.1"
2346
+    regexpp "^3.0.0"
2347
+    tsutils "^3.17.1"
2348
+
2338 2349
 "@typescript-eslint/eslint-plugin@^2.8.0":
2339 2350
   version "2.13.0"
2340 2351
   resolved "https://registry.npm.taobao.org/@typescript-eslint/eslint-plugin/download/@typescript-eslint/eslint-plugin-2.13.0.tgz#57e933fe16a2fc66dbac059af0d6d85d921d748e"
@@ -2355,6 +2366,25 @@
2355 2366
     "@typescript-eslint/typescript-estree" "2.13.0"
2356 2367
     eslint-scope "^5.0.0"
2357 2368
 
2369
+"@typescript-eslint/experimental-utils@2.16.0":
2370
+  version "2.16.0"
2371
+  resolved "https://registry.npm.taobao.org/@typescript-eslint/experimental-utils/download/@typescript-eslint/experimental-utils-2.16.0.tgz?cache=0&sync_timestamp=1578977990265&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40typescript-eslint%2Fexperimental-utils%2Fdownload%2F%40typescript-eslint%2Fexperimental-utils-2.16.0.tgz#bba65685728c532e0ddc811a0376e8d38e671f77"
2372
+  integrity sha1-u6ZWhXKMUy4N3IEaA3bo045nH3c=
2373
+  dependencies:
2374
+    "@types/json-schema" "^7.0.3"
2375
+    "@typescript-eslint/typescript-estree" "2.16.0"
2376
+    eslint-scope "^5.0.0"
2377
+
2378
+"@typescript-eslint/parser@^2.16.0":
2379
+  version "2.16.0"
2380
+  resolved "https://registry.npm.taobao.org/@typescript-eslint/parser/download/@typescript-eslint/parser-2.16.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40typescript-eslint%2Fparser%2Fdownload%2F%40typescript-eslint%2Fparser-2.16.0.tgz#d0c0135a8fdb915f670802ddd7c1ba457c1b4f9d"
2381
+  integrity sha1-0MATWo/bkV9nCALd18G6RXwbT50=
2382
+  dependencies:
2383
+    "@types/eslint-visitor-keys" "^1.0.0"
2384
+    "@typescript-eslint/experimental-utils" "2.16.0"
2385
+    "@typescript-eslint/typescript-estree" "2.16.0"
2386
+    eslint-visitor-keys "^1.1.0"
2387
+
2358 2388
 "@typescript-eslint/parser@^2.8.0":
2359 2389
   version "2.13.0"
2360 2390
   resolved "https://registry.npm.taobao.org/@typescript-eslint/parser/download/@typescript-eslint/parser-2.13.0.tgz#ea1ab394cf9ca17467e3da7f96eca9309f57c326"
@@ -2378,6 +2408,19 @@
2378 2408
     semver "^6.3.0"
2379 2409
     tsutils "^3.17.1"
2380 2410
 
2411
+"@typescript-eslint/typescript-estree@2.16.0":
2412
+  version "2.16.0"
2413
+  resolved "https://registry.npm.taobao.org/@typescript-eslint/typescript-estree/download/@typescript-eslint/typescript-estree-2.16.0.tgz#b444943a76c716ed32abd08cbe96172d2ca0ab75"
2414
+  integrity sha1-tESUOnbHFu0yq9CMvpYXLSygq3U=
2415
+  dependencies:
2416
+    debug "^4.1.1"
2417
+    eslint-visitor-keys "^1.1.0"
2418
+    glob "^7.1.6"
2419
+    is-glob "^4.0.1"
2420
+    lodash "^4.17.15"
2421
+    semver "^6.3.0"
2422
+    tsutils "^3.17.1"
2423
+
2381 2424
 "@webassemblyjs/ast@1.8.5":
2382 2425
   version "1.8.5"
2383 2426
   resolved "https://registry.npm.taobao.org/@webassemblyjs/ast/download/@webassemblyjs/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359"
@@ -4459,7 +4502,7 @@ core-js@^1.0.0:
4459 4502
   resolved "https://registry.npm.taobao.org/core-js/download/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
4460 4503
   integrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=
4461 4504
 
4462
-core-js@^2.4.0, core-js@^2.6.5:
4505
+core-js@^2.4.0, core-js@^2.4.1, core-js@^2.6.5:
4463 4506
   version "2.6.11"
4464 4507
   resolved "https://registry.npm.taobao.org/core-js/download/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c"
4465 4508
   integrity sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw=
@@ -5304,6 +5347,15 @@ draft-js@^0.10.0, draft-js@~0.10.0:
5304 5347
     immutable "~3.7.4"
5305 5348
     object-assign "^4.1.0"
5306 5349
 
5350
+draft-js@^0.11.4:
5351
+  version "0.11.4"
5352
+  resolved "https://registry.npm.taobao.org/draft-js/download/draft-js-0.11.4.tgz#e48782b96b90a5c14f2cb34c164c2a1a359d8a48"
5353
+  integrity sha1-5IeCuWuQpcFPLLNMFkwqGjWdikg=
5354
+  dependencies:
5355
+    fbjs "^1.0.0"
5356
+    immutable "~3.7.4"
5357
+    object-assign "^4.1.1"
5358
+
5307 5359
 duplexer@^0.1.1:
5308 5360
   version "0.1.1"
5309 5361
   resolved "https://registry.npm.taobao.org/duplexer/download/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
@@ -5687,7 +5739,7 @@ eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0:
5687 5739
   resolved "https://registry.npm.taobao.org/eslint-visitor-keys/download/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2"
5688 5740
   integrity sha1-4qgs6oT/JGrW+1f5veW0ZiFFnsI=
5689 5741
 
5690
-eslint@^6.0.0, eslint@^6.6.0:
5742
+eslint@^6.0.0, eslint@^6.6.0, eslint@^6.8.0:
5691 5743
   version "6.8.0"
5692 5744
   resolved "https://registry.npm.taobao.org/eslint/download/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb"
5693 5745
   integrity sha1-YiYtZylzn5J1cjgkMC+yJ8jJP/s=
@@ -6040,6 +6092,11 @@ fb-watchman@^2.0.0:
6040 6092
   dependencies:
6041 6093
     bser "2.1.1"
6042 6094
 
6095
+fbjs-css-vars@^1.0.0:
6096
+  version "1.0.2"
6097
+  resolved "https://registry.npm.taobao.org/fbjs-css-vars/download/fbjs-css-vars-1.0.2.tgz#216551136ae02fe255932c3ec8775f18e2c078b8"
6098
+  integrity sha1-IWVRE2rgL+JVkyw+yHdfGOLAeLg=
6099
+
6043 6100
 fbjs@^0.6.1:
6044 6101
   version "0.6.1"
6045 6102
   resolved "https://registry.npm.taobao.org/fbjs/download/fbjs-0.6.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffbjs%2Fdownload%2Ffbjs-0.6.1.tgz#9636b7705f5ba9684d44b72f78321254afc860f7"
@@ -6064,6 +6121,20 @@ fbjs@^0.8.0, fbjs@^0.8.15, fbjs@^0.8.16, fbjs@^0.8.4, fbjs@^0.8.9:
6064 6121
     setimmediate "^1.0.5"
6065 6122
     ua-parser-js "^0.7.18"
6066 6123
 
6124
+fbjs@^1.0.0:
6125
+  version "1.0.0"
6126
+  resolved "https://registry.npm.taobao.org/fbjs/download/fbjs-1.0.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffbjs%2Fdownload%2Ffbjs-1.0.0.tgz#52c215e0883a3c86af2a7a776ed51525ae8e0a5a"
6127
+  integrity sha1-UsIV4Ig6PIavKnp3btUVJa6OClo=
6128
+  dependencies:
6129
+    core-js "^2.4.1"
6130
+    fbjs-css-vars "^1.0.0"
6131
+    isomorphic-fetch "^2.1.1"
6132
+    loose-envify "^1.0.0"
6133
+    object-assign "^4.1.0"
6134
+    promise "^7.1.1"
6135
+    setimmediate "^1.0.5"
6136
+    ua-parser-js "^0.7.18"
6137
+
6067 6138
 figgy-pudding@^3.5.1:
6068 6139
   version "3.5.1"
6069 6140
   resolved "https://registry.npm.taobao.org/figgy-pudding/download/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790"