Skip to content

Migrating to eslint.config.js #2522

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

Merged
merged 15 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
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
138 changes: 138 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsdoc from "eslint-plugin-tsdoc";
import _import from "eslint-plugin-import";
import { fixupPluginRules } from "@eslint/compat";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import parser from "@graphql-eslint/eslint-plugin";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname
});

export default [{
ignores: [
"**/.github",
"**/.vscode",
"**/build",
"**/coverage",
"**/node_modules",
"src/types",
"docs/Schema.md",
],
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"), {
plugins: {
"@typescript-eslint": typescriptEslint,
tsdoc,
"import": fixupPluginRules(_import),
},

languageOptions: {
env: {
node: true,
},
parser: tsParser,
}
,

rules: {
"no-restricted-imports": ["error", {
patterns: ["**/src/**"],
}],

"import/no-duplicates": "error",
"tsdoc/syntax": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-var-requires": "error",
},
}, {
files: ["**/*.ts"],

languageOptions: {
parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",

parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: ".",
},
},

rules: {
"@typescript-eslint/array-type": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "error",

"@typescript-eslint/naming-convention": ["error", {
selector: "interface",
format: ["PascalCase"],
prefix: ["Interface", "TestInterface"],
}, {
selector: ["typeAlias", "typeLike", "enum"],
format: ["PascalCase"],
}, {
selector: "typeParameter",
format: ["PascalCase"],
prefix: ["T"],
}, {
selector: "variable",
format: ["camelCase", "UPPER_CASE"],
leadingUnderscore: "allow",
}, {
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
}, {
selector: "function",
format: ["camelCase"],
}, {
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
}, {
selector: "variable",
modifiers: ["exported"],
format: null,
}],
},
}, {
files: ["./src/typeDefs/**/*.ts"],
processor: "@graphql-eslint/graphql",
}, {
files: ["./src/typeDefs/**/*.graphql"],

plugins: {
"@graphql-eslint": graphqlEslint,
},

languageOptions: {
parser: parser,
},
}, {
files: ["tests/**/*"],

rules: {
"no-restricted-imports": "off",
},
}, {
files: ["./src/index.ts", "./src/utilities/copyToClipboard.ts"],

rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-function": "off",
},
}];
127 changes: 93 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
"zod-error": "^1.5.0"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.10.0",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/typescript": "^4.0.9",
"@graphql-codegen/typescript-resolvers": "^4.2.1",
Expand Down
Loading