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): enable 3 rules of the unicorn plugin #2912

Merged
merged 6 commits into from
Oct 6, 2023
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
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ module.exports = {
'unicorn/prefer-ternary': 'error',
'unicorn/prefer-logical-operator-over-ternary': 'error',
'unicorn/consistent-function-scoping': 'error',
'unicorn/prefer-at': 'error',
'unicorn/prefer-dom-node-append': 'error',
'unicorn/prefer-dom-node-dataset': 'error',
'unicorn/prefer-dom-node-remove': 'error',
'unicorn/no-negated-condition': 'error',
'unicorn/no-array-callback-reference': 'error',
Expand All @@ -72,6 +74,7 @@ module.exports = {
'unicorn/prefer-switch': 'error',
'unicorn/switch-case-braces': 'error',
'unicorn/prefer-spread': 'error',
'unicorn/text-encoding-identifier-case': 'error',
'import/newline-after-import': ['error', { count: 1 }],
'import/first': 'error',
'import/order': [
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/parseBpmn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if (!['json', 'model'].includes(outputType)) {
console.info('Use BPMN diagram located at "%s"', bpmnFilePath);

const xmlParser = new BpmnXmlParser();
const json = xmlParser.parse(readFileSync(bpmnFilePath, 'utf-8', __dirname));
const json = xmlParser.parse(readFileSync(bpmnFilePath, 'utf8', __dirname));
const prettyString = (object: BpmnJsonModel | BpmnModel): string => JSON.stringify(object, null, 2);

let result = '';
Expand Down
2 changes: 1 addition & 1 deletion src/component/mxgraph/BpmnCellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BpmnCellRenderer extends mxgraph.mxCellRenderer {
// START bpmn-visualization CUSTOMIZATION
if (overlayShape instanceof OverlayBadgeShape) {
overlayShape.node.classList.add('overlay-badge');
overlayShape.node.setAttribute('data-bpmn-id', state.cell.id);
overlayShape.node.dataset.bpmnId = state.cell.id;
}
// END bpmn-visualization CUSTOMIZATION

Expand Down
2 changes: 1 addition & 1 deletion src/component/mxgraph/BpmnGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,6 @@ class BpmnGraphView extends mxgraph.mxGraphView {
return super.getFloatingTerminalPoint(edge, start, end, source);
}
const pts = edge.absolutePoints;
return source ? pts[1] : pts[pts.length - 2];
return source ? pts[1] : pts.at(-2);
}
}
2 changes: 1 addition & 1 deletion src/component/mxgraph/config/ShapeConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class ShapeConfigurator {
}

this.node.setAttribute('class', allBpmnClassNames.join(' '));
this.node.setAttribute('data-bpmn-id', this.state.cell.id);
this.node.dataset.bpmnId = this.state.cell.id;
}
// END bpmn-visualization CUSTOMIZATION
canvas.minStrokeWidth = this.minSvgStrokeWidth;
Expand Down
2 changes: 1 addition & 1 deletion src/component/mxgraph/overlay/custom-overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class MxGraphCustomOverlay extends mxgraph.mxCellOverlay {
}
// last point for end position
else {
return pts[pts.length - 1];
return pts.at(-1);
}
}
}
2 changes: 1 addition & 1 deletion src/component/mxgraph/renderer/CoordinatesTranslator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class CoordinatesTranslator {
const points: mxPointType[] = edge.geometry.points;

const p0 = points[0];
const pe = points[points.length - 1];
const pe = points.at(-1);

if (p0 != null && pe != null) {
const dx = pe.x - p0.x;
Expand Down
2 changes: 1 addition & 1 deletion src/component/registry/bpmn-elements-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class BpmnElementsRegistry implements CssClassesRegistry, ElementsRegistr
}

private getRelatedBpmnSemantic(htmlElement: HTMLElement): BpmnSemantic {
return this.bpmnModelRegistry.getBpmnSemantic(htmlElement.getAttribute('data-bpmn-id'));
return this.bpmnModelRegistry.getBpmnSemantic(htmlElement.dataset.bpmnId);
}

addCssClasses(bpmnElementIds: string | string[], classNames: string | string[]): void {
Expand Down
2 changes: 1 addition & 1 deletion test/shared/file-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import { readdirSync, readFileSync as fsReadFileSync } from 'node:fs';
import { join } from 'node:path';

export function readFileSync(relativePathToSourceFile: string, encoding: BufferEncoding = 'utf-8', directoryName = __dirname): string {
export function readFileSync(relativePathToSourceFile: string, encoding: BufferEncoding = 'utf8', directoryName = __dirname): string {
return fsReadFileSync(join(directoryName, relativePathToSourceFile), { encoding });
}

Expand Down