Skip to content

Commit

Permalink
fix typos and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNuc committed Aug 18, 2023
1 parent fd14d08 commit 2e61da7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/rule-must-colocate-fragment-spreads.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ function checkColocation(context) {
loc: utils.getLoc(context, node, queriedFragments[fragment]),
message:
`This spreads the fragment \`${fragment}\` but ` +
`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 ` +
`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
18 changes: 10 additions & 8 deletions test/must-colocate-fragment-spreads.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ const RuleTester = eslint.RuleTester;

const ruleTester = new RuleTester({
parser: require.resolve('babel-eslint'),
parserOptions: {ecmaVersion: 6, sourceType: 'module'}
parserOptions: { ecmaVersion: 6, sourceType: 'module' }
});

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 All @@ -45,7 +47,7 @@ ruleTester.run(
...component_fragment
}\`;
`,
options: [{allowNamedImports: true}]
options: [{ allowNamedImports: true }]
},
`
const Component = require('../shared/component.js');
Expand Down Expand Up @@ -136,7 +138,7 @@ ruleTester.run(
...component_fragment
}\`;
`,
options: [{allowNamedImports: true}],
options: [{ allowNamedImports: true }],
errors: [
{
message: unusedFieldsWarning('component_fragment'),
Expand All @@ -151,7 +153,7 @@ ruleTester.run(
...component_fragment
}\`;
`,
options: [{allowNamedImports: false}],
options: [{ allowNamedImports: false }],
errors: [
{
message: unusedFieldsWarning('component_fragment'),
Expand Down

0 comments on commit 2e61da7

Please sign in to comment.