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 4 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
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ If you are new to contributing to open source, please read the Open Source Guide
<!-- toc -->

- [Code of Conduct](#code-of-conduct)
- [Videos](#videos)
- [Ways to Contribute](#ways-to-contribute)
- [Our Development Process](#our-development-process)
- [Issues](#issues)
Expand All @@ -34,6 +35,7 @@ If you are new to contributing to open source, please read the Open Source Guide
- [Community](#community)

<!-- tocstop -->

## Code of Conduct

A safe environment is required for everyone to contribute. Read our [Code of Conduct Guide](CODE_OF_CONDUCT.md) to understand what this means. Let us know immediately if you have unacceptable experiences in this area.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Core features include:

- [Talawa Components](#talawa-components)
- [Documentation](#documentation)
- [Videos](#videos)
- [Videos](#videos)

<!-- tocstop -->

Expand Down
140 changes: 140 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
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,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

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: {
globals: {
...globals.node,
},

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",
},
}];
Loading