Skip to content

Commit c03e2fb

Browse files
Migrating to eslint.config.js (#2522)
* Migrating to eslint.config.js * Resolving conflicts * Resolving Dependency conflict * Removing the dev and license keys to resolve conflict * Removing the dev and license key for eslint/eslintrc * Resolving the conflicts in the package.json file and modifying the eslint.config.js file to handle the global variables * resolving package conflicts * Quoting the 'import' property name to avoid syntax errors Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * bringing package-lock and package.json in sync * Updating package-lock.json * Commiting coderabbitai suggestion Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: suyash <suyashmishra145.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent f63e383 commit c03e2fb

File tree

3 files changed

+260
-52
lines changed

3 files changed

+260
-52
lines changed

eslint.config.mjs

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2+
import tsdoc from "eslint-plugin-tsdoc";
3+
import _import from "eslint-plugin-import";
4+
import { fixupPluginRules } from "@eslint/compat";
5+
import globals from "globals";
6+
import tsParser from "@typescript-eslint/parser";
7+
import parser from "@graphql-eslint/eslint-plugin";
8+
import path from "node:path";
9+
import { fileURLToPath } from "node:url";
10+
import js from "@eslint/js";
11+
import { FlatCompat } from "@eslint/eslintrc";
12+
import graphqlEslint from "@graphql-eslint/eslint-plugin";
13+
14+
const __filename = fileURLToPath(import.meta.url);
15+
const __dirname = path.dirname(__filename);
16+
const compat = new FlatCompat({
17+
baseDirectory: __dirname
18+
});
19+
20+
export default [{
21+
ignores: [
22+
"**/.github",
23+
"**/.vscode",
24+
"**/build",
25+
"**/coverage",
26+
"**/node_modules",
27+
"src/types",
28+
"docs/Schema.md",
29+
],
30+
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"), {
31+
plugins: {
32+
"@typescript-eslint": typescriptEslint,
33+
tsdoc,
34+
"import": fixupPluginRules(_import),
35+
},
36+
37+
languageOptions: {
38+
env: {
39+
node: true,
40+
},
41+
parser: tsParser,
42+
}
43+
,
44+
45+
rules: {
46+
"no-restricted-imports": ["error", {
47+
patterns: ["**/src/**"],
48+
}],
49+
50+
"import/no-duplicates": "error",
51+
"tsdoc/syntax": "error",
52+
"@typescript-eslint/ban-ts-comment": "error",
53+
"@typescript-eslint/ban-types": "error",
54+
"@typescript-eslint/no-duplicate-enum-values": "error",
55+
"@typescript-eslint/no-explicit-any": "warn",
56+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
57+
"@typescript-eslint/no-non-null-assertion": "error",
58+
"@typescript-eslint/no-var-requires": "error",
59+
},
60+
}, {
61+
files: ["**/*.ts"],
62+
63+
languageOptions: {
64+
parser: tsParser,
65+
ecmaVersion: "latest",
66+
sourceType: "module",
67+
68+
parserOptions: {
69+
project: "./tsconfig.json",
70+
tsconfigRootDir: ".",
71+
},
72+
},
73+
74+
rules: {
75+
"@typescript-eslint/array-type": "error",
76+
"@typescript-eslint/consistent-type-assertions": "error",
77+
"@typescript-eslint/consistent-type-imports": "error",
78+
"@typescript-eslint/explicit-function-return-type": "error",
79+
80+
"@typescript-eslint/naming-convention": ["error", {
81+
selector: "interface",
82+
format: ["PascalCase"],
83+
prefix: ["Interface", "TestInterface"],
84+
}, {
85+
selector: ["typeAlias", "typeLike", "enum"],
86+
format: ["PascalCase"],
87+
}, {
88+
selector: "typeParameter",
89+
format: ["PascalCase"],
90+
prefix: ["T"],
91+
}, {
92+
selector: "variable",
93+
format: ["camelCase", "UPPER_CASE"],
94+
leadingUnderscore: "allow",
95+
}, {
96+
selector: "parameter",
97+
format: ["camelCase"],
98+
leadingUnderscore: "allow",
99+
}, {
100+
selector: "function",
101+
format: ["camelCase"],
102+
}, {
103+
selector: "memberLike",
104+
modifiers: ["private"],
105+
format: ["camelCase"],
106+
leadingUnderscore: "require",
107+
}, {
108+
selector: "variable",
109+
modifiers: ["exported"],
110+
format: null,
111+
}],
112+
},
113+
}, {
114+
files: ["./src/typeDefs/**/*.ts"],
115+
processor: "@graphql-eslint/graphql",
116+
}, {
117+
files: ["./src/typeDefs/**/*.graphql"],
118+
119+
plugins: {
120+
"@graphql-eslint": graphqlEslint,
121+
},
122+
123+
languageOptions: {
124+
parser: parser,
125+
},
126+
}, {
127+
files: ["tests/**/*"],
128+
129+
rules: {
130+
"no-restricted-imports": "off",
131+
},
132+
}, {
133+
files: ["./src/index.ts", "./src/utilities/copyToClipboard.ts"],
134+
135+
rules: {
136+
"@typescript-eslint/explicit-function-return-type": "off",
137+
"@typescript-eslint/no-empty-function": "off",
138+
},
139+
}];

0 commit comments

Comments
 (0)