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

feat: new interfaceTypeIdMatch rule #491

Closed
wants to merge 3 commits into from
Closed

Conversation

Jermayy
Copy link
Contributor

@Jermayy Jermayy commented Aug 2, 2021

Copy link
Contributor

@Brianzchen Brianzchen left a 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

Comment on lines 57 to 60
"flowtype/interface-type-id-match": [
2,
"^([A-Z][a-z0-9]+)+Type$"
],
Copy link
Contributor

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.

const typeIdentifierName = interfaceDeclarationNode.id.name;

if (!pattern.test(typeIdentifierName)) {
context.report(interfaceDeclarationNode, 'Type identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
context.report(interfaceDeclarationNode, 'Type identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.', {
context.report(interfaceDeclarationNode, 'Interface identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.', {

const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$');

const checkType = (interfaceDeclarationNode) => {
const typeIdentifierName = interfaceDeclarationNode.id.name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const typeIdentifierName = interfaceDeclarationNode.id.name;
const interfaceIdentifierName = interfaceDeclarationNode.id.name;

const create = (context) => {
const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$');

const checkType = (interfaceDeclarationNode) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const checkType = (interfaceDeclarationNode) => {
const checkInterface = (interfaceDeclarationNode) => {

@@ -19,6 +19,7 @@ const reportingRules = [
'delimiter-dangle',
'enforce-line-break',
'generic-spacing',
'interface-type-id-match',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'interface-type-id-match',
'interface-id-match',

Copy link
Contributor

@Brianzchen Brianzchen left a comment

Choose a reason for hiding this comment

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

LGTM

@Jermayy
Copy link
Contributor Author

Jermayy commented Aug 2, 2021

closing in favour of #492

@Jermayy Jermayy closed this Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants