Feature request...
A rule to check source file names, configuring in such a way that it can check that components, services, etc follow the file name patterns shown in the style guide.
For example, check that component class MyComponent resides in a file named my.component.ts.
That's a good candidate and should be relatively straightforward to implement. Do you have suggestion for the rule's config?
How about something like this?
"directive-file-name": [true, "snake-case", "directive"],
true: means this is on.
snake-case: means to look for the-words not theWords. Alternative values: TitleCase, camelCase.
directive: means to look for the-words.directive.ts.
Of course, similar settings for component, module.
This could handle projects that follow the style guide closely:
some-name.component.ts
and also projects that choose another variation:
someName.cmp.ts
This way we need to have:
pipe-file-namecomponent-file-nameservice-file-namemodule-file-namecomponent-file-nameWe should come up with a more generic configuration which will not require declaration of 5 or more individual rules.
In our team we also use the name.model.ts notation to mane files storing data structure and API Interfaces
I don't think this would be a easy configuration model, but still would be so useful to use this.
Maybe we can use something like
"check-file-name": [
true,
{
"type": "component" | "directive" | "pipe" | "service" | "module" | "model" | "*",
"rule": "kebab-case" | "camelCase" | "PascalCase",
"suffix": "*" // default: same as type
}
],
Underneath this could have some default configuration that follows the standard guide style, as usual.
"check-file-name": true,
But allow configuration per objects.
"check-file-name": [
true,
{
"type": "component",
"rule": "PascalCase",
"suffix": "Cmp"
}
],
This would look for
AnyTitleCmp.tsfiles and ensure there is anAnyTitleCmpclass using@Componentdecorator (If that is something is the scope of this rule).
Or just set the rule or casing that would check that this rule would check
"check-file-name": [
true,
"PascalCase",
],
This would look for standards files and ensure they are using PascalCase, and there is a class using the corresponding decorator.
Hi, any news?
Hi @mgechev ,
Any news or update on this? When is this planned to be fixed & released ?
Thanks,
Bhasker
Following the feature request process that lodash has, I'm closing the issue and adding votes needed label.
Later we can prioritize the feature requests by popularity and include them in a future release.
Just want to say I hate the feature request process that Lodash has. But, I understand you would like to close some issues if they won't be implemented anytime soon. Thanks for the notice.
Actually, that's a feature great for people who want to contribute to codelyzer! There's no AST traversal required.
Just want to point that a similar rule has landed recently in tslint: file-name-casing.
Also, there's some suggestions to improve this rule: https://github.com/palantir/tslint/issues/4050 (for exclusions) and https://github.com/palantir/tslint/issues/4071 (for pattern matching).
Most helpful comment
Hi, any news?