Skip to content

Commit 541e777

Browse files
committed
refactor: using var instead of let/const to be ES5 compatiability like other rules
1 parent 4c64ecb commit 541e777

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

lib/rules/sequentialChars.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const _ = require('../helper');
1+
var _ = require('../helper');
22

33
/**
44
* @readonly
55
* @enum {number}
66
*/
7-
const Direction = {
7+
var Direction = {
88
Ascending: 1,
99
Descending: -1,
1010
None: 0
@@ -14,7 +14,7 @@ const Direction = {
1414
* @readonly
1515
* @enum {number}
1616
*/
17-
const CharacterCodes = {
17+
var CharacterCodes = {
1818
LowerCaseA: 'a'.charCodeAt(0),
1919
LowerCaseZ: 'z'.charCodeAt(0),
2020
Zero: '0'.charCodeAt(0),
@@ -57,20 +57,20 @@ function assert(options, password) {
5757
return false;
5858
}
5959

60-
let prevCode = password.charCodeAt(0);
61-
let seqLen = isAlphanumeric(prevCode) ? 1 : 0;
62-
let currentDirection = Direction.None;
60+
var prevCode = password.charCodeAt(0);
61+
var seqLen = isAlphanumeric(prevCode) ? 1 : 0;
62+
var currentDirection = Direction.None;
6363

64-
for (let i = 1; i < password.length; i++) {
65-
const currentCode = password.charCodeAt(i);
64+
for (var i = 1; i < password.length; i++) {
65+
var currentCode = password.charCodeAt(i);
6666
if (!isAlphanumeric(currentCode) || !isAlphanumeric(prevCode)) {
6767
currentDirection = Direction.None;
6868
seqLen = 1;
6969
prevCode = currentCode;
7070
continue;
7171
}
7272

73-
const diff = currentCode - prevCode;
73+
var diff = currentCode - prevCode;
7474
prevCode = currentCode;
7575

7676
if (diff === Direction.Ascending || diff === Direction.Descending) {
@@ -100,11 +100,11 @@ function assert(options, password) {
100100
* @return {boolean}
101101
*/
102102
function explain(options, verified) {
103-
let example = '';
104-
for (let i = 0; i < options.max + 1; i++) {
103+
var example = '';
104+
for (var i = 0; i < options.max + 1; i++) {
105105
example += String.fromCharCode('a'.charCodeAt(0) + i);
106106
}
107-
const d = {
107+
var d = {
108108
message: 'No more than %d sequential alphanumeric characters (e.g., "%s" not allowed)', // updated
109109
code: 'sequentialChars',
110110
format: [options.max, example]

test/rules/sequentialChars.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const expect = require('chai').expect;
1+
var expect = require('chai').expect;
22

3-
const sequentialChars = require('../../lib/rules/sequentialChars');
3+
var sequentialChars = require('../../lib/rules/sequentialChars');
44

55
function sequentialCharsMessage(x, verified) {
6-
let example = '';
7-
for (let i = 0; i < x + 1; i++) {
6+
var example = '';
7+
for (var i = 0; i < x + 1; i++) {
88
example += String.fromCharCode('a'.charCodeAt(0) + i);
99
}
10-
const msg = 'No more than %d sequential alphanumeric characters (e.g., "%s" not allowed)'; // updated wording
11-
const d = {message: msg, format: [x, example], code: 'sequentialChars'};
10+
var msg = 'No more than %d sequential alphanumeric characters (e.g., "%s" not allowed)'; // updated wording
11+
var d = {message: msg, format: [x, example], code: 'sequentialChars'};
1212
if (verified !== undefined) {
1313
d.verified = verified;
1414
}

0 commit comments

Comments
 (0)