Skip to content

Commit ad65cc1

Browse files
Merge pull request #461 from tpeiffer/Issue-452/angular/file-name/casing/unit-tests
Issue 452/angular/file name/casing/unit tests
2 parents 9b49849 + 2cc5263 commit ad65cc1

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

rules/file-name.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ module.exports = {
105105
if (typeSeparator !== undefined) {
106106
name = name + typeSeparator + type;
107107
}
108+
if (options.casing === 'camel') {
109+
name = filenameUtil.firstToLower(name);
110+
}
111+
if (options.casing === 'pascal') {
112+
name = filenameUtil.firstToUpper(name);
113+
}
108114
return name + fileEnding;
109115
}
110116
};

test/file-name.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,38 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
227227
},
228228
typeSeparator: 'dot'
229229
}]
230+
}, {
231+
// camel casing, dot typeSeparator, ignoreTypeSuffix of true
232+
filename: 'src/app/some.controller.js',
233+
code: 'app.controller("SomeController", function() {});',
234+
options: [{
235+
casing: 'camel',
236+
typeSeparator: 'dot',
237+
ignoreTypeSuffix: true
238+
}]
239+
}, {
240+
// camel casing
241+
filename: 'src/app/someController.js',
242+
code: 'app.controller("SomeController", function() {});',
243+
options: [{
244+
casing: 'camel'
245+
}]
246+
}, {
247+
// pascal casing, dot typeSeparator, ignoreTypeSuffix of true
248+
filename: 'src/app/Some.controller.js',
249+
code: 'app.controller("SomeController", function() {});',
250+
options: [{
251+
casing: 'pascal',
252+
typeSeparator: 'dot',
253+
ignoreTypeSuffix: true
254+
}]
255+
}, {
256+
// pascal casing
257+
filename: 'src/app/SomeController.js',
258+
code: 'app.controller("SomeController", function() {});',
259+
options: [{
260+
casing: 'pascal'
261+
}]
230262
}].concat(commonFalsePositives),
231263
invalid: [{
232264
filename: 'src/app/filters.js',
@@ -322,5 +354,41 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
322354
typeSeparator: 'dot'
323355
}],
324356
errors: [{message: 'Filename must be "users.provider.js"'}]
357+
}, {
358+
// camel casing, dot typeSeparator, ignoreTypeSuffix of true
359+
filename: 'src/app/SomeController.js',
360+
code: 'app.controller("SomeController", function() {});',
361+
options: [{
362+
casing: 'camel',
363+
typeSeparator: 'dot',
364+
ignoreTypeSuffix: true
365+
}],
366+
errors: [{message: 'Filename must be "some.controller.js"'}]
367+
}, {
368+
// camel casing
369+
filename: 'src/app/SomeController.js',
370+
code: 'app.controller("SomeController", function() {});',
371+
options: [{
372+
casing: 'camel'
373+
}],
374+
errors: [{message: 'Filename must be "someController.js"'}]
375+
}, {
376+
// pascal casing, dot typeSeparator, ignoreTypeSuffix of true
377+
filename: 'src/app/someController.js',
378+
code: 'app.controller("SomeController", function() {});',
379+
options: [{
380+
casing: 'pascal',
381+
typeSeparator: 'dot',
382+
ignoreTypeSuffix: true
383+
}],
384+
errors: [{message: 'Filename must be "Some.controller.js"'}]
385+
}, {
386+
// pascal casing
387+
filename: 'src/app/someController.js',
388+
code: 'app.controller("SomeController", function() {});',
389+
options: [{
390+
casing: 'pascal'
391+
}],
392+
errors: [{message: 'Filename must be "SomeController.js"'}]
325393
}]
326394
});

0 commit comments

Comments
 (0)