-
Notifications
You must be signed in to change notification settings - Fork 106
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
[#2291] Support the '...' group for alphabetizing fragment spreads #2293
[#2291] Support the '...' group for alphabetizing fragment spreads #2293
Conversation
🦋 Changeset detectedLatest commit: 52ef9cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
[Kind.OBJECT_TYPE_EXTENSION]: 'type', | ||
[Kind.INTERFACE_TYPE_DEFINITION]: 'interface', | ||
[Kind.INTERFACE_TYPE_EXTENSION]: 'interface', | ||
const DisplayNodeNameMap: Record<Kind, string> = { |
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.
Added display name for all Kind
enum values, and sorted the list
…ql-hive#2435) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…hql-hive#2446) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…hive#2436) * fix(deps): update dependency @theguild/components to v6.6.3 * fix * a * aa * aa --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
…ql-hive#2447) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* chore(deps): update dependency vitest to v2 * fix * aa --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
…raphql-hive#1648) * chore(deps): update dependency eslint-plugin-eslint-plugin to v5.5.1 * aa --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…hive#2453) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* chore(deps): update dependency eslint to v9 * upd * upd * upd * more * more * more * more * prettier * fix type check * fix type check * fix type check * fix type check * fix bob check * more work * pnpm i * fix prebuild * Update website/src/components/graphql-editor.tsx * fix types error --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…les for multi projects (graphql-hive#2455) * aa * update tests * fix lint
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…r` to be compatible with ESLint 9 (graphql-hive#2458) * fix lint * aa * aa * more * more * more * more * more * more * format * fix examples test * fix website * fix * aa * try * okk * nowww
…raphql-hive#2459) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#2463) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…aphql-hive#2465) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* add new docs * more * more * add * more * more * more * more * more * fix generate docs prettier, incorrectly formatted _meta.ts * add baseUrl * update eslint patch * fix snapshots * fix lint
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* add new docs * more * more * add * more * more * more * more * more * fix generate docs prettier, incorrectly formatted _meta.ts * add baseUrl * update eslint patch * fix snapshots * fix lint * move * more * more * more * more * more * prettier * more * more * more * prettier * more * prettier * more * more * more * prettier * fix for generate-configs * pnpm dedupe
* add new docs * more * more * add * more * more * more * more * more * fix generate docs prettier, incorrectly formatted _meta.ts * add baseUrl * update eslint patch * fix snapshots * fix lint * move * more * more * more * more * more * prettier * more * more * more * prettier * more * prettier * more * more * more * prettier * fix for generate-configs * test legacy configs examples * more * more * prettier * more * more * more * run tests for examples with legacy configs * lint * polish introduction * add banner * fill usages * more * more * more * polish configs * more * new link * more * more * more * more * more * new link * more * more
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* add new docs * more * more * add * more * more * more * more * more * fix generate docs prettier, incorrectly formatted _meta.ts * add baseUrl * update eslint patch * fix snapshots * fix lint * move * more * more * more * more * more * prettier * more * more * more * prettier * more * prettier * more * more * more * prettier * fix for generate-configs * test legacy configs examples * more * more * prettier * more * more * more * run tests for examples with legacy configs * lint * Add Vue usage instructions * prettier * 1. graphql plugin can now we specified with ```js plugins: { '@graphql-eslint': graphqlPlugin }, ``` 2. config rules now should be specified with accessing `rules` property ```diff rules: { - ...graphqlESLint.configs['flat/operations-recommended'] + ...graphqlESLint.configs['flat/operations-recommended'].rules ``` 3. processor can now be specified with accessing `processor` property ```js processor: graphqlPlugin.processor ``` 4. plugin can now be imported with default import ```js import graphqlPlugin from '@graphql-eslint/eslint-plugin' ``` * improve * fix indent --------- Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
* runs tests of Windows * fix * prettier * fix lint * set ``"moduleResolution": "bundler"` * set `"module": "esnext"` * try to fix examples.spec.ts * use optional chaining * add log * fix * should fix * fix new line on windows * fix * and here * maybe this * try * try * try * attempt to fix schema.spec * add shell: true * improve * try * try * try * try * try * try * try fix prettier example on windows * try * try now * try now * more * try * upd banner * merge * more * more * more * fix * log * more * now * more * try slash for filePath * yoyo * more * try * add changeset * aa * more * i know the problem * fix eslint tailwindcss * see * aa * use `"eslint-plugin-tailwindcss": "3.17.3"` * yes * should be all good now * try now * thiiis
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
|
||
function getIndex({ | ||
node, | ||
groups, | ||
}: { | ||
node: GraphQLESTreeNode<ASTNode>; | ||
groups: string[]; | ||
}): number { | ||
// Try an exact match | ||
let index = groups.indexOf(getName(node)); | ||
|
||
// Check for the fragment spread group | ||
if (index === -1 && node.kind === Kind.FRAGMENT_SPREAD) { | ||
index = groups.indexOf('...'); | ||
} | ||
|
||
// Check for the catch-all group | ||
if (index === -1) { | ||
index = groups.indexOf('*'); | ||
} | ||
return index; | ||
} | ||
|
||
function getName(node: GraphQLESTreeNode<ASTNode>): string { | ||
return ( | ||
('alias' in node && node.alias?.value) || | ||
// | ||
('name' in node && node.name?.value) || | ||
'' | ||
); | ||
} |
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.
refactored a bit for better readability
@@ -203,7 +203,7 @@ export const rule: GraphQLESLintRule<RuleOptions> = { | |||
selections: selectionsEnum, | |||
variables: true, | |||
arguments: [Kind.FIELD, Kind.DIRECTIVE], | |||
groups: ['id', '*', 'createdAt', 'updatedAt'], | |||
groups: ['id', '*', 'createdAt', 'updatedAt', '...'], |
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.
why this preference? I think the start is better?
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.
I refactored a bit duplicated code
I have only 1 comment https://github.com/dimaMachina/graphql-eslint/pull/2293/files#r1841895177
Thanks for contribution
Description
Adds a group type to the
groups
property of thealphabetize
rule indicating where fragment spreads should be in a selection set.Similarly to the
'*'
group, which stands for "everything else," the'...'
stands for "all fragment spreads."Fixes #2291
Type of change
How Has This Been Tested?
Added the following unit tests, ran
yarn test
and verified that the error messages match the expected ones:...
is at the start...
is between...
is at the endChecklist:
CONTRIBUTING doc and the
style guidelines of this project
Further comments
When working on this change, the display name for a fragment spread was showing
undefined <fragment name>
, which was because there was no name mapping for thatKind
— so I went ahead and added display names for allKind
values, and sorted the map.