@@ -225,6 +225,59 @@ ruleTester.run("camelcase", rule, {
225
225
code : "foo = { [computedBar]: 0 };" ,
226
226
options : [ { ignoreDestructuring : true } ] ,
227
227
parserOptions : { ecmaVersion : 6 }
228
+ } ,
229
+ {
230
+ code : "({ a: obj.fo_o } = bar);" ,
231
+ options : [ { allow : [ "fo_o" ] } ] ,
232
+ parserOptions : { ecmaVersion : 6 }
233
+ } ,
234
+ {
235
+ code : "({ a: obj.foo } = bar);" ,
236
+ options : [ { allow : [ "fo_o" ] } ] ,
237
+ parserOptions : { ecmaVersion : 6 }
238
+ } ,
239
+ {
240
+ code : "({ a: obj.fo_o } = bar);" ,
241
+ options : [ { properties : "never" } ] ,
242
+ parserOptions : { ecmaVersion : 6 }
243
+ } ,
244
+ {
245
+ code : "({ a: obj.fo_o.b_ar } = bar);" ,
246
+ options : [ { properties : "never" } ] ,
247
+ parserOptions : { ecmaVersion : 6 }
248
+ } ,
249
+ {
250
+ code : "({ a: { b: obj.fo_o } } = bar);" ,
251
+ options : [ { properties : "never" } ] ,
252
+ parserOptions : { ecmaVersion : 6 }
253
+ } ,
254
+ {
255
+ code : "([obj.fo_o] = bar);" ,
256
+ options : [ { properties : "never" } ] ,
257
+ parserOptions : { ecmaVersion : 6 }
258
+ } ,
259
+ {
260
+ code : "({ c: [ob.fo_o]} = bar);" ,
261
+ options : [ { properties : "never" } ] ,
262
+ parserOptions : { ecmaVersion : 6 }
263
+ } ,
264
+ {
265
+ code : "([obj.fo_o.b_ar] = bar);" ,
266
+ options : [ { properties : "never" } ] ,
267
+ parserOptions : { ecmaVersion : 6 }
268
+ } ,
269
+ {
270
+ code : "({obj} = baz.fo_o);" ,
271
+ parserOptions : { ecmaVersion : 6 }
272
+ } ,
273
+ {
274
+ code : "([obj] = baz.fo_o);" ,
275
+ parserOptions : { ecmaVersion : 6 }
276
+ } ,
277
+ {
278
+ code : "([obj.foo = obj.fo_o] = bar);" ,
279
+ options : [ { properties : "always" } ] ,
280
+ parserOptions : { ecmaVersion : 6 }
228
281
}
229
282
] ,
230
283
invalid : [
@@ -736,6 +789,163 @@ ruleTester.run("camelcase", rule, {
736
789
type : "Identifier"
737
790
}
738
791
]
792
+ } ,
793
+ {
794
+ code : "({ a: obj.fo_o } = bar);" ,
795
+ parserOptions : { ecmaVersion : 6 } ,
796
+ errors : [
797
+ {
798
+ messageId : "notCamelCase" ,
799
+ data : { name : "fo_o" } ,
800
+ type : "Identifier"
801
+ }
802
+ ]
803
+ } ,
804
+ {
805
+ code : "({ a: obj.fo_o } = bar);" ,
806
+ options : [ { ignoreDestructuring : true } ] ,
807
+ parserOptions : { ecmaVersion : 6 } ,
808
+ errors : [
809
+ {
810
+ messageId : "notCamelCase" ,
811
+ data : { name : "fo_o" } ,
812
+ type : "Identifier"
813
+ }
814
+ ]
815
+ } ,
816
+ {
817
+ code : "({ a: obj.fo_o.b_ar } = baz);" ,
818
+ parserOptions : { ecmaVersion : 6 } ,
819
+ errors : [
820
+ {
821
+ messageId : "notCamelCase" ,
822
+ data : { name : "b_ar" } ,
823
+ type : "Identifier"
824
+ }
825
+ ]
826
+ } ,
827
+ {
828
+ code : "({ a: { b: { c: obj.fo_o } } } = bar);" ,
829
+ parserOptions : { ecmaVersion : 6 } ,
830
+ errors : [
831
+ {
832
+ messageId : "notCamelCase" ,
833
+ data : { name : "fo_o" } ,
834
+ type : "Identifier"
835
+ }
836
+ ]
837
+ } ,
838
+ {
839
+ code : "({ a: { b: { c: obj.fo_o.b_ar } } } = baz);" ,
840
+ parserOptions : { ecmaVersion : 6 } ,
841
+ errors : [
842
+ {
843
+ messageId : "notCamelCase" ,
844
+ data : { name : "b_ar" } ,
845
+ type : "Identifier"
846
+ }
847
+ ]
848
+ } ,
849
+ {
850
+ code : "([obj.fo_o] = bar);" ,
851
+ parserOptions : { ecmaVersion : 6 } ,
852
+ errors : [
853
+ {
854
+ messageId : "notCamelCase" ,
855
+ data : { name : "fo_o" } ,
856
+ type : "Identifier"
857
+ }
858
+ ]
859
+ } ,
860
+ {
861
+ code : "([obj.fo_o] = bar);" ,
862
+ options : [ { ignoreDestructuring : true } ] ,
863
+ parserOptions : { ecmaVersion : 6 } ,
864
+ errors : [
865
+ {
866
+ messageId : "notCamelCase" ,
867
+ data : { name : "fo_o" } ,
868
+ type : "Identifier"
869
+ }
870
+ ]
871
+ } ,
872
+ {
873
+ code : "([obj.fo_o = 1] = bar);" ,
874
+ options : [ { properties : "always" } ] ,
875
+ parserOptions : { ecmaVersion : 6 } ,
876
+ errors : [
877
+ {
878
+ messageId : "notCamelCase" ,
879
+ data : { name : "fo_o" } ,
880
+ type : "Identifier"
881
+ }
882
+ ]
883
+ } ,
884
+ {
885
+ code : "({ a: [obj.fo_o] } = bar);" ,
886
+ parserOptions : { ecmaVersion : 6 } ,
887
+ errors : [
888
+ {
889
+ messageId : "notCamelCase" ,
890
+ data : { name : "fo_o" } ,
891
+ type : "Identifier"
892
+ }
893
+ ]
894
+ } ,
895
+ {
896
+ code : "({ a: { b: [obj.fo_o] } } = bar);" ,
897
+ parserOptions : { ecmaVersion : 6 } ,
898
+ errors : [
899
+ {
900
+ messageId : "notCamelCase" ,
901
+ data : { name : "fo_o" } ,
902
+ type : "Identifier"
903
+ }
904
+ ]
905
+ } ,
906
+ {
907
+ code : "([obj.fo_o.ba_r] = baz);" ,
908
+ parserOptions : { ecmaVersion : 6 } ,
909
+ errors : [
910
+ {
911
+ messageId : "notCamelCase" ,
912
+ data : { name : "ba_r" } ,
913
+ type : "Identifier"
914
+ }
915
+ ]
916
+ } ,
917
+ {
918
+ code : "({...obj.fo_o} = baz);" ,
919
+ parserOptions : { ecmaVersion : 9 } ,
920
+ errors : [
921
+ {
922
+ messageId : "notCamelCase" ,
923
+ data : { name : "fo_o" } ,
924
+ type : "Identifier"
925
+ }
926
+ ]
927
+ } ,
928
+ {
929
+ code : "({...obj.fo_o.ba_r} = baz);" ,
930
+ parserOptions : { ecmaVersion : 9 } ,
931
+ errors : [
932
+ {
933
+ messageId : "notCamelCase" ,
934
+ data : { name : "ba_r" } ,
935
+ type : "Identifier"
936
+ }
937
+ ]
938
+ } ,
939
+ {
940
+ code : "({c: {...obj.fo_o }} = baz);" ,
941
+ parserOptions : { ecmaVersion : 9 } ,
942
+ errors : [
943
+ {
944
+ messageId : "notCamelCase" ,
945
+ data : { name : "fo_o" } ,
946
+ type : "Identifier"
947
+ }
948
+ ]
739
949
}
740
950
]
741
951
} ) ;
0 commit comments