-
Notifications
You must be signed in to change notification settings - Fork 101
Add missing converter: file-name-casing #204
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
Add missing converter: file-name-casing #204
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far! A few changes before merging, please.
const casesMap = new Map(); | ||
casesMap.set("camel-case", "camelCase"); | ||
casesMap.set("pascal-case", "pascalCase"); | ||
casesMap.set("kebab-case", "kebabCase"); | ||
casesMap.set("snake-case", "snakeCase"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make a map with initialized properties in the constructor:
new Map([
["camel-case", "camelCase"],
// ...
]);
That being said, I don't think this really needs to be a Map
. Only .get
is used on it, and always for keys guaranteed to exist. Can you switch it to just a regular object, and initialize it outside of collectArguments
(since it's only assigned to and never modified)?
@@ -0,0 +1,56 @@ | |||
import { RuleConverter } from "../converter"; | |||
|
|||
const IGNORE_CASE_NOTICE = "ESLint (Unicorn plugin) does not support ignore as case"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const IGNORE_CASE_NOTICE = "ESLint (Unicorn plugin) does not support ignore as case"; | |
const IGNORE_CASE_NOTICE = "ESLint (Unicorn plugin) does not support the 'ignore' case."; |
...to be a little more clear. Other notices
end with periods too.
casesMap.set("pascal-case", "pascalCase"); | ||
casesMap.set("kebab-case", "kebabCase"); | ||
casesMap.set("snake-case", "snakeCase"); | ||
const foundCases: { [k: string]: any } = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const foundCases: { [k: string]: any } = {}; | |
const foundCases: { [k: string]: string } = {}; |
...right? Once casesMap
is converted to a { [i: string]: string }
, this should work more easily in the typings.
* Add notice for changed behavior * Change map to object * Correct notice about the 'ignore' case * Specify map typing
Thank you for your feedback! I tried to fix all issues. Let me know if there is anything else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks for the changes!
Linked to issue: #161
PR Checklist
status: accepting prs
Overview
Add converter for file-name-casing. Map casings to new rule in the unicorn plugin.