mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
b2f3a7b8c9
- Add all current globals from _createExtGlobal in .eslintrc.js. - Remove non-existing globals. - State the sources of the extension-specific globals in .eslintrc.js. - Move extension-specific globals from common mobile/shared/ to a deeper level at mobile/shared/components/extensions/. - Remove obsolete globals/exported/import-globals-from comments from various ext-*.js files. - Fix linting errors in some tests due to use of non-global globals, that have become apparent due to the corrected linter definitions. Differential Revision: https://phabricator.services.mozilla.com/D228308
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
module.exports = {
|
|
overrides: [
|
|
{
|
|
files: [
|
|
"chrome/geckoview/**",
|
|
"components/geckoview/**",
|
|
"modules/geckoview/**",
|
|
"actors/**",
|
|
],
|
|
rules: {
|
|
"no-unused-vars": [
|
|
"error",
|
|
{
|
|
args: "none",
|
|
vars: "local",
|
|
varsIgnorePattern: "(debug|warn)",
|
|
},
|
|
],
|
|
"no-restricted-syntax": [
|
|
"error",
|
|
{
|
|
selector: `CallExpression > \
|
|
Identifier.callee[name = /^debug$|^warn$/]`,
|
|
message:
|
|
"Use debug and warn with template literals, e.g. debug `foo`;",
|
|
},
|
|
{
|
|
selector: `BinaryExpression[operator = '+'] > \
|
|
TaggedTemplateExpression.left > \
|
|
Identifier.tag[name = /^debug$|^warn$/]`,
|
|
message:
|
|
"Use only one template literal with debug/warn instead of concatenating multiple expressions,\n" +
|
|
" e.g. (debug `foo ${42} bar`) instead of (debug `foo` + 42 + `bar`)",
|
|
},
|
|
{
|
|
selector: `TaggedTemplateExpression[tag.type = 'Identifier'][tag.name = /^debug$|^warn$/] > \
|
|
TemplateLiteral.quasi CallExpression > \
|
|
MemberExpression.callee[object.type = 'Identifier'][object.name = 'JSON'] > \
|
|
Identifier.property[name = 'stringify']`,
|
|
message:
|
|
"Don't call JSON.stringify within debug/warn literals,\n" +
|
|
" e.g. (debug `foo=${foo}`) instead of (debug `foo=${JSON.stringify(foo)}`)",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
};
|