diff options
Diffstat (limited to 'tools/lint/eslint/eslint-plugin-mozilla/tests')
7 files changed, 44 insertions, 5 deletions
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js index 37fc424617..54cf29ab68 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js @@ -16,7 +16,7 @@ const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: "latest" } }); // Tests // ------------------------------------------------------------------------------ -function invalidCode(code, type, message) { +function invalidCode(code, type) { return { code, errors: [{ messageId: "usePerfNow", type }] }; } diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/helper-no-more-globals.js.globals b/tools/lint/eslint/eslint-plugin-mozilla/tests/helper-no-more-globals.js.globals new file mode 100644 index 0000000000..029ed81ce0 --- /dev/null +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/helper-no-more-globals.js.globals @@ -0,0 +1 @@ +["foo"] diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-comparison-or-assignment-inside-ok.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-comparison-or-assignment-inside-ok.js index 3c43e5879f..59e31d7361 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-comparison-or-assignment-inside-ok.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-comparison-or-assignment-inside-ok.js @@ -16,7 +16,7 @@ const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: "latest" } }); // Tests // ------------------------------------------------------------------------------ -function invalidCode(code, output, messageId, options = []) { +function invalidCode(code, output, messageId) { let rv = { code, errors: [{ messageId }], diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-more-globals.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-more-globals.js new file mode 100644 index 0000000000..5b4b560e3c --- /dev/null +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-more-globals.js @@ -0,0 +1,38 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// ------------------------------------------------------------------------------ +// Requirements +// ------------------------------------------------------------------------------ + +var rule = require("../lib/rules/no-more-globals"); +var RuleTester = require("eslint").RuleTester; + +const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: "latest" } }); + +function makeTest(code, errors = []) { + return { + code, + errors, + filename: __dirname + "/helper-no-more-globals.js", + }; +} + +ruleTester.run("no-more-globals", rule, { + valid: [ + makeTest("function foo() {}"), + makeTest("var foo = 5;"), + makeTest("let foo = 42;"), + ], + invalid: [ + makeTest("console.log('hello');", [ + { messageId: "removedGlobal", data: { name: "foo" } }, + ]), + makeTest("let bar = 42;", [ + { messageId: "newGlobal", data: { name: "bar" } }, + { messageId: "removedGlobal", data: { name: "foo" } }, + ]), + ], +}); diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-top-level-await.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-top-level-await.js index 4416b42abb..537deb9ac8 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-top-level-await.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-top-level-await.js @@ -18,7 +18,7 @@ const ruleTester = new RuleTester({ // Tests // ------------------------------------------------------------------------------ -function invalidCode(code, messageId) { +function invalidCode(code) { return { code, errors: [{ messageId: "rejectTopLevelAwait" }] }; } diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js index a7e95769c1..2be1beccf8 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js @@ -16,7 +16,7 @@ const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: "latest" } }); // Tests // ------------------------------------------------------------------------------ -function invalidCode(code, messageId) { +function invalidCode(code) { return { code, errors: [{ messageId: "rejectRequiresAwait" }] }; } diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-static-import.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-static-import.js index 656e83e0e9..08b667cba9 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-static-import.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-static-import.js @@ -41,7 +41,7 @@ ruleTester.run("use-static-import", rule, { }, { // importESModule with two args cannot be converted. - code: 'const { f } = ChromeUtils.importESModule("some/module.sys.mjs", { loadInDevToolsLoader : true });', + code: 'const { f } = ChromeUtils.importESModule("some/module.sys.mjs", { global : "shared" });', filename: "test.sys.mjs", }, { |