Skip to content

Commit b34895a

Browse files
committed
build: fix lints
1 parent 721cc75 commit b34895a

File tree

6 files changed

+51
-28
lines changed

6 files changed

+51
-28
lines changed

.eslintrc.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
{
77
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
88
"rules": {
9-
"@typescript-eslint/no-unused-vars": "off",
109
"prefer-const": "warn",
10+
"@typescript-eslint/no-unused-vars": "off",
1111
"@nrwl/nx/enforce-module-boundaries": [
1212
"error",
1313
{
@@ -26,7 +26,9 @@
2626
{
2727
"files": ["*.ts", "*.tsx"],
2828
"extends": ["plugin:@nrwl/nx/typescript"],
29-
"rules": {}
29+
"rules": {
30+
"prefer-const": "warn"
31+
}
3032
},
3133
{
3234
"files": ["*.js", "*.jsx"],

package-lock.json

+17-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/feakin-exporter/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
"cheerio": "^1.0.0-rc.12",
77
"pako": "^2.0.4",
88
"xml-js": "^1.6.11"
9+
},
10+
"devDependencies": {
11+
"@types/pako": "^2.0.0"
912
}
1013
}

packages/feakin-exporter/src/target/mxgraph/mxgraph-encode.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ describe('MxGraphEncoder', () => {
55
it('should work', () => {
66
const sampleStr =
77
'<mxfile host="Electron" modified="2022-07-26T06:50:38.916Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/19.0.3 Chrome/102.0.5005.63 Electron/19.0.3 Safari/537.36" etag="S-i-T2jFARcjY2b3OQvQ" version="19.0.3" type="device"><diagram id="bN4dli3-ZhfTxRglmdzi" name="Page-1">jZJNT8QgEIZ/DUcTWlbdPdp11Rj1YA97NKSMhQRKw1Lb+uulduhHNpvsieGZD2begbC96Z4dr+W7FaBJSkVH2CNJ0yTdbcMxkH4k2106gtIpgUEzyNUvIKRIGyXgtAr01mqv6jUsbFVB4VeMO2fbddi31etXa17CGcgLrs/pUQkvcYpbOvMXUKWMLycUPYbHYAQnyYVtF4gdCNs7a/1omW4PehAv6jLmPV3wTo05qPw1CQ+feUk39r4zx+yL5R/ZK7zdYJUfrhscGJv1fVTA2aYSMBShhGWtVB7ymheDtw07D0x6o8MtCSaWA+ehu9hnMk0fvg1YA971IQQT2B0Khj9mw/DezvonUVS50D7mcVx5OZWeVQkGChOv8wL+fYtvzA5/</diagram></mxfile>';
8-
let data = MxGraphEncode.decodeXml(sampleStr);
8+
const data = MxGraphEncode.decodeXml(sampleStr);
99
expect(data?.startsWith('<mxGraphModel')).toBeTruthy();
1010
});
1111

1212
it('encode with decode', () => {
13-
let source = '<mxGraphModel><root><mxCell id="0"/></root></mxGraphModel>';
14-
let encoded = MxGraphEncode.encode(source);
15-
let decoded = MxGraphEncode.decode(encoded);
13+
const source = '<mxGraphModel><root><mxCell id="0"/></root></mxGraphModel>';
14+
const encoded = MxGraphEncode.encode(source);
15+
const decoded = MxGraphEncode.decode(encoded);
1616
expect(decoded).toEqual(source);
1717
});
1818

1919
it('text from hello world', () => {
2020
const sampleStr =
2121
'<mxfile host="Electron" modified="2022-07-26T12:42:39.225Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/19.0.3 Chrome/102.0.5005.63 Electron/19.0.3 Safari/537.36" etag="O1qmAbmb6dEBzrUx5KlV" version="19.0.3" type="device"><diagram id="bN4dli3-ZhfTxRglmdzi" name="Page-1">jZNNT4QwEIZ/i4ceTYDuh1cX190Y9SCHPZqGjrRJYbAUYf31lm270BgTL2T6vPPRzgyE5vV40KwVL8hBkSzhI6EPJMvWq9R+J3B2gG4zByotuUPpDAr5DR4mnvaSQxc5GkRlZBvDEpsGShMxpjUOsdsHqrhqyyr4BYqSqd/0JLkRjt6tk5kfQVYiVE4Tr9QsOHvQCcZxWCC6JzTXiMZZ9ZiDmnoX+uLiHv9QrxfT0Jj/BNy/FVWywu1Yn3bvtHjdPcHzrc/yxVTvH0yyjbL5dq0Ga1aTGVDXsmZqtWKd6+rms8eLMJsh5miLI8ly6z+gVvwmJLEXdHni3BZHFS8dM+cwBo19w2F6SWLlQUgDRcvKSR3s3lkmTK3sKb1GLzsTngnawLhAvlMHwBqMPlsXr9KNn5pf2xX152FegjRMViwWIMQxv3fVNfU8Gmv46YTjvAUXbfEr0f0P</diagram></mxfile>';
22-
let encoded = MxGraphEncode.decodeXml(sampleStr);
22+
const encoded = MxGraphEncode.decodeXml(sampleStr);
2323

24-
let xmlInJson: MxGraph = MxGraphEncode.xml2obj(encoded!);
25-
let mxCell = xmlInJson.mxGraphModel.root.mxCell;
24+
const xmlInJson: MxGraph = MxGraphEncode.xml2obj(encoded!);
25+
const mxCell = xmlInJson.mxGraphModel.root.mxCell;
2626

2727
expect(xmlInJson.mxGraphModel.root.mxCell.length).toBe(3);
2828
expect(mxCell[2].value!.includes('Hello, world!')).toBeTruthy();

packages/feakin-exporter/src/target/mxgraph/mxgraph-encode.ts

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import * as cheerio from 'cheerio';
2-
import { xml2json } from 'xml-js';
3-
4-
const convert = require('xml-js');
5-
6-
const pako = require('pako');
1+
import cheerio from 'cheerio';
2+
import * as convert from 'xml-js';
3+
import * as pako from 'pako';
74

85
const MxGraphEncode = {
96
xml2json: (xml: string) => {
107
return convert.xml2js(xml, {
118
compact: true,
12-
spaces: 4,
139
alwaysChildren: true,
1410
});
1511
},
1612
inlineAttrs: function (obj: any) {
17-
for (let prop in obj) {
13+
for (const prop in obj) {
1814
if (typeof obj[prop] == 'object') {
1915
if (obj[prop]._attributes) {
2016
Object.assign(obj[prop], obj[prop]._attributes);
@@ -34,9 +30,8 @@ const MxGraphEncode = {
3430
},
3531
decodeXml: (source: string) => {
3632
const $ = MxGraphEncode.parseXml(source);
37-
let mxfile = $('mxfile');
33+
const mxfile = $('mxfile');
3834
if (mxfile) {
39-
// @ts-ignore
4035
const diagrams = cheerio.text($('mxfile diagram'));
4136

4237
if (diagrams.length > 0) {
@@ -57,16 +52,15 @@ const MxGraphEncode = {
5752
},
5853
encode: (source: string) => {
5954
const data = encodeURIComponent(source);
60-
const compressed = pako.deflateRaw(data, { to: 'string' });
55+
const compressed = pako.deflateRaw(data);
6156
const base64 = btoa(MxGraphEncode.arrayBufferToString(compressed));
6257
return base64;
6358
},
6459
arrayBufferToString: (array: ArrayBuffer) => {
6560
let result = '';
66-
array = new Uint8Array(array);
67-
for (let c = array.byteLength, d = 0; d < c; d++) {
68-
// @ts-ignore
69-
result += String.fromCharCode(array[d]);
61+
const uint8Array = new Uint8Array(array);
62+
for (let c = uint8Array.byteLength, d = 0; d < c; d++) {
63+
result += String.fromCharCode(uint8Array[d]);
7064
}
7165
return result;
7266
},

tsconfig.base.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@
1010
"importHelpers": true,
1111
"target": "es2015",
1212
"module": "esnext",
13-
"lib": ["es2017", "dom"],
13+
"lib": [
14+
"es2017",
15+
"dom"
16+
],
1417
"skipLibCheck": true,
1518
"skipDefaultLibCheck": true,
1619
"baseUrl": "./feakin",
1720
"paths": {
18-
"@feakin/feakin-exporter": ["packages/feakin-exporter/src/index.ts"]
21+
"@feakin/feakin-exporter": [
22+
"packages/feakin-exporter/src/index.ts"
23+
]
1924
}
2025
},
21-
"exclude": ["feakin/node_modules", "tmp"]
26+
"exclude": [
27+
"feakin/node_modules",
28+
"tmp"
29+
]
2230
}

0 commit comments

Comments
 (0)