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

getRuleName doesn't work for packages with multiple rules. #1054

Closed
sarvaje opened this issue May 11, 2018 · 8 comments
Closed

getRuleName doesn't work for packages with multiple rules. #1054

sarvaje opened this issue May 11, 2018 · 8 comments

Comments

@sarvaje
Copy link
Contributor

sarvaje commented May 11, 2018

In these cases, it returns just the name of the package, but not the name of the rule you want to test.

@kshyju
Copy link
Member

kshyju commented May 18, 2018

What is it supposed to return when a package has more than one rules in it ? How does it know what to return ?

@sarvaje
Copy link
Contributor Author

sarvaje commented May 18, 2018

For example, in the case of rule-typescript-config, getRuleName should return something like:
typescript-config/consistent-casing or typescript-config/import-helpers.

@kshyju
Copy link
Member

kshyju commented May 18, 2018

should return something like:
typescript-config/consistent-casing or typescript-config/import-helpers.

Or ?
Does that mean, any rule present in the package directory ? What is the value of doing that ? What if i want the rule name for a test i am writing for the second/third rule ?

@sarvaje
Copy link
Contributor Author

sarvaje commented May 18, 2018

Those were just a couple of examples.

What I mean is that getRuleName should return, for multi rules packages, {packageName}/{ruleName}

@kshyju
Copy link
Member

kshyju commented May 19, 2018

Going back to my original question.

What is it supposed to return when a package has more than one rules in it ? How does it know which rule name to return ? The only way to solve the problem is to take the optional rule name when calling the method ?

const ruleName = getRuleName(__dirname,"is-installed");

@sarvaje
Copy link
Contributor Author

sarvaje commented May 19, 2018

IMO, if we need to pass the rule name, then it is better to hardcode the name.
I think that is the tricky part, how to get the name of the rule given the file path or the folder...

Maybe you can check if getRuleName get a folder or a file, if it is a file, then you get the package name from the directory and the rule name from the fileName.

@molant
Copy link
Member

molant commented May 19, 2018

In multi rule packages the convention so far is to name the file test the same as the rule we are testing.

alrra pushed a commit that referenced this issue Jun 21, 2018
@alrra
Copy link
Contributor

alrra commented Jun 21, 2018

Done in 232564d.

@alrra alrra closed this as completed Jun 21, 2018
alrra pushed a commit that referenced this issue Jul 3, 2018
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

4 participants