@@ -100,4 +100,183 @@ describe('rules/require-camelcase-or-uppercase-identifiers', function() {
100100 expect ( checker . checkString ( 'var extend = { set c_d(v) { } };' ) ) . to . have . no . errors ( ) ;
101101 } ) ;
102102 } ) ;
103+
104+ describe ( 'option object value `"ignoreProperties"`' , function ( ) {
105+ beforeEach ( function ( ) {
106+ checker . configure ( { requireCamelCaseOrUpperCaseIdentifiers : { ignoreProperties : true } } ) ;
107+ } ) ;
108+
109+ it ( 'should not report object keys' , function ( ) {
110+ expect ( checker . checkString ( 'var extend = { snake_case: a };' ) ) . to . have . no . errors ( ) ;
111+ } ) ;
112+
113+ it ( 'should not report object properties' , function ( ) {
114+ expect ( checker . checkString ( 'var extend = a.snake_case;' ) ) . to . have . no . errors ( ) ;
115+ } ) ;
116+
117+ it ( 'should report identifiers that are the last token' , function ( ) {
118+ expect ( checker . checkString ( 'var a = snake_case' ) )
119+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
120+ } ) ;
121+
122+ it ( 'should report identifiers that are the first token' , function ( ) {
123+ expect ( checker . checkString ( 'snake_case = a;' ) )
124+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
125+ } ) ;
126+
127+ it ( 'should not report es5 getters' , function ( ) {
128+ expect ( checker . checkString ( 'var extend = { get a_b() { } };' ) ) . to . have . no . errors ( ) ;
129+ } ) ;
130+
131+ it ( 'should not report es5 setters' , function ( ) {
132+ expect ( checker . checkString ( 'var extend = { set c_d(v) { } };' ) ) . to . have . no . errors ( ) ;
133+ } ) ;
134+ } ) ;
135+
136+ describe ( 'option object value `"strict"`' , function ( ) {
137+ beforeEach ( function ( ) {
138+ checker . configure ( { requireCamelCaseOrUpperCaseIdentifiers : { strict : true } } ) ;
139+ } ) ;
140+
141+ it ( 'should report capital' , function ( ) {
142+ expect ( checker . checkString ( 'var X = "x";' ) )
143+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
144+ } ) ;
145+
146+ it ( 'should report capital word' , function ( ) {
147+ expect ( checker . checkString ( 'var Xoe = "x";' ) )
148+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
149+ } ) ;
150+
151+ it ( 'should report capital used even with second one lower cased' , function ( ) {
152+ expect ( checker . checkString ( 'var Xy = "x";' ) )
153+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
154+ } ) ;
155+
156+ it ( 'should not report no capital used' , function ( ) {
157+ expect ( checker . checkString ( 'var xy = "x";' ) ) . to . have . no . errors ( ) ;
158+ } ) ;
159+
160+ it ( 'should not report leading underscores' , function ( ) {
161+ expect ( checker . checkString ( 'var _x = "x", __y = "y";' ) ) . to . have . no . errors ( ) ;
162+ } ) ;
163+
164+ it ( 'should report trailing underscores' , function ( ) {
165+ expect ( checker . checkString ( 'var x_ = "x", y__ = "y";' ) ) . to . have . no . errors ( ) ;
166+ } ) ;
167+
168+ it ( 'should not report underscore.js' , function ( ) {
169+ expect ( checker . checkString ( 'var extend = _.extend;' ) ) . to . have . no . errors ( ) ;
170+ } ) ;
171+
172+ it ( 'should not report node globals' , function ( ) {
173+ expect ( checker . checkString ( 'var a = __dirname + __filename;' ) ) . to . have . no . errors ( ) ;
174+ } ) ;
175+
176+ it ( 'should report object keys' , function ( ) {
177+ expect ( checker . checkString ( 'var extend = { snake_case: a };' ) )
178+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
179+ } ) ;
180+
181+ it ( 'should report object properties' , function ( ) {
182+ expect ( checker . checkString ( 'var extend = a.snake_case;' ) )
183+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
184+ } ) ;
185+
186+ it ( 'should not report object properties without capital' , function ( ) {
187+ expect ( checker . checkString ( 'var extend = a.snakeCase;' ) ) . to . have . no . errors ( ) ;
188+ } ) ;
189+
190+ it ( 'should report object properties with capital' , function ( ) {
191+ expect ( checker . checkString ( 'var extend = a.SnakeCase;' ) )
192+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
193+ } ) ;
194+
195+ it ( 'should report identifiers that are the last token' , function ( ) {
196+ expect ( checker . checkString ( 'var a = snake_case' ) )
197+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
198+ } ) ;
199+
200+ it ( 'should report identifiers that are the first token' , function ( ) {
201+ expect ( checker . checkString ( 'snake_case = a;' ) )
202+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
203+ } ) ;
204+
205+ it ( 'should report identifiers that start with a capital' , function ( ) {
206+ expect ( checker . checkString ( 'E' ) )
207+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
208+ } ) ;
209+ } ) ;
210+
211+ describe ( 'option object value `"strict"` and `"ignoreProperties"`' , function ( ) {
212+ beforeEach ( function ( ) {
213+ checker . configure ( { requireCamelCaseOrUpperCaseIdentifiers : { strict : true , ignoreProperties : true } } ) ;
214+ } ) ;
215+
216+ it ( 'should report capital' , function ( ) {
217+ expect ( checker . checkString ( 'var X = "x";' ) )
218+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
219+ } ) ;
220+
221+ it ( 'should report capital word' , function ( ) {
222+ expect ( checker . checkString ( 'var Xoe = "x";' ) )
223+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
224+ } ) ;
225+
226+ it ( 'should report capital used even with second one lower cased' , function ( ) {
227+ expect ( checker . checkString ( 'var Xy = "x";' ) )
228+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
229+ } ) ;
230+
231+ it ( 'should not report no capital used' , function ( ) {
232+ expect ( checker . checkString ( 'var xy = "x";' ) ) . to . have . no . errors ( ) ;
233+ } ) ;
234+
235+ it ( 'should not report leading underscores' , function ( ) {
236+ expect ( checker . checkString ( 'var _x = "x", __y = "y";' ) ) . to . have . no . errors ( ) ;
237+ } ) ;
238+
239+ it ( 'should report trailing underscores' , function ( ) {
240+ expect ( checker . checkString ( 'var x_ = "x", y__ = "y";' ) ) . to . have . no . errors ( ) ;
241+ } ) ;
242+
243+ it ( 'should not report underscore.js' , function ( ) {
244+ expect ( checker . checkString ( 'var extend = _.extend;' ) ) . to . have . no . errors ( ) ;
245+ } ) ;
246+
247+ it ( 'should not report node globals' , function ( ) {
248+ expect ( checker . checkString ( 'var a = __dirname + __filename;' ) ) . to . have . no . errors ( ) ;
249+ } ) ;
250+
251+ it ( 'should not report object keys' , function ( ) {
252+ expect ( checker . checkString ( 'var extend = { snake_case: a };' ) ) . to . have . no . errors ( ) ;
253+ } ) ;
254+
255+ it ( 'should not report object properties' , function ( ) {
256+ expect ( checker . checkString ( 'var extend = a.snake_case;' ) ) . to . have . no . errors ( ) ;
257+ } ) ;
258+
259+ it ( 'should not report object properties without capital' , function ( ) {
260+ expect ( checker . checkString ( 'var extend = a.snakeCase;' ) ) . to . have . no . errors ( ) ;
261+ } ) ;
262+
263+ it ( 'should report object properties with capital' , function ( ) {
264+ expect ( checker . checkString ( 'var extend = a.SnakeCase;' ) ) . to . have . no . errors ( ) ;
265+ } ) ;
266+
267+ it ( 'should report identifiers that are the last token' , function ( ) {
268+ expect ( checker . checkString ( 'var a = snake_case' ) )
269+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
270+ } ) ;
271+
272+ it ( 'should report identifiers that are the first token' , function ( ) {
273+ expect ( checker . checkString ( 'snake_case = a;' ) )
274+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
275+ } ) ;
276+
277+ it ( 'should report identifiers that start with a capital' , function ( ) {
278+ expect ( checker . checkString ( 'E' ) )
279+ . to . have . one . validation . error . from ( 'requireCamelCaseOrUpperCaseIdentifiers' ) ;
280+ } ) ;
281+ } ) ;
103282} ) ;
0 commit comments