From 51d44ccce8257a0addb9f302c4cef413ca5adef0 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Thu, 24 Oct 2024 18:00:55 +0100 Subject: [PATCH 1/2] refactor: replace `var` statements --- index.js | 12 ++++-------- lib/serializer.js | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 862c7c83..81132fd4 100644 --- a/index.js +++ b/index.js @@ -252,20 +252,16 @@ const numberKeywords = [ * https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6 */ function inferTypeByKeyword (schema) { - // eslint-disable-next-line - for (var keyword of objectKeywords) { + for (let keyword of objectKeywords) { if (keyword in schema) return 'object' } - // eslint-disable-next-line - for (var keyword of arrayKeywords) { + for (let keyword of arrayKeywords) { if (keyword in schema) return 'array' } - // eslint-disable-next-line - for (var keyword of stringKeywords) { + for (let keyword of stringKeywords) { if (keyword in schema) return 'string' } - // eslint-disable-next-line - for (var keyword of numberKeywords) { + for (let keyword of numberKeywords) { if (keyword in schema) return 'number' } return schema.type diff --git a/lib/serializer.js b/lib/serializer.js index 1a006d5f..df81960e 100644 --- a/lib/serializer.js +++ b/lib/serializer.js @@ -102,8 +102,7 @@ module.exports = class Serializer { let result = '' let last = -1 let point = 255 - // eslint-disable-next-line - for (var i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { point = str.charCodeAt(i) if ( point === 0x22 || // '"' From 3979ddd727b1767fbed181f2b2af3c3eb0c22a37 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Thu, 24 Oct 2024 18:04:48 +0100 Subject: [PATCH 2/2] chore: lint --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 81132fd4..2390c28a 100644 --- a/index.js +++ b/index.js @@ -252,16 +252,16 @@ const numberKeywords = [ * https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6 */ function inferTypeByKeyword (schema) { - for (let keyword of objectKeywords) { + for (const keyword of objectKeywords) { if (keyword in schema) return 'object' } - for (let keyword of arrayKeywords) { + for (const keyword of arrayKeywords) { if (keyword in schema) return 'array' } - for (let keyword of stringKeywords) { + for (const keyword of stringKeywords) { if (keyword in schema) return 'string' } - for (let keyword of numberKeywords) { + for (const keyword of numberKeywords) { if (keyword in schema) return 'number' } return schema.type