Skip to content
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

Ionic 2 Support #132

Closed
plmetz opened this issue Nov 2, 2016 · 13 comments
Closed

Ionic 2 Support #132

plmetz opened this issue Nov 2, 2016 · 13 comments

Comments

@plmetz
Copy link

plmetz commented Nov 2, 2016

I have been using Codelyzer with an Ng2 project and loving it. I have started an Ionic 2 project that uses Codelyzer and it works almost perfectly except for an issue with pages. In Ionic the Component decorator is used for pages but the class name is suffixed with "Page." For example the file hello-ionic.page.ts would be:

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

@Component({
  templateUrl: 'hello-ionic.page.html'
})
export class HelloIonicPage {
  constructor() {

  }
}

This causes Codelyzer to state that "The name of the class HelloIonicPage should end with the suffix Component".

Changing componentClassSuffixRule.js line 16 from:

return /.*Component$/.test(className);

to

return (/.*Component$/.test(className) || /.*Page$/.test(className));

Fixes the problem but I figure there is probably a more elegant solution. In Ionic projects there will still be components so is there a way of discerning between a page and component based on location (src/pages/* vs srv/components/*)? Or allowing custom component suffixes in the rules config?

@abierbaum
Copy link

I think it would be a great addition to let user's configure an optional regex that is used to test all naming conventions that Codelyzer checks. Then for your code you could allow either Component or Page. Some other people may have other conventions they want to allow. (for example we would like to allow "Panel" for some types of components)

@mgechev mgechev self-assigned this Nov 28, 2016
@mgechev mgechev added this to the Beta 6 - Turing switch milestone Nov 28, 2016
@mgechev
Copy link
Owner

mgechev commented Nov 28, 2016

This rule can be made configurable and by default the suffix will be Component. It is going to be part of the next release.

@michaeljota
Copy link

Thanks! Will follow this then. 👍

@plmetz
Copy link
Author

plmetz commented Dec 10, 2016

Great! Thanks for all your work on this project

@TomDemulierChevret
Copy link

Can you confirm that currently (beta3) it's not possible to specify an array of suffixes in tslint.json ?
Since Ionic 2 use both "*Component" and "*Page", we still got an error.

I saw there was a more recent commit allowing this.
Is the master version stable enough to use or do we need to wait for beta4 ?

Thanks

@mgechev
Copy link
Owner

mgechev commented Dec 16, 2016

Beta3 doesn't support multiple suffixes. Yes, master is usually stable so you can give it a try.

@michaeljota
Copy link

@mgechev so this will support an array of suffixes? Thanks you. 👍

@mgechev
Copy link
Owner

mgechev commented Dec 16, 2016

Yes, master does.

@michaeljota
Copy link

I think README.md should be updated with an example for using both, the single syntax and the array syntax, or at least mention it. :). Do you mind if I do it?

@michaeljota
Copy link

michaeljota commented Jul 8, 2017

Reviewing this now, and still the docs lacks of examples of how to pass an array. Even the JSON Schema is lacking this options, throwing warnings in the tslint.json file if the array is passed as an option. (This is mostly because it's not an array of strings, but n strings.

@mgechev
Copy link
Owner

mgechev commented Jul 8, 2017

The JSON schema in maintained by third--party. I opened a PR sometimes back, at some point it will go upstream.

It'll be great if you open a PR with docs improvement.

@michaeljota
Copy link

I was just doing that, but found the actual documentation. I think that maybe the problem. As is right now it seems like all the docs are in README, cause there is no link to the documentation, nor a mention of it. Maybe less information of usage in README and instead a link to the docs?

@mgechev
Copy link
Owner

mgechev commented Jul 9, 2017

http://codelyzer.com/rules/ generated from the source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants