.eslintrc.mjs (2434B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import config from "../../toolkit/components/extensions/parent/.eslintrc.mjs"; 6 7 export default [ 8 { 9 files: ["components/extensions/ext-*.js"], 10 ignores: ["components/extensions/ext-c-*.js"], 11 languageOptions: { 12 globals: { 13 ...config[0].globals, 14 // These globals are defined in ext-android.js and can only be used in 15 // the extension files that run in the parent process. 16 EventDispatcher: true, 17 ExtensionError: true, 18 makeGlobalEvent: true, 19 TabContext: true, 20 tabTracker: true, 21 windowTracker: true, 22 }, 23 }, 24 }, 25 { 26 files: [ 27 "chrome/geckoview/**", 28 "components/geckoview/**", 29 "modules/geckoview/**", 30 "actors/**", 31 ], 32 rules: { 33 "no-unused-vars": [ 34 "error", 35 { 36 argsIgnorePattern: "^_", 37 caughtErrors: "none", 38 vars: "local", 39 varsIgnorePattern: "(debug|warn)", 40 }, 41 ], 42 "no-restricted-syntax": [ 43 "error", 44 { 45 selector: `CallExpression > \ 46 Identifier.callee[name = /^debug$|^warn$/]`, 47 message: 48 "Use debug and warn with template literals, e.g. debug `foo`;", 49 }, 50 { 51 selector: `BinaryExpression[operator = '+'] > \ 52 TaggedTemplateExpression.left > \ 53 Identifier.tag[name = /^debug$|^warn$/]`, 54 message: 55 "Use only one template literal with debug/warn instead of concatenating multiple expressions,\n" + 56 " e.g. (debug `foo ${42} bar`) instead of (debug `foo` + 42 + `bar`)", 57 }, 58 { 59 selector: `TaggedTemplateExpression[tag.type = 'Identifier'][tag.name = /^debug$|^warn$/] > \ 60 TemplateLiteral.quasi CallExpression > \ 61 MemberExpression.callee[object.type = 'Identifier'][object.name = 'JSON'] > \ 62 Identifier.property[name = 'stringify']`, 63 message: 64 "Don't call JSON.stringify within debug/warn literals,\n" + 65 " e.g. (debug `foo=${foo}`) instead of (debug `foo=${JSON.stringify(foo)}`)", 66 }, 67 ], 68 }, 69 }, 70 ];