]> git.openstreetmap.org Git - rails.git/blob - config/eslint.js
Merge remote-tracking branch 'upstream/pull/5083'
[rails.git] / config / eslint.js
1 const globals = require("globals");
2 const js = require("@eslint/js");
3
4 module.exports = [
5   js.configs.recommended,
6   {
7     languageOptions: {
8       ecmaVersion: 2015,
9       sourceType: "script",
10       globals: {
11         ...globals.browser,
12         ...globals.jquery,
13         Cookies: "readonly",
14         I18n: "readonly",
15         L: "readonly",
16         OSM: "writable",
17         Matomo: "readonly",
18         Qs: "readonly",
19         Turbo: "readonly",
20         updateLinks: "readonly"
21       }
22     },
23     rules: {
24       "accessor-pairs": "error",
25       "array-bracket-newline": ["error", "consistent"],
26       "array-bracket-spacing": "error",
27       "array-callback-return": "error",
28       "block-scoped-var": "error",
29       "block-spacing": "error",
30       "brace-style": ["error", "1tbs", { allowSingleLine: true }],
31       "comma-dangle": "error",
32       "comma-spacing": "error",
33       "comma-style": "error",
34       "computed-property-spacing": "error",
35       "curly": ["error", "multi-line", "consistent"],
36       "dot-location": ["error", "property"],
37       "dot-notation": "error",
38       "eol-last": "error",
39       "eqeqeq": ["error", "smart"],
40       "func-call-spacing": "error",
41       "indent": ["error", 2, {
42         SwitchCase: 1,
43         VariableDeclarator: "first",
44         FunctionDeclaration: { parameters: "first" },
45         FunctionExpression: { parameters: "first" },
46         CallExpression: { arguments: "first" }
47       }],
48       "key-spacing": "error",
49       "keyword-spacing": "error",
50       "no-alert": "warn",
51       "no-array-constructor": "error",
52       "no-caller": "error",
53       "no-console": "warn",
54       "no-div-regex": "error",
55       "no-eq-null": "error",
56       "no-eval": "error",
57       "no-extend-native": "error",
58       "no-extra-bind": "error",
59       "no-extra-label": "error",
60       "no-floating-decimal": "error",
61       "no-implicit-coercion": "warn",
62       "no-implicit-globals": "warn",
63       "no-implied-eval": "error",
64       "no-invalid-this": "error",
65       "no-iterator": "error",
66       "no-labels": "error",
67       "no-label-var": "error",
68       "no-lone-blocks": "error",
69       "no-lonely-if": "error",
70       "no-loop-func": "error",
71       "no-mixed-operators": "error",
72       "no-multiple-empty-lines": "error",
73       "no-multi-spaces": "error",
74       "no-multi-str": "error",
75       "no-negated-condition": "error",
76       "no-nested-ternary": "error",
77       "no-new": "error",
78       "no-new-func": "error",
79       "no-new-object": "error",
80       "no-new-wrappers": "error",
81       "no-octal-escape": "error",
82       "no-param-reassign": "error",
83       "no-process-env": "error",
84       "no-proto": "error",
85       "no-script-url": "error",
86       "no-self-compare": "error",
87       "no-sequences": "error",
88       "no-throw-literal": "error",
89       "no-trailing-spaces": "error",
90       "no-undef-init": "error",
91       "no-undefined": "error",
92       "no-unmodified-loop-condition": "error",
93       "no-unneeded-ternary": "error",
94       "no-unused-expressions": "off",
95       "no-unused-vars": ["error", { caughtErrors: "none" }],
96       "no-useless-call": "error",
97       "no-useless-concat": "error",
98       "no-useless-return": "error",
99       "no-use-before-define": ["error", { functions: false }],
100       "no-void": "error",
101       "no-warning-comments": "warn",
102       "no-whitespace-before-property": "error",
103       "object-curly-newline": ["error", { consistent: true }],
104       "object-curly-spacing": ["error", "always"],
105       "object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
106       "operator-linebreak": ["error", "after"],
107       "padded-blocks": ["error", "never"],
108       "quote-props": ["error", "consistent-as-needed", { keywords: true, numbers: true }],
109       "quotes": ["error", "double"],
110       "radix": ["error", "always"],
111       "semi": ["error", "always"],
112       "semi-spacing": "error",
113       "semi-style": "error",
114       "space-before-blocks": "error",
115       "space-before-function-paren": ["error", { named: "never" }],
116       "space-in-parens": "error",
117       "space-infix-ops": "error",
118       "space-unary-ops": "error",
119       "switch-colon-spacing": "error",
120       "wrap-iife": "error",
121       "wrap-regex": "error",
122       "yoda": "error"
123     }
124   },
125   {
126     files: ["config/eslint.js"],
127     languageOptions: {
128       ecmaVersion: 2019,
129       sourceType: "commonjs",
130       globals: {
131         ...globals.commonjs
132       }
133     }
134   }
135 ];