Skip to content

Commit

Permalink
incorporate new eslint rules to forbid namespace imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kubabutkiewicz committed Jan 13, 2025
1 parent 7b7876e commit 6f446da
Show file tree
Hide file tree
Showing 10 changed files with 542 additions and 417 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ module.exports = {
rules: {
'deprecation/deprecation': 'error',
'rulesdir/no-default-id-values': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^@libs/]',
message: 'Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"',
},
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^@userActions/]',
message: 'Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"',
},
],
},
overrides: [
{
Expand All @@ -24,5 +35,21 @@ module.exports = {
'rulesdir/no-default-id-values': 'off',
},
},
{
files: ['**/libs/**/*.{ts,tsx}'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^\\.\\./]',
message: 'Namespace imports are not allowed. Use named imports instead. Example: import { method } from "../libs/module"',
},
{
selector: 'ImportNamespaceSpecifier[parent.source.value=/^\\./]',
message: 'Namespace imports are not allowed. Use named imports instead. Example: import { method } from "./libs/module"',
},
],
},
},
],
};
179 changes: 111 additions & 68 deletions src/components/ReportActionItem/ReportPreview.tsx

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject';
import {hasSynchronizationErrorMessage} from './actions/connections';
import {getCurrentUserAccountID} from './actions/Report';
import {getCategoryApproverRule} from './CategoryUtils';
import * as Localize from './Localize';
import {translateLocal} from './Localize';
import Navigation from './Navigation/Navigation';
import * as NetworkStore from './Network/NetworkStore';
import {isOffline as isOfflineNetworkStore} from './Network/NetworkStore';
import {getAccountIDsByLogins, getLoginsByAccountIDs, getPersonalDetailByEmail} from './PersonalDetailsUtils';
import {getAllSortedTransactions, getCategory, getTag} from './TransactionUtils';

Expand Down Expand Up @@ -668,7 +668,7 @@ function getPolicy(policyID: string | undefined, policies: OnyxCollection<Policy
/** Return active policies where current user is an admin */
function getActiveAdminWorkspaces(policies: OnyxCollection<Policy> | null, currentUserLogin: string | undefined): Policy[] {
const activePolicies = getActivePolicies(policies, currentUserLogin);
return activePolicies.filter((policy) => shouldShowPolicy(policy, NetworkStore.isOffline(), currentUserLogin) && isPolicyAdmin(policy, currentUserLogin));
return activePolicies.filter((policy) => shouldShowPolicy(policy, isOfflineNetworkStore(), currentUserLogin) && isPolicyAdmin(policy, currentUserLogin));
}

/** Whether the user can send invoice from the workspace */
Expand Down Expand Up @@ -888,7 +888,7 @@ function getNetSuiteApprovalAccountOptions(policy: Policy | undefined, selectedB
const payableAccounts = policy?.connections?.netsuite.options.data.payableList;
const defaultApprovalAccount: NetSuiteAccount = {
id: CONST.NETSUITE_APPROVAL_ACCOUNT_DEFAULT,
name: Localize.translateLocal('workspace.netsuite.advancedConfig.defaultApprovalAccount'),
name: translateLocal('workspace.netsuite.advancedConfig.defaultApprovalAccount'),
type: CONST.NETSUITE_ACCOUNT_TYPE.ACCOUNTS_PAYABLE,
};
const accountOptions = getFilteredApprovalAccountOptions([defaultApprovalAccount].concat(payableAccounts ?? []));
Expand Down Expand Up @@ -1161,11 +1161,11 @@ function getActivePolicy(): OnyxEntry<Policy> {
function getUserFriendlyWorkspaceType(workspaceType: ValueOf<typeof CONST.POLICY.TYPE>) {
switch (workspaceType) {
case CONST.POLICY.TYPE.CORPORATE:
return Localize.translateLocal('workspace.type.control');
return translateLocal('workspace.type.control');
case CONST.POLICY.TYPE.TEAM:
return Localize.translateLocal('workspace.type.collect');
return translateLocal('workspace.type.collect');
default:
return Localize.translateLocal('workspace.type.free');
return translateLocal('workspace.type.free');
}
}

Expand Down
Loading

0 comments on commit 6f446da

Please sign in to comment.