Skip to content

Commit 12cfb2e

Browse files
Merge pull request #462 from Gillespie59/development
2.1.0
2 parents f3080fd + d1fdeb8 commit 12cfb2e

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-angular",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "ESLint rules for AngularJS projects",
55
"main": "index.js",
66
"scripts": {

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
};

rules/service-name.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,31 @@ function getConfig(options) {
4444
return config;
4545
}
4646

47+
/**
48+
* Used only by `ForDeprecatedBehavior()` for making sure it was run only one time
49+
* @type {boolean}
50+
*/
51+
var didWarnForDeprecatedBehavior = false;
52+
53+
/**
54+
* Warn if API is deprecated
55+
* @param {Array.<*>} options
56+
*/
57+
function warnForDeprecatedBehavior(options) {
58+
if (didWarnForDeprecatedBehavior) {
59+
return;
60+
}
61+
didWarnForDeprecatedBehavior = true;
62+
63+
var config = getConfig(options);
64+
65+
/* istanbul ignore if */
66+
if (config.oldBehavior) {
67+
// eslint-disable-next-line
68+
console.warn('The rule `angular/service-name` will be split up to different rules in the next version. Please read the docs for more information');
69+
}
70+
}
71+
4772
module.exports = {
4873
meta: {
4974
schema: [{
@@ -53,6 +78,8 @@ module.exports = {
5378
}]
5479
},
5580
create: function(context) {
81+
warnForDeprecatedBehavior(context.options);
82+
5683
return {
5784

5885
CallExpression: function(node) {

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)