-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflow.js
111 lines (109 loc) · 4.47 KB
/
flow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
module.exports = {
'globals': {
'$Abstract': true,
'$All': true,
'$Diff': true,
'$Enum': true,
'$Either': true,
'$Exact': true,
'$Exports': true,
'$Keys': true,
'$NonMaybeType': true,
'$PropertyType': true,
'$Shape': true,
'$Subtype': true,
'$Supertype': true,
'$Tuple': true,
'$Type': true,
'Class': true,
'ReactClass': true,
'ReactComponent': true,
'ReactElement': true
},
'plugins': ['flowtype', 'import'],
'rules': {
// 関数の括弧まわりの改行スタイル
// https://eslint.org/docs/rules/function-paren-newline
'function-paren-newline': [2, 'consistent'], // 引数の型を含めると可読性のため引数1つでも改行したくなる場合がある
// flowの`import type {..} form './foo'`を考慮してくれる
'no-duplicate-imports': 0,
'import/no-duplicates': 2,
/**
* Flow
*/
// boolean typeのスタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/boolean-style': [2, 'boolean'],
// 未定義のflowtypeを警告
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/define-flow-type': 2,
// ケツカンマのスタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/delimiter-dangle': [2, 'never'],
// genericsの空白スタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/generic-spacing': [2, 'never'],
// キーの重複禁止
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/no-dupe-keys': 2,
// Array, []の使用禁止 ($ReadOnlyArrayを強制)
// https://github.com/gajus/eslint-plugin-flowtype#no-mutable-array
'flowtype/no-mutable-array': 0, // 書くのとかつらそう
// プリミティブ型のconstructorを型として使用禁止
// https://github.com/gajus/eslint-plugin-flowtype#no-primitive-constructor-types
'flowtype/no-primitive-constructor-types': 2,
// flow annotation忘れ防止
// https://github.com/gajus/eslint-plugin-flowtype#no-types-missing-file-annotation
'flowtype/no-types-missing-file-annotation': 2,
// 未使用の式を禁止
// https://github.com/gajus/eslint-plugin-flowtype#no-unused-expressions
'flowtype/no-unused-expressions': 2,
// 逃げの型を禁止
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/no-weak-types': 0, // 逃げたいときはある
// オブジェクト属性の区切り記号
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/object-type-delimiter': [2, 'comma'],
// 引数の型付けを強制
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/require-parameter-type': 0, // flow側にまかせたいときがある
// 戻り値の型付けを強制
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/require-return-type': 0, // flow側にまかせたいときがある
// flow annotationを強制
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/require-valid-file-annotation': [2, 'always'],
// 変数の型付けを強制
// https://github.com/gajus/eslint-plugin-flowtype#require-variable-type
'flowtype/require-variable-type': 0, // flow側にまかせたいときがある
// セミコロンのスタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/semi': [2, 'always'],
// プロパティの並び順
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/sort-keys': [2, 'asc'],
// コロン後の空白スタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/space-after-type-colon': [2, 'always'],
// generics括弧前の空白スタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/space-before-generic-bracket': [2, 'never'],
// コロン前の空白スタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/space-before-type-colon': [2, 'never'],
// type名のフォーマット
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/type-id-match': [2, '^([A-Z][a-z0-9]*)+$'],
// union, intersectionの空白スタイル
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/union-intersection-spacing': [2, 'always'],
// type aliasを使用したものと解釈
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/use-flow-type': 2
},
'settings': {
'flowtype': {
'onlyFilesWithFlowAnnotation': true
}
}
};