/
.eslintrc.js
149 lines (124 loc) · 5.32 KB
/
.eslintrc.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
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
"use strict";
/**
* @file
* This is the main configuration file that defines all the rules eslint will use to validate code.
*/
const os = require("os");
module.exports = {
plugins: [
"jsdoc",
"promise",
],
env: {
"es2021": true,
"browser": true,
"worker": true,
"serviceworker": true,
"node": true,
},
ignorePatterns: [
//Dotfiles are ignored by default. This makes sure they are linted.
"!**/.*.js",
//Ignore any test fixture files. They might be intentionally bad.
"test/fixture/**",
],
extends: [
"eslint:recommended",
"plugin:jsdoc/recommended",
"plugin:promise/recommended",
],
//Rules are ordered according to their documentation: https://eslint.org/docs/rules/
rules: {
//Possible Errors
"no-loss-of-precision": "error",
"no-unreachable-loop": "error",
"no-unsafe-optional-chaining": ["error", {"disallowArithmeticOperators": true}],
"no-useless-backreference": "error",
"require-atomic-updates": "off", //disabled until bug is resolved: https://github.com/eslint/eslint/issues/11899
//Best Practices
"curly": ["error", "multi-line"],
"default-case-last": "error",
"dot-location": ["error", "property"],
"eqeqeq": ["error", "always"],
"guard-for-in": "error",
"no-empty-function": "error",
"no-eval": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": ["error", {"lexicalBindings": false}],
"no-implied-eval": "error",
"no-script-url": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"no-void": "error",
"prefer-named-capture-group": "error",
"require-unicode-regexp": "error",
//Strict Mode
"strict": ["error", "global"],
//Variables
"no-label-var": "error",
"no-undef-init": "error",
//Stylistic Issues
"array-element-newline": ["error", "consistent"],
"brace-style": ["error", "1tbs", {"allowSingleLine": true}],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": ["error", {"before": false, "after": true}],
"comma-style": ["error", "last"],
"eol-last": ["error", "always"],
"func-call-spacing": ["error", "never"],
"function-call-argument-newline": ["error", "consistent"],
"function-paren-newline": ["error", "consistent"],
"implicit-arrow-linebreak": ["error", "beside"],
"indent": ["error", "tab", {"MemberExpression": "off", "SwitchCase": 1}],
"key-spacing": ["error", {"beforeColon": false, "afterColon": true, "mode": "minimum"}],
// If the operating system does not use Unix EOLs, Git should auto-convert between EOL types when pushing/pulling code.
// If Git is incorrectly configured, the wrong EOLs can end up in the codebase, but will be detected next time linting is run on an OS with Unix EOLs.
// This is mainly a problem on Windows and it's a mess.
"linebreak-style": [os.EOL === "\n" ? "error" : "off", "unix"],
"max-depth": ["error", {"max": 10}],
"max-nested-callbacks": ["error", {"max": 10}],
"multiline-ternary": ["error", "always-multiline"],
"new-cap": ["error", {"newIsCap": true, "capIsNew": true, "properties": true}],
"no-array-constructor": "error",
"no-bitwise": "error",
"no-mixed-operators": "error",
"no-multi-assign": "error",
"no-multiple-empty-lines": ["error", {"max": 4, "maxEOF": 1, "maxBOF": 3}],
"no-new-object": "error",
"no-underscore-dangle": "error",
"no-unneeded-ternary": "error",
"object-curly-newline": ["error", {"consistent": true}],
"prefer-exponentiation-operator": "error",
"prefer-object-spread": "error",
"quote-props": ["error", "consistent"],
"quotes": ["error", "double", {"avoidEscape": true, "allowTemplateLiterals": true}],
"semi": ["error", "always"],
"semi-spacing": ["error", {"before": false, "after": true}],
"semi-style": ["error", "last"],
// "keywords" has to be off to allow blocks in switch-statements, but this also means that things like if- and for-statements are not enforced :/
"space-before-blocks": ["error", {"functions": "never", "keywords": "off", "classes": "never"}],
"space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}],
"space-infix-ops": "error",
"space-unary-ops": ["error", {"words": true, "nonwords": false}],
"switch-colon-spacing": ["error", {"after": true, "before": false}],
"unicode-bom": ["error", "never"],
"wrap-regex": "error",
//ECMAScript 6
"arrow-spacing": ["error", {"before": true, "after": true}],
"no-var": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-template": "error",
"rest-spread-spacing": ["error", "never"],
//JSDOC rules: https://github.com/gajus/eslint-plugin-jsdoc
"jsdoc/check-access": "warn",
"jsdoc/check-examples": "warn",
"jsdoc/check-indentation": "warn",
"jsdoc/check-syntax": "warn",
"jsdoc/require-description": "warn",
"jsdoc/require-description-complete-sentence": "warn",
"jsdoc/require-file-overview": "warn",
"jsdoc/require-hyphen-before-param-description": "warn",
"jsdoc/tag-lines": "off",
},
};