Просмотр исходного кода

fix: replace strict null checks with loose equality for consistency

Yuki Takei 1 год назад
Родитель
Сommit
168748b569

+ 1 - 1
apps/app/src/components/ShareLinkPageView/ShareLinkAlert.tsx

@@ -42,7 +42,7 @@ const ShareLinkAlert: FC<Props> = (props: Props) => {
   return (
     <p className={`alert alert-${alertColor} px-4 d-edit-none`}>
       <span className="material-symbols-outlined me-1">link</span>
-      {(expiredAt === null ? <span>{t('page_page.notice.no_deadline')}</span>
+      {(expiredAt == null ? <span>{t('page_page.notice.no_deadline')}</span>
       // eslint-disable-next-line react/no-danger
         : <span dangerouslySetInnerHTML={{ __html: t('page_page.notice.expiration', { expiredAt }) }} />
       )}

+ 1 - 1
apps/app/src/server/routes/apiv3/security-settings/index.js

@@ -942,7 +942,7 @@ module.exports = (crowi) => {
     for (const configKey of crowi.passportService.mandatoryConfigKeysForSaml) {
       const key = configKey.replace('security:passport-saml:', '');
       const formValue = req.body[key];
-      if (configManager.getConfig(configKey, ConfigSource.env) === null && formValue == null) {
+      if (configManager.getConfig(configKey, ConfigSource.env) == null && formValue == null) {
         const formItemName = t(`security_settings.form_item_name.${key}`);
         invalidValues.push(t('input_validation.message.required', { param: formItemName }));
       }

+ 2 - 2
apps/app/src/server/routes/apiv3/users.js

@@ -1127,10 +1127,10 @@ module.exports = (crowi) => {
    *              $ref: '#/components/responses/500'
    */
   router.get('/list', accessTokenParser, loginRequired, async(req, res) => {
-    const userIds = req.query.userIds || null;
+    const userIds = req.query.userIds ?? null;
 
     let userFetcher;
-    if (userIds !== null && userIds.split(',').length > 0) {
+    if (userIds != null && userIds.split(',').length > 0) {
       userFetcher = User.findUsersByIds(userIds.split(','));
     }
     else {

+ 2 - 2
apps/app/src/server/service/page/index.ts

@@ -299,8 +299,8 @@ class PageService implements IPageService {
     if (username == null) {
       throw new Error('Cannot found username by path');
     }
-    const ownerExists = await User.exists({ username });
-    return ownerExists === null;
+    const ownerExists = await User.exists({ username }).exec();
+    return ownerExists == null;
   }
 
   private canDeleteLogic(

+ 1 - 1
apps/app/src/server/service/passport.ts

@@ -799,7 +799,7 @@ class PassportService implements S2sMessageHandlable {
   getSamlMissingMandatoryConfigKeys() {
     const missingRequireds: string[] = [];
     for (const key of this.mandatoryConfigKeysForSaml) {
-      if (this.crowi.configManager.getConfig('crowi', key) === null) {
+      if (this.crowi.configManager.getConfig('crowi', key) == null) {
         missingRequireds.push(key);
       }
     }