UNPKG

2.85 kBJavaScriptView Raw
1module.exports = {
2 parser: "babel-eslint", // now needed for class properties
3 parserOptions: {
4 sourceType: "module",
5 ecmaFeatures: {
6 }
7 },
8 env: {
9 browser: true,
10 node: true,
11
12 // babel's transform-runtime converts references to ES6 globals such as
13 // Promise and Map to core-js polyfills, so we can use ES6 globals.
14 es6: true,
15 },
16 extends: ["eslint:recommended", "google"],
17 plugins: [
18 "babel",
19 ],
20 rules: {
21 // rules we've always adhered to or now do
22 "max-len": ["error", {
23 code: 90,
24 ignoreComments: true,
25 }],
26 curly: ["error", "multi-line"],
27 "prefer-const": ["error"],
28 "comma-dangle": ["error", {
29 arrays: "always-multiline",
30 objects: "always-multiline",
31 imports: "always-multiline",
32 exports: "always-multiline",
33 functions: "always-multiline",
34 }],
35
36 // loosen jsdoc requirements a little
37 "require-jsdoc": ["error", {
38 require: {
39 FunctionDeclaration: false,
40 }
41 }],
42 "valid-jsdoc": ["error", {
43 requireParamDescription: false,
44 requireReturn: false,
45 requireReturnDescription: false,
46 }],
47
48 // rules we do not want from eslint-recommended
49 "no-console": ["off"],
50 "no-constant-condition": ["off"],
51 "no-empty": ["error", { "allowEmptyCatch": true }],
52
53 // rules we do not want from the google styleguide
54 "object-curly-spacing": ["off"],
55 "spaced-comment": ["off"],
56 "guard-for-in": ["off"],
57
58 // in principle we prefer single quotes, but life is too short
59 quotes: ["off"],
60
61 // rules we'd ideally like to adhere to, but the current
62 // code does not (in most cases because it's still ES5)
63 // we set these to warnings, and assert that the number
64 // of warnings doesn't exceed a given threshold
65 "no-var": ["warn"],
66 "brace-style": ["warn", "1tbs", {"allowSingleLine": true}],
67 "prefer-rest-params": ["warn"],
68 "prefer-spread": ["warn"],
69 "one-var": ["warn"],
70 "padded-blocks": ["warn"],
71 "no-extend-native": ["warn"],
72 "camelcase": ["warn"],
73 "no-multi-spaces": ["error", { "ignoreEOLComments": true }],
74 "space-before-function-paren": ["error", {
75 "anonymous": "never",
76 "named": "never",
77 "asyncArrow": "always",
78 }],
79 "arrow-parens": "off",
80
81 // eslint's built in no-invalid-this rule breaks with class properties
82 "no-invalid-this": "off",
83 // so we replace it with a version that is class property aware
84 "babel/no-invalid-this": "error",
85 }
86}