Skip to content

Commit

Permalink
Merge pull request #7 from productboard/SKIP-123-collocated-fragments…
Browse files Browse the repository at this point in the history
…-message
  • Loading branch information
MartinNuc authored Aug 18, 2023
2 parents a7d245a + 15a8e3d commit 68291db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
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 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 is <nameOfComponentCamelCase>_<optionalSuffix>. ` +
`The <nameOfComponentCamelCase> must 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
10 changes: 6 additions & 4 deletions test/must-colocate-fragment-spreads.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ const ruleTester = new RuleTester({
function unusedFieldsWarning(fragment) {
return (
`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 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 is <nameOfComponentCamelCase>_<optionalSuffix>. ` +
`The <nameOfComponentCamelCase> must 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

0 comments on commit 68291db

Please sign in to comment.