Skip to content

Commit 29463b0

Browse files
authored
Merge pull request #1 from 290352095/development
项目初始化
2 parents 965d3cd + a8c1c36 commit 29463b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2004
-1
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.env

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#指定覆盖默认配置的配置文件
2+
UMI_ENV=prod umi build
3+
4+
#指定端口号
5+
PORT=8008 umi dev
6+
7+
HOST=0.0.0.0
8+
9+
#默认自动打开浏览器,值为none不打开 在umi dev生效
10+
$ BROWSER=none umi dev
11+
12+
# 分析build构成 默认关闭 端口默认为8888
13+
$ ANALYZE=1 umi build
14+
$ ANALYZE_PORT=8888
15+
16+
#默认引入polyfill 值为none不引入 2.2.0+版本支持 当前版本不支持
17+
$ BABEL_POLYFILL=none umi build
18+
19+
#默认压缩css和js 值为none时不压缩
20+
COMPRESS=none umi build
21+
#默认压缩CSS 有时css压缩会出问题 可选择性只压缩JS
22+
CSS_COMPRESS=none umi build
23+
24+
#默认清屏值为none不清
25+
CLEAR_CONSOLE=none
26+
27+
#默认开启 值为none禁用 值为reload时 文件有变化刷新
28+
HMR=reload
29+
30+
#默认不解析
31+
$ BABELRC
32+
33+
#默认开启babel cache 值为none禁用
34+
BABEL_CACHE=none umi dev
35+
36+
#默认开启mock 值为none禁用
37+
$ MOCK=none umi dev
38+
39+
#默认打包html文件 值为none不打包
40+
$ HTML=none umi build
41+
42+
#默认不开启TS检查,值为1 启用
43+
$ FORK_TS_CHECKER=1 umi dev
44+
45+
$ WATCH_FILES
46+
$ RM_TMPDIR

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/

