Skip to content

Commit

Permalink
front: deactivate some eslint rules
Browse files Browse the repository at this point in the history
- no-await-in-loop
- no-continue
- no-restricted-syntax
  • Loading branch information
clarani committed Aug 30, 2024
1 parent 3b54f5d commit 074ce44
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
16 changes: 11 additions & 5 deletions front/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"no-shadow": "off",
"@typescript-eslint/consistent-type-imports": ["error", { "fixStyle": "inline-type-imports" }],
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-use-before-define": ["error"],
"@typescript-eslint/no-use-before-define": "error",

"@typescript-eslint/ban-types": [
"error",
Expand Down Expand Up @@ -69,10 +69,13 @@
"import/no-unresolved": [2, { "commonjs": true, "amd": true }],
"jsx-a11y/click-events-have-key-events": "off",
"linebreak-style": ["error", "unix"],
"no-await-in-loop": "off",
"no-console": ["error", { "allow": ["info", "debug", "warn", "error"] }],
"no-continue": "off",
"no-named-as-default": "off",
"no-param-reassign": "off",
"no-use-before-define": "off",
"no-restricted-syntax": "off",
"prettier/prettier": ["warn"],
"react/forbid-prop-types": "off",
"react/jsx-filename-extension": "off",
Expand All @@ -82,10 +85,13 @@
"react/static-property-placement": 0,
// disable vitest/prefer-to-be because it does not authorize toEqual for the floats
"vitest/prefer-to-be": "off",
"no-restricted-imports": ["error", {
"name": "common/api/generatedEditoastApi",
"message": "Please use common/api/osrdEditoastApi instead"
}]
"no-restricted-imports": [
"error",
{
"name": "common/api/generatedEditoastApi",
"message": "Please use common/api/osrdEditoastApi instead"
}
]
},
"settings": {
"import/resolver": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const GroupedTrackRangeList = ({ displayedRanges }: GroupedTrackRangeListProps)
>;

const rangesByRoute = groupBy(displayedRanges, (currentRange) => {
// eslint-disable-next-line no-restricted-syntax
for (const [routeKey, { trackRanges }] of Object.entries(routeElements)) {
if (
partialIsEqual(['track', 'begin', 'end'], currentRange, routeExtra[routeKey]) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const buildOpQuery = (
const pathItems = trainSchedules.map((schedule) => schedule.path).flat();
const pathItemQueries = [];
const pathItemSet = new Set<string>();
// eslint-disable-next-line no-restricted-syntax
for (const item of pathItems) {
let query: SearchQuery;
if ('uic' in item) {
Expand All @@ -120,14 +119,12 @@ const buildOpQuery = (
} else if ('operational_point' in item) {
query = ['=', ['obj_id'], item.operational_point];
} else {
// eslint-disable-next-line no-continue
continue; // track offset, handled by creating an empty node
}

// Avoid including the same query twice in the search payload
const key = JSON.stringify(query);
if (pathItemSet.has(key)) {
// eslint-disable-next-line no-continue
continue;
}

Expand Down Expand Up @@ -163,7 +160,6 @@ const executeSearch = async (
searchPayload,
})
);
// eslint-disable-next-line no-await-in-loop
const results = (await searchPromise.unwrap()) as SearchResultItemOperationalPoint[];
searchResults.push(...results);
done = results.length < pageSize;
Expand Down Expand Up @@ -277,7 +273,6 @@ const importTimetable = async (
return node;
};

// eslint-disable-next-line no-restricted-syntax
for (const op of searchResults) {
createNode({
id: op.obj_id,
Expand Down
1 change: 0 additions & 1 deletion front/src/applications/operationalStudies/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ export const isTooFast = (

const pathItemMap = getPathItemByIndexDict(trainSchedule);

// eslint-disable-next-line no-restricted-syntax
for (const pathItemId of toCheckPathItemIds) {
const pathItemIndex = pathItemMap[pathItemId];
const pathItemTimeFinal = trainSummary.path_item_times_final[pathItemIndex];
Expand Down
1 change: 0 additions & 1 deletion front/src/common/IntervalsDataViz/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export function shortNumber(value: unknown): string {
const exponent = size % 3 === 0 ? size - 3 : size - (size % 3);
let shortNumberValue = `${Math.round(10 * (num / 10 ** exponent)) / 10}`;

// eslint-disable-next-line no-restricted-syntax
for (const suffix in suffixes) {
if (exponent < suffixes[suffix]) {
shortNumberValue += suffix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const updateRestrictions = (
): PowerRestrictionV2[] =>
compact(
restrictions.map((restriction) => {
// eslint-disable-next-line no-restricted-syntax
for (const restrictionToRemove of restrictionsToRemove) {
if (
restriction.from === restrictionToRemove.from &&
Expand Down
4 changes: 0 additions & 4 deletions front/tests/pages/operational-studies-page-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ class OperationalStudiesPage {
expect(actualMessage).toContain(expectedMessage);
}

/* eslint-disable no-restricted-syntax, no-await-in-loop */
// Clicks the add buttons for the specified via names.
async clickOnViaAddButtons(...viaNames: string[]) {
for (const viaName of viaNames) {
Expand All @@ -278,7 +277,6 @@ class OperationalStudiesPage {
await expect(this.getMapPathfindingMarker(markerName)).toBeVisible();
}
}
/* eslint-enable no-restricted-syntax, no-await-in-loop */

// Validates the waypoint suggestions by checking the name, CH, UIC, and distance.
static async validateWaypointSuggestions(
Expand Down Expand Up @@ -336,7 +334,6 @@ class OperationalStudiesPage {
const waypointSuggestion = this.waypointSuggestions.nth(waypointSuggestionCount);
const expectedValue = expectedValues[waypointSuggestionCount];

// eslint-disable-next-line no-await-in-loop
await OperationalStudiesPage.validateWaypointSuggestions(
waypointSuggestion,
expectedValue.name,
Expand All @@ -357,7 +354,6 @@ class OperationalStudiesPage {
const droppedWaypoint = this.droppedWaypoints.nth(droppedWaypointCount);
const expectedValue = expectedValues[droppedWaypointCount];

// eslint-disable-next-line no-await-in-loop
await OperationalStudiesPage.validateAddedWaypoint(
droppedWaypoint,
expectedValue.name,
Expand Down

0 comments on commit 074ce44

Please sign in to comment.