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
feat: new interfaceTypeIdMatch rule #491
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.
Just left some suggestions on cleaning up the naming conventions because I know you copied this from type id match, it should ideally reference more to interface id match in the code and rule name
.README/README.md
Outdated
"flowtype/interface-type-id-match": [ | ||
2, | ||
"^([A-Z][a-z0-9]+)+Type$" | ||
], |
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.
Don't think is necessary, but fine to keep.
src/rules/interfaceTypeIdMatch.js
Outdated
const typeIdentifierName = interfaceDeclarationNode.id.name; | ||
|
||
if (!pattern.test(typeIdentifierName)) { | ||
context.report(interfaceDeclarationNode, 'Type identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.', { |
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.
context.report(interfaceDeclarationNode, 'Type identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.', { | |
context.report(interfaceDeclarationNode, 'Interface identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.', { |
src/rules/interfaceTypeIdMatch.js
Outdated
const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$'); | ||
|
||
const checkType = (interfaceDeclarationNode) => { | ||
const typeIdentifierName = interfaceDeclarationNode.id.name; |
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 typeIdentifierName = interfaceDeclarationNode.id.name; | |
const interfaceIdentifierName = interfaceDeclarationNode.id.name; |
src/rules/interfaceTypeIdMatch.js
Outdated
const create = (context) => { | ||
const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$'); | ||
|
||
const checkType = (interfaceDeclarationNode) => { |
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 checkType = (interfaceDeclarationNode) => { | |
const checkInterface = (interfaceDeclarationNode) => { |
tests/rules/index.js
Outdated
@@ -19,6 +19,7 @@ const reportingRules = [ | |||
'delimiter-dangle', | |||
'enforce-line-break', | |||
'generic-spacing', | |||
'interface-type-id-match', |
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.
'interface-type-id-match', | |
'interface-id-match', |
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.
LGTM
closing in favour of #492 |
solves #483
cc: @gajus @angelica-bocanegra @Brianzchen