mirror of
https://github.com/hanzoai/eslint.git
synced 2026-10-30 19:38:10 +00:00
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
/**
|
|
* @fileoverview Tests for symbol-description rule.
|
|
* @author Jarek Rencz
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Requirements
|
|
//------------------------------------------------------------------------------
|
|
|
|
const rule = require("../../../lib/rules/symbol-description");
|
|
const RuleTester = require("../../../lib/rule-tester/rule-tester");
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Tests
|
|
//------------------------------------------------------------------------------
|
|
|
|
const ruleTester = new RuleTester({
|
|
languageOptions: {
|
|
ecmaVersion: 6,
|
|
sourceType: "script",
|
|
},
|
|
});
|
|
|
|
ruleTester.run("symbol-description", rule, {
|
|
valid: [
|
|
'Symbol("Foo");',
|
|
'var foo = "foo"; Symbol(foo);',
|
|
|
|
// Ignore if it's shadowed.
|
|
"var Symbol = function () {}; Symbol();",
|
|
"Symbol(); var Symbol = function () {};",
|
|
"function bar() { var Symbol = function () {}; Symbol(); }",
|
|
|
|
// Ignore if it's an argument.
|
|
"function bar(Symbol) { Symbol(); }",
|
|
],
|
|
|
|
invalid: [
|
|
{
|
|
code: "Symbol();",
|
|
errors: [
|
|
{
|
|
messageId: "expected",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: "Symbol(); Symbol = function () {};",
|
|
errors: [
|
|
{
|
|
messageId: "expected",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|