mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Merge pull request #1049 from FredKSchott/eslint
Replace tslint (since deprecated) with eslint
This commit is contained in:
25
.eslintrc.json
Normal file
25
.eslintrc.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"mocha": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"no-useless-constructor": 0,
|
||||
"no-unused-vars": 0,
|
||||
"no-prototype-builtins": 0,
|
||||
"require-atomic-updates": 0
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "11.13.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.3.3",
|
||||
"@typescript-eslint/parser": "^2.3.3",
|
||||
"assert-diff": "^1.0.1",
|
||||
"doctoc": "^0.15.0",
|
||||
"ejs": "^2.3.4",
|
||||
"eslint": "^6.5.1",
|
||||
"eventemitter2": "^0.4.14",
|
||||
"gulp": "^4.0.2",
|
||||
"json-loader": "^0.5.2",
|
||||
@@ -46,8 +49,6 @@
|
||||
"source-map-support": "0.5.12",
|
||||
"ts-loader": "^3.2.0",
|
||||
"ts-node": "8.0.3",
|
||||
"tslint": "^5.8.0",
|
||||
"tslint-eslint-rules": "^4.1.1",
|
||||
"typescript": "^3.6.4",
|
||||
"uglifyjs-webpack-plugin": "^1.1.4",
|
||||
"webpack": "3.12.0"
|
||||
@@ -61,7 +62,7 @@
|
||||
"watch": "tsc -w",
|
||||
"prepublish": "npm run clean && npm run compile && npm run build",
|
||||
"test": "TS_NODE_PROJECT=src/tsconfig.json nyc mocha --exit",
|
||||
"lint": "tslint -p ./",
|
||||
"lint": "eslint src/**/*.ts 'test/*-test.{ts,js}'",
|
||||
"perf": "./scripts/perf_test.sh",
|
||||
"start": "node scripts/http.js"
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ function dropsToXrp(drops: string | BigNumber): string {
|
||||
if (typeof drops === 'string') {
|
||||
if (!drops.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
||||
throw new ValidationError(`dropsToXrp: invalid value '${drops}',` +
|
||||
` should be a number matching (^-?[0-9]*\.?[0-9]*$).`)
|
||||
` should be a number matching (^-?[0-9]*\\.?[0-9]*$).`)
|
||||
} else if (drops === '.') {
|
||||
throw new ValidationError(`dropsToXrp: invalid value '${drops}',` +
|
||||
` should be a BigNumber or string-encoded number.`)
|
||||
@@ -51,7 +51,7 @@ function xrpToDrops(xrp: string | BigNumber): string {
|
||||
if (typeof xrp === 'string') {
|
||||
if (!xrp.match(/^-?[0-9]*\.?[0-9]*$/)) {
|
||||
throw new ValidationError(`xrpToDrops: invalid value '${xrp}',` +
|
||||
` should be a number matching (^-?[0-9]*\.?[0-9]*$).`)
|
||||
` should be a number matching (^-?[0-9]*\\.?[0-9]*$).`)
|
||||
} else if (xrp === '.') {
|
||||
throw new ValidationError(`xrpToDrops: invalid value '${xrp}',` +
|
||||
` should be a BigNumber or string-encoded number.`)
|
||||
|
||||
@@ -147,17 +147,17 @@ describe('RippleAPI', function () {
|
||||
|
||||
assert.throws(() => {
|
||||
this.api.xrpToDrops('.')
|
||||
}, /xrpToDrops\: invalid value '\.', should be a BigNumber or string-encoded number\./)
|
||||
}, /xrpToDrops: invalid value '\.', should be a BigNumber or string-encoded number\./)
|
||||
})
|
||||
|
||||
it('throws with an amount more than one decimal point', function () {
|
||||
assert.throws(() => {
|
||||
this.api.xrpToDrops('1.0.0')
|
||||
}, /xrpToDrops:\ invalid\ value\ '1\.0\.0'\,\ should\ be\ a\ number\ matching\ \(\^\-\?\[0\-9\]\*\.\?\[0\-9\]\*\$\)\./)
|
||||
}, /xrpToDrops: invalid value '1\.0\.0', should be a number matching \(\^-\?\[0-9\]\*\.\?\[0-9\]\*\$\)\./)
|
||||
|
||||
assert.throws(() => {
|
||||
this.api.xrpToDrops('...')
|
||||
}, /xrpToDrops:\ invalid\ value\ '\.\.\.'\,\ should\ be\ a\ number\ matching\ \(\^\-\?\[0\-9\]\*\.\?\[0\-9\]\*\$\)\./)
|
||||
}, /xrpToDrops: invalid value '\.\.\.', should be a number matching \(\^-\?\[0-9\]\*\.\?\[0-9\]\*\$\)\./)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -261,17 +261,17 @@ describe('RippleAPI', function () {
|
||||
|
||||
assert.throws(() => {
|
||||
this.api.dropsToXrp('.')
|
||||
}, /dropsToXrp\: invalid value '\.', should be a BigNumber or string-encoded number\./)
|
||||
}, /dropsToXrp: invalid value '\.', should be a BigNumber or string-encoded number\./)
|
||||
})
|
||||
|
||||
it('throws with an amount more than one decimal point', function () {
|
||||
assert.throws(() => {
|
||||
this.api.dropsToXrp('1.0.0')
|
||||
}, /dropsToXrp:\ invalid\ value\ '1\.0\.0'\,\ should\ be\ a\ number\ matching\ \(\^\-\?\[0\-9\]\*\.\?\[0\-9\]\*\$\)\./)
|
||||
}, /dropsToXrp: invalid value '1\.0\.0', should be a number matching \(\^-\?\[0-9\]\*\.\?\[0-9\]\*\$\)\./)
|
||||
|
||||
assert.throws(() => {
|
||||
this.api.dropsToXrp('...')
|
||||
}, /dropsToXrp:\ invalid\ value\ '\.\.\.'\,\ should\ be\ a\ number\ matching\ \(\^\-\?\[0\-9\]\*\.\?\[0\-9\]\*\$\)\./)
|
||||
}, /dropsToXrp: invalid value '\.\.\.', should be a number matching \(\^-\?\[0-9\]\*\.\?\[0-9\]\*\$\)\./)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -311,7 +311,7 @@ describe('RippleAPI', function () {
|
||||
it('throws with an invalid secret', function (){
|
||||
assert.throws(() => {
|
||||
this.api.deriveKeypair('...');
|
||||
}, /^Error\: Non\-base58 character$/)
|
||||
}, /^Error: Non-base58 character$/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1364,7 +1364,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects promise and does not throw when field is missing', function (done) {
|
||||
@@ -1393,7 +1393,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects promise and does not throw when fee exceeds maxFeeXRP', function (done) {
|
||||
@@ -1427,7 +1427,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('preparePayment - XRP to XRP no partial', function (done) {
|
||||
@@ -1442,7 +1442,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('preparePayment - address must match payment.source.address', function (done) {
|
||||
@@ -1457,7 +1457,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('preparePayment - wrong amount', function (done) {
|
||||
@@ -1472,7 +1472,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('preparePayment - throws when fee exceeds 2 XRP', function (done) {
|
||||
@@ -1492,7 +1492,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1593,7 +1593,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareOrderCancellation', function () {
|
||||
@@ -1632,7 +1632,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareTrustline - simple', function () {
|
||||
@@ -1667,7 +1667,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareSettings', function () {
|
||||
@@ -1764,7 +1764,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareSettings - signers no weights', function () {
|
||||
@@ -1820,7 +1820,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareEscrowCreation', function () {
|
||||
@@ -1855,7 +1855,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareEscrowExecution', function () {
|
||||
@@ -1888,7 +1888,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareEscrowExecution - no fulfillment', function (done) {
|
||||
@@ -1903,7 +1903,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('prepareEscrowCancellation', function () {
|
||||
@@ -2507,7 +2507,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects Promise on preparePaymentChannelClaim with no signature', function (done) {
|
||||
@@ -2522,7 +2522,7 @@ describe('RippleAPI', function () {
|
||||
}).catch(done); // Finish test with assertion failure immediately instead of waiting for timeout.
|
||||
} catch (err) {
|
||||
done(new Error('Expected method to reject, but method threw. Thrown: ' + err));
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('sign', function () {
|
||||
|
||||
76
tslint.json
76
tslint.json
@@ -1,76 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"tslint-eslint-rules"
|
||||
],
|
||||
"rules": {
|
||||
"ban": [true, ["alert"]],
|
||||
"no-arg": true,
|
||||
"no-conditional-assignment": true,
|
||||
"no-console": false,
|
||||
"no-constant-condition": true,
|
||||
"no-control-regex": true,
|
||||
"no-debugger": true,
|
||||
"no-duplicate-case": true,
|
||||
"no-empty": true,
|
||||
"no-empty-character-class": true,
|
||||
"no-eval": true,
|
||||
"no-ex-assign": true,
|
||||
"no-extra-boolean-cast": true,
|
||||
"no-extra-semi": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-inner-declarations": [true, "functions"],
|
||||
"no-invalid-regexp": true,
|
||||
// this rule would cause problems with mocha test cases,
|
||||
"no-invalid-this": false,
|
||||
"no-irregular-whitespace": true,
|
||||
"ter-no-irregular-whitespace": true,
|
||||
"label-position": true,
|
||||
"indent": [true, "spaces", 2],
|
||||
"linebreak-style": [true, "unix"],
|
||||
"no-multi-spaces": true,
|
||||
"no-consecutive-blank-lines": [true, 2],
|
||||
"no-unused-expression": true,
|
||||
"no-construct": true,
|
||||
"no-duplicate-variable": true,
|
||||
"no-regex-spaces": true,
|
||||
"no-shadowed-variable": true,
|
||||
"ter-no-sparse-arrays": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-string-throw": true,
|
||||
"no-unexpected-multiline": true,
|
||||
"no-unused-variable": [true, {"ignore-pattern": "^_"}],
|
||||
"no-use-before-declare": true,
|
||||
"no-var-keyword": true,
|
||||
"no-magic-numbers": false,
|
||||
"array-bracket-spacing": [true, "never"],
|
||||
"ter-arrow-body-style": false,
|
||||
"ter-arrow-parens": [true, "as-needed"],
|
||||
"ter-arrow-spacing": true,
|
||||
"block-spacing": true,
|
||||
"brace-style": [true, "1tbs", {"allowSingleLine": true}],
|
||||
"variable-name": false,
|
||||
"trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
|
||||
"cyclomatic-complexity": [false, 11],
|
||||
"curly": [true, "all"],
|
||||
"switch-default": false,
|
||||
"eofline": true,
|
||||
"triple-equals": true,
|
||||
"forin": false,
|
||||
"handle-callback-err": true,
|
||||
"ter-max-len": [true, 120],
|
||||
"new-parens": true,
|
||||
"object-curly-spacing": [true, "never"],
|
||||
"object-literal-shorthand": false,
|
||||
"one-variable-per-declaration": [true, "ignore-for-loop"],
|
||||
"ter-prefer-arrow-callback": false,
|
||||
"prefer-const": true,
|
||||
"object-literal-key-quotes": false,
|
||||
"quotemark": [true, "single"],
|
||||
"radix": true,
|
||||
"semicolon": [true, "never"],
|
||||
"space-in-parens": [true, "never"],
|
||||
"comment-format": [true, "check-space"],
|
||||
"use-isnan": true,
|
||||
"valid-typeof": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user