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

Improve error message of collocated fragments. #7

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/rule-must-colocate-fragment-spreads.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ function checkColocation(context) {
loc: utils.getLoc(context, node, queriedFragments[fragment]),
message:
`This spreads the fragment \`${fragment}\` but ` +
'this module does not use it directly. If a different module ' +
'needs this information, that module should directly define a ' +
'fragment querying for that data, colocated next to where the ' +
'data is used.\n'
`this module does not use it directly or it the fragment is named incorrectly. If a different module ` +
Copy link
Member

Choose a reason for hiding this comment

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

I'd even remove the first part of the error message. Let's make it clear that the problem is a) name of the imported component and b) the underscore.

Choose a reason for hiding this comment

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

Suggested change
`this module does not use it directly or it the fragment is named incorrectly. If a different module ` +
`this module does not use it directly or the fragment is named incorrectly. If a different module ` +

`needs the data from this fragment, that module should directly define it's own fragment ` +
`to query for it's own data, and such fragment should be spread in the parent component.` +
`The naming convention should be <nameOfComponentCamelCase>_<optionalSuffix>. ` +
`The <nameOfComponentCamelCase> should match the import name. Optinal suffix should be separated ` +

Choose a reason for hiding this comment

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

Suggested change
`The <nameOfComponentCamelCase> should match the import name. Optinal suffix should be separated ` +
`The <nameOfComponentCamelCase> should match the import name. The optional suffix should be separated ` +

`by underscore (usually when you need to pass multiple fragments to the same component).\n`
});
}
}
Expand Down
Loading