Skip to content

Commit

Permalink
xstream-595 typescript 5 migration + eslint 8 (#565)
Browse files Browse the repository at this point in the history
xstream-595 typescript 5 migration + eslint 8
  • Loading branch information
fatb38 authored Sep 16, 2024
2 parents 735b0ae + 47d286e commit 68d1526
Show file tree
Hide file tree
Showing 64 changed files with 483 additions and 609 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
ignorePatterns: ['**/_gqlTypes/*.ts', '**/dist/*', '**/plugins/*'],
parser: '@typescript-eslint/parser',
parserOptions: {tsconfigRootDir: __dirname},
plugins: ['@typescript-eslint', 'react-app', 'react-refresh'],
plugins: ['@typescript-eslint', 'react-refresh'],
settings: {react: {version: 'latest'}},
extends: ['plugin:@aristid/recommended'],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"redux-mock-store": "1.5.4",
"ts-jest": "29.0.5",
"ts-jest-mock-import-meta": "1.0.0",
"typescript": "4.8.3",
"typescript": "5.5.3",
"vite": "4.5.3",
"vite-jest": "0.1.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ function PurgeTab({library, readonly}: IPurgeTabProps): JSX.Element {

const confirmContent = (
<ConfirmContent>
<div className="warning">{t('libraries.purge.warning', {interpolation: false})}</div>
<div className="warning">
{t('libraries.purge.warning', {
interpolation: false,
defaultValue: 'warning'
})}
</div>
<div>{t('libraries.purge.confirm')}</div>
</ConfirmContent>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/components/tasks/Tasks/Tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Tasks = (): JSX.Element => {
const [delTasks] = useMutation<DELETE_TASKS, DELETE_TASKSVariables>(deleteTasksMutation);
const [cancelTask] = useMutation<CANCEL_TASK, CANCEL_TASKVariables>(cancelTaskMutation);

const _onDeleteAll = async (archivesOnly: boolean = false) => {
const _onDeleteAll = async (archivesOnly = false) => {
const tasksToDel = !archivesOnly ? completedTasks : completedTasks.filter(ct => ct.archive);

await delTasks({variables: {tasks: tasksToDel.map(ttd => ({id: ttd.id, archive: false}))}});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {mockTree} from '__mocks__/trees';
import TreeStructure from './TreeStructure';

describe('TreeStructure', () => {
const _renderTreeStructure = (tree: GET_TREES_trees_list, readOnly: boolean = false, mocks?: MockedResponse[]) => {
const _renderTreeStructure = (tree: GET_TREES_trees_list, readOnly = false, mocks?: MockedResponse[]) => {
render(
<DndProvider backend={TestBackend}>
<TreeStructure tree={tree} readOnly={readOnly} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const TreeExplorer = ({
* @param path No path = root
* @param expand Should expand node?
*/
const _loadChildren = async (parent?: string | null, path?: Array<string | number>, expand: boolean = true) => {
const _loadChildren = async (parent?: string | null, path?: Array<string | number>, expand = true) => {
const withPath = !!path;

// Retrieve data
Expand Down
3 changes: 1 addition & 2 deletions apps/admin/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import i18n from './i18n';
import './index.css';
import registerServiceWorker from './registerServiceWorker';

// eslint-disable-next-line react-refresh/only-export-components
function Index() {
export function Index() {
const {lang, loading, error} = useAppLang();
const [i18nIsInitialized, seti18nIsInitialized] = useState(false);

Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function versionObjToGraphql(version: {

export function isLinkAttribute(
attribute: GET_ATTRIBUTE_BY_ID_attributes_list,
strict: boolean = true
strict = true
): attribute is GET_ATTRIBUTE_BY_ID_attributes_list_LinkAttribute {
const linkTypes = [AttributeType.advanced_link, AttributeType.simple_link];

Expand Down
2 changes: 1 addition & 1 deletion apps/automate-scan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"prettier": "3.3.3",
"ts-jest": "29.0.1",
"ts-node-dev": "2.0.0",
"typescript": "4.8.3"
"typescript": "5.5.3"
},
"dependencies": {
"@leav/app-root-path": "workspace:libs/app-root-path",
Expand Down
12 changes: 6 additions & 6 deletions apps/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@types/compression": "1.7.5",
"@types/debug": "0.0.31",
"@types/glob": "5.0.37",
"@types/jest": "29.0.2",
"@types/jest-when": "3.5.2",
"@types/jest": "29.5.13",
"@types/jest-when": "3.5.5",
"@types/jsonwebtoken": "8.5.9",
"@types/lodash": "4.14.185",
"@types/ms": "0.7.31",
Expand All @@ -51,18 +51,18 @@
"@types/winston": "2.3.9",
"@types/ws": "8.5.3",
"axios": "1.7.4",
"jest": "29.0.3",
"jest-when": "3.5.1",
"jest": "29.7.0",
"jest-when": "3.6.0",
"license-check-and-add": "3.0.5",
"lint-staged": "7.3.0",
"moment-timezone": "0.5.37",
"nodemon": "1.19.4",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"ts-jest": "29.0.1",
"ts-jest": "29.2.5",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "4.8.3",
"typescript": "5.5.3",
"watch": "1.0.2"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function ({config}: IDeps): ISystemTranslationGenerator {
}
};

const getScalar = (optional: boolean = true) =>
const getScalar = (optional = true) =>
new GraphQLScalarType({
name: optional ? 'SystemTranslationOptional' : 'SystemTranslation',
description: 'System entities fields translation (label...)',
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/depsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const _registerModules = async (
container: AwilixContainer,
folder: string,
glob: string,
prefix: string = ''
prefix = ''
): Promise<AwilixContainer> => {
// We only consider index files so that we explicity declare what we want to make available
// in dependency injector. This allows to have some helper files kept private inside a module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function ({
config = null
}: IDeps): IMessagesHandlerHelper {
const _messagesQueue: IFileEventData[] = [];
let _isWorking: boolean = false;
let _isWorking = false;

const _processMessage = async (ctx: IQueryInfos): Promise<void> => {
if (_isWorking || !_messagesQueue.length) {
Expand Down
6 changes: 3 additions & 3 deletions apps/core/src/domain/tasksManager/tasksManagerDomain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('Tasks Manager', () => {
expect(mockEventsManager.sendPubSubEvent).toBeCalled();
expect(mockAmqpService.publish).toBeCalled();

clearInterval(timerId);
clearInterval(Number(timerId));
});

test('Init Master / Task to cancel', async () => {
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('Tasks Manager', () => {

expect(mockAmqpService.publish).toBeCalled();

clearInterval(timerId);
clearInterval(Number(timerId));
});

test('Init Master / Pending callback', async () => {
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('Tasks Manager', () => {
}
);

clearInterval(timerId);
clearInterval(Number(timerId));
});

test('Init Worker', async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/domain/user/userDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function ({

return userDataRepo.saveUserData({key, value, global, isCoreData, ctx});
},
async getUserData(keys: string[], global: boolean = false, ctx: IQueryInfos): Promise<IUserData> {
async getUserData(keys: string[], global = false, ctx: IQueryInfos): Promise<IUserData> {
const isAllowed = await permissionDomain.isAllowed({
type: PermissionTypes.ADMIN,
action: AdminPermissionsActions.MANAGE_GLOBAL_PREFERENCES,
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/errors/AuthenticationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt

export default class AuthenticationError extends Error {
public constructor(message: string = 'Unauthorized') {
public constructor(message = 'Unauthorized') {
super();
this.message = message;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/errors/GraphQLAuthenticationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Maybe} from 'graphql/jsutils/Maybe';

export default class GraphQLAuthenticationError extends GraphQLError {
public constructor(
message: string = 'Unauthorized',
message = 'Unauthorized',
nodes?: Maybe<readonly ASTNode[] | ASTNode>,
source?: Maybe<Source>,
positions?: Maybe<readonly number[]>,
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/errors/LeavError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class LeavError<T> extends Error {
public type: ErrorTypes;
public record?: ILeavErrorRecord;

public constructor(type: ErrorTypes, message: string = 'Action forbidden', details?: ILeavErrorDetails) {
public constructor(type: ErrorTypes, message = 'Action forbidden', details?: ILeavErrorDetails) {
super(message);

this.type = type;
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/errors/PermissionError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class PermissionError<T> extends LeavError<T> {
*/
public action: PermissionsActions;

public constructor(action: PermissionsActions, fields?: ErrorFieldDetail<T>, message: string = 'Action forbidden') {
public constructor(action: PermissionsActions, fields?: ErrorFieldDetail<T>, message = 'Action forbidden') {
super(ErrorTypes.PERMISSION_ERROR, message, {fields});
this.action = action;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/core/src/errors/ValidationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default class ValidationError<T> extends LeavError<T> {

public constructor(
fields: ErrorFieldDetail<T>,
message: string = 'Invalid request',
isCustomMessage: boolean = false,
message = 'Invalid request',
isCustomMessage = false,
context?: any
) {
super(ErrorTypes.VALIDATION_ERROR, message, {fields});
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/infra/log/logRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ({'core.infra.elasticSearch.service': esService, config}
* {match: {'topic.record.id': '123456'}}
* ]
*/
const _flattenTopicFilter = (obj: Record<string, any>, parentKey: string = '') => {
const _flattenTopicFilter = (obj: Record<string, any>, parentKey = '') => {
let result: SearchQueryType[] = [];

for (const [key, value] of Object.entries(obj)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/infra/oidc/__tests__/oidcClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Issuer} from 'openid-client';
const clientMock = jest.fn();

class ClientClassMock {
constructor(...args) {
public constructor(...args: any) {
clientMock(...args);
}
}
Expand Down
3 changes: 1 addition & 2 deletions apps/core/src/infra/record/recordRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export interface IRecordRepo {
updateRecord({
libraryId,
recordData,
mergeObjects = true,
ctx
}: {
libraryId: string;
Expand Down Expand Up @@ -313,7 +312,7 @@ export default function ({

return dbUtils.cleanup(deletedRecord);
},
async updateRecord({libraryId, recordData, mergeObjects = true, ctx}) {
async updateRecord({libraryId, recordData, ctx}) {
const collection = dbService.db.collection<IRecord>(libraryId);
const dataToSave = {...recordData};
const recordId = dataToSave.id;
Expand Down
6 changes: 1 addition & 5 deletions apps/core/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,7 @@ export default function ({config = null, translator = null}: IUtilsDeps = {}): I
}, {})
: null;
},
objToNameValArray<T extends object>(
obj: object,
keyFieldName: string = 'name',
valueFieldName: string = 'value'
): T[] {
objToNameValArray<T extends object>(obj: object, keyFieldName = 'name', valueFieldName = 'value'): T[] {
if (!obj) {
return [];
}
Expand Down
6 changes: 3 additions & 3 deletions apps/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["jest", "node", "@types/jest"],
"types": ["jest", "node"],
"baseUrl": "src",
"outDir": "dist",
"isolatedModules": false,
"typeRoots": ["./src/_types"]
"typeRoots": ["./src/_types", "./node_modules/@types"]
},
"exclude": [
"applications"
]
}
}
2 changes: 1 addition & 1 deletion apps/data-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"styled-components": "6.0.8",
"ts-jest": "29.0.5",
"ts-jest-mock-import-meta": "1.0.0",
"typescript": "4.8.3",
"typescript": "5.5.3",
"vite": "4.5.3",
"vite-jest": "0.1.4",
"vite-plugin-dynamic-base": "0.4.9",
Expand Down
3 changes: 1 addition & 2 deletions apps/data-studio/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import * as serviceWorker from './serviceWorker';

const root = createRoot(document.getElementById('root') as HTMLElement);

// eslint-disable-next-line react-refresh/only-export-components
function Index() {
export function Index() {
const {lang, loading, error} = useAppLang();
const [i18nIsInitialized, seti18nIsInitialized] = useState(false);

Expand Down
2 changes: 1 addition & 1 deletion apps/login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"terser": "5.17.3",
"ts-jest": "29.0.5",
"ts-jest-mock-import-meta": "1.0.0",
"typescript": "4.8.3",
"typescript": "5.5.3",
"vite": "4.5.3",
"vite-plugin-dynamic-base": "0.4.9",
"vite-plugin-rewrite-all": "1.0.1"
Expand Down
2 changes: 1 addition & 1 deletion apps/login/src/components/Login/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock('react-router-dom', () => ({
.mockReturnValue({})
}));

const _renderComponent = (url: string = '/') =>
const _renderComponent = (url = '/') =>
render(
<KitApp>
<MemoryRouter initialEntries={[url]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jest.mock('react-router-dom', () => ({
useParams: () => ({token: '123456'})
}));

const _renderComponent = (url: string = '/') =>
const _renderComponent = (url = '/') =>
render(
<KitApp>
<MemoryRouter initialEntries={[url]}>
Expand Down
2 changes: 1 addition & 1 deletion apps/logs-collector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"prettier": "3.3.3",
"ts-jest": "29.0.1",
"ts-node-dev": "2.0.0",
"typescript": "4.8.3"
"typescript": "5.5.3"
},
"dependencies": {
"@elastic/elasticsearch": "8.10.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"jest-fetch-mock": "3.0.3",
"ts-jest": "29.0.5",
"ts-jest-mock-import-meta": "1.0.0",
"typescript": "4.8.3",
"typescript": "5.5.3",
"vite": "4.5.3",
"vite-jest": "0.1.4",
"vite-plugin-dynamic-base": "0.4.9"
Expand Down
2 changes: 2 additions & 0 deletions apps/portal/src/_tests/testUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface IProvidersProps {
globalSettings?: GET_GLOBAL_SETTINGS_globalSettings;
}

// eslint-disable-next-line react-refresh/only-export-components
const Providers = ({
children,
apolloMocks,
Expand Down Expand Up @@ -64,5 +65,6 @@ const renderWithProviders = (ui: ReactElement, options?: ICustomRenderOptions):

// Re-export everything from testing-library to improve DX. You can everything you need from this file when you use this
// custom render
// eslint-disable-next-line react-refresh/only-export-components
export * from '@testing-library/react';
export {renderWithProviders as render};
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// This file is released under LGPL V3
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
export const stringToColor = (
str: string = '',
str = '',
format: 'hsl' | 'rgb' | 'hex' = 'hsl',
saturation: number = 30,
luminosity: number = 80
saturation = 30,
luminosity = 80
): string => {
let hash = 0;
for (let i = 0; i < str.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion apps/preview-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"prettier": "3.3.3",
"ts-jest": "29.0.1",
"ts-node-dev": "2.0.0",
"typescript": "4.8.3"
"typescript": "5.5.3"
},
"dependencies": {
"@leav/app-root-path": "workspace:libs/app-root-path",
Expand Down
Loading

0 comments on commit 68d1526

Please sign in to comment.