Sfoglia il codice sorgente

Merge pull request #10203 from weseek/fix/169757-normalize-ci

fix(EnhancedAccessToken): Normalize CI
Yuki Takei 8 mesi fa
parent
commit
f4896ec073

+ 5 - 0
apps/app/src/server/middlewares/access-token-parser/index.ts

@@ -1,10 +1,14 @@
 import type { Scope } from '@growi/core/dist/interfaces';
 import type { NextFunction, Response } from 'express';
 
+import loggerFactory from '~/utils/logger';
+
 import { parserForAccessToken } from './access-token';
 import { parserForApiToken } from './api-token';
 import type { AccessTokenParserReq } from './interfaces';
 
+const logger = loggerFactory('growi:middleware:access-token-parser');
+
 export type AccessTokenParser = (scopes?: Scope[], opts?: {acceptLegacy: boolean})
   => (req: AccessTokenParserReq, res: Response, next: NextFunction) => Promise<void>
 
@@ -12,6 +16,7 @@ export const accessTokenParser: AccessTokenParser = (scopes, opts) => {
   return async(req, res, next): Promise<void> => {
     // TODO: comply HTTP header of RFC6750 / Authorization: Bearer
     if (scopes == null || scopes.length === 0) {
+      logger.warn('scopes is empty');
       return next();
     }
 

+ 1 - 1
apps/app/src/server/service/import/construct-convert-map.integ.ts

@@ -30,6 +30,6 @@ describe('constructConvertMap', () => {
 
     // assert
     expect(result).not.toBeNull();
-    expect(Object.keys(result).length).toEqual(32);
+    expect(Object.keys(result).length).toEqual(33);
   });
 });

+ 1 - 1
packages/core/src/interfaces/index.ts

@@ -13,8 +13,8 @@ export * from './locale';
 export * from './page';
 export * from './primitive/string';
 export * from './revision';
+export * from './scope';
 export * from './subscription';
 export * from './tag';
 export * from './user';
 export * from './vite';
-export * from './scope';

+ 2 - 3
packages/core/src/interfaces/scope.ts

@@ -108,11 +108,10 @@ const buildScopeConstants = (): ScopeConstantType => {
   const result = {} as Partial<ScopeConstantType>;
 
   const processObject = (
-    // biome-ignore lint/suspicious/noExplicitAny: <explanation>
+    // biome-ignore lint/suspicious/noExplicitAny: ignore
     obj: Record<string, any>,
-    // biome-ignore lint/style/useDefaultParameterLast: <explanation>
     path: string[] = [],
-    // biome-ignore lint/suspicious/noExplicitAny: <explanation>
+    // biome-ignore lint/suspicious/noExplicitAny: ignore
     resultObj: Record<string, any>,
   ) => {
     for (const [key, value] of Object.entries(obj)) {

+ 1 - 1
packages/core/src/models/devided-page-path.ts

@@ -43,7 +43,7 @@ export class DevidedPagePath {
       // for non-chrome browsers
       // biome-ignore lint/complexity/useRegexLiterals: ignore
       PATTERN_DEFAULT = new RegExp('^((.*)(?<!<)\\/)?(.+)$'); // https://regex101.com/r/HJNvMW/1
-    } catch (err) {
+    } catch {
       // lookbehind regex is not supported on non-chrome browsers
     }
 

+ 2 - 1
packages/core/src/models/serializers/user-serializer.ts

@@ -14,8 +14,9 @@ export const omitInsecureAttributes = <U extends IUser>(
   const leanDoc = user instanceof Document ? user.toObject<U>() : user;
 
   const {
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
+    // biome-ignore lint/correctness/noUnusedVariables: ignore
     password,
+    // biome-ignore lint/correctness/noUnusedVariables: ignore
     apiToken,
     email,
     ...rest

+ 1 - 3
packages/core/src/utils/page-path-utils/index.ts

@@ -1,7 +1,5 @@
 import escapeStringRegexp from 'escape-string-regexp';
 
-import type { IUser } from '~/interfaces';
-
 import { isValidObjectId } from '../objectid-utils';
 import { addTrailingSlash } from '../path-utils';
 
@@ -184,7 +182,7 @@ export const generateEditorPath = (...paths: string[]): string => {
   try {
     const url = new URL(joinedPath, 'https://dummy');
     return `${url.pathname}#edit`;
-  } catch (err) {
+  } catch {
     throw new Error('Invalid path format');
   }
 };

+ 5 - 5
packages/remark-lsx/src/client/components/Lsx.tsx

@@ -57,7 +57,7 @@ const LsxSubstance = React.memo(
 
     const ErrorMessage = useCallback((): JSX.Element => {
       if (!hasError) {
-        return <></>;
+        return;
       }
 
       return (
@@ -73,10 +73,10 @@ const LsxSubstance = React.memo(
 
     const Loading = useCallback((): JSX.Element => {
       if (hasError) {
-        return <></>;
+        return;
       }
       if (!isLoading) {
-        return <></>;
+        return;
       }
 
       return (
@@ -116,14 +116,14 @@ const LsxSubstance = React.memo(
       const lastResult = data?.at(-1);
 
       if (lastResult == null) {
-        return <></>;
+        return;
       }
 
       const { cursor, total } = lastResult;
       const leftItemsNum = total - cursor;
 
       if (leftItemsNum === 0) {
-        return <></>;
+        return;
       }
 
       return (

+ 1 - 1
packages/remark-lsx/src/client/components/LsxPageList/LsxPage.tsx

@@ -102,7 +102,7 @@ export const LsxPage = React.memo((props: Props): JSX.Element => {
 
   const pageListMetaElement: JSX.Element = useMemo(() => {
     if (pageNode.page == null) {
-      return <></>;
+      return;
     }
 
     const { page } = pageNode;

+ 1 - 0
packages/remark-lsx/src/client/utils/page-node.spec.ts

@@ -8,6 +8,7 @@ import { generatePageNodeTree } from './page-node';
 
 function omitPageData(pageNode: PageNode): Omit<PageNode, 'page'> {
   // Destructure to omit 'page', and recursively process children
+  // biome-ignore lint/correctness/noUnusedVariables: ignore
   const { page, children, ...rest } = pageNode;
   return {
     ...rest,

+ 2 - 4
packages/remark-lsx/src/server/index.ts

@@ -1,10 +1,8 @@
+import { SCOPE } from '@growi/core/dist/interfaces';
 import type { NextFunction, Request, Response } from 'express';
 import { query, validationResult } from 'express-validator';
 import { FilterXSS } from 'xss';
-
 import type { LsxApiOptions } from '../interfaces/api';
-
-import { SCOPE } from '@growi/core/dist/interfaces';
 import { listPages } from './routes/list-pages';
 
 const loginRequiredFallback = (req: Request, res: Response) => {
@@ -28,7 +26,7 @@ const lsxValidator = [
         }
 
         return jsonData;
-      } catch (err) {
+      } catch {
         throw new Error('Invalid JSON format in options');
       }
     }),