Skip to content
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

Test PR to check if workflows break. #3159

Open
wants to merge 42 commits into
base: develop-postgres
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bae223d
performing the migration
Suyash878 Dec 14, 2024
cf2bf9f
performing the migration
Suyash878 Dec 14, 2024
b29d1a4
Merge branch 'issue#2645' of https://github.com/Suyash878/talawa-admi…
Suyash878 Dec 14, 2024
d56b259
Update eslint.config.mjs
Suyash878 Dec 14, 2024
6c52fc6
adding globals package
Suyash878 Dec 14, 2024
cf1714d
Merge branch 'issue#2645' of https://github.com/Suyash878/talawa-admi…
Suyash878 Dec 14, 2024
d089b64
fixing linting errors
Suyash878 Dec 14, 2024
b12b94f
Apply suggestions from code review
Suyash878 Dec 17, 2024
6adc55d
Merge branch 'develop-postgres' into issue#2645
Suyash878 Dec 17, 2024
5e9c6da
Merge branch 'develop-postgres' into issue#2645
Suyash878 Dec 21, 2024
a4d770e
Excluding L15-L17 from codeCov
Suyash878 Dec 21, 2024
1e1bec7
Merge branch 'develop-postgres' into issue#2645
palisadoes Dec 24, 2024
f1f943c
refactoring the config file and updating package-lock.json
Suyash878 Dec 29, 2024
8021ea1
re-making eslintrc.json and eslintignore to resolve conflicts
Suyash878 Dec 29, 2024
0641541
Merge branch 'develop-postgres' into issue#2645
Suyash878 Dec 29, 2024
7b54c25
adding @eslint/compat
Suyash878 Dec 29, 2024
d714f34
updating eslint.config.mjs
Suyash878 Dec 29, 2024
f4f5af0
upgrading eslint version to satisfy the peer deps for @eslint/compat
Suyash878 Dec 29, 2024
2035b91
updating globals package to resolve an error
Suyash878 Dec 29, 2024
8dca9cf
Merge branch 'develop-postgres' into issue#2645
palisadoes Dec 29, 2024
1189e20
Merge branch 'develop-postgres' into issue#2645
Suyash878 Dec 30, 2024
e6363f4
Adding test for eslint.config.mjs
Suyash878 Dec 30, 2024
1a6710e
fixing lint
Suyash878 Dec 30, 2024
18f8d81
linting fix
Suyash878 Dec 30, 2024
379f67b
fixing lint finally
Suyash878 Dec 30, 2024
b7281f4
fixing failing test
Suyash878 Dec 30, 2024
80067b5
removing eslintrc.json and eslintignore and adding test for eslint.co…
Suyash878 Dec 30, 2024
cb39776
Merge branch 'develop-postgres' into issue#2645
Suyash878 Dec 30, 2024
e93fbaa
refactoring eslint.config.js
Suyash878 Jan 3, 2025
4cc1e02
Merge branch 'issue#2645' of https://github.com/Suyash878/talawa-admi…
Suyash878 Jan 3, 2025
af0adba
Adding eslint.config.js to ignores property
Suyash878 Jan 5, 2025
75b3cd3
Adding suggestions from coderabbit
Suyash878 Jan 5, 2025
5b47969
removing the test
Suyash878 Jan 5, 2025
bb8508e
test commit
Suyash878 Jan 5, 2025
d360e81
commit
Suyash878 Jan 5, 2025
869dad5
test
Suyash878 Jan 5, 2025
8bf66f3
lint fix
Suyash878 Jan 5, 2025
4ea04e5
reverting package-lock.json and package.json
Suyash878 Jan 5, 2025
a32116b
resolving conflicts with package.json
Suyash878 Jan 5, 2025
8100361
adding eslint/compat
Suyash878 Jan 5, 2025
43ae646
commit
Suyash878 Jan 5, 2025
9acec1e
resolving package-lock.json and package.json
Suyash878 Jan 5, 2025
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
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

157 changes: 0 additions & 157 deletions .eslintrc.json

This file was deleted.

215 changes: 215 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import react from 'eslint-plugin-react';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import jest from 'eslint-plugin-jest';
import _import from 'eslint-plugin-import';
import tsdoc from 'eslint-plugin-tsdoc';
import prettier from 'eslint-plugin-prettier';
import { fixupPluginRules } from '@eslint/compat';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