.eslintrc.js

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
/* eslint quotes: false*/
2+
module.exports = {
3+
extends: ['eslint-config-alloy/typescript-react', 'eslint-config-umi'],
4+
settings: {
5+
//用于支持webpack定义的别名 (需要安装 eslint-plugin-import 和 eslint-import-resolver-webpack 插件)
6+
'import/resolver': 'webpack',
7+
},
8+
env: {
9+
browser: true,
10+
node: false,
11+
es6: true,
12+
mocha: false,
13+
commonjs: false,
14+
amd: false,
15+
},
16+
plugins: [
17+
'typescript',
18+
'react', // 插件地址 https://github.com/yannickcr/eslint-plugin-react
19+
'import', // 插件地址 https://github.com/benmosher/eslint-plugin-import
20+
],
21+
parserOptions: {
22+
23+
sourceType: 'module',
24+
ecmaVersion: 6,
25+
ecmaFeatures: {
26+
jsx: true, // 迁移说明: http://eslint.org/docs/user-guide/migrating-to-2.0.0
27+
},
28+
},
29+
ecmaFeatures: {
30+
arrowFunctions: true, // 是否支持箭头函数
31+
blockBindings: true, // 是否支持 let 和 const`
32+
classes: true, // 是否支持 class
33+
defaultParams: true, // 是否支持
34+
destructuring: true, // 是否支持对象析构
35+
forOf: true, // 是否支持 for-of 语法
36+
objectLiteralComputedProperties: true, // 是否支持 计算属性名称 var lastName = "last name"; person[lastName] = "Zakas";
37+
objectLiteralShorthandMethods: true, // 是否支持缩短方法名 sayName: function() { => sayName() {
38+
objectLiteralShorthandProperties: true, // 是否支持缩短对象名 name: name, => name,
39+
spread: true, // 是否支持 spread
40+
superInFunctions: true, // 是否支持函数里调用 super
41+
templateStrings: true, // 是否支持 ES6 模板语法
42+
},
43+
globals: {
44+
__webpack_public_path__: true,
45+
process: true,
46+
__dirname: true,
47+
CFG: true, // VM配置全局变量
48+
_: true, // lodash 全局变量
49+
React: true,
50+
ReactDom: true,
51+
KISSY: false,
52+
TB: false,
53+
JSTracker: false,
54+
JSTracker2: false,
55+
$: false, // Kimi 全局变量
56+
goldlog: true, // 黄金令箭
57+
WindVane: false, // 手淘环境
58+
require: true, // 手淘环境
59+
},
60+
parser: 'typescript-eslint-parser',
61+
rules: {
62+
// ES6 规则
63+
// http://gitlab.alibaba-inc.com/specs/style-guide/issues/50#96
64+
'no-redeclare': 0,
65+
'prefer-const': 0,
66+
'no-const-assign': 2,
67+
'no-undefined': 0,
68+
'no-class-assign': 2,
69+
'no-param-reassign': 0,
70+
'no-dupe-class-members': 2,
71+
'rest-spread-spacing': 2,
72+
'no-duplicate-imports': 2,
73+
'no-useless-rename': 2,
74+
'arrow-spacing': 2,
75+
'no-useless-computed-key': 2,
76+
'template-curly-spacing': 2,
77+
'object-curly-spacing': 0,
78+
'generator-star-spacing': [1, { before: false, after: true }],
79+
'yield-star-spacing': [1, { before: false, after: true }],
80+
/**
81+
* 最佳实践
82+
*/
83+
strict: [0, 'global'],
84+
'global-strict': [0, 'always'], // deprecated rule, 忽略,采用上面规则限制
85+
'no-extra-strict': 0,
86+
'no-shadow': 1, // 局部变量和外层变量重名
87+
88+
// 使用该项配置会导致esLint挂掉? babel-eslint升级之8.0.0版本
89+
// "no-unused-vars": "error",
90+
'no-unused-vars': [
91+
0, // 局部变量未使用
92+
{
93+
vars: 'all',
94+
args: 'after-used',
95+
},
96+
],
97+
98+
'no-undef': 0, // 未定义的变量
99+
'no-dupe-keys': 2, // 在创建对象字面量时不允许键重复 {a:1,a:1}
100+
'no-dupe-args': 2, // 函数参数不能重复
101+
'no-unused-expressions': 0, // 未使用的表达式
102+
'no-use-before-define': 0, // 允许定义前使用
103+
yoda: 0,
104+
eqeqeq: 0,
105+
'no-new': 0, // 允许 new 创建的对象没有被引用
106+
'consistent-return': 0, // 允许没有 return
107+
'dot-notation': [
108+
2,
109+
{
110+
// 操作对象属性时,优先使用 . 操作
111+
allowKeywords: true,
112+
},
113+
],
114+
'no-extend-native': 2, // 禁止通过 prototype 给原生对象增加额外方法。
115+
'no-native-reassign': 2, // 阻止复写内置类型
116+
'no-return-assign': 2, // 是否允许 return 返回表达式
117+
'no-return-await': 0, // 是否允许 await 返回表达式
118+
'no-constant-condition': [
119+
2,
120+
{
121+
checkLoops: false,
122+
},
123+
], // 提示拒绝使用已经明确意义的判断条件 if (true)
124+
'max-len': [
125+
1,
126+
200,
127+
2,
128+
{
129+
ignoreComments: true,
130+
ignoreUrls: true,
131+
},
132+
],
133+
134+
'no-caller': 2,
135+
'no-loop-func': 1,
136+
137+
// nodejs 环境规则
138+
//"no-console": "warn", // 代码禁止出现 console
139+
'no-catch-shadow': 2, // try catch 捕获的变量名禁止重名定义
140+
'no-new-require': 0, // require 前面是否能添加 new
141+
'no-mixed-requires': [0, false], // 是否合并 var requires
142+
'no-path-concat': 0, // 是否可以自行拼接 path 还是必须要引用 path 模块
143+
'handle-callback-err': 0, // 代码里面是否有处理 err 的逻辑?
144+
145+
/**
146+
* 代码风格
147+
*/
148+
'no-empty': 0, // 允许空 block 语句
149+
indent: [
150+
2,
151+
2,
152+
{
153+
// 缩进
154+
SwitchCase: 1,
155+
},
156+
],
157+
camelcase: [
158+
1,
159+
{
160+
// 驼峰,同时检查属性名
161+
properties: 'always',
162+
},
163+
],
164+
quotes: [2, 'single', 'avoid-escape'], // 引号,强制使用单引号
165+
'brace-style': [
166+
2,
167+
'1tbs',
168+
{
169+
allowSingleLine: false,
170+
},
171+
],
172+
'comma-spacing': [
173+
2,
174+
{
175+
// 逗号空格
176+
before: false,
177+
after: true,
178+
},
179+
],
180+
'comma-style': [2, 'last'], // 逗号风格
181+
'eol-last': 0, // 最后留一行空行
182+
'func-names': 0, // 是否所有函数必须命名
183+
'new-cap': [
184+
1,
185+
{
186+
// 类名首字母大写
187+
newIsCap: true,
188+
},
189+
],
190+
'key-spacing': [
191+
2,
192+
{
193+
// object 的 key value :的前后空格
194+
beforeColon: false,
195+
afterColon: true,
196+
},
197+
],
198+
'no-multi-spaces': 2, // 表达式中是否允许多个空格
199+
'no-multiple-empty-lines': 0, // 是否允许多行空格
200+
'no-nested-ternary': 0, // 是否禁止三目运算
201+
'no-new-object': 2, // 禁止 new Object()
202+
'no-spaced-func': 2, // 函数与括号的空格
203+
'no-trailing-spaces': 0, // 是否允许末尾有空格
204+
'no-extra-parens': [1, 'functions'], // "no-wrap-func": 1, 禁止额外的括号 允许括号内是方法
205+
'no-underscore-dangle': 0, // 允许任意使用下划线
206+
'one-var': [1, 'never'], // 定义变量一行一个
207+
'padded-blocks': [0, 'never'], // 块代码上下不能留空行
208+
semi: 2, // 校验分号
209+
'semi-spacing': 2, // 分号后面留空
210+
'keyword-spacing': 2, // 关键词后面加空格
211+
'space-before-blocks': 2, // 块级代码加空格
212+
'space-infix-ops': 0, // 操作符之间的空格
213+
'spaced-comment': [
214+
1,
215+
'always',
216+
{
217+
line: {
218+
markers: ['/'],
219+
exceptions: ['-', '+'],
220+
},
221+
block: {
222+
markers: ['!'],
223+
exceptions: ['*'],
224+
balanced: true,
225+
},
226+
},
227+
], // 注释斜线后面是否需要空格
228+
229+
/**
230+
* ts 规范
231+
*/
232+
233+
// 'typescript/no-constant-condition': 2,
234+
'typescript/quotemark': [true,"single","avoid-escape","jsx-double"],
235+
'typescript/no-console': 0,
236+
'typescript/ordered-imports': 0,
237+
'typescript/no-namespace': 0,
238+
'typescript/object-literal-sort-keys': 0,
239+
'typescript/arrow-parens': 0,
240+
'typescript/no-empty': 0,
241+
'typescript/no-var-requires': 0,
242+
'typescript/array-type': 0,
243+
// 'typescript/member-ordering': [true,{
244+
// "order":[
245+
// "private-static-field",
246+
// "protected-static-field",
247+
// "public-static-field",
248+
// "private-instence-field",
249+
// "protected-instence-field",
250+
// "public-instence-field",
251+
// "private-constructor",
252+
// "protected-constructor",
253+
// "public-constructor",
254+
// "private-static-method",
255+
// "protected-static-method",
256+
// "public-static-method",
257+
// "private-instence-method",
258+
// "protected-instence-method",
259+
// "public-instence-method"
260+
// ]
261+
// }],
262+
'typescript/object-literal-key-quotes': [true,"as-needed"],
263+
'typescript/no-trailing-whitespace': [false,"ignore-comments"],
264+
'typescript/class-name-casing': 2,
265+
266+
/**
267+
* React JSX 规范
268+
*/
269+
'react/display-name': 0, // 是否显示 Component 名称
270+
'react/jsx-boolean-value': [0, 'always'], // 传递布尔值时是否明确支持
271+
'jsx-quotes': [2, 'prefer-double'], // jsx 属性值用双引号
272+
'react/jsx-no-undef': 2, // 判断 jsx 是否已经定义
273+
'react/jsx-sort-props': 0, // 是否排序 props
274+
'react/jsx-sort-prop-types': 0, // 是否排序 prop types
275+
'react/jsx-uses-react': 2, // 组件中中是否用了 react
276+
'react/jsx-uses-vars': 2, // 定义了 jsx component 没有使用
277+
'react/no-did-mount-set-state': 0, // 不要在 componentDidMount 里面设置 state
278+
'react/no-did-update-set-state': 0, // 同上
279+
'react/no-multi-comp': 0, // 一个文件里面禁止声明多个 component
280+
'react/no-unknown-property': 2, // 检查 class、for 属性是否转义
281+
'react/prop-types': 0, // 不强制设置 proptypes
282+
'react/react-in-jsx-scope': 1, // 查看 jsx 是否引入 react
283+
'react/self-closing-comp': 2, // 检查是否有没有 children 的非子闭合标签
284+
'react/jsx-wrap-multilines': 1, // 不强制 return 的时候,结构的格式
285+
'react/sort-comp': [
286+
0,
287+
{
288+
// 不强制 createClass 属性的排序
289+
order: [
290+
'lifecycle',
291+
'/^on.+$/',
292+
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
293+
'everything-else',
294+
'/^render.+$/',
295+
'render',
296+
],
297+
},
298+
],
299+
'react/jsx-indent-props': 0,
300+
301+
302+
'no-var':0
303+
},
304+
305+
};

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/npm-debug.log*
6+
/yarn-error.log
7+
/yarn.lock
8+
/package-lock.json
9+
10+
# production
11+
/dist
12+
13+
# misc
14+
.DS_Store
15+
16+
# umi
17+
.umi
18+
.umi-production
19+
20+
# ide
21+
.idea
22+
23+
.eslintrc.1.js

0 commit comments

Comments
 (0)