-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: linting issues and rule changes #5681
Changes from all commits
ef43411
5d14f3c
d4130d8
59b2fdb
fec36cc
45a2dc9
01ffa83
a71e182
7d3689f
e1bca90
8462fb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,8 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["custom"], | ||
extends: ["@plane/eslint-config/next.js"], | ||
parser: "@typescript-eslint/parser", | ||
settings: { | ||
"import/resolver": { | ||
typescript: {}, | ||
node: { | ||
moduleDirectory: ["node_modules", "."], | ||
}, | ||
}, | ||
parserOptions: { | ||
project: true, | ||
}, | ||
rules: { | ||
"import/order": [ | ||
"error", | ||
{ | ||
groups: ["builtin", "external", "internal", "parent", "sibling",], | ||
pathGroups: [ | ||
{ | ||
pattern: "react", | ||
group: "external", | ||
position: "before", | ||
}, | ||
{ | ||
pattern: "lucide-react", | ||
group: "external", | ||
position: "after", | ||
}, | ||
{ | ||
pattern: "@headlessui/**", | ||
group: "external", | ||
position: "after", | ||
}, | ||
{ | ||
pattern: "@plane/**", | ||
group: "external", | ||
position: "after", | ||
}, | ||
{ | ||
pattern: "@/**", | ||
group: "internal", | ||
} | ||
], | ||
pathGroupsExcludedImportTypes: ["builtin", "internal", "react"], | ||
alphabetize: { | ||
order: "asc", | ||
caseInsensitive: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
{ | ||
"extends": "tsconfig/nextjs.json", | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"], | ||
"extends": "@plane/typescript-config/nextjs.json", | ||
"compilerOptions": { | ||
"plugins": [{ "name": "next" }], | ||
"baseUrl": ".", | ||
"jsx": "preserve", | ||
"esModuleInterop": true, | ||
"paths": { | ||
"@/*": ["core/*"], | ||
"@/helpers/*": ["helpers/*"], | ||
"@/public/*": ["public/*"], | ||
"@/plane-admin/*": ["ce/*"] | ||
}, | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"include": ["next-env.d.ts", "next.config.js", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.turbo/* | ||
out/* | ||
dist/* | ||
public/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"root": true, | ||
"extends": ["@plane/eslint-config/server.js"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ | |
"type": "module", | ||
"scripts": { | ||
"build": "babel src --out-dir dist --extensions \".ts,.js\"", | ||
"start": "node dist/server.js" | ||
"start": "node dist/server.js", | ||
"lint": "eslint . --ext .ts,.tsx", | ||
"lint:errors": "eslint . --ext .ts,.tsx --quiet" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
|
@@ -55,6 +57,6 @@ | |
"nodemon": "^3.1.0", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^7.2.0", | ||
"typescript": "5.4.5" | ||
"typescript": "5.3.3" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Potential Compatibility Issue with TypeScript Downgrade The TypeScript version has been downgraded to 5.3.3, but the
Analysis chainPlease clarify the reason for downgrading TypeScript The TypeScript version has been downgraded from 5.4.5 to 5.3.3. While there may be valid reasons for this change, it's important to ensure that it doesn't introduce compatibility issues or lose access to needed language features. Could you please provide the rationale for this downgrade? Also, let's verify if this change affects any other parts of the project: Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for TypeScript version references and potential incompatibilities
# Test: Search for TypeScript version references
echo "Searching for TypeScript version references:"
rg --type json '"typescript":\s*"[^"]*"' -g '!package.json'
# Test: Check for usage of TypeScript 5.4 features
echo "Checking for usage of TypeScript 5.4 features:"
rg --type typescript 'const\s+enum|satisfies\s+' -g '*.ts'
# Test: Check if there are any TypeScript errors after downgrade
echo "Checking for TypeScript errors after downgrade:"
npx tsc --noEmit
Length of output: 555 Script: #!/bin/bash
# Description: Re-run TypeScript version checks with corrected commands
# Test: Search for TypeScript version references excluding package.json
echo "Searching for TypeScript version references:"
rg '"typescript":\s*"[^"]*"' -g '*.json' --ignore-file package.json
# Test: Check for usage of TypeScript 5.4 features by targeting .ts files
echo "Checking for usage of TypeScript 5.4 features:"
rg 'const\s+enum|satisfies\s+' -g '*.ts'
# Note: Skipping TypeScript compilation check as 'npx' is unavailable
echo "Skipping TypeScript compilation check due to environment limitations."
Length of output: 1565 |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export type TAdditionalDocumentTypes = {} | ||
export type TAdditionalDocumentTypes = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,15 +45,16 @@ export const getExtensions: () => Promise<Extension[]> = async () => { | |
const documentType = params.get("documentType")?.toString() as | ||
| TDocumentTypes | ||
| undefined; | ||
|
||
// TODO: Fix this lint error. | ||
// eslint-disable-next-line no-async-promise-executor | ||
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactor to address the linting issue properly The added TODO comment and eslint-disable directive indicate a known linting issue with the use of an async executor in a Promise constructor. While the eslint-disable comment temporarily suppresses the error, it's better to refactor the code to address the underlying issue. Consider refactoring the code to avoid using an async executor in the Promise constructor. Here's a suggested approach: return Promise.resolve().then(async () => {
try {
let fetchedData = null;
if (documentType === "project_page") {
fetchedData = await fetchPageDescriptionBinary(
params,
pageId,
cookie
);
} else {
fetchedData = await fetchDocument({
cookie,
documentType,
pageId,
params,
});
}
return fetchedData;
} catch (error) {
manualLogger.error("Error in fetching document", error);
throw error; // Re-throw the error to be consistent with Promise rejection
}
}); This refactoring wraps the async logic in a |
||
return new Promise(async (resolve) => { | ||
try { | ||
let fetchedData = null; | ||
if (documentType === "project_page") { | ||
fetchedData = await fetchPageDescriptionBinary( | ||
params, | ||
pageId, | ||
cookie, | ||
cookie | ||
); | ||
} else { | ||
fetchedData = await fetchDocument({ | ||
|
@@ -83,6 +84,8 @@ export const getExtensions: () => Promise<Extension[]> = async () => { | |
| TDocumentTypes | ||
| undefined; | ||
|
||
// TODO: Fix this lint error. | ||
// eslint-disable-next-line no-async-promise-executor | ||
Comment on lines
+87
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Refactor multiple async Promise executors and review similar patterns Two instances of async Promise executors were found in
Both instances use async functions within Promise constructors, which violates the Analysis chainRefactor to address the linting issue and review similar patterns Similar to the previous instance, this code segment uses an async executor in a Promise constructor, which is flagged by the linter. The added TODO comment and eslint-disable directive are temporary solutions that should be replaced with a proper refactor.
return Promise.resolve().then(async () => {
try {
if (documentType === "project_page") {
await updatePageDescription(params, pageId, state, cookie);
} else {
await updateDocument({
cookie,
documentType,
pageId,
params,
updatedDescription: state,
});
}
} catch (error) {
manualLogger.error("Error in updating document:", error);
throw error; // Re-throw the error to be consistent with Promise rejection
}
});
To help identify other instances of this pattern in the codebase, you can run the following command: This will help locate other occurrences of this pattern that may need refactoring. Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for async Promise executors in TypeScript files
rg --type typescript 'new Promise\(async' -C 3
Length of output: 83 Script: #!/bin/bash
# Search for async Promise executors in TypeScript files
rg --type ts 'new Promise\(async' -C 3
Length of output: 1076 |
||
return new Promise(async () => { | ||
try { | ||
if (documentType === "project_page") { | ||
|
@@ -121,7 +124,7 @@ export const getExtensions: () => Promise<Extension[]> = async () => { | |
} | ||
manualLogger.warn( | ||
`Redis Client wasn't able to connect, continuing without Redis (you won't be able to sync data between multiple plane live servers)`, | ||
error, | ||
error | ||
); | ||
reject(error); | ||
}); | ||
|
@@ -135,12 +138,12 @@ export const getExtensions: () => Promise<Extension[]> = async () => { | |
} catch (error) { | ||
manualLogger.warn( | ||
`Redis Client wasn't able to connect, continuing without Redis (you won't be able to sync data between multiple plane live servers)`, | ||
error, | ||
error | ||
); | ||
} | ||
} else { | ||
manualLogger.warn( | ||
"Redis URL is not set, continuing without Redis (you won't be able to sync data between multiple plane live servers)", | ||
"Redis URL is not set, continuing without Redis (you won't be able to sync data between multiple plane live servers)" | ||
); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { ErrorRequestHandler } from "express"; | ||
import { manualLogger } from "@/core/helpers/logger.js"; | ||
|
||
export const errorHandler: ErrorRequestHandler = (err, _req, res, _next) => { | ||
export const errorHandler: ErrorRequestHandler = (err, _req, res) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caution: Removing The removal of the Consider keeping the export const errorHandler: ErrorRequestHandler = (err, _req, res, _next) => {
// ... existing code ...
}; This ensures compatibility with Express's error handling middleware expectations. |
||
// Log the error | ||
manualLogger.error(err); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enhance error logging with additional context While the current implementation logs the error, it could be improved by including more context. Consider enhancing the error logging: manualLogger.error('An error occurred', {
error: err,
stack: err.stack,
url: _req.url,
method: _req.method
}); This provides more information for debugging purposes. |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,26 @@ | ||
{ | ||
"extends": "tsconfig/base.json", | ||
"extends": "@plane/typescript-config/base.json", | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
|
||
"lib": [ | ||
"ES2015" | ||
], | ||
|
||
"lib": ["ES2015"], | ||
"outDir": "./dist", | ||
"rootDir": "./src", | ||
"rootDir": ".", | ||
"baseUrl": ".", | ||
|
||
"paths": { | ||
"@/*": [ | ||
"./src/*" | ||
], | ||
"@/plane-live/*": [ | ||
"./src/ce/*" | ||
] | ||
"@/*": ["./src/*"], | ||
"@/plane-live/*": ["./src/ce/*"] | ||
}, | ||
|
||
"removeComments": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"sourceMap": true, | ||
"inlineSources": true, | ||
|
||
// Set `sourceRoot` to "/" to strip the build path prefix | ||
// from generated source code references. | ||
// This improves issue grouping in Sentry. | ||
"sourceRoot": "/" | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"exclude": [ | ||
"./dist", | ||
"./build", | ||
"./node_modules" | ||
] | ||
"include": ["src/**/*.ts", "tsup.config.ts"], | ||
"exclude": ["./dist", "./build", "./node_modules"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider specifying the tsconfig.json path
Setting
"project": true
in parserOptions is correct and allows the parser to use TypeScript's project configuration. This is necessary for TypeScript-specific rules that require type information.However, for larger projects, this can significantly slow down linting. For better performance, consider explicitly specifying the path to your tsconfig.json file.
You could optimize this by changing the configuration to:
Replace "./tsconfig.json" with the actual path to your TypeScript configuration file if it's located elsewhere.