Skip to content

Commit fcfbc2c

Browse files
refactor: format using eslint
1 parent 4fb8ce3 commit fcfbc2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+497
-438
lines changed

.eslintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
coverage
3+
dist
4+
doc
5+
6+
**/*.spec.ts
7+
8+
**/*.html

describe.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const testScl = new DOMParser().parseFromString(
8888
</EnumType>
8989
</DataTypeTemplates>
9090
</SCL>`,
91-
"application/xml"
91+
"application/xml",
9292
);
9393

9494
const sclElement = testScl.querySelector("SCL")!;
@@ -111,21 +111,21 @@ describe("Describe SCL elements function", () => {
111111

112112
it("return equal description with semantically equal SCL element", () =>
113113
expect(JSON.stringify(describeSclElement(baseEnumType))).to.equal(
114-
JSON.stringify(describeSclElement(equalEnumType))
114+
JSON.stringify(describeSclElement(equalEnumType)),
115115
));
116116

117117
it("return different description with semantically unequal SCL element", () =>
118118
expect(JSON.stringify(describeSclElement(diffEnumType))).to.not.equal(
119-
JSON.stringify(describeSclElement(equalEnumType))
119+
JSON.stringify(describeSclElement(equalEnumType)),
120120
));
121121

122122
it("returns same description with semantically equal LN's", () =>
123123
expect(JSON.stringify(describeSclElement(baseLN))).to.equal(
124-
JSON.stringify(describeSclElement(equalLN))
124+
JSON.stringify(describeSclElement(equalLN)),
125125
));
126126

127127
it("returns different description with unequal LN elements", () =>
128128
expect(JSON.stringify(describeSclElement(baseLN))).to.not.equal(
129-
JSON.stringify(describeSclElement(diffLN))
129+
JSON.stringify(describeSclElement(diffLN)),
130130
));
131131
});

describe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { LN, LNDescription } from "./describe/LN.js";
88

99
export type Description =
1010
| PrivateDescription
11-
| TextDescription
11+
// eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents
12+
| TextDescription // FIXME: duplication to PrivateDescription
1213
| EnumTypeDescription
1314
| DATypeDescription
1415
| DOTypeDescription

describe/AbstractDataAttribute.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const scl = new DOMParser().parseFromString(
4848
</EnumType>
4949
</DataTypeTemplates>
5050
</SCL>`,
51-
"application/xml"
51+
"application/xml",
5252
);
5353

5454
const baseBDA = scl.querySelector(`#baseDAType>BDA`)!;
@@ -57,14 +57,14 @@ const equalBDA = scl.querySelector(`#equalDAType>BDA`)!;
5757
const orphanBDA = new DOMParser()
5858
.parseFromString(
5959
`<BDA name="hstVal" desc="refArrayBDA" bType="FLOAT32" count="hstRangeC" />`,
60-
"application/xml"
60+
"application/xml",
6161
)
6262
.querySelector("BDA")!;
6363