export function createESLintCompat() {
const _filename = fileURLToPath(import.meta.url);
const _dirname = path.dirname(_filename);

return new FlatCompat({
baseDirectory: _dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
}
Comment on lines +15 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

The createESLintCompat() function is defined but not used, and there's an undefined compat variable being used

Looking at the complete file content, I found:

  1. The createESLintCompat() function is exported but never used within the file
  2. There's an undefined compat variable being used in the configuration (in ...compat.extends())

It appears that the intention was to use the createESLintCompat() function to create the compat instance, but this step was missed. The code should be fixed by adding:

const compat = createESLintCompat();

before using compat.extends().

🔗 Analysis chain

Check if createESLintCompat() is invoked or referenced.

The createESLintCompat() function is exported but never called within this file. If you intend to use its returned FlatCompat instance, ensure you do something like:

const compat = createESLintCompat();

Otherwise, remove the unused function.


Let me search for references to createESLintCompat in the codebase.


Let me check the actual usage of createESLintCompat in the file to see if it's being used beyond just its definition.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for references to createESLintCompat
rg "createESLintCompat" -l

Length of output: 44


Script:

#!/bin/bash
# Show the complete content of eslint.config.mjs to see if createESLintCompat is used
cat eslint.config.mjs

Length of output: 5425


const compat = createESLintCompat();

export default [
{
ignores: [
'**/*.css',
'**/*.scss',
'**/*.less',
'**/*.json',
'**/*.svg',
'docs/docusaurus.config.ts',
'docs/sidebars.ts',
'docs/src/**/*',
'docs/blog/**/*',
'src/components/CheckIn/tagTemplate.ts',
'**/package.json',
'**/package-lock.json',
'**/tsconfig.json',
'docs/**/*',
],
},
...compat.extends(
'plugin:react/recommended',
'eslint:recommended',
'plugin:jest/recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
'eslint-config-prettier',
'prettier',
),
Comment on lines +47 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Undefined variable compat.

The spread syntax ...compat.extends calls a compat variable that is not declared in this scope. Possibly you meant to instantiate compat from the createESLintCompat() function. Otherwise, this will raise a ReferenceError.

+const compat = createESLintCompat(); // Example usage
 export default [
   ...compat.extends(
     ...
   ),
   ...
 ];

Committable suggestion skipped: line range outside the PR's diff.

{
plugins: {
react,
'@typescript-eslint': typescriptEslint,
jest,
import: fixupPluginRules(_import),
tsdoc,
prettier,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},

parser: tsParser,
ecmaVersion: 2018,
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

settings: {
react: {
version: 'detect',
},
},

rules: {
'react/destructuring-assignment': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',

'react/no-multi-comp': [
'error',
{
ignoreStateless: false,
},
],

'react/jsx-filename-extension': [
'error',
{
extensions: ['.tsx'],
},
],

'import/no-duplicates': 'error',
'tsdoc/syntax': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/no-unsafe-function-type': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-imports': 'error',

Comment on lines +91 to +125
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Consider relaxing TypeScript rules based on codebase analysis

Based on the codebase analysis:

  1. The no-explicit-any rule should be relaxed to warn as there are several legitimate uses of any in utility functions and state management:

    • Helper functions in useLocalstorage.ts
    • Redux action creators and reducers
    • Plugin management utilities
  2. The no-non-null-assertion rule can remain as error since most ! occurrences in the codebase are in:

    • CSS files (for !important)
    • Logical negations in conditionals
    • No actual non-null assertions found
  3. The consistent-type-imports rule can remain as error since no type-only imports were found, suggesting the codebase already follows a consistent import style.

🔗 Analysis chain

Review strict TypeScript rules for potential impact.

The configuration enables several strict TypeScript rules that might impact development velocity:

  • no-explicit-any
  • no-non-null-assertion
  • consistent-type-imports

While these rules promote type safety, consider if they align with your team's development practices and whether some could be relaxed to warn instead of error.

Run this script to check current usage patterns that might be affected:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for patterns that would violate these strict rules
echo "Checking for 'any' type usage..."
rg ":\s*any\b" --type typescript

echo "Checking for non-null assertions..."
rg "!\b" --type typescript

echo "Checking for type import consistency..."
rg "import.*\{.*\}\s+from" --type typescript

Length of output: 466


Script:

#!/bin/bash
# Check for patterns that would violate these strict rules
echo "Checking for 'any' type usage..."
rg ":\s*any\b" -t ts -t tsx

echo "Checking for non-null assertions..."
rg "!\b" -t ts -t tsx

echo "Checking for type import consistency..."
rg "import.*\{.*\}\s+from" -t ts -t tsx

# Also check for .ts and .tsx files to confirm TypeScript usage
echo "Checking TypeScript files in the project..."
fd "\.(ts|tsx)$"

Length of output: 27995


Script:

#!/bin/bash
# Search for patterns without file type filtering since ripgrep's typescript detection isn't working
echo "Checking for 'any' type usage..."
rg ":\s*any\b"

echo "Checking for non-null assertions..."
rg "!\b"

echo "Checking for type import consistency..."
rg "^import\s+type\s*\{.*\}\s+from|^import\s*\{\s*type\s"

Length of output: 92867

'@typescript-eslint/explicit-function-return-type': [
2,
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
},
],

camelcase: 'off',

'@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', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: 'variable',
modifiers: ['exported'],
format: null,
},
],
Comment on lines +136 to +177
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Revise naming conventions to align with common practices.

Two concerns with the current naming conventions:

  1. Requiring Interface/TestInterface prefix for interfaces goes against TypeScript best practices
  2. Having no format for exported variables (format: null) could lead to inconsistent naming
       {
         selector: 'interface',
         format: ['PascalCase'],
-        prefix: ['Interface', 'TestInterface'],
       },
       {
         selector: 'variable',
         modifiers: ['exported'],
-        format: null,
+        format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
       },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'@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', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: 'variable',
modifiers: ['exported'],
format: null,
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
},
{
selector: ['typeAlias', 'typeLike', 'enum'],
format: ['PascalCase'],
},
{
selector: 'typeParameter',
format: ['PascalCase'],
prefix: ['T'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: 'variable',
modifiers: ['exported'],
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
],


'react/jsx-pascal-case': [
'error',
{
allowAllCaps: false,
allowNamespace: false,
},
],

'react/jsx-equals-spacing': ['warn', 'never'],
'react/no-this-in-sfc': 'error',
'jest/expect-expect': 0,

'react/no-unstable-nested-components': [
'error',
{
allowAsProps: true,
},
],

'react/function-component-definition': [
0,
{
namedComponents: 'function-declaration',
},
],

'prettier/prettier': 'error',
},
},
{
files: ['eslint.config.mjs'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
];
Loading
Loading