Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions front/.oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
],
"rules": {
"array-callback-return": "off",
"await-thenable": "off",
"checked-requires-onchange-or-readonly": "off",
"click-events-have-key-events": "off",
"consistent-return": "off",
Expand All @@ -45,14 +44,10 @@
"max-lines": "off",
"no-array-index-key": "off",
"no-await-in-loop": "off",
"no-base-to-string": "off",
"no-confusing-non-null-assertion": "off",
"no-confusing-void-expression": "off",
"no-duplicate-type-constituents": "off",
"no-else-return": "off",
"no-floating-promises": "off",
"no-inline-comments": "off",
"no-lonely-if": "off",
"no-loop-func": "off",
"no-misused-promises": "off",
"no-misused-spread": "off",
Expand All @@ -63,31 +58,21 @@
"no-throw-literal": "off",
"no-unassigned-import": "off",
"no-underscore-dangle": "off",
"no-unnecessary-boolean-literal-compare": "off",
"no-unnecessary-template-expression": "off",
"no-unnecessary-type-arguments": "off",
"no-unnecessary-type-conversion": "off",
"no-unnecessary-type-parameters": "off",
"no-unsafe-argument": "off",
"no-unsafe-assignment": "off",
"no-unsafe-enum-comparison": "off",
"no-unsafe-member-access": "off",
"no-unsafe-optional-chaining": "off",
"no-unsafe-type-assertion": "off",
"no-useless-constructor": "off",
"no-useless-default-assignment": "off",
"no-useless-return": "off",
"no-warning-comments": "off",
"only-throw-error": "off",
"prefer-enum-initializers": "off",
"prefer-includes": "off",
"prefer-nullish-coalescing": "off",
"prefer-readonly-parameter-types": "off",
"prefer-tag-over-role": "off",
"preserve-caught-error": "off",
"radix": "off",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unconvinced this rule is useful to us, though I guess trimming this list is nice

"react-in-jsx-scope": "off",
"require-array-sort-compare": "off",
"require-mock-type-parameters": "off",
"require-unicode-regexp": "off",
"restrict-template-expressions": "off",
Expand Down
6 changes: 3 additions & 3 deletions front/scripts/i18n-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ async function checkI18N(

if (
!(
error.properties &&
'enum' in error.properties?.type &&
error.properties?.type &&
'enum' in error.properties.type &&
Array.isArray(error.properties.type.enum) &&
error.properties.type.enum.length !== 0 &&
typeof error.properties.type.enum[0] === 'string'
Expand Down Expand Up @@ -69,7 +69,7 @@ async function checkI18N(
fs.readFileSync(new URL(localized_i18n_error_path, import.meta.url), 'utf8')
);
// Init the i18n system
const i18n = await i18next.createInstance(
const i18n = i18next.createInstance(
{
lng: locale,
resources: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const LinearMetadataTooltip = <T extends Record<string, unknown>>({
<span className="mr-3">
{((schema.properties || {})[k] as JSONSchema7 | undefined)?.title || k}
</span>
{/* oxlint-disable-next-line typescript/no-base-to-string */}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can get rid of this disable by changing the unkwown in LinearMetadataTooltip signature to string | number (which should be the only values allowed by LinearMetadataItem, so no loss of generality).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah, good catch indeed! Thanks for that, I wouldn't have thought about that 👍

{isNil(item[k]) ? '-' : `${item[k]}`}
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function getRangeEditionTool<T extends EditorRange>({
entityId && entityId !== entity.properties.id
? {
...entity,
properties: { ...entity.properties, id: `${entityId}` },
properties: { ...entity.properties, id: entityId },
}
: entity;
setState({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const SwitchEditionLeftPanel = () => {
if (id && id !== entityToSave.properties.id) {
const savedEntity = {
...entityToSave,
properties: { ...entityToSave.properties, id: `${id}` },
properties: { ...entityToSave.properties, id },
};
setState({
...state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AddNewCard = ({ testId, className, modalComponent, item, onOpenModal }: Ad
return (
<div
data-testid={testId}
className={`${className}`}
className={className}
{...(!newProjectStudyScenarioAllowed && { 'aria-disabled': true })}
role="button"
tabIndex={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ export default class TrainTrackProjectionLazyLoader extends TrainProjectionLazyL
*/
declare readonly options: TrainTrackProjectionLazyLoaderOptions;

constructor(options: TrainTrackProjectionLazyLoaderOptions) {
super(options);
}

async processBatch(ids: number[]) {
const { infraId, timetableId, path, electricalProfileSetId } = this.options;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const useMultiSelection = <T extends { id: number }>(
const toggleSelection = useCallback(
(id: number) => {
setSelectedItemIds(
selectedItemIds.indexOf(id) !== -1
selectedItemIds.includes(id)
? selectedItemIds.filter((selectedItemId) => selectedItemId !== id)
: selectedItemIds.concat([id])
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const TrainScheduleSetCartItem = ({
<SegmentedControl
value={importType}
getOptionLabel={(set) => t(`importType.${set}`)}
getOptionValue={(set) => `${set}`}
getOptionValue={(set) => set}
getOptionIcon={renderOptionIcon}
onChange={(set) => upsertToCart(trainScheduleSet.id, set)}
options={TRAINSCHEDULESET_IMPORT_TYPE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,5 +789,5 @@ export const loadNgeDto = async (
).unwrap();

await loadAndIndexNge(state, trainSchedules, dispatch, t, subCategories, notes);
return await getNgeDto(state, groupedTrainSchedules, subCategories, notes);
return getNgeDto(state, groupedTrainSchedules, subCategories, notes);
};
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const PathStepItem = ({
.sort((a, b) => {
const aIsNum = !isNaN(Number(a));
const bIsNum = !isNaN(Number(b));
if (aIsNum && bIsNum) return parseInt(a) - parseInt(b);
if (aIsNum && bIsNum) return parseInt(a, 10) - parseInt(b, 10);
if (aIsNum) return -1;
if (bIsNum) return 1;
return a.localeCompare(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getOpKey = (location: PathItemLocation | null): string | null => {
if (!location || location.type === 'track_offset') return null;
const op = location.operational_point;
if (op.type === 'domestic') return `${op.country_code} ${op.main_code} ${op.secondary_code}`;
if (op.type === 'id') return `${op.operational_point}`;
if (op.type === 'id') return op.operational_point;
if (op.type === 'uic') return `${op.uic} ${op.secondary_code}`;
return null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export type TransitionDto = {
};

export enum PortAlignment {
Top,
Bottom,
Left,
Right,
Top = 0,
Bottom = 1,
Left = 2,
Right = 3,
Comment on lines +46 to +49

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, these originate from NGE. We should no longer need this file, see #18458.

}

export type TrainrunDto = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ const PacedTrainItem = ({
dispatch(
setSuccess({
title: t('timetable.pacedTrainAdded'),
text: `${pacedTrainName}`,
text: pacedTrainName,
})
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const UniqueTrainItem = ({
dispatch(
setSuccess({
title: t('timetable.trainAdded'),
text: `${trainName}`,
text: trainName,
})
);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ const useFilterTrainSchedules = (

if (isMainCategory(category)) {
if (category.main_category !== trainCategoryFilter) return false;
} else {
if (category.sub_category_code !== trainCategoryFilter) return false;
} else if (category.sub_category_code !== trainCategoryFilter) {
return false;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function makeEffortCurve(selectedMode: string): ValueOf<EffortCurveForms>
export const getDefaultRollingStockMode = (selectedMode: string | null): EffortCurveForms | null =>
selectedMode
? {
[`${selectedMode}`]: makeEffortCurve(selectedMode),
[selectedMode]: makeEffortCurve(selectedMode),
}
: null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const getElectricalProfilesAndPowerRestrictions = (
export const orderSelectorList = (list: (string | null)[]) => {
const index = list.includes('O') ? 2 : 1;
return isNull(list[0]) || list[0] === 'O'
? list.slice(0, index).concat(list.slice(index).sort())
: list.sort();
? /* eslint-disable-next-line typescript/require-array-sort-compare */
list.slice(0, index).concat(list.slice(index).sort())
: /* eslint-disable-next-line typescript/require-array-sort-compare */
list.sort();
};
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ const DebugMap = ({ failureData, simulationData }: DebugMapProps) => {
<strong>{hovered.point.lastOPName}</strong>
</div>
<div>at: {hovered.point.at}</div>
{/* eslint-disable-next-line typescript/no-base-to-string */}
<div>caused by: {hovered.point.source?.toString()}</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a JSON.stringify instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't dug because it was in DebugMap, but indeed, a JSON-stringified version is good enough 👍

<div>time lost: {fmtSeconds(hovered.point.time_lost)}</div>
<div>best remaining: {fmtSeconds(hovered.point.best_remaining_time)}</div>
Expand Down
2 changes: 1 addition & 1 deletion front/src/applications/stdcm/components/StdcmLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const StdcmLoader = ({
return (
<div
ref={loaderRef}
className={cx('stdcm-loader', `${loaderStatus.status}`, {
className={cx('stdcm-loader', loaderStatus.status, {
'with-fade-in-animation':
loaderStatus.status === 'loader-absolute' && loaderStatus.firstLaunch,
'with-slide-animation':
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/stdcm/hooks/useStdcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ const useStdcm = ({
await handleSuccess(result, payload);
break;
case 'preprocessing_simulation_error':
await handleRejection(result.error);
handleRejection(result.error);
break;
case 'internal_error':
await handleRejection(result.error);
handleRejection(result.error);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const fetchPathProperties = async (
};
} catch (error) {
console.error('Error fetching path properties:', error);
throw new Error('Path properties could not be fetched.');
throw new Error('Path properties could not be fetched.', { cause: error });
}
};

Expand Down
2 changes: 1 addition & 1 deletion front/src/common/BootstrapSNCF/DropdownSNCF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const DropdownSNCF = ({
{titleContent}
{noArrow && (
<i
className={`${isDropdownShown ? 'icons-arrow-up' : 'icons-arrow-down'}`}
className={isDropdownShown ? 'icons-arrow-up' : 'icons-arrow-down'}
aria-hidden="true"
/>
)}
Expand Down
4 changes: 2 additions & 2 deletions front/src/common/IntervalsDataViz/dataviz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export type LinearMetadataDatavizProps<T> = IntervalItemBaseProps<T> & {
/**
* Event when mouse leaves data item
*/
onMouseLeave?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
onMouseLeave?: (e: React.MouseEvent<HTMLDivElement>) => void;

/**
* Event when the mouse move on a data item
*/
onMouseMove?: (
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
e: React.MouseEvent<HTMLDivElement>,
item: LinearMetadataItem<T>,
index: number,
point: number // point on the linear metadata
Expand Down
8 changes: 4 additions & 4 deletions front/src/common/IntervalsDataViz/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type IntervalItemBaseProps<T> = {
* Event on click on a data item
*/
onClick?: (
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
e: React.MouseEvent<HTMLDivElement>,
item: LinearMetadataItem<T>,
index: number,
point: number // point on the linear metadata
Expand All @@ -53,7 +53,7 @@ export type IntervalItemBaseProps<T> = {
* Event on click on a data item
*/
onDoubleClick?: (
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
e: React.MouseEvent<HTMLDivElement>,
item: LinearMetadataItem<T>,
index: number,
point: number // point on the linear metadata
Expand All @@ -63,7 +63,7 @@ export type IntervalItemBaseProps<T> = {
* Event when mouse enter into data item
*/
onMouseEnter?: (
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
e: React.MouseEvent<HTMLDivElement>,
item: LinearMetadataItem<T>,
index: number,
point: number // point on the linear metadata
Expand All @@ -73,7 +73,7 @@ export type IntervalItemBaseProps<T> = {
* Event when mouse over a data item
*/
onMouseOver?: (
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
e: React.MouseEvent<HTMLDivElement>,
item: LinearMetadataItem<T>,
index: number,
point: number // point on the linear metadata
Expand Down
1 change: 1 addition & 0 deletions front/src/common/IntervalsDataViz/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function castToNumber(value: unknown): number | null | undefined {
if (typeof value === 'boolean') return +value;
if (value === '') return null;

/* eslint-disable-next-line typescript/no-base-to-string */
const stringValue = `${value}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should also be a JSON.stringify instead

const castValue = +stringValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function getFilterHighlighted(
];
else if (data.highlightedArea) result = ['within', data.highlightedArea];

if (reverseCondition === true) {
if (reverseCondition) {
return ['!=', result, true];
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getPSLSpeedValueLayerProps({
colors: Theme;
sourceTable?: string;
layersSettings: LayersSettings;
t?: TFunction<'translation'>;
t?: TFunction;
}): OmitLayer<SymbolLayerSpecification> {
const res: OmitLayer<SymbolLayerSpecification> = {
type: 'symbol',
Expand Down
2 changes: 1 addition & 1 deletion front/src/common/Map/Layers/useMapBlankStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const useMapBlankStyle = (): MapProps['mapStyle'] => {
const isDefaultSpriteValid = await isValidUrl(ponctualObjectsSprites.url);

const sprites: (Sprite | null)[] = await Promise.all([
isDefaultSpriteValid ? ponctualObjectsSprites : null,
Promise.resolve(isDefaultSpriteValid ? ponctualObjectsSprites : null),
...signalingSystems.map(async (id) => {
const signalingSystemsURL = `${SPRITES_URL}/${id}/sprites`;
const isValid = await isValidUrl(signalingSystemsURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function useSearchOperationalPoint({
object: 'operationalpoint',
query: [
'and',
['=', ['main_code'], `${searchQuery}`],
['=', ['main_code'], searchQuery],
['=', ['infra_id'], infraId],
stdcmPerimeterOperationalpointsFilter,
],
Expand Down
2 changes: 1 addition & 1 deletion front/src/common/Map/components/LayersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const LayersModal = ({
</div>
<div className="row">
{layers.map(({ layer, icon }) => (
<div className="col-lg-6" key={`${layer}`}>
<div className="col-lg-6" key={layer}>
<div className="d-flex align-items-center mt-2">
<SwitchSNCF
id={`map-layer-${layer}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function postTimetableByIdStdcm(args: PostTimetableByIdStdcmApiAr
callback({ ...data, traceId });
} catch (e) {
console.error(e);
throw new Error(`Error while JSON parse ${line}`);
throw new Error(`Error while JSON parse ${line}`, { cause: e });
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const generateGrantSelectProps = ({

// In case of not owner of the resource, we need to remove all options below the subject one.
// A user can't revoke a grant if he is not owner
if (userPrivileges.has('can_share_ownership') === false) {
if (!userPrivileges.has('can_share_ownership')) {
const filteredOptions = allowedOptions.filter((_, index) => index >= subjectValueIndex);
return {
value: allowedOptions[subjectValueIndex],
Expand Down
Loading