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

chore(eslint): add unicorn/prefer-logical-operator-over-ternary rule #2871

Merged
Merged
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
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
'unicorn/no-array-for-each': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/prefer-logical-operator-over-ternary': 'error',
'import/newline-after-import': ['error', { count: 1 }],
'import/first': 'error',
'import/order': [
Expand Down
2 changes: 1 addition & 1 deletion test/config/jest-playwright.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const computeLaunchOptionsAndBrowsersConfiguration = defaultBrowsers => {
/** @type {import('playwright-core/types/types').LaunchOptions} */
const launchOptions = {
headless: process.env.HEADLESS !== 'false',
slowMo: process.env.SLOWMO ? process.env.SLOWMO : 0,
slowMo: process.env.SLOWMO ?? 0,
};

const browsersAndChannelConfig = computeBrowsersAndChannelConfiguration(defaultBrowsers);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/diagram.navigation.fit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FitImageSnapshotConfigurator extends ImageSnapshotConfigurator {
margin?: number;
}): MatchImageSnapshotOptions {
const config = super.getConfig(parameter);
config.customSnapshotsDir = FitImageSnapshotConfigurator.buildSnapshotFitDirectory(config.customSnapshotsDir, parameter.fitType, true, parameter.margin ? parameter.margin : 0);
config.customSnapshotsDir = FitImageSnapshotConfigurator.buildSnapshotFitDirectory(config.customSnapshotsDir, parameter.fitType, true, parameter.margin ?? 0);
config.customDiffDir = parameter.buildCustomDiffDir(config, parameter.fitType, parameter.margin);
return config;
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/matchers/toBeCell/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function buildExpectedCell(id: string, expected: ExpectedCellWithGeometry): Expe

return {
id,
parent: { id: parentId ? parentId : getDefaultParentId() },
parent: { id: parentId ?? getDefaultParentId() },
geometry: expect.objectContaining(expectedObject),
};
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/matchers/toBeEdge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function buildExpectedCell(id: string, expectedModel: ExpectedEdgeModelElement |
styleViewState: buildExpectedEdgeCellStyle(expectedModel),
edge: true,
vertex: false,
parent: { id: parentId ? parentId : getDefaultParentId() },
parent: { id: parentId ?? getDefaultParentId() },
overlays: expectedModel.overlays,
};

Expand Down
2 changes: 1 addition & 1 deletion test/integration/matchers/toBeShape/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function buildExpectedCell(id: string, expectedModel: ExpectedShapeModelElement)
styleViewState: buildExpectedShapeCellStyle(expectedModel),
edge: false,
vertex: true,
parent: { id: parentId ? parentId : getDefaultParentId() },
parent: { id: parentId ?? getDefaultParentId() },
overlays: expectedModel.overlays,
};
}
Expand Down
11 changes: 6 additions & 5 deletions test/unit/helpers/JsonBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export function buildDefinitions({ process, messageFlows, globalTask }: BuildDef
}

function addParticipantProcessAndElements(processParameter: BuildProcessParameter, jsonModel: BpmnJsonModel, index: number): void {
const id = processParameter.id ? processParameter.id : String(index);
const id = processParameter.id ?? String(index);
if (processParameter.withParticipant) {
addParticipant(id, jsonModel);
}
Expand Down Expand Up @@ -314,7 +314,7 @@ function addMessageFlow(messageFlowParameter: BuildMessageFlowParameter, jsonMod

const addGlobalTask = ({ id, bpmnKind = 'globalTask', ...rest }: BuildGlobalTaskParameter, jsonModel: BpmnJsonModel, index: number): void => {
const globalTask: TGlobalTask = {
id: id ? id : `${bpmnKind}_id_${index}`,
id: id ?? `${bpmnKind}_id_${index}`,
...rest,
};

Expand Down Expand Up @@ -417,7 +417,7 @@ function enrichBpmnElement<T extends TBaseElement | DiagramElement>(currentEleme

function addLane(jsonModel: BpmnJsonModel, { id, name, ...rest }: BuildLaneParameter, index: number, processIndex: number): void {
const lane: TLane = {
id: id ? id : `lane_id_${processIndex}_${index}`,
id: id ?? `lane_id_${processIndex}_${index}`,
...rest,
};
if (name) {
Expand Down Expand Up @@ -453,7 +453,7 @@ function addProcessElementWithEdge(jsonModel: BpmnJsonModel, bpmnKind: keyof TPr

function addProcessElement(jsonModel: BpmnJsonModel, bpmnKind: keyof TProcess, { id, index, processIndex, ...rest }: BuildProcessElementParameter): TFlowNode | TArtifact {
const processElement: TFlowElement | TArtifact = {
id: id ? id : `${bpmnKind}_id_${processIndex}_${index}`,
id: id ?? `${bpmnKind}_id_${processIndex}_${index}`,
...rest,
};

Expand Down Expand Up @@ -500,6 +500,7 @@ function addEventDefinitionsOnDefinition(jsonModel: BpmnJsonModel, buildParamete
addEventDefinitions(jsonModel.definitions, { ...buildParameter, eventDefinition: { id: 'event_definition_id' } }, { id: 'other_event_definition_id' });
(event.eventDefinitionRef as string[]) = ['event_definition_id', 'other_event_definition_id'];
} else {
// eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary -- Because if `eventDefinition` is an empty string, the logical operator returns `true` and the ternary returns `false`.
const eventDefinition = buildParameter.eventDefinition
? buildParameter.eventDefinition
: buildParameter.withMultipleDefinitions
Expand Down Expand Up @@ -541,7 +542,7 @@ function buildEvent({
outgoing?: string | string[];
}): BPMNTEvent {
const event: BPMNTEvent = {
id: id ? id : `event_id_${processIndex}_${index}`,
id: id ?? `event_id_${processIndex}_${index}`,
name: name,
incoming,
outgoing,
Expand Down