Skip to content

Commit 7902084

Browse files
author
Rik Smale
committed
chore: update to eslint 8
1 parent bdb8f9e commit 7902084

48 files changed

Lines changed: 388 additions & 445 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "airbnb-base",
3-
"parser": "babel-eslint",
3+
"parser": "@babel/eslint-parser",
44
"parserOptions": {
55
"ecmaVersion": 6,
66
"sourceType": "module"
@@ -14,13 +14,6 @@
1414
"rules": {
1515
"camelcase": 0,
1616
"no-param-reassign": 0,
17-
"one-var": 0,
18-
"one-var-declaration-per-line": 0,
19-
"func-names": 0,
20-
"no-console": 0,
21-
"newline-per-chained-call": 0,
22-
"prefer-const": 0,
23-
"linebreak-style": 0,
2417
"no-restricted-syntax": [2, "DebuggerStatement", "LabeledStatement", "WithStatement"],
2518
"no-restricted-globals": 0,
2619
"prefer-destructuring": 0,

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ jobs:
2020
uses: actions/checkout@v4
2121
- name: Install dependencies
2222
run: npm install --legacy-peer-deps
23+
- if: matrix.node-version == 22
24+
name: Run lint
25+
run: npm run lint
26+
- name: Run build
27+
run: npm run build
2328
- name: Run tests
24-
run: npm test
29+
run: npm run test:ci
2530
- if: matrix.node-version == 22
2631
name: Send coverage info to Codecov
2732
uses: codecov/codecov-action@v5

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
"@babel/core": "^7.0.0",
4141
"@babel/preset-env": "^7.0.0",
4242
"@babel/register": "^7.0.0",
43-
"babel-eslint": "^10.0.1",
43+
"@babel/eslint-parser": "^7.0.0",
4444
"babel-plugin-add-module-exports": "^1.0.0",
45-
"eslint": "^4.19.1",
46-
"eslint-config-airbnb-base": "^12.1.0",
45+
"eslint": "^8.57.1",
46+
"eslint-config-airbnb-base": "^15.0.0",
4747
"eslint-plugin-import": "^2.11.0",
4848
"mocha": "^6.2.3",
4949
"npm-run-all": "^4.1.5",
@@ -67,7 +67,8 @@
6767
"build:node": "babel src -d .",
6868
"build": "run-p build:*",
6969
"pretest": "npm run build && npm run lint",
70-
"test": "nyc --reporter=cobertura --reporter=text-summary mocha --require @babel/register --reporter dot --recursive"
70+
"test": "npm run test:ci",
71+
"test:ci": "nyc --reporter=cobertura --reporter=text-summary mocha --require @babel/register --reporter dot --recursive"
7172
},
7273
"engines": {
7374
"node": ">= 0.10"

src/lib/alpha.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export const alpha = {
3131
'vi-VN': /^[A-ZÀÁÃÂĂĐÈÉÊÌÍĨÒÓÕÔƠÙÚŨƯÝ]+$/i,
3232
'ko-KR': /^[---]*$/,
3333
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
34-
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
34+
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/, // eslint-disable-line no-misleading-character-class
3535
he: /^[א-ת]+$/,
3636
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
37-
bn: /^['ি']+$/,
37+
bn: /^['ি']+$/, // eslint-disable-line no-misleading-character-class
3838
eo: /^[ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
3939
'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i,
4040
'si-LK': /^[\u0D80-\u0DFF]+$/,
@@ -72,10 +72,10 @@ export const alphanumeric = {
7272
'ko-KR': /^[0-9---]*$/,
7373
'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
7474
'vi-VN': /^[0-9A-ZÀÁÃÂĂĐÈÉÊÌÍĨÒÓÕÔƠÙÚŨƯÝ]+$/i,
75-
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
75+
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/, // eslint-disable-line no-misleading-character-class
7676
he: /^[0-9א-ת]+$/,
7777
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
78-
bn: /^['ি']+$/,
78+
bn: /^['ি']+$/, // eslint-disable-line no-misleading-character-class
7979
eo: /^[0-9ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
8080
'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i,
8181
'si-LK': /^[0-9\u0D80-\u0DFF]+$/,
@@ -86,7 +86,6 @@ export const decimal = {
8686
ar: '٫',
8787
};
8888

89-
9089
export const englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
9190

9291
for (let locale, i = 0; i < englishLocales.length; i++) {

src/lib/isAscii.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import assertString from './util/assertString';
22

3-
/* eslint-disable no-control-regex */
4-
const ascii = /^[\x00-\x7F]+$/;
5-
/* eslint-enable no-control-regex */
3+
const ascii = /^[\x00-\x7F]+$/; // eslint-disable-line no-control-regex
64

75
export default function isAscii(str) {
86
assertString(str);

src/lib/isByteLength.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import assertString from './util/assertString';
22

3-
/* eslint-disable prefer-rest-params */
43
export default function isByteLength(str, options) {
54
assertString(str);
65
let min;
@@ -9,8 +8,8 @@ export default function isByteLength(str, options) {
98
min = options.min || 0;
109
max = options.max;
1110
} else { // backwards compatibility: isByteLength(str, min [, max])
12-
min = arguments[1];
13-
max = arguments[2];
11+
min = arguments[1]; // eslint-disable-line prefer-rest-params
12+
max = arguments[2]; // eslint-disable-line prefer-rest-params
1413
}
1514
const len = encodeURI(str).split(/%..|./).length - 1;
1615
return len >= min && (typeof max === 'undefined' || len <= max);

src/lib/isCreditCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function isCreditCard(card, options = {}) {
3434
} else if (provider && !(provider.toLowerCase() in cards)) {
3535
/* specific provider not in the list */
3636
throw new Error(`${provider} is not a valid credit card provider.`);
37-
} else if (!allCards.some(cardProvider => cardProvider.test(sanitized))) {
37+
} else if (!allCards.some((cardProvider) => cardProvider.test(sanitized))) {
3838
// no specific provider
3939
return false;
4040
}

src/lib/isCurrency.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ function currencyRegex(options) {
55
let decimal_digits = `\\d{${options.digits_after_decimal[0]}}`;
66
options.digits_after_decimal.forEach((digit, index) => { if (index !== 0) decimal_digits = `${decimal_digits}|\\d{${digit}}`; });
77

8-
const symbol =
9-
`(${options.symbol.replace(/\W/, m => `\\${m}`)})${(options.require_symbol ? '' : '?')}`,
10-
negative = '-?',
11-
whole_dollar_amount_without_sep = '[1-9]\\d*',
12-
whole_dollar_amount_with_sep = `[1-9]\\d{0,2}(\\${options.thousands_separator}\\d{3})*`,
13-
valid_whole_dollar_amounts = [
14-
'0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
15-
whole_dollar_amount = `(${valid_whole_dollar_amounts.join('|')})?`,
16-
decimal_amount = `(\\${options.decimal_separator}(${decimal_digits}))${options.require_decimal ? '' : '?'}`;
8+
const symbol = `(${options.symbol.replace(/\W/, (m) => `\\${m}`)})${(options.require_symbol ? '' : '?')}`;
9+
const negative = '-?';
10+
const whole_dollar_amount_without_sep = '[1-9]\\d*';
11+
const whole_dollar_amount_with_sep = `[1-9]\\d{0,2}(\\${options.thousands_separator}\\d{3})*`;
12+
const valid_whole_dollar_amounts = [
13+
'0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep];
14+
const whole_dollar_amount = `(${valid_whole_dollar_amounts.join('|')})?`;
15+
const decimal_amount = `(\\${options.decimal_separator}(${decimal_digits}))${options.require_decimal ? '' : '?'}`;
1716
let pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : '');
1817

1918
// default is negative sign before symbol, but there are two other options (besides parens)
@@ -53,7 +52,6 @@ function currencyRegex(options) {
5352
return new RegExp(`^(?!-? )(?=.*\\d)${pattern}$`);
5453
}
5554

56-
5755
const default_currency_options = {
5856
symbol: '$',
5957
require_symbol: false,

src/lib/isDataURI.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
88

99
export default function isDataURI(str) {
1010
assertString(str);
11-
let data = str.split(',');
11+
const data = str.split(',');
1212
if (data.length < 2) {
1313
return false;
1414
}
@@ -23,8 +23,8 @@ export default function isDataURI(str) {
2323
}
2424
for (let i = 0; i < attributes.length; i++) {
2525
if (
26-
!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') &&
27-
!validAttribute.test(attributes[i])
26+
!(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64')
27+
&& !validAttribute.test(attributes[i])
2828
) {
2929
return false;
3030
}

src/lib/isDate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function isValidFormat(format) {
1111
}
1212

1313
function zip(date, format) {
14-
const zippedArr = [],
15-
len = Math.max(date.length, format.length);
14+
const zippedArr = [];
15+
const len = Math.max(date.length, format.length);
1616

1717
for (let i = 0; i < len; i++) {
1818
zippedArr.push([date[i], format[i]]);
@@ -30,10 +30,10 @@ export default function isDate(input, options) {
3030
if (typeof input === 'string' && isValidFormat(options.format)) {
3131
if (options.strictMode && input.length !== options.format.length) return false;
3232
const formatDelimiter = options.delimiters
33-
.find(delimiter => options.format.indexOf(delimiter) !== -1);
33+
.find((delimiter) => options.format.indexOf(delimiter) !== -1);
3434
const dateDelimiter = options.strictMode
3535
? formatDelimiter
36-
: options.delimiters.find(delimiter => input.indexOf(delimiter) !== -1);
36+
: options.delimiters.find((delimiter) => input.indexOf(delimiter) !== -1);
3737
const dateAndFormat = zip(
3838
input.split(dateDelimiter),
3939
options.format.toLowerCase().split(formatDelimiter)

0 commit comments

Comments
 (0)