Skip to content

Commit 26f3ec5

Browse files
authored
Merge pull request #59 from aliasadidev/replace-xml-2-js-package
fix lint errors
2 parents 8ed953c + 47dc5b8 commit 26f3ec5

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/modules/js2xml.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { helper } from "./xml-helper.module";
1+
import { Helper } from "./xml-helper.module";
22

33
var currentElement: any, currentElementName: any;
4-
var h = new helper();
4+
var h = new Helper();
55

66
function validateOptions(userOptions: any) {
77
var options = h.copyOptions(userOptions);
@@ -98,7 +98,9 @@ function writeInstruction(instruction: any, options: any, depth: any) {
9898
return '<?' + instructionName + writeAttributes(instruction[key][options.attributesKey], options, depth) + '?>';
9999
} else {
100100
var instructionValue = instruction[key] ? instruction[key] : '';
101-
if ('instructionFn' in options) instructionValue = options.instructionFn(instructionValue, key, currentElementName, currentElement);
101+
if ('instructionFn' in options) {
102+
instructionValue = options.instructionFn(instructionValue, key, currentElementName, currentElement);
103+
}
102104
return '<?' + instructionName + (instructionValue ? ' ' + instructionValue : '') + '?>';
103105
}
104106
}
@@ -116,7 +118,9 @@ function writeDoctype(doctype: any, options: any) {
116118
}
117119

118120
function writeText(text: any, options: any) {
119-
if (options.ignoreText) return '';
121+
if (options.ignoreText) {
122+
return '';
123+
}
120124
text = '' + text; // ensure Number and Boolean are converted to String
121125
text = text.replace(/&amp;/g, '&'); // desanitize to avoid double sanitization
122126
text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');

src/modules/xml-helper.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export class helper {
1+
export class Helper {
22
public copyOptions(options: any) {
33
var key, copy: any = {};
44
for (key in options) {

src/modules/xml2js.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { helper } from "./xml-helper.module";
1+
import { Helper } from "./xml-helper.module";
22
var sax = require('sax');
33

44
var options: any;
55
var pureJsParser = true;
66

77
var currentElement: any;
88

9-
let h = new helper();
9+
let h = new Helper();
1010
function validateOptions(userOptions: any) {
1111
options = h.copyOptions(userOptions);
1212
h.ensureFlagExists('ignoreDeclaration', options);
@@ -142,11 +142,15 @@ function manipulateAttributes(attributes: any) {
142142
var key;
143143
for (key in attributes) {
144144
if (attributes.hasOwnProperty(key)) {
145-
if (options.trim) attributes[key] = attributes[key].trim();
145+
if (options.trim) {
146+
attributes[key] = attributes[key].trim();
147+
}
146148
if (options.nativeTypeAttributes) {
147149
attributes[key] = nativeType(attributes[key]);
148150
}
149-
if ('attributeValueFn' in options) attributes[key] = options.attributeValueFn(attributes[key], key, currentElement);
151+
if ('attributeValueFn' in options) {
152+
attributes[key] = options.attributeValueFn(attributes[key], key, currentElement);
153+
}
150154
if ('attributeNameFn' in options) {
151155
var temp = attributes[key];
152156
delete attributes[key];
@@ -199,7 +203,7 @@ function onInstruction(instruction: any) {
199203

200204
function onStartElement(name: any, attributes: any) {
201205
var element: any;
202-
var isSelfClosing = name?.isSelfClosing === true
206+
var isSelfClosing = name?.isSelfClosing === true;
203207
if (typeof name === 'object') {
204208
attributes = name.attributes;
205209
name = name.name;

0 commit comments

Comments
 (0)