6464
const missingBType = scl.querySelector(`BDA[desc="missingBType"`)!;
6565
const refInvalidCount = scl.querySelector(`BDA[desc="invalidRefArrayBDA"`)!;
6666
const refInvalidSiblingCount = scl.querySelector(
67-
`BDA[desc="invalidSiblingCount"`
67+
`BDA[desc="invalidSiblingCount"`,
6868
)!;
6969
const refMissingCount = scl.querySelector(`BDA[desc="missingRefArrayBDA"`)!;
7070
const refValidCount = scl.querySelector(`BDA[desc="refArrayBDA"`)!;
@@ -78,7 +78,7 @@ describe("Description for SCL schema type tAbstractDataAttribute", () => {
7878
it("returns property sAddr with existing sAddr attribute", () => {
7979
expect(describeDAorSDAorDAI(baseBDA)).to.have.property(
8080
"sAddr",
81-
"someSAddr"
81+
"someSAddr",
8282
);
8383
expect(describeDAorSDAorDAI(diffBDA1)).to.not.have.property("sAddr");
8484
});
@@ -97,7 +97,7 @@ describe("Description for SCL schema type tAbstractDataAttribute", () => {
9797
expect(describeDAorSDAorDAI(diffBDA1)).to.have.property("bType", "FLOAT32");
9898
expect(describeDAorSDAorDAI(missingBType)).to.have.property(
9999
"bType",
100-
"undefined"
100+
"undefined",
101101
);
102102
});
103103

@@ -115,7 +115,7 @@ describe("Description for SCL schema type tAbstractDataAttribute", () => {
115115

116116
expect(describeDAorSDAorDAI(refInvalidSiblingCount)).to.have.property(
117117
"count",
118-
0
118+
0,
119119
);
120120
});
121121

@@ -125,7 +125,7 @@ describe("Description for SCL schema type tAbstractDataAttribute", () => {
125125
expect(describeDAorSDAorDAI(baseBDA).type).to.satisfy(isDATypeDescription);
126126

127127
expect(describeDAorSDAorDAI(diffBDA2).type).to.satisfy(
128-
isEnumTypeDescription
128+
isEnumTypeDescription,
129129
);
130130
});
131131

@@ -138,11 +138,11 @@ describe("Description for SCL schema type tAbstractDataAttribute", () => {
138138

139139
it("returns same description with semantically equal BDA's", () =>
140140
expect(JSON.stringify(describeDAorSDAorDAI(baseBDA))).to.equal(
141-
JSON.stringify(describeDAorSDAorDAI(equalBDA))
141+
JSON.stringify(describeDAorSDAorDAI(equalBDA)),
142142
));
143143

144144
it("returns different description with unequal BDA elements", () =>
145145
expect(JSON.stringify(describeDAorSDAorDAI(baseBDA))).to.not.equal(
146-
JSON.stringify(describeDAorSDAorDAI(diffBDA2))
146+
JSON.stringify(describeDAorSDAorDAI(diffBDA2)),
147147
));
148148
});

describe/AbstractDataAttribute.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { NamingDescription, describeNaming } from "./Naming.js";
44
import { ValDescription, describeVal, compareBySGroup } from "./Val.js";
55

66
export function isAbstractDataAttributeDescription(
7-
type: any
7+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8+
type: any,
89
): type is AbstractDataAttributeDescription {
910
return (
1011
"bType" in type &&
@@ -37,7 +38,7 @@ function siblingCount(element: Element, name: string): number {
3738
if (!parent) return NaN;
3839

3940
const sibling = Array.from(parent.children).find(
40-
(child) => child.getAttribute("name") === name
41+
(child) => child.getAttribute("name") === name,
4142
);
4243
if (!sibling) return NaN;
4344

@@ -50,11 +51,11 @@ function siblingCount(element: Element, name: string): number {
5051
}
5152

5253
export function describeDAorSDAorDAI(
53-
element: Element
54+
element: Element,
5455
): AbstractDataAttributeDescription {
5556
const abstractDataAttributeDesc: AbstractDataAttributeDescription = {
5657
...describeNaming(element),
57-
bType: element.getAttribute("bType") || "undefined",
58+
bType: element.getAttribute("bType") ?? "undefined",
5859
valKind: "Set",
5960
valImport: false,
6061
count: 0,
@@ -94,10 +95,8 @@ export function describeDAorSDAorDAI(
9495
.sort(compareBySGroup);
9596

9697
const referencedType = Array.from(
97-
element.closest("DataTypeTemplates")?.children ?? []
98-
).find(
99-
(sibling) => sibling.getAttribute("id") === element.getAttribute("type")
100-
);
98+
element.closest("DataTypeTemplates")?.children ?? [],
99+
).find((sibling) => sibling.getAttribute("id") === type);
101100
if (
102101
abstractDataAttributeDesc.bType === "Enum" &&
103102
referencedType &&

describe/BaseElement.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const scl = new DOMParser().parseFromString(
5555
<EnumVal ord="13">SomeOtherContent</EnumVal>
5656
</EnumType>
5757
</SCL>`,
58-
"application/xml"
58+
"application/xml",
5959
);
6060

6161
const baseElement = scl.querySelector("#someEqual")!;
@@ -83,43 +83,43 @@ describe("Description for SCL element typed tBaseElement", () => {
8383
const attributes = describeBaseElement(baseElement).eNSAttributes;
8484
expect(attributes).to.not.be.undefined;
8585
expect(attributes["http://somevalidURI"]["ens:some"]).to.equal(
86-
"someOtherNamespace"
86+
"someOtherNamespace",
8787
);
8888
expect(
89-
attributes["http://www.iec.ch/61850/2003/SCLcoordinates"]["sxy:x"]
89+
attributes["http://www.iec.ch/61850/2003/SCLcoordinates"]["sxy:x"],
9090
).to.equal("1");
9191
expect(
92-
attributes["http://www.iec.ch/61850/2003/SCLcoordinates"]["sxy:y"]
92+
attributes["http://www.iec.ch/61850/2003/SCLcoordinates"]["sxy:y"],
9393
).to.equal("3");
9494
});
9595

9696
it("returns same description with semantically equal SCL element", () =>
9797
expect(JSON.stringify(describeBaseElement(baseElement))).to.equal(
98-
JSON.stringify(describeBaseElement(equalElement))
98+
JSON.stringify(describeBaseElement(equalElement)),
9999
));
100100

101101
it("returns different description with unequal extra namespace attributes", () =>
102102
expect(JSON.stringify(describeBaseElement(diffElement1))).to.not.equal(
103-
JSON.stringify(describeBaseElement(equalElement))
103+
JSON.stringify(describeBaseElement(equalElement)),
104104
));
105105

106106
it("returns different description with unequal Private child element", () =>
107107
expect(JSON.stringify(describeBaseElement(diffElement2))).to.not.equal(
108-
JSON.stringify(describeBaseElement(equalElement))
108+
JSON.stringify(describeBaseElement(equalElement)),
109109
));
110110

111111
it("returns different description with unequal Text child element", () =>
112112
expect(JSON.stringify(describeBaseElement(diffElement4))).to.not.equal(
113-
JSON.stringify(describeBaseElement(equalElement))
113+
JSON.stringify(describeBaseElement(equalElement)),
114114
));
115115

116116
it("returns different description with unequal Private child element order", () =>
117117
expect(JSON.stringify(describeBaseElement(diffElement3))).to.not.equal(
118-
JSON.stringify(describeBaseElement(equalElement))
118+
JSON.stringify(describeBaseElement(equalElement)),
119119
));
120120

121121
it("is insensitive to any attribute order", () =>
122122
expect(JSON.stringify(describeBaseElement(diffElement5))).to.equal(
123-
JSON.stringify(describeBaseElement(equalElement))
123+
JSON.stringify(describeBaseElement(equalElement)),
124124
));
125125
});

describe/BaseElement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface BaseElementDescription {
1313
}
1414

1515
function sortENsAttributes(
16-
eNsAttributes: ExtensionNSAttributes
16+
eNsAttributes: ExtensionNSAttributes,
1717
): ExtensionNSAttributes {
1818
return Object.keys(eNsAttributes)
1919
.sort()

describe/Control.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const scl = new DOMParser().parseFromString(
4242
</AccessPoint>
4343
</IED>
4444
</SCL>`,
45-
"application/xml"
45+
"application/xml",
4646
);
4747

4848
const baseDataSet = scl.querySelector(`*[datSet="baseDataSet"]`)!;
@@ -54,7 +54,7 @@ const invalidDataSet = scl.querySelector('*[datSet="invalidDataSet"]')!;
5454
const parentLessControl = new DOMParser()
5555
.parseFromString(
5656
`<ReportControl name="reportControl" datSet="parentLessDataSet" >`,
57-
"application/xml"
57+
"application/xml",
5858
)
5959
.querySelector("ReportControl")!;
6060

@@ -70,11 +70,11 @@ describe("Description for SCL schema type tControl", () => {
7070

7171
it("returns same description with semantically equal Control's", () =>
7272
expect(JSON.stringify(describeControl(baseDataSet))).to.equal(
73-
JSON.stringify(describeControl(equalDataSet))
73+
JSON.stringify(describeControl(equalDataSet)),
7474
));
7575

7676
it("returns different description with unequal Control elements", () =>
7777
expect(JSON.stringify(describeControl(baseDataSet))).to.not.equal(
78-
JSON.stringify(describeControl(diffDataSet))
78+
JSON.stringify(describeControl(diffDataSet)),
7979
));
8080
});

describe/Control.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface ControlDescription extends NamingDescription {
66
}
77

88
export function describeControl(
9-
element: Element
9+
element: Element,
1010
): ControlDescription | undefined {
1111
const datSet = element.getAttribute("datSet");
1212
if (!datSet) return { ...describeNaming(element) };
@@ -15,7 +15,7 @@ export function describeControl(
1515
(child) =>
1616
child.tagName === "DataSet" &&
1717
child.getAttribute("name") &&
18-
child.getAttribute("name") === datSet
18+
child.getAttribute("name") === datSet,
1919
);
2020
if (!dataSet) return;
2121

describe/ControlWithTriggerOpt.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const scl = new DOMParser().parseFromString(
4444
</AccessPoint>
4545
</IED>
4646
</SCL>`,
47-
"application/xml"
47+
"application/xml",
4848
);
4949

5050
const baseDataSet = scl.querySelector(`*[datSet="baseDataSet"]`)!;
@@ -62,11 +62,11 @@ describe("Description for SCL schema type tControlWithTriggerOpt", () => {
6262

6363
it("returns same description with semantically equal Control's", () =>
6464
expect(JSON.stringify(describeControlWithTriggerOpt(baseDataSet))).to.equal(
65-
JSON.stringify(describeControlWithTriggerOpt(equalDataSet))
65+
JSON.stringify(describeControlWithTriggerOpt(equalDataSet)),
6666
));
6767

6868
it("returns different description with unequal Control elements", () =>
6969
expect(
70-
JSON.stringify(describeControlWithTriggerOpt(baseDataSet))
70+
JSON.stringify(describeControlWithTriggerOpt(baseDataSet)),
7171
).to.not.equal(JSON.stringify(describeControlWithTriggerOpt(diffDataSet))));
7272
});

0 commit comments

Comments
 (0)