Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

[New rule] add fileNameCasing rule #3978

Merged
merged 4 commits into from
Jun 26, 2018
Merged

Conversation

euclio
Copy link
Contributor

@euclio euclio commented Jun 20, 2018

PR checklist

Overview of change:

Creates a new fileNameCasing rule that ensures consistent casing for all file names.

CHANGELOG.md entry:

[new-rule] file-name-casing

@palantirtech
Copy link
Member

Thanks for your interest in palantir/tslint, @euclio! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@euclio euclio force-pushed the file-name-casing branch 3 times, most recently from 1721259 to b8dc933 Compare June 20, 2018 17:32

const casing = this.ruleArguments[0] as Casing;

let isCorrectCasing = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor: make a private isCorrectCasing(fileName) function that returns a boolean in each switch case instead of declaring a let variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

case Casing.KebabCase:
return isKebabCased(fileName);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: blank line between function members.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

enum Casing {
CamelCase = "camel-case",
PascalCase = "pascal-case",
KebabCase = "kebab-case",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 camelCase, PascalCase, kebab-case? weird to write them all in kebab case. this comment is inspired by the error message:

File name must be camel-cased. vs File name must be camelCased.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i'm into the string matching the expected casing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change the error message, but I think that the option names should stay kebab-cased for consistency with other rule options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link

@giladgray giladgray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@giladgray giladgray merged commit 1c31dc0 into palantir:master Jun 26, 2018
@euclio
Copy link
Contributor Author

euclio commented Jun 26, 2018

@giladgray Awesome, thanks! Could you go ahead and close #3434? Looks like it didn't close automatically.

@euclio euclio deleted the file-name-casing branch June 26, 2018 19:52
pablobirukov pushed a commit to evolution-gaming/tslint that referenced this pull request Jul 4, 2018
* add fileNameCasing rule

* use camel case name for tslintCli

* refactor casing check into helper function

* use stylized name for casing in failure message
@tommedema
Copy link

tommedema commented Jul 5, 2018

Getting

could not find implementations for the following rules specified in the configuration:
    file-name-casing

Version 5.10.0

@euclio
Copy link
Contributor Author

euclio commented Jul 5, 2018

@tommedema This lint hasn't been included in a release yet

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

Successfully merging this pull request may close these issues.

4 participants