Skip to content

Commit

Permalink
adding graphql-eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
zemd committed Mar 10, 2024
1 parent 05ab2a5 commit e425255
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-cats-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zemd/eslint-flat-config": patch
---

adding @graphql-eslint rules
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"dependencies": {
"@eslint/js": "^8.57.0",
"@graphql-eslint/eslint-plugin": "^3.20.1",
"@next/eslint-plugin-next": "^14.1.1",
"@stylistic/eslint-plugin": "^1.6.3",
"@typescript-eslint/eslint-plugin": "^7.1.0",
Expand Down
5 changes: 5 additions & 0 deletions src/createEslintConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { graphql } from "@graphql-eslint";
import { type Linter } from "eslint";

import { rules as storybookRules } from "./features/storybook.js";
Expand All @@ -11,6 +12,7 @@ import { rules as tailwindRules } from "./features/tailwind.js";
import { rules as typescriptRules } from "./features/typescript.js";
import { rules as recommendedRules } from "./features/recommended.js";
import { rules as stylisticRules } from "./features/stylistic.js";
import { rules as graphqlRules } from "./features/graphql.js";

type CreateEslintConfigOptions = {
useStorybook: boolean;
Expand All @@ -21,6 +23,7 @@ type CreateEslintConfigOptions = {
useTurbo: boolean;
useTailwind: boolean;
useAsFormatter: boolean;
useGraphQL: boolean;
};

export const createEslintConfig = (
Expand All @@ -35,6 +38,7 @@ export const createEslintConfig = (
useTurbo: true,
useTailwind: false,
useAsFormatter: false,
useGraphQL: false,
...opts,
};
return [
Expand All @@ -52,5 +56,6 @@ export const createEslintConfig = (
...(options.useVitest ? vitestRules : []),
...(options.useTurbo ? turboRules : []),
...(options.useTailwind ? tailwindRules : []),
...(options.useGraphQL ? graphqlRules : []),
];
};
27 changes: 27 additions & 0 deletions src/features/graphql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Linter } from "eslint";
import * as graphql from "@graphql-eslint/eslint-plugin";

const GQL_FILES = ["**/*.{graphql,gql}"];

export const rules: Array<Linter.FlatConfig> = [
{
files: GQL_FILES,
plugins: {
// @ts-ignore
"@graphql-eslint": graphql,
},
languageOptions: {
parser: graphql,
},
},
// @ts-ignore
{
files: GQL_FILES,
...graphql.flatConfigs["schema-recommended"],
},
// @ts-ignore
{
files: GQL_FILES,
...graphql.flatConfigs["operations-recommended"],
},
];

0 comments on commit e425255

Please sign in to comment.