|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +const recommended = { |
| 4 | + extends: [ |
| 5 | + "airbnb-base", |
| 6 | + "plugin:prettier/recommended", |
| 7 | + "plugin:yml/recommended", |
| 8 | + ], |
| 9 | + root: true, |
| 10 | + env: { |
| 11 | + browser: true, |
| 12 | + es6: true, |
| 13 | + node: true, |
| 14 | + }, |
| 15 | + globals: { |
| 16 | + Drupal: true, |
| 17 | + drupalSettings: true, |
| 18 | + drupalTranslations: true, |
| 19 | + jQuery: true, |
| 20 | + _: true, |
| 21 | + Cookies: true, |
| 22 | + Backbone: true, |
| 23 | + Modernizr: true, |
| 24 | + loadjs: true, |
| 25 | + Popper: true, |
| 26 | + Shepherd: true, |
| 27 | + Sortable: true, |
| 28 | + once: true, |
| 29 | + CKEDITOR: true, |
| 30 | + CKEditor5: true, |
| 31 | + tabbable: true, |
| 32 | + }, |
| 33 | + rules: { |
| 34 | + "prettier/prettier": "error", |
| 35 | + "consistent-return": ["off"], |
| 36 | + "no-underscore-dangle": ["off"], |
| 37 | + "max-nested-callbacks": ["warn", 3], |
| 38 | + "import/no-mutable-exports": ["warn"], |
| 39 | + "no-plusplus": [ |
| 40 | + "warn", |
| 41 | + { |
| 42 | + allowForLoopAfterthoughts: true, |
| 43 | + }, |
| 44 | + ], |
| 45 | + "no-param-reassign": ["off"], |
| 46 | + "no-prototype-builtins": ["off"], |
| 47 | + "valid-jsdoc": [ |
| 48 | + "warn", |
| 49 | + { |
| 50 | + prefer: { |
| 51 | + returns: "return", |
| 52 | + property: "prop", |
| 53 | + }, |
| 54 | + requireReturn: false, |
| 55 | + }, |
| 56 | + ], |
| 57 | + "no-unused-vars": ["warn"], |
| 58 | + "operator-linebreak": [ |
| 59 | + "error", |
| 60 | + "after", |
| 61 | + { overrides: { "?": "ignore", ":": "ignore" } }, |
| 62 | + ], |
| 63 | + "yml/indent": ["error", 2], |
| 64 | + }, |
| 65 | +}; |
| 66 | + |
| 67 | +const jquery = { |
| 68 | + plugins: ["jquery"], |
| 69 | + rules: { |
| 70 | + "jquery/no-ajax": 0, |
| 71 | + "jquery/no-ajax-events": 2, |
| 72 | + "jquery/no-animate": 0, |
| 73 | + "jquery/no-attr": 0, |
| 74 | + "jquery/no-bind": 2, |
| 75 | + "jquery/no-class": 0, |
| 76 | + "jquery/no-clone": 0, |
| 77 | + "jquery/no-closest": 0, |
| 78 | + "jquery/no-css": 0, |
| 79 | + "jquery/no-data": 0, |
| 80 | + "jquery/no-deferred": 0, |
| 81 | + "jquery/no-delegate": 2, |
| 82 | + "jquery/no-each": 0, |
| 83 | + "jquery/no-extend": 0, |
| 84 | + "jquery/no-fade": 0, |
| 85 | + "jquery/no-filter": 0, |
| 86 | + "jquery/no-find": 0, |
| 87 | + "jquery/no-global-eval": 2, |
| 88 | + "jquery/no-grep": 2, |
| 89 | + "jquery/no-has": 0, |
| 90 | + "jquery/no-hide": 0, |
| 91 | + "jquery/no-html": 0, |
| 92 | + "jquery/no-in-array": 0, |
| 93 | + "jquery/no-is-array": 0, |
| 94 | + "jquery/no-is-function": 2, |
| 95 | + "jquery/no-is": 0, |
| 96 | + "jquery/no-load": 2, |
| 97 | + "jquery/no-map": 2, |
| 98 | + "jquery/no-merge": 2, |
| 99 | + "jquery/no-param": 2, |
| 100 | + "jquery/no-parent": 0, |
| 101 | + "jquery/no-parents": 0, |
| 102 | + "jquery/no-parse-html": 0, |
| 103 | + "jquery/no-prop": 0, |
| 104 | + "jquery/no-proxy": 0, |
| 105 | + "jquery/no-ready": 0, |
| 106 | + "jquery/no-serialize": 0, |
| 107 | + "jquery/no-show": 0, |
| 108 | + "jquery/no-size": 2, |
| 109 | + "jquery/no-sizzle": 0, |
| 110 | + "jquery/no-slide": 0, |
| 111 | + "jquery/no-submit": 2, |
| 112 | + "jquery/no-text": 2, |
| 113 | + "jquery/no-toggle": 0, |
| 114 | + "jquery/no-trigger": 0, |
| 115 | + "jquery/no-trim": 2, |
| 116 | + "jquery/no-val": 2, |
| 117 | + "jquery/no-when": 0, |
| 118 | + "jquery/no-wrap": 0, |
| 119 | + }, |
| 120 | +}; |
| 121 | + |
| 122 | +const legacy = { |
| 123 | + extends: "eslint:recommended", |
| 124 | + root: true, |
| 125 | + env: { |
| 126 | + browser: true, |
| 127 | + }, |
| 128 | + globals: { |
| 129 | + Drupal: true, |
| 130 | + drupalSettings: true, |
| 131 | + drupalTranslations: true, |
| 132 | + domready: true, |
| 133 | + jQuery: true, |
| 134 | + _: true, |
| 135 | + matchMedia: true, |
| 136 | + Backbone: true, |
| 137 | + Modernizr: true, |
| 138 | + CKEDITOR: true, |
| 139 | + }, |
| 140 | + rules: { |
| 141 | + "array-bracket-spacing": ["error", "never"], |
| 142 | + "block-scoped-var": "error", |
| 143 | + "brace-style": ["error", "stroustrup", { allowSingleLine: true }], |
| 144 | + "comma-dangle": ["error", "never"], |
| 145 | + "comma-spacing": "error", |
| 146 | + "comma-style": ["error", "last"], |
| 147 | + "computed-property-spacing": ["error", "never"], |
| 148 | + curly: ["error", "all"], |
| 149 | + "eol-last": "error", |
| 150 | + eqeqeq: ["error", "smart"], |
| 151 | + "guard-for-in": "error", |
| 152 | + indent: ["error", 2, { SwitchCase: 1 }], |
| 153 | + "key-spacing": ["error", { beforeColon: false, afterColon: true }], |
| 154 | + "keyword-spacing": ["error", { before: true, after: true }], |
| 155 | + "linebreak-style": ["error", "unix"], |
| 156 | + "lines-around-comment": [ |
| 157 | + "error", |
| 158 | + { beforeBlockComment: true, afterBlockComment: false }, |
| 159 | + ], |
| 160 | + "new-parens": "error", |
| 161 | + "no-array-constructor": "error", |
| 162 | + "no-caller": "error", |
| 163 | + "no-catch-shadow": "error", |
| 164 | + "no-eval": "error", |
| 165 | + "no-extend-native": "error", |
| 166 | + "no-extra-bind": "error", |
| 167 | + "no-extra-parens": ["error", "functions"], |
| 168 | + "no-implied-eval": "error", |
| 169 | + "no-iterator": "error", |
| 170 | + "no-label-var": "error", |
| 171 | + "no-labels": "error", |
| 172 | + "no-lone-blocks": "error", |
| 173 | + "no-loop-func": "error", |
| 174 | + "no-multi-spaces": "error", |
| 175 | + "no-multi-str": "error", |
| 176 | + "no-native-reassign": "error", |
| 177 | + "no-nested-ternary": "error", |
| 178 | + "no-new-func": "error", |
| 179 | + "no-new-object": "error", |
| 180 | + "no-new-wrappers": "error", |
| 181 | + "no-octal-escape": "error", |
| 182 | + "no-process-exit": "error", |
| 183 | + "no-proto": "error", |
| 184 | + "no-return-assign": "error", |
| 185 | + "no-script-url": "error", |
| 186 | + "no-sequences": "error", |
| 187 | + "no-shadow-restricted-names": "error", |
| 188 | + "no-spaced-func": "error", |
| 189 | + "no-trailing-spaces": "error", |
| 190 | + "no-undef-init": "error", |
| 191 | + "no-undefined": "error", |
| 192 | + "no-unused-expressions": "error", |
| 193 | + "no-unused-vars": ["error", { vars: "all", args: "none" }], |
| 194 | + "no-with": "error", |
| 195 | + "object-curly-spacing": ["error", "never"], |
| 196 | + "one-var": ["error", "never"], |
| 197 | + "quote-props": ["error", "consistent-as-needed"], |
| 198 | + quotes: ["error", "single", "avoid-escape"], |
| 199 | + semi: ["error", "always"], |
| 200 | + "semi-spacing": ["error", { before: false, after: true }], |
| 201 | + "space-before-blocks": ["error", "always"], |
| 202 | + "space-before-function-paren": [ |
| 203 | + "error", |
| 204 | + { anonymous: "always", named: "never" }, |
| 205 | + ], |
| 206 | + "space-in-parens": ["error", "never"], |
| 207 | + "space-infix-ops": "error", |
| 208 | + "space-unary-ops": ["error", { words: true, nonwords: false }], |
| 209 | + "spaced-comment": ["error", "always"], |
| 210 | + strict: ["error", "function"], |
| 211 | + yoda: ["error", "never"], |
| 212 | + "max-nested-callbacks": ["warn", 3], |
| 213 | + "valid-jsdoc": [ |
| 214 | + "warn", |
| 215 | + { |
| 216 | + prefer: { |
| 217 | + returns: "return", |
| 218 | + property: "prop", |
| 219 | + }, |
| 220 | + requireReturn: false, |
| 221 | + }, |
| 222 | + ], |
| 223 | + }, |
| 224 | +}; |
| 225 | + |
| 226 | +const passing = { |
| 227 | + extends: [ |
| 228 | + "plugin:drupal-contrib/recommended", |
| 229 | + "plugin:drupal-contrib/jquery", |
| 230 | + ], |
| 231 | + rules: { |
| 232 | + "no-shadow": "off", |
| 233 | + "no-new": "off", |
| 234 | + "no-continue": "off", |
| 235 | + "new-cap": "off", |
| 236 | + "max-len": "off", |
| 237 | + "default-case": "off", |
| 238 | + "default-param-last": "off", |
| 239 | + "prefer-destructuring": "off", |
| 240 | + "prefer-regex-literals": "off", |
| 241 | + "import/named": "off", |
| 242 | + "import/no-import-module-exports": "off", |
| 243 | + }, |
| 244 | +}; |
| 245 | + |
| 246 | +const index = { |
| 247 | + configs: { |
| 248 | + recommended, |
| 249 | + jquery, |
| 250 | + legacy, |
| 251 | + passing, |
| 252 | + }, |
| 253 | +}; |
| 254 | + |
| 255 | +module.exports = index; |
0 commit comments