-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcamelCase.test.js
64 lines (60 loc) · 1.37 KB
/
camelCase.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"use strict";
const rule = require("../../lib/rules/camelCase");
const RuleTester = require("eslint").RuleTester;
const ruleTester = new RuleTester({
parser: require.resolve("@peggyjs/eslint-parser"),
});
ruleTester.run("camelCase", rule, {
valid: [
{
code: "Foo = '1'",
},
{
code: "Foo = bar:'1'",
},
{
code: "FOO_BAR = bar:'1'",
},
{
code: "__FOO_BAR__ = bar:'1'",
},
{
code: "__Foo__ = bar:'1'",
},
],
invalid: [
{
code: "Bar = foo\nfoo = '1'",
errors: [{ messageId: "notInitialCap" }],
output: "Bar = Foo\nFoo = '1'",
},
{
code: "Bar = foo_bar\nfoo_bar = '1'",
errors: [{ messageId: "notCamelCase" }],
output: "Bar = FooBar\nFooBar = '1'",
},
{
code: "Bar = _foo_bar_\n_foo_bar_ = '1'",
errors: [{ messageId: "notCamelCase" }],
output: "Bar = _FooBar_\n_FooBar_ = '1'",
},
{
// Don't change to existing identifier
code: "Bar = foo_bar\nfoo_bar = '1'\nFooBar = '2'",
errors: [{ messageId: "notCamelCase" }],
output: null,
},
{
// Can't fix labels
code: "Bar = foo_bar:'1'",
errors: [{ messageId: "notCamelCase" }],
output: null,
},
{
// Can't fix labels
code: "Bar = Foo:'1'",
errors: [{ messageId: "initialCap" }],
output: null,
},
],
});