Skip to content

Commit

Permalink
Merge pull request #473 from gustavderdrache/fix-file-name-rule-with-…
Browse files Browse the repository at this point in the history
…components

angular/file-name: Lint component declarations
  • Loading branch information
EmmanuelDemey committed May 27, 2017
2 parents 7db701b + a61b040 commit 54fd935
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rules/file-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = {

return {
CallExpression: function(node) {
if (utils.isAngularComponent(node) && utils.isMemberExpression(node.callee)) {
if ((utils.isAngularComponent(node) || utils.isAngularComponentDeclaration(node)) && utils.isMemberExpression(node.callee)) {
var name = node.arguments[0].value;
var type = componentTypeMappings[node.callee.property.name];
var expectedName;
Expand Down
23 changes: 20 additions & 3 deletions test/file-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
ignoreTypeSuffix: true
}]
}, {
// typeSeparator dot with controller and ignored type suffix
filename: 'src/app/Avengers.controller.js',
code: 'app.controller("AvengersController", function() {});',
// typeSeparator dot with component and ignored type suffix
filename: 'src/app/Avengers.component.js',
code: 'app.component("AvengersComponent", {});',
options: [{
typeSeparator: 'dot',
ignoreTypeSuffix: true
Expand Down Expand Up @@ -287,6 +287,14 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
typeSeparator: 'dot'
}],
errors: [{message: 'Filename must be "AvengersController.controller.js"'}]
}, {
// typeSeparator dot with component, but no ignored type suffix
filename: 'src/app/Avengers.component.js',
code: 'app.component("AvengersComponent", {});',
options: [{
typeSeparator: 'dot'
}],
errors: [{message: 'Filename must be "AvengersComponent.component.js"'}]
}, {
// typeSeparator dot with controller and ignored type suffix
filename: 'src/app/AvengersController.controller.js',
Expand All @@ -296,6 +304,15 @@ angular.module(mod, [mod + '.core.angular', mod + '.thirdparty']);
ignoreTypeSuffix: true
}],
errors: [{message: 'Filename must be "Avengers.controller.js"'}]
}, {
// typeSeparator dot with component and ignored type suffix
filename: 'src/app/AvengersComponent.component.js',
code: 'app.component("AvengersComponent", {});',
options: [{
typeSeparator: 'dot',
ignoreTypeSuffix: true
}],
errors: [{message: 'Filename must be "Avengers.component.js"'}]
}, {
// nameStyle dash and typeSeparator dot with directive
filename: 'src/app/avangerProfile.directive.js',
Expand Down

0 comments on commit 54fd935

Please sign in to comment.