Skip to content

Generated directive class name should have 'Directive' suffix #1217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Blasz opened this issue Jun 27, 2016 · 7 comments · Fixed by #1750 · May be fixed by abhiit89/angular-cli#13
Closed

Generated directive class name should have 'Directive' suffix #1217

Blasz opened this issue Jun 27, 2016 · 7 comments · Fixed by #1750 · May be fixed by abhiit89/angular-cli#13
Assignees
Labels
effort1: easy (hours) P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix

Comments

@Blasz
Copy link

Blasz commented Jun 27, 2016

Version
$ ng --version
(node:20286) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.6
node: 6.2.1
os: linux x64
Repro steps

The following generate command produces a directive class name without the 'Directive' suffix.

$ ng g directive shared/directives/wrap-if
(node:20210) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
installing directive
  create src/app/shared/directives/wrap-if.directive.spec.ts
  create src/app/shared/directives/wrap-if.directive.ts

src/app/shared/directives/wrap-if.directive.ts

import { Directive } from '@angular/core';

@Directive({
  selector: '[wrap-if]'
})
export class WrapIf {

  constructor() {}

}

As per the styleguide,

Do append the symbol name with the suffix that it represents.
...
export class ValidationDirective

The generated class name should be WrapIfDirective.

@filipesilva filipesilva added the P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful label Aug 19, 2016
@filipesilva
Copy link
Contributor

@Brocco could you have a look please?

@Blasz
Copy link
Author

Blasz commented Sep 22, 2016

The associated spec file of the directive still imports the wrong directive name:

/* tslint:disable:no-unused-variable */

import { TestBed, async } from '@angular/core/testing';
import { HoverEvent } from './hover-event.directive';

describe('Directive: HoverEvent', () => {
  it('should create an instance', () => {
    let directive = new HoverEventDirective();
    expect(directive).toBeTruthy();
  });
});

Is this better suited to a new issue or can this one be re-opened?

@hansl
Copy link
Contributor

hansl commented Sep 22, 2016

What version are you using? ng version

@Blasz
Copy link
Author

Blasz commented Sep 22, 2016

$ ng version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.15
node: 6.2.1
os: linux x64

@hansl
Copy link
Contributor

hansl commented Sep 22, 2016

Okay I'll reopen this and assign it to @Brocco.

@hansl hansl reopened this Sep 22, 2016
@Brocco
Copy link
Contributor

Brocco commented Sep 24, 2016

This has been resolved via PR #1940 and will be included in the next release

@Brocco Brocco closed this as completed Sep 24, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: easy (hours) P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix
Projects
None yet
4 participants