Skip to content

Commit e83db29

Browse files
lancefabiojose
authored andcommitted
chore: update eslint rules to disallow var usage
Enforce the use of `let` and `const` by using elsint rules. When creating the eslint configuration, I had assumed that `extends: eslint:recommended` would have covered this, but apparently not! Existing usage of `var` fixed with `npm run lint -- --fix`. Fixes: cloudevents#97 Signed-off-by: Lance Ball <[email protected]>
1 parent 42246ce commit e83db29

File tree

11 files changed

+244
-243
lines changed

11 files changed

+244
-243
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"mocha": true
77
},
88
"rules": {
9+
"no-var": "error",
910
"space-before-function-paren": ["error", "never"],
1011
"standard/no-callback-literal": "off",
1112
"arrow-spacing": "error",

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
var Cloudevent = require("./lib/cloudevent.js");
1+
const Cloudevent = require("./lib/cloudevent.js");
22

33
module.exports = Cloudevent;

lib/formats/json/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const asJSON = (v) => (isString(v) ? JSON.parse(v) : v);
1919

2020
// Level 0 of validation: is that string? is that JSON?
2121
function validateAndParse(payload) {
22-
var json =
22+
const json =
2323
Array.of(payload)
2424
.filter((p) => isDefinedOrThrow(p, nullOrIndefinedPayload))
2525
.filter((p) => isStringOrObjectOrThrow(p, invalidPayloadTypeError))

lib/specs/spec_1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function Spec1(_caller) {
109109
* Check the spec constraints
110110
*/
111111
Spec1.prototype.check = function(ce) {
112-
var toCheck = (!ce ? this.payload : ce);
112+
const toCheck = (!ce ? this.payload : ce);
113113

114114
if (!isValidAgainstSchema(toCheck)) {
115115
const err = new TypeError("invalid payload");

0 commit comments

Comments
 (0)