]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/camelcase.js
2 * @fileoverview Tests for camelcase rule.
3 * @author Nicholas C. Zakas
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/camelcase"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
21 ruleTester
.run("camelcase", rule
, {
23 "firstName = \"Nicholas\"",
24 "FIRST_NAME = \"Nicholas\"",
25 "__myPrivateVariable = \"Patrick\"",
26 "myPrivateVariable_ = \"Patrick\"",
27 "function doSomething(){}",
32 "var foo = bar.baz_boom;",
33 "var foo = bar.baz_boom.something;",
34 "foo.boom_pow.qux = bar.baz_boom.something;",
35 "if (bar.baz_boom) {}",
36 "var obj = { key: foo.bar_baz };",
37 "var arr = [foo.bar_baz];",
39 "var arr = [foo.bar_baz.qux];",
40 "[foo.bar_baz.nesting]",
41 "if (foo.bar_baz === boom.bam_pow) { [foo.baz_boom] }",
43 code
: "var o = {key: 1}",
44 options
: [{ properties
: "always" }]
47 code
: "var o = {_leading: 1}",
48 options
: [{ properties
: "always" }]
51 code
: "var o = {trailing_: 1}",
52 options
: [{ properties
: "always" }]
55 code
: "var o = {bar_baz: 1}",
56 options
: [{ properties
: "never" }]
59 code
: "var o = {_leading: 1}",
60 options
: [{ properties
: "never" }]
63 code
: "var o = {trailing_: 1}",
64 options
: [{ properties
: "never" }]
68 options
: [{ properties
: "never" }]
72 options
: [{ properties
: "always" }]
76 options
: [{ properties
: "always" }]
80 options
: [{ properties
: "never" }]
84 options
: [{ properties
: "never" }]
87 code
: "var obj = {\n a_a: 1 \n};\n obj.a_b = 2;",
88 options
: [{ properties
: "never" }]
91 code
: "obj.foo_bar = function(){};",
92 options
: [{ properties
: "never" }]
95 code
: "const { ['foo']: _foo } = obj;",
96 parserOptions
: { ecmaVersion
: 6 }
99 code
: "const { [_foo_]: foo } = obj;",
100 parserOptions
: { ecmaVersion
: 6 }
103 code
: "var { category_id } = query;",
104 options
: [{ ignoreDestructuring
: true }],
105 parserOptions
: { ecmaVersion
: 6 }
108 code
: "var { category_id: category_id } = query;",
109 options
: [{ ignoreDestructuring
: true }],
110 parserOptions
: { ecmaVersion
: 6 }
113 code
: "var { category_id = 1 } = query;",
114 options
: [{ ignoreDestructuring
: true }],
115 parserOptions
: { ecmaVersion
: 6 }
118 code
: "var { [{category_id} = query]: categoryId } = query;",
119 options
: [{ ignoreDestructuring
: true }],
120 parserOptions
: { ecmaVersion
: 6 }
123 code
: "var { category_id: category } = query;",
124 parserOptions
: { ecmaVersion
: 6 }
127 code
: "var { _leading } = query;",
128 parserOptions
: { ecmaVersion
: 6 }
131 code
: "var { trailing_ } = query;",
132 parserOptions
: { ecmaVersion
: 6 }
135 code
: "import { camelCased } from \"external module\";",
136 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
139 code
: "import { _leading } from \"external module\";",
140 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
143 code
: "import { trailing_ } from \"external module\";",
144 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
147 code
: "import { no_camelcased as camelCased } from \"external-module\";",
148 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
151 code
: "import { no_camelcased as _leading } from \"external-module\";",
152 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
155 code
: "import { no_camelcased as trailing_ } from \"external-module\";",
156 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
159 code
: "import { no_camelcased as camelCased, anotherCamelCased } from \"external-module\";",
160 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
163 code
: "import { snake_cased } from 'mod'",
164 options
: [{ ignoreImports
: true }],
165 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
168 code
: "import { camelCased } from 'mod'",
169 options
: [{ ignoreImports
: false }],
170 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" }
173 code
: "var _camelCased = aGlobalVariable",
174 options
: [{ ignoreGlobals
: false }],
175 globals
: { aGlobalVariable
: "readonly" }
178 code
: "var camelCased = _aGlobalVariable",
179 options
: [{ ignoreGlobals
: false }],
180 globals
: { _aGlobalVariable
: "readonly" }
183 code
: "var camelCased = a_global_variable",
184 options
: [{ ignoreGlobals
: true }],
185 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
188 code
: "a_global_variable.foo()",
189 options
: [{ ignoreGlobals
: true }],
190 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
193 code
: "a_global_variable[undefined]",
194 options
: [{ ignoreGlobals
: true }],
195 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
198 code
: "var foo = a_global_variable.bar",
199 options
: [{ ignoreGlobals
: true }],
200 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
203 code
: "a_global_variable.foo = bar",
204 options
: [{ ignoreGlobals
: true }],
205 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
208 code
: "( { foo: a_global_variable.bar } = baz )",
209 options
: [{ ignoreGlobals
: true }],
210 parserOptions
: { ecmaVersion
: 6 },
211 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
214 code
: "a_global_variable = foo",
215 options
: [{ ignoreGlobals
: true }],
216 globals
: { a_global_variable
: "writable" } // eslint-disable-line camelcase
219 code
: "a_global_variable = foo",
220 options
: [{ ignoreGlobals
: true }],
221 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
224 code
: "({ a_global_variable } = foo)",
225 options
: [{ ignoreGlobals
: true }],
226 parserOptions
: { ecmaVersion
: 6 },
227 globals
: { a_global_variable
: "writable" } // eslint-disable-line camelcase
230 code
: "({ snake_cased: a_global_variable } = foo)",
231 options
: [{ ignoreGlobals
: true }],
232 parserOptions
: { ecmaVersion
: 6 },
233 globals
: { a_global_variable
: "writable" } // eslint-disable-line camelcase
236 code
: "({ snake_cased: a_global_variable = foo } = bar)",
237 options
: [{ ignoreGlobals
: true }],
238 parserOptions
: { ecmaVersion
: 6 },
239 globals
: { a_global_variable
: "writable" } // eslint-disable-line camelcase
242 code
: "[a_global_variable] = bar",
243 options
: [{ ignoreGlobals
: true }],
244 parserOptions
: { ecmaVersion
: 6 },
245 globals
: { a_global_variable
: "writable" } // eslint-disable-line camelcase
248 code
: "[a_global_variable = foo] = bar",
249 options
: [{ ignoreGlobals
: true }],
250 parserOptions
: { ecmaVersion
: 6 },
251 globals
: { a_global_variable
: "writable" } // eslint-disable-line camelcase
254 code
: "foo[a_global_variable] = bar",
255 options
: [{ ignoreGlobals
: true }],
256 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
259 code
: "var foo = { [a_global_variable]: bar }",
260 options
: [{ ignoreGlobals
: true }],
261 parserOptions
: { ecmaVersion
: 6 },
262 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
265 code
: "var { [a_global_variable]: foo } = bar",
266 options
: [{ ignoreGlobals
: true }],
267 parserOptions
: { ecmaVersion
: 6 },
268 globals
: { a_global_variable
: "readonly" } // eslint-disable-line camelcase
271 code
: "function foo({ no_camelcased: camelCased }) {};",
272 parserOptions
: { ecmaVersion
: 6 }
275 code
: "function foo({ no_camelcased: _leading }) {};",
276 parserOptions
: { ecmaVersion
: 6 }
279 code
: "function foo({ no_camelcased: trailing_ }) {};",
280 parserOptions
: { ecmaVersion
: 6 }
283 code
: "function foo({ camelCased = 'default value' }) {};",
284 parserOptions
: { ecmaVersion
: 6 }
287 code
: "function foo({ _leading = 'default value' }) {};",
288 parserOptions
: { ecmaVersion
: 6 }
291 code
: "function foo({ trailing_ = 'default value' }) {};",
292 parserOptions
: { ecmaVersion
: 6 }
295 code
: "function foo({ camelCased }) {};",
296 parserOptions
: { ecmaVersion
: 6 }
299 code
: "function foo({ _leading }) {}",
300 parserOptions
: { ecmaVersion
: 6 }
303 code
: "function foo({ trailing_ }) {}",
304 parserOptions
: { ecmaVersion
: 6 }
307 code
: "ignored_foo = 0;",
308 options
: [{ allow
: ["ignored_foo"] }]
311 code
: "ignored_foo = 0; ignored_bar = 1;",
312 options
: [{ allow
: ["ignored_foo", "ignored_bar"] }]
315 code
: "user_id = 0;",
316 options
: [{ allow
: ["_id$"] }]
319 code
: "__option_foo__ = 0;",
320 options
: [{ allow
: ["__option_foo__"] }]
323 code
: "foo = { [computedBar]: 0 };",
324 options
: [{ ignoreDestructuring
: true }],
325 parserOptions
: { ecmaVersion
: 6 }
328 code
: "({ a: obj.fo_o } = bar);",
329 options
: [{ allow
: ["fo_o"] }],
330 parserOptions
: { ecmaVersion
: 6 }
333 code
: "({ a: obj.foo } = bar);",
334 options
: [{ allow
: ["fo_o"] }],
335 parserOptions
: { ecmaVersion
: 6 }
338 code
: "({ a: obj.fo_o } = bar);",
339 options
: [{ properties
: "never" }],
340 parserOptions
: { ecmaVersion
: 6 }
343 code
: "({ a: obj.fo_o.b_ar } = bar);",
344 options
: [{ properties
: "never" }],
345 parserOptions
: { ecmaVersion
: 6 }
348 code
: "({ a: { b: obj.fo_o } } = bar);",
349 options
: [{ properties
: "never" }],
350 parserOptions
: { ecmaVersion
: 6 }
353 code
: "([obj.fo_o] = bar);",
354 options
: [{ properties
: "never" }],
355 parserOptions
: { ecmaVersion
: 6 }
358 code
: "({ c: [ob.fo_o]} = bar);",
359 options
: [{ properties
: "never" }],
360 parserOptions
: { ecmaVersion
: 6 }
363 code
: "([obj.fo_o.b_ar] = bar);",
364 options
: [{ properties
: "never" }],
365 parserOptions
: { ecmaVersion
: 6 }
368 code
: "({obj} = baz.fo_o);",
369 parserOptions
: { ecmaVersion
: 6 }
372 code
: "([obj] = baz.fo_o);",
373 parserOptions
: { ecmaVersion
: 6 }
376 code
: "([obj.foo = obj.fo_o] = bar);",
377 options
: [{ properties
: "always" }],
378 parserOptions
: { ecmaVersion
: 6 }
383 code
: "first_name = \"Nicholas\"",
386 messageId
: "notCamelCase",
387 data
: { name
: "first_name" },
393 code
: "__private_first_name = \"Patrick\"",
396 messageId
: "notCamelCase",
397 data
: { name
: "__private_first_name" },
403 code
: "function foo_bar(){}",
406 messageId
: "notCamelCase",
407 data
: { name
: "foo_bar" },
413 code
: "obj.foo_bar = function(){};",
416 messageId
: "notCamelCase",
417 data
: { name
: "foo_bar" },
423 code
: "bar_baz.foo = function(){};",
426 messageId
: "notCamelCase",
427 data
: { name
: "bar_baz" },
433 code
: "[foo_bar.baz]",
436 messageId
: "notCamelCase",
437 data
: { name
: "foo_bar" },
443 code
: "if (foo.bar_baz === boom.bam_pow) { [foo_bar.baz] }",
446 messageId
: "notCamelCase",
447 data
: { name
: "foo_bar" },
453 code
: "foo.bar_baz = boom.bam_pow",
456 messageId
: "notCamelCase",
457 data
: { name
: "bar_baz" },
463 code
: "var foo = { bar_baz: boom.bam_pow }",
466 messageId
: "notCamelCase",
467 data
: { name
: "bar_baz" },
473 code
: "var foo = { bar_baz: boom.bam_pow }",
474 options
: [{ ignoreDestructuring
: true }],
477 messageId
: "notCamelCase",
478 data
: { name
: "bar_baz" },
484 code
: "foo.qux.boom_pow = { bar: boom.bam_pow }",
487 messageId
: "notCamelCase",
488 data
: { name
: "boom_pow" },
494 code
: "var o = {bar_baz: 1}",
495 options
: [{ properties
: "always" }],
498 messageId
: "notCamelCase",
499 data
: { name
: "bar_baz" },
505 code
: "obj.a_b = 2;",
506 options
: [{ properties
: "always" }],
509 messageId
: "notCamelCase",
510 data
: { name
: "a_b" },
516 code
: "var { category_id: category_alias } = query;",
517 parserOptions
: { ecmaVersion
: 6 },
520 messageId
: "notCamelCase",
521 data
: { name
: "category_alias" },
527 code
: "var { category_id: category_alias } = query;",
528 options
: [{ ignoreDestructuring
: true }],
529 parserOptions
: { ecmaVersion
: 6 },
532 messageId
: "notCamelCase",
533 data
: { name
: "category_alias" },
539 code
: "var { [category_id]: categoryId } = query;",
540 options
: [{ ignoreDestructuring
: true }],
541 parserOptions
: { ecmaVersion
: 6 },
544 messageId
: "notCamelCase",
545 data
: { name
: "category_id" },
551 code
: "var { [category_id]: categoryId } = query;",
552 parserOptions
: { ecmaVersion
: 6 },
555 messageId
: "notCamelCase",
556 data
: { name
: "category_id" },
562 code
: "var { category_id: categoryId, ...other_props } = query;",
563 options
: [{ ignoreDestructuring
: true }],
564 parserOptions
: { ecmaVersion
: 2018 },
567 messageId
: "notCamelCase",
568 data
: { name
: "other_props" },
574 code
: "var { category_id } = query;",
575 parserOptions
: { ecmaVersion
: 6 },
578 messageId
: "notCamelCase",
579 data
: { name
: "category_id" },
585 code
: "var { category_id: category_id } = query;",
586 parserOptions
: { ecmaVersion
: 6 },
589 messageId
: "notCamelCase",
590 data
: { name
: "category_id" },
596 code
: "var { category_id = 1 } = query;",
597 parserOptions
: { ecmaVersion
: 6 },
600 messageId
: "notCamelCase",
601 data
: { name
: "category_id" },
607 code
: "import no_camelcased from \"external-module\";",
608 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
611 messageId
: "notCamelCase",
612 data
: { name
: "no_camelcased" },
618 code
: "import * as no_camelcased from \"external-module\";",
619 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
622 messageId
: "notCamelCase",
623 data
: { name
: "no_camelcased" },
629 code
: "import { no_camelcased } from \"external-module\";",
630 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
633 messageId
: "notCamelCase",
634 data
: { name
: "no_camelcased" },
640 code
: "import { no_camelcased as no_camel_cased } from \"external module\";",
641 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
644 messageId
: "notCamelCase",
645 data
: { name
: "no_camel_cased" },
651 code
: "import { camelCased as no_camel_cased } from \"external module\";",
652 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
655 messageId
: "notCamelCase",
656 data
: { name
: "no_camel_cased" },
662 code
: "import { camelCased, no_camelcased } from \"external-module\";",
663 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
666 messageId
: "notCamelCase",
667 data
: { name
: "no_camelcased" },
673 code
: "import { no_camelcased as camelCased, another_no_camelcased } from \"external-module\";",
674 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
677 messageId
: "notCamelCase",
678 data
: { name
: "another_no_camelcased" },
684 code
: "import camelCased, { no_camelcased } from \"external-module\";",
685 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
688 messageId
: "notCamelCase",
689 data
: { name
: "no_camelcased" },
695 code
: "import no_camelcased, { another_no_camelcased as camelCased } from \"external-module\";",
696 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
699 messageId
: "notCamelCase",
700 data
: { name
: "no_camelcased" },
706 code
: "import snake_cased from 'mod'",
707 options
: [{ ignoreImports
: true }],
708 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
711 messageId
: "notCamelCase",
712 data
: { name
: "snake_cased" },
718 code
: "import * as snake_cased from 'mod'",
719 options
: [{ ignoreImports
: true }],
720 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
723 messageId
: "notCamelCase",
724 data
: { name
: "snake_cased" },
730 code
: "import snake_cased from 'mod'",
731 options
: [{ ignoreImports
: false }],
732 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
735 messageId
: "notCamelCase",
736 data
: { name
: "snake_cased" },
742 code
: "import * as snake_cased from 'mod'",
743 options
: [{ ignoreImports
: false }],
744 parserOptions
: { ecmaVersion
: 6, sourceType
: "module" },
747 messageId
: "notCamelCase",
748 data
: { name
: "snake_cased" },
754 code
: "var camelCased = snake_cased",
755 options
: [{ ignoreGlobals
: false }],
756 globals
: { snake_cased
: "readonly" }, // eslint-disable-line camelcase
759 messageId
: "notCamelCase",
760 data
: { name
: "snake_cased" },
766 code
: "a_global_variable.foo()",
767 options
: [{ ignoreGlobals
: false }],
768 globals
: { snake_cased
: "readonly" }, // eslint-disable-line camelcase
771 messageId
: "notCamelCase",
772 data
: { name
: "a_global_variable" },
778 code
: "a_global_variable[undefined]",
779 options
: [{ ignoreGlobals
: false }],
780 globals
: { snake_cased
: "readonly" }, // eslint-disable-line camelcase
783 messageId
: "notCamelCase",
784 data
: { name
: "a_global_variable" },
790 code
: "var camelCased = snake_cased",
791 globals
: { snake_cased
: "readonly" }, // eslint-disable-line camelcase
794 messageId
: "notCamelCase",
795 data
: { name
: "snake_cased" },
801 code
: "var camelCased = snake_cased",
803 globals
: { snake_cased
: "readonly" }, // eslint-disable-line camelcase
806 messageId
: "notCamelCase",
807 data
: { name
: "snake_cased" },
813 code
: "foo.a_global_variable = bar",
814 options
: [{ ignoreGlobals
: true }],
815 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
818 messageId
: "notCamelCase",
819 data
: { name
: "a_global_variable" },
825 code
: "var foo = { a_global_variable: bar }",
826 options
: [{ ignoreGlobals
: true }],
827 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
830 messageId
: "notCamelCase",
831 data
: { name
: "a_global_variable" },
837 code
: "var foo = { a_global_variable: a_global_variable }",
838 options
: [{ ignoreGlobals
: true }],
839 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
842 messageId
: "notCamelCase",
843 data
: { name
: "a_global_variable" },
850 code
: "var foo = { a_global_variable() {} }",
851 options
: [{ ignoreGlobals
: true }],
852 parserOptions
: { ecmaVersion
: 6 },
853 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
856 messageId
: "notCamelCase",
857 data
: { name
: "a_global_variable" },
863 code
: "class Foo { a_global_variable() {} }",
864 options
: [{ ignoreGlobals
: true }],
865 parserOptions
: { ecmaVersion
: 6 },
866 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
869 messageId
: "notCamelCase",
870 data
: { name
: "a_global_variable" },
876 code
: "a_global_variable: for (;;);",
877 options
: [{ ignoreGlobals
: true }],
878 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
881 messageId
: "notCamelCase",
882 data
: { name
: "a_global_variable" },
888 code
: "if (foo) { let a_global_variable; a_global_variable = bar; }",
889 options
: [{ ignoreGlobals
: true }],
890 parserOptions
: { ecmaVersion
: 6 },
891 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
894 messageId
: "notCamelCase",
895 data
: { name
: "a_global_variable" },
900 messageId
: "notCamelCase",
901 data
: { name
: "a_global_variable" },
908 code
: "function foo(a_global_variable) { foo = a_global_variable; }",
909 options
: [{ ignoreGlobals
: true }],
910 parserOptions
: { ecmaVersion
: 6 },
911 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
914 messageId
: "notCamelCase",
915 data
: { name
: "a_global_variable" },
920 messageId
: "notCamelCase",
921 data
: { name
: "a_global_variable" },
928 code
: "var a_global_variable",
929 options
: [{ ignoreGlobals
: true }],
930 parserOptions
: { ecmaVersion
: 6 },
933 messageId
: "notCamelCase",
934 data
: { name
: "a_global_variable" },
940 code
: "function a_global_variable () {}",
941 options
: [{ ignoreGlobals
: true }],
942 parserOptions
: { ecmaVersion
: 6 },
945 messageId
: "notCamelCase",
946 data
: { name
: "a_global_variable" },
952 code
: "const a_global_variable = foo; bar = a_global_variable",
953 options
: [{ ignoreGlobals
: true }],
954 parserOptions
: { ecmaVersion
: 6 },
955 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
958 messageId
: "notCamelCase",
959 data
: { name
: "a_global_variable" },
964 messageId
: "notCamelCase",
965 data
: { name
: "a_global_variable" },
972 code
: "bar = a_global_variable; var a_global_variable;",
973 options
: [{ ignoreGlobals
: true }],
974 parserOptions
: { ecmaVersion
: 6 },
975 globals
: { a_global_variable
: "writable" }, // eslint-disable-line camelcase
978 messageId
: "notCamelCase",
979 data
: { name
: "a_global_variable" },
984 messageId
: "notCamelCase",
985 data
: { name
: "a_global_variable" },
992 code
: "var foo = { a_global_variable }",
993 options
: [{ ignoreGlobals
: true }],
994 parserOptions
: { ecmaVersion
: 6 },
995 globals
: { a_global_variable
: "readonly" }, // eslint-disable-line camelcase
998 messageId
: "notCamelCase",
999 data
: { name
: "a_global_variable" },
1005 code
: "export * as snake_cased from 'mod'",
1006 parserOptions
: { ecmaVersion
: 2020, sourceType
: "module" },
1009 messageId
: "notCamelCase",
1010 data
: { name
: "snake_cased" },
1016 code
: "function foo({ no_camelcased }) {};",
1017 parserOptions
: { ecmaVersion
: 6 },
1020 messageId
: "notCamelCase",
1021 data
: { name
: "no_camelcased" },
1027 code
: "function foo({ no_camelcased = 'default value' }) {};",
1028 parserOptions
: { ecmaVersion
: 6 },
1031 messageId
: "notCamelCase",
1032 data
: { name
: "no_camelcased" },
1038 code
: "const no_camelcased = 0; function foo({ camelcased_value = no_camelcased}) {}",
1039 parserOptions
: { ecmaVersion
: 6 },
1042 messageId
: "notCamelCase",
1043 data
: { name
: "no_camelcased" },
1047 messageId
: "notCamelCase",
1048 data
: { name
: "camelcased_value" },
1054 code
: "const { bar: no_camelcased } = foo;",
1055 parserOptions
: { ecmaVersion
: 6 },
1058 messageId
: "notCamelCase",
1059 data
: { name
: "no_camelcased" },
1065 code
: "function foo({ value_1: my_default }) {}",
1066 parserOptions
: { ecmaVersion
: 6 },
1069 messageId
: "notCamelCase",
1070 data
: { name
: "my_default" },
1076 code
: "function foo({ isCamelcased: no_camelcased }) {};",
1077 parserOptions
: { ecmaVersion
: 6 },
1080 messageId
: "notCamelCase",
1081 data
: { name
: "no_camelcased" },
1087 code
: "var { foo: bar_baz = 1 } = quz;",
1088 parserOptions
: { ecmaVersion
: 6 },
1091 messageId
: "notCamelCase",
1092 data
: { name
: "bar_baz" },
1098 code
: "const { no_camelcased = false } = bar;",
1099 parserOptions
: { ecmaVersion
: 6 },
1102 messageId
: "notCamelCase",
1103 data
: { name
: "no_camelcased" },
1109 code
: "const { no_camelcased = foo_bar } = bar;",
1110 parserOptions
: { ecmaVersion
: 6 },
1113 messageId
: "notCamelCase",
1114 data
: { name
: "no_camelcased" },
1120 code
: "not_ignored_foo = 0;",
1121 options
: [{ allow
: ["ignored_bar"] }],
1124 messageId
: "notCamelCase",
1125 data
: { name
: "not_ignored_foo" },
1131 code
: "not_ignored_foo = 0;",
1132 options
: [{ allow
: ["_id$"] }],
1135 messageId
: "notCamelCase",
1136 data
: { name
: "not_ignored_foo" },
1142 code
: "foo = { [computed_bar]: 0 };",
1143 options
: [{ ignoreDestructuring
: true }],
1144 parserOptions
: { ecmaVersion
: 6 },
1147 messageId
: "notCamelCase",
1148 data
: { name
: "computed_bar" },
1154 code
: "({ a: obj.fo_o } = bar);",
1155 parserOptions
: { ecmaVersion
: 6 },
1158 messageId
: "notCamelCase",
1159 data
: { name
: "fo_o" },
1165 code
: "({ a: obj.fo_o } = bar);",
1166 options
: [{ ignoreDestructuring
: true }],
1167 parserOptions
: { ecmaVersion
: 6 },
1170 messageId
: "notCamelCase",
1171 data
: { name
: "fo_o" },
1177 code
: "({ a: obj.fo_o.b_ar } = baz);",
1178 parserOptions
: { ecmaVersion
: 6 },
1181 messageId
: "notCamelCase",
1182 data
: { name
: "b_ar" },
1188 code
: "({ a: { b: { c: obj.fo_o } } } = bar);",
1189 parserOptions
: { ecmaVersion
: 6 },
1192 messageId
: "notCamelCase",
1193 data
: { name
: "fo_o" },
1199 code
: "({ a: { b: { c: obj.fo_o.b_ar } } } = baz);",
1200 parserOptions
: { ecmaVersion
: 6 },
1203 messageId
: "notCamelCase",
1204 data
: { name
: "b_ar" },
1210 code
: "([obj.fo_o] = bar);",
1211 parserOptions
: { ecmaVersion
: 6 },
1214 messageId
: "notCamelCase",
1215 data
: { name
: "fo_o" },
1221 code
: "([obj.fo_o] = bar);",
1222 options
: [{ ignoreDestructuring
: true }],
1223 parserOptions
: { ecmaVersion
: 6 },
1226 messageId
: "notCamelCase",
1227 data
: { name
: "fo_o" },
1233 code
: "([obj.fo_o = 1] = bar);",
1234 options
: [{ properties
: "always" }],
1235 parserOptions
: { ecmaVersion
: 6 },
1238 messageId
: "notCamelCase",
1239 data
: { name
: "fo_o" },
1245 code
: "({ a: [obj.fo_o] } = bar);",
1246 parserOptions
: { ecmaVersion
: 6 },
1249 messageId
: "notCamelCase",
1250 data
: { name
: "fo_o" },
1256 code
: "({ a: { b: [obj.fo_o] } } = bar);",
1257 parserOptions
: { ecmaVersion
: 6 },
1260 messageId
: "notCamelCase",
1261 data
: { name
: "fo_o" },
1267 code
: "([obj.fo_o.ba_r] = baz);",
1268 parserOptions
: { ecmaVersion
: 6 },
1271 messageId
: "notCamelCase",
1272 data
: { name
: "ba_r" },
1278 code
: "({...obj.fo_o} = baz);",
1279 parserOptions
: { ecmaVersion
: 9 },
1282 messageId
: "notCamelCase",
1283 data
: { name
: "fo_o" },
1289 code
: "({...obj.fo_o.ba_r} = baz);",
1290 parserOptions
: { ecmaVersion
: 9 },
1293 messageId
: "notCamelCase",
1294 data
: { name
: "ba_r" },
1300 code
: "({c: {...obj.fo_o }} = baz);",
1301 parserOptions
: { ecmaVersion
: 9 },
1304 messageId
: "notCamelCase",
1305 data
: { name
: "fo_o" },
1311 // Optional chaining.
1313 code
: "obj.o_k.non_camelcase = 0",
1314 options
: [{ properties
: "always" }],
1315 parserOptions
: { ecmaVersion
: 2020 },
1316 errors
: [{ messageId
: "notCamelCase", data
: { name
: "non_camelcase" } }]
1319 code
: "(obj?.o_k).non_camelcase = 0",
1320 options
: [{ properties
: "always" }],
1321 parserOptions
: { ecmaVersion
: 2020 },
1322 errors
: [{ messageId
: "notCamelCase", data
: { name
: "non_camelcase" } }]