Skip to content

Commit a61b040

Browse files
angular/file-name: Lint component declarations
1 parent cdc5bb9 commit a61b040

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

rules/file-name.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ module.exports = {
122122

123123
return {
124124
CallExpression: function(node) {
125-
if (utils.isAngularComponent(node) && utils.isMemberExpression(node.callee)) {
125+
if ((utils.isAngularComponent(node) || utils.isAngularComponentDeclaration(node)) && utils.isMemberExpression(node.callee)) {
126126
var name = node.arguments[0].value;
127127
var type = componentTypeMappings[node.callee.property.name];
128128
var expectedName;

test/file-name.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
102102
ignoreTypeSuffix: true
103103
}]
104104
}, {
105-
// typeSeparator dot with controller and ignored type suffix
106-
filename: 'src/app/Avengers.controller.js',
107-
code: 'app.controller("AvengersController", function() {});',
105+
// typeSeparator dot with component and ignored type suffix
106+
filename: 'src/app/Avengers.component.js',
107+
code: 'app.component("AvengersComponent", {});',
108108
options: [{
109109
typeSeparator: 'dot',
110110
ignoreTypeSuffix: true
@@ -287,6 +287,14 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
287287
typeSeparator: 'dot'
288288
}],
289289
errors: [{message: 'Filename must be "AvengersController.controller.js"'}]
290+
}, {
291+
// typeSeparator dot with component, but no ignored type suffix
292+
filename: 'src/app/Avengers.component.js',
293+
code: 'app.component("AvengersComponent", {});',
294+
options: [{
295+
typeSeparator: 'dot'
296+
}],
297+
errors: [{message: 'Filename must be "AvengersComponent.component.js"'}]
290298
}, {
291299
// typeSeparator dot with controller and ignored type suffix
292300
filename: 'src/app/AvengersController.controller.js',
@@ -296,6 +304,15 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
296304
ignoreTypeSuffix: true
297305
}],
298306
errors: [{message: 'Filename must be "Avengers.controller.js"'}]
307+
}, {
308+
// typeSeparator dot with component and ignored type suffix
309+
filename: 'src/app/AvengersComponent.component.js',
310+
code: 'app.component("AvengersComponent", {});',
311+
options: [{
312+
typeSeparator: 'dot',
313+
ignoreTypeSuffix: true
314+
}],
315+
errors: [{message: 'Filename must be "Avengers.component.js"'}]
299316
}, {
300317
// nameStyle dash and typeSeparator dot with directive
301318
filename: 'src/app/avangerProfile.directive.js',

0 commit comments

Comments
 (0)