summaryrefslogtreecommitdiff
path: root/.eslintrc.json
blob: 9571d853cf2bc3c9d90276155a32b85fd1c23950 (plain)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
{
    "root": true,
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "script"
    },
    "env": {
        "browser": true,
        "es2017": true,
        "webextensions": true
    },
    "plugins": ["no-unsanitized"],
    "ignorePatterns": [
        "/ext/lib/"
    ],
    "rules": {
        "arrow-parens": ["error", "always"],
        "comma-dangle": ["error", "never"],
        "curly": ["error", "all"],
        "dot-notation": "error",
        "eqeqeq": "error",
        "func-names": ["error", "always"],
        "guard-for-in": "error",
        "new-parens": "error",
        "no-case-declarations": "error",
        "no-const-assign": "error",
        "no-constant-condition": "off",
        "no-global-assign": "error",
        "no-param-reassign": "off",
        "no-prototype-builtins": "error",
        "no-shadow": ["error", {"builtinGlobals": false}],
        "no-undef": "error",
        "no-undefined": "error",
        "no-underscore-dangle": ["error", {"allowAfterThis": true, "allowAfterSuper": false, "allowAfterThisConstructor": false}],
        "no-unexpected-multiline": "error",
        "no-unneeded-ternary": "error",
        "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}],
        "no-unused-expressions": "error",
        "no-var": "error",
        "prefer-const": ["error", {"destructuring": "all"}],
        "quote-props": ["error", "consistent"],
        "quotes": ["error", "single", "avoid-escape"],
        "require-atomic-updates": "off",
        "semi": "error",
        "wrap-iife": ["error", "inside"],

        "brace-style": ["error", "1tbs", {"allowSingleLine": true}],
        "indent": ["error", 4, {"SwitchCase": 1, "MemberExpression": 1, "flatTernaryExpressions": true, "ignoredNodes": ["ConditionalExpression"]}],
        "object-curly-newline": "error",
        "padded-blocks": ["error", "never"],

        "array-bracket-spacing": ["error", "never"],
        "arrow-spacing": ["error", {"before": true, "after": true}],
        "block-spacing": ["error", "always"],
        "comma-spacing": ["error", { "before": false, "after": true }],
        "computed-property-spacing": ["error", "never"],
        "func-call-spacing": ["error", "never"],
        "function-paren-newline": ["error", "multiline-arguments"],
        "generator-star-spacing": ["error", "before"],
        "key-spacing": ["error", {"beforeColon": false, "afterColon": true, "mode": "strict"}],
        "keyword-spacing": ["error", {"before": true, "after": true}],
        "no-trailing-spaces": "error",
        "no-whitespace-before-property": "error",
        "object-curly-spacing": ["error", "never"],
        "rest-spread-spacing": ["error", "never"],
        "semi-spacing": ["error", {"before": false, "after": true}],
        "space-before-function-paren": ["error", {
            "anonymous": "never",
            "named": "never",
            "asyncArrow": "always"
        }],
        "space-in-parens": ["error", "never"],
        "space-unary-ops": "error",
        "spaced-comment": ["error", "always"],
        "switch-colon-spacing": ["error", {"after": true, "before": false}],
        "template-curly-spacing": ["error", "never"],
        "template-tag-spacing": ["error", "never"],

        "no-unsanitized/method": "error",
        "no-unsanitized/property": "error"
    },
    "overrides": [
        {
            "files": [
                "ext/js/core.js",
                "ext/js/data/anki-note-data.js",
                "ext/js/language/dictionary-data-util.js",
                "ext/js/templates/template-renderer.js"
            ],
            "env": {
                "webextensions": false
            }
        },
        {
            "files": ["ext/**/*.js"],
            "excludedFiles": [
                "ext/js/core.js",
                "ext/js/data/anki-note-data.js",
                "ext/js/language/dictionary-data-util.js",
                "ext/js/templates/template-renderer.js"
            ],
            "globals": {
                "serializeError": "readonly",
                "deserializeError": "readonly",
                "isObject": "readonly",
                "stringReverse": "readonly",
                "promiseTimeout": "readonly",
                "escapeRegExp": "readonly",
                "deferPromise": "readonly",
                "clone": "readonly",
                "deepEqual": "readonly",
                "generateId": "readonly",
                "promiseAnimationFrame": "readonly",
                "invokeMessageHandler": "readonly",
                "log": "readonly",
                "DynamicProperty": "readonly",
                "EventDispatcher": "readonly",
                "EventListenerCollection": "readonly",
                "Logger": "readonly"
            }
        },
        {
            "files": ["ext/**/*.js"],
            "excludedFiles": [
                "ext/js/core.js",
                "ext/js/yomichan.js",
                "ext/js/data/anki-note-data.js",
                "ext/js/language/dictionary-data-util.js",
                "ext/js/templates/template-renderer.js"
            ],
            "globals": {
                "yomichan": "readonly"
            }
        },
        {
            "files": ["ext/js/yomichan.js"],
            "globals": {
                "chrome": "writable"
            }
        },
        {
            "files": ["ext/js/pages/settings/modal-jquery.js"],
            "env": {
                "jquery": true
            }
        },
        {
            "files": [
                "test/**/*.js",
                "dev/**/*.js"
            ],
            "excludedFiles": ["test/data/html/*.js"],
            "parserOptions": {
                "ecmaVersion": 8,
                "sourceType": "module"
            },
            "env": {
                "browser": false,
                "es2017": true,
                "node": true,
                "webextensions": false
            }
        },
        {
            "files": [
                "ext/js/core.js",
                "ext/js/yomichan.js",
                "ext/js/background/backend.js",
                "ext/js/background/environment.js",
                "ext/js/background/profile-conditions-util.js",
                "ext/js/background/request-builder.js",
                "ext/js/comm/anki.js",
                "ext/js/comm/clipboard-monitor.js",
                "ext/js/comm/clipboard-reader.js",
                "ext/js/comm/mecab.js",
                "ext/js/data/database.js",
                "ext/js/data/json-schema.js",
                "ext/js/data/options-util.js",
                "ext/js/data/permissions-util.js",
                "ext/js/dom/simple-dom-parser.js",
                "ext/js/general/cache-map.js",
                "ext/js/general/object-property-accessor.js",
                "ext/js/general/text-source-map.js",
                "ext/js/language/deinflector.js",
                "ext/js/language/dictionary-data-util.js",
                "ext/js/language/dictionary-database.js",
                "ext/js/language/japanese-util.js",
                "ext/js/language/translator.js",
                "ext/js/media/audio-downloader.js",
                "ext/js/media/media-util.js",
                "ext/js/templates/template-patcher.js",
                "ext/js/background/background-main.js"
            ],
            "env": {
                "browser": false,
                "serviceworker": true,
                "es2017": true,
                "webextensions": true
            },
            "globals": {
                "FileReader": "readonly",
                "Intl": "readonly",
                "crypto": "readonly"
            }
        }
    ]
}