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

[Bug] Triage existing linting issues #1060

Merged
merged 9 commits into from
Dec 12, 2024
9 changes: 8 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"plugin:prettier/recommended"
],
"rules": {
"no-console": [
"error",
{
"allow": ["warn", "error"]
}
],
"react/jsx-props-no-spreading": "off",
"no-dupe-else-if": "error",
"no-promise-executor-return": "error",
Expand Down Expand Up @@ -111,6 +117,7 @@
"react/no-unused-state": "off",
"react/prefer-stateless-function": "off",
"react/require-render-return": "off",
"react/require-default-props": "off",
"react/sort-comp": "off",
"react/state-in-constructor": "off",
"react/static-property-placement": "off",
Expand Down Expand Up @@ -150,7 +157,7 @@
],
"react/jsx-no-constructed-context-values": "error",
"react/jsx-no-script-url": "error",
"react/jsx-no-useless-fragment": "error",
"react/jsx-no-useless-fragment": "off",

"unicorn/filename-case": [
"error",
Expand Down
2 changes: 0 additions & 2 deletions e2e/utils/createDomainAssociation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export default async function createDomainAssociation({
try {
await axios.request(optionsForDomainAssociation);
} catch (error) {
// Part of evaluation for linter issues see: https://github.com/cfpb/sbl-frontend/issues/1039
// eslint-disable-next-line no-console
console.error(
'error when creating a domain/institution association :>>',
error,
Expand Down
3 changes: 1 addition & 2 deletions e2e/utils/createInstitution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export default async function createInstitution({
try {
await axios.request(options);
} catch (error) {
// eslint-disable-next-line no-console
console.log('error when creating institutions :>>', error);
console.error('error when creating institutions :>>', error);
throw error;
}
}
8 changes: 2 additions & 6 deletions e2e/utils/createKeycloakUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { config } from './authConstants';
export class KeycloakService {
private readonly kcAdminClient: KeycloakAdminClient;

// Part of evaluation for linter issues see: https://github.com/cfpb/sbl-frontend/issues/1039
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
constructor() {
public constructor() {
this.kcAdminClient = new KeycloakAdminClient({
baseUrl: config.target,
realmName: config.realm,
Expand Down Expand Up @@ -46,7 +44,6 @@ export default async function createKeycloakUser({
grantType: config.cli.grantType,
});
} catch (error) {
// eslint-disable-next-line no-console
console.error(
'error when attempting to auth into keycloak admin :>>',
error,
Expand All @@ -70,8 +67,7 @@ export default async function createKeycloakUser({
});
result = response?.id ?? '';
} catch (error) {
// eslint-disable-next-line no-console
console.log('error when trying to create a user in keycloak :>>', error);
console.error('error when trying to create a user in keycloak :>>', error);
throw error;
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion e2e/utils/deleteKeycloakUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default async function deleteKeycloakUser({

try {
await kcAdminClient.users.del({
id: id,
id,
});
} catch (error) {
// eslint-disable-next-line no-console
Expand Down
8 changes: 3 additions & 5 deletions e2e/utils/getKeycloakToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ export default async function getAdminKeycloakToken(): Promise<string> {
data: encodedParameters,
};
try {
// Part of evaluation for linter issues see: https://github.com/cfpb/sbl-frontend/issues/1039
// Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { data } = await axios.request(optionsForGetAdminKeycloakToken);
// Part of evaluation for linter issues see: https://github.com/cfpb/sbl-frontend/issues/1039
// Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return data.access_token as string;
} catch (error) {
// Part of evaluation for linter issues see: https://github.com/cfpb/sbl-frontend/issues/1039
// eslint-disable-next-line no-console
console.log(
console.error(
'error when trying to fetch an admin token from keycloak :>>',
error,
);
Expand Down
1 change: 0 additions & 1 deletion e2e/utils/verifyDownloadableReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export async function verifyDownloadableReport({
console.log(`Deleted the downloaded file: ${downloadFilePath}`);
}
} catch (error) {
// eslint-disable-next-line no-console
console.error(
`Failed to delete file: ${downloadFilePath}. Error: ${
(error as Error).message
Expand Down
48 changes: 10 additions & 38 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-misused-promises */
import { useQuery } from '@tanstack/react-query';
import { MarkdownText } from 'MarkdownTest';
import { fetchUserProfile } from 'api/requests';
Expand Down Expand Up @@ -65,7 +64,6 @@ const TypesFinancialInstitutions = lazy(
async () => import('pages/TypesFinancialInstitutions'),
);
const FilingCreate = lazy(
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
async () => import('pages/Filing/FilingApp/FilingCreate'),
);

Expand All @@ -75,7 +73,6 @@ if (import.meta.env.DEV) {
window.toggleRouting = toggleRouting;
window.setIsRoutingEnabled = setIsRoutingEnabled;
}
// eslint-disable-next-line no-console
if (!isRoutingEnabled) console.warn('Routing is disabled!');

/**
Expand Down Expand Up @@ -116,7 +113,7 @@ export function NavItem({
);
}

function BasicLayout(): Promise<void> | ReactElement {
function BasicLayout(): ReactElement {
const headerLinks = [...useHeaderAuthLinks()];
const location = useLocation();
const auth = useSblAuth();
Expand All @@ -140,7 +137,8 @@ function BasicLayout(): Promise<void> | ReactElement {
errorMessage.includes("Session doesn't have required client") &&
location.pathname !== '/'
) {
return auth.onLogout();
void auth.onLogout();
return <></>;
}
}

Expand Down Expand Up @@ -177,7 +175,7 @@ interface ProtectedRouteProperties {
isAuthenticated: boolean;
isLoading: boolean;
onLogin: () => Promise<void>;
UserProfile: UserProfileType;
UserProfile: UserProfileType | undefined;
children: JSX.Element;
}

Expand All @@ -188,7 +186,7 @@ function ProtectedRoute({
onLogin,
UserProfile,
children,
}: ProtectedRouteProperties): JSX.Element | null {
}: ProtectedRouteProperties): JSX.Element {
const { pathname } = useLocation();
const isProfileFormPath = pathname.includes('/profile/complete');

Expand All @@ -198,13 +196,13 @@ function ProtectedRoute({

if (!isInitialAuthorizationLoading && !isAuthenticated) {
void onLogin();
return null;
return <></>;
}

if (isAnyAuthorizationLoading) return <LoadingContent />;

const isUserAssociatedWithAnyInstitution =
UserProfile.institutions.length > 0;
(UserProfile?.institutions?.length ?? 0) > 0;
if (!isUserAssociatedWithAnyInstitution && !isProfileFormPath)
return <Navigate replace to='/profile/complete' />;
if (isProfileFormPath && isUserAssociatedWithAnyInstitution)
Expand Down Expand Up @@ -240,19 +238,12 @@ export default function App(): ReactElement {
<ScrollToTop />
<Suspense fallback={<LoadingApp />}>
<Routes>
<Route
path='/'
element={
// @ts-expect-error Part of evaluation for linter issues see: https://github.com/cfpb/sbl-frontend/issues/1039
<BasicLayout />
}
>
<Route path='/' element={<BasicLayout />}>
<Route path='/' element={<FilingHome />} />
{import.meta.env.DEV ? (
<Route
path='/markdown'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<MarkdownText />
</ProtectedRoute>
Expand All @@ -262,7 +253,6 @@ export default function App(): ReactElement {
<Route
path='/filing/:year/:lei/create'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<FilingCreate />
Expand All @@ -273,7 +263,6 @@ export default function App(): ReactElement {
<Route
path='/filing/:year/:lei/upload'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<FilingProtectedRoute>
Expand All @@ -287,11 +276,10 @@ export default function App(): ReactElement {
'/filing/:year/:lei/errors',
'/filing/:year/:lei/errors/errors-syntax',
'/filing/:year/:lei/errors/errors-logic',
].map((path, index) => (
].map(path => (
<Route
path={path}
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<FilingProtectedRoute>
Expand All @@ -300,14 +288,12 @@ export default function App(): ReactElement {
</InstitutionProtectedRoute>
</ProtectedRoute>
}
// eslint-disable-next-line react/no-array-index-key
key={index}
key={`error-route${path.replaceAll(/[/:]+/gi, '-')}`}
/>
))}
<Route
path='/filing/:year/:lei/warnings'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<FilingProtectedRoute>
Expand All @@ -320,7 +306,6 @@ export default function App(): ReactElement {
<Route
path='/filing/:year/:lei/details'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<FilingProtectedRoute>
Expand All @@ -333,7 +318,6 @@ export default function App(): ReactElement {
<Route
path='/filing/:year/:lei/submit'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<FilingProtectedRoute>
Expand All @@ -346,7 +330,6 @@ export default function App(): ReactElement {
<Route
path='/filing/:year/:lei/done'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<FilingProtectedRoute>
Expand All @@ -359,7 +342,6 @@ export default function App(): ReactElement {
<Route
path='/filing'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<FilingOverview />
</ProtectedRoute>
Expand All @@ -368,7 +350,6 @@ export default function App(): ReactElement {
<Route
path='/landing'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<AuthenticatedLanding />
</ProtectedRoute>
Expand All @@ -377,7 +358,6 @@ export default function App(): ReactElement {
<Route
path='/institution/:lei'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<ViewInstitutionProfile />
Expand All @@ -388,7 +368,6 @@ export default function App(): ReactElement {
<Route
path='/institution/:lei/update'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<UpdateFinancialProfile />
Expand All @@ -399,7 +378,6 @@ export default function App(): ReactElement {
<Route
path='/profile/view'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<ViewUserProfile />
</ProtectedRoute>
Expand All @@ -408,7 +386,6 @@ export default function App(): ReactElement {
<Route
path='/profile/complete/no-associations'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<main id='main'>
<CreateProfileFormNoAssoc />
Expand All @@ -419,7 +396,6 @@ export default function App(): ReactElement {
<Route
path='/profile/complete/with-associations'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<main id='main'>
<CreateProfileFormWAssoc />
Expand All @@ -430,7 +406,6 @@ export default function App(): ReactElement {
<Route
path='/profile/complete'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<ProfileForm />
</ProtectedRoute>
Expand All @@ -439,7 +414,6 @@ export default function App(): ReactElement {
<Route
path='/update-financial-profile'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<UpdateFinancialProfile />
</ProtectedRoute>
Expand All @@ -448,7 +422,6 @@ export default function App(): ReactElement {
<Route
path='/institution/:lei/type'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<TypesFinancialInstitutions />
Expand All @@ -459,7 +432,6 @@ export default function App(): ReactElement {
<Route
path='/institution/:lei/type/:year'
element={
// @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<InstitutionProtectedRoute>
<TypesFinancialInstitutions />
Expand Down
4 changes: 1 addition & 3 deletions src/api/requests/downloadValidationReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ export const downloadValidationReport = async ({
URL.revokeObjectURL(url);
});
} catch (error) {
// Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717
// eslint-disable-next-line no-console
console.log(error);
console.error(error);
} finally {
if (afterDownloadCallback) afterDownloadCallback();
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Link.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function IconExternalLink(): ReactElement {
return (
<>
{' '}
{/* @ts-expect-error Part of evaluation for linter issues see: https://github.com/cfpb/sbl-frontend/issues/1039 */}
{/* @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717 */}
<Icon name='external-link' className='link-icon-override-color' />
</>
);
Expand Down
3 changes: 0 additions & 3 deletions src/components/SectionIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { Heading } from 'design-system-react';
import type { ReactNode } from 'react';

export interface SectionIntroProperties {
// TODO: chore(linting): set react/require-default-props function property to defaultArguments
// https://github.com/cfpb/sbl-frontend/issues/355
// eslint-disable-next-line react/require-default-props
heading?: ReactNode;
children: ReactNode;
}
Expand Down
Loading
Loading