UNPKG

4.88 kBJavaScriptView Raw
1const presentRulesOnly = require("./tools/presentRulesOnly");
2
3module.exports = {
4 extends: ["prettier"],
5 env: { browser: true },
6 parserOptions: {
7 ecmaFeatures: {
8 jsx: true,
9 },
10 },
11 settings: {
12 react: {
13 version: "detect",
14 },
15 },
16 plugins: ["react", "react-hooks"],
17 rules: presentRulesOnly({
18 "react/boolean-prop-naming": [
19 "error",
20 { rule: "^(is|has)[A-Z]([A-Za-z0-9]?)+" },
21 ],
22 "react/button-has-type": "error",
23 "react/default-props-match-prop-types": "off", // PropTypesはもう使わない
24 "react/destructuring-assignment": "off", // 気にしない
25 "react/display-name": "error",
26 "react/forbid-component-props": "off",
27 "react/forbid-dom-props": "off", // 厳しすぎる
28 "react/forbid-elements": "off",
29 "react/forbid-foreign-prop-types": "off",
30 "react/forbid-prop-types": "off",
31 "react/function-component-definition": "off", // どっちでもいい
32 "react/jsx-boolean-value": "error",
33 "react/jsx-curly-brace-presence": "off",
34 "react/jsx-filename-extension": "off",
35 "react/jsx-fragments": ["error", "syntax"],
36 "react/jsx-handler-names": "off",
37 "react/jsx-key": "error",
38 "react/jsx-max-depth": "off",
39 "react/jsx-no-bind": [
40 "error",
41 {
42 ignoreDOMComponents: false,
43 ignoreRefs: false,
44 allowArrowFunctions: true, // hooks
45 allowFunctions: false,
46 allowBind: false,
47 },
48 ],
49 "react/jsx-no-comment-textnodes": "error",
50 "react/jsx-no-duplicate-props": "error",
51 "react/jsx-no-literals": "off",
52 "react/jsx-no-script-url": [
53 "error",
54 [
55 {
56 name: "Link",
57 props: ["to"],
58 },
59 ],
60 ],
61 "react/jsx-no-target-blank": "error",
62 "react/jsx-no-undef": "error",
63 "react/jsx-no-useless-fragment": "error",
64 "react/jsx-pascal-case": "error",
65 "react/jsx-props-no-spreading": "off",
66 "react/jsx-sort-default-props": "off",
67 "react/jsx-sort-props": [
68 "error",
69 {
70 callbacksLast: false,
71 shorthandFirst: false,
72 shorthandLast: false,
73 ignoreCase: true,
74 noSortAlphabetically: true,
75 reservedFirst: true,
76 },
77 ],
78 "react/jsx-uses-react": "off",
79 "react/jsx-uses-vars": "error",
80 "react/jsx-indent": "off",
81 "react/no-access-state-in-setstate": "error",
82 "react/no-adjacent-inline-elements": "error",
83 "react/no-array-index-key": "off", // index以外を指定できることは少ない
84 "react/no-children-prop": "error",
85 "react/no-danger": "off", // 使うときはそもそも覚悟してる
86 "react/no-danger-with-children": "error",
87 "react/no-deprecated": "error",
88 "react/no-did-mount-set-state": "error",
89 "react/no-did-update-set-state": "error",
90 "react/no-direct-mutation-state": "error",
91 "react/no-find-dom-node": "error",
92 "react/no-is-mounted": "error",
93 "react/no-multi-comp": ["warn", { ignoreStateless: true }],
94 "react/no-redundant-should-component-update": "error",
95 "react/no-render-return-value": "error",
96 "react/no-set-state": "off", // ストイックすぎる
97 "react/no-string-refs": "error",
98 "react/no-this-in-sfc": "error",
99 "react/no-typos": "error",
100 "react/no-unescaped-entities": "error",
101 "react/no-unknown-property": "error",
102 "react/no-unsafe": "error",
103 "react/no-unused-prop-types": "off",
104 "react/no-unused-state": "error",
105 "react/no-will-update-set-state": "error",
106 "react/prefer-es6-class": ["error", "always"],
107 "react/prefer-read-only-props": "error",
108 "react/prefer-stateless-function": "off",
109 "react/prop-types": "off",
110 "react/react-in-jsx-scope": "off",
111 "react/require-default-props": "off", // PropTypesに依存
112 "react/require-optimization": "off",
113 "react/require-render-return": "error",
114 "react/self-closing-comp": [
115 "error",
116 {
117 component: true,
118 html: false,
119 },
120 ],
121 "react/sort-comp": "off",
122 "react/sort-prop-types": "off",
123 "react/state-in-constructor": "off",
124 "react/static-property-placement": "error",
125 "react/style-prop-object": "error",
126 "react/void-dom-elements-no-children": "error",
127 "react-hooks/rules-of-hooks": "error",
128 "react-hooks/exhaustive-deps": "error",
129 "react/jsx-newline": "off",
130 "react/jsx-no-constructed-context-values": "error",
131 "react/no-unstable-nested-components": ["error", { allowAsProps: true }],
132 "react/no-arrow-function-lifecycle": "error",
133 "react/no-invalid-html-attribute": "error",
134 "react/no-namespace": "error",
135 "react/no-unused-class-component-methods": "off",
136 "react/prefer-exact-props": "off",
137 "react/hook-use-state": "error",
138 "react/iframe-missing-sandbox": "error",
139 "react/jsx-no-leaked-render": "off", // TS側でbooleanを強制する
140 }),
141};