Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v24
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig, globalIgnores } from "eslint/config";
import braintreeClientConfig from "eslint-config-braintree/client";

export default defineConfig([
globalIgnores(["**/dist/", "**/dist-app/"]),
...braintreeClientConfig.default,
{
languageOptions: {
globals: {
define: true,
},
},
},
]);
16,191 changes: 5,681 additions & 10,510 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"prestart": "npm run build:app",
"start": "node ./test/support/server.js",
"development": "npm start & chokidar 'src/lib/**/*.ts' -c 'npm run build:app; echo $(tput setaf 2)rebuilt$(tput sgr0)'",
"lint": "eslint --ext js,ts src test",
"lint": "eslint src test",
"posttest": "npm run lint",
"test": "npm run test:unit",
"test:watch": "jest --watchAll",
Expand All @@ -44,28 +44,29 @@
"prepublishOnly": "npm run build && npm run build:app"
},
"dependencies": {
"@braintree/browser-detection": "^1.17.2"
"@braintree/browser-detection": "^2.1.1"
},
"devDependencies": {
"@playwright/test": "^1.58.0",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"browserify": "^17.0.0",
"browserstack-local": "^1.5.4",
"@playwright/test": "^1.58.2",
"@types/jest": "^30.0.0",
"@typescript-eslint/eslint-plugin": "^8.56.0",
"browserify": "^17.0.1",
"browserstack-local": "^1.5.10",
"chokidar-cli": "^3.0.0",
"dotenv": "^16.3.1",
"eslint": "^8.47.0",
"eslint-config-braintree": "^6.0.0-typescript-prep-rc.2",
"eslint-plugin-prettier": "^4.2.1",
"express": "^4.18.2",
"jest": "^29.6.3",
"jest-environment-jsdom": "^29.6.3",
"jsdoc": "^4.0.2",
"playwright": "^1.58.0",
"prettier": "^2.8.8",
"ts-jest": "^29.1.1",
"dotenv": "^17.3.1",
"eslint": "^9.39.2",
"eslint-config-braintree": "^7.0.1",
"eslint-plugin-prettier": "^5.5.5",
"express": "^5.2.1",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"jest-util": "^30.2.0",
"jsdoc": "^4.0.5",
"playwright": "^1.58.2",
"prettier": "^3.8.1",
"ts-jest": "^29.4.6",
"tsify": "^5.0.4",
"typescript": "^5.1.6"
"typescript": "^5.9.3"
},
"jest": {
"testEnvironment": "jsdom",
Expand Down
7 changes: 4 additions & 3 deletions src/lib/formatter/parse-pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PLACEHOLDER_PATTERN = "({{[^}]+}})";
const PERMACHAR_REGEX = "(\\s|\\S)";
const PATTERN_REGEX = new RegExp(
PLACEHOLDER_PATTERN + "|" + PERMACHAR_REGEX,
"g"
"g",
);
const PLACEHOLDER_PATTERN_REGEX = new RegExp("^" + PLACEHOLDER_PATTERN + "$");
const replacerRegex = new RegExp("{|}", "g");
Expand All @@ -28,7 +28,8 @@ function isAlpha(char: string): boolean {
function createRegexForChar(char: string): RegExp {
if (isDigit(char)) {
return DIGIT_REGEX;
} else if (isAlpha(char)) {
}
if (isAlpha(char)) {
return ALPHA_REGEX;
}

Expand Down Expand Up @@ -61,7 +62,7 @@ export function parsePattern(patternString: string): Pattern[] {

if (!isPlaceholder(placeholderChar)) {
throw new Error(
"Only alphanumeric or wildcard pattern matchers are allowed"
"Only alphanumeric or wildcard pattern matchers are allowed",
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/key-cannot-mutate-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function keyCannotMutateValue(event: KeyboardEvent): boolean {

// https://www.w3.org/TR/DOM-Level-3-Events/#widl-KeyboardEvent-key
switch (event.key) {
case undefined: // eslint-disable-line
case undefined:
case "Unidentified": // Cannot be determined
case "": // Uninitialized
break;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/strategies/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { isBackspace } from "../is-backspace";
import { isDelete } from "../is-delete";
import { PatternFormatter as Formatter, FormatMetadata } from "../formatter";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare global {
interface Window {
clipboardData: {
// eslint-disable-next-line no-unused-vars
getData: (text: string) => string;
};
}
Expand Down Expand Up @@ -151,7 +151,7 @@ export class BaseStrategy extends StrategyInterface {
setSelection(
input,
formattedState.selection.start,
formattedState.selection.end
formattedState.selection.end,
);

this.afterReformatInput(formattedState);
Expand Down Expand Up @@ -183,7 +183,7 @@ export class BaseStrategy extends StrategyInterface {
setSelection(
input,
unformattedState.selection.start,
unformattedState.selection.end
unformattedState.selection.end,
);
}

Expand Down Expand Up @@ -218,7 +218,7 @@ export class BaseStrategy extends StrategyInterface {
splicedEntry.splice(
selection.start,
selection.end - selection.start,
entryValue
entryValue,
);
splicedEntry = splicedEntry.join("");

Expand All @@ -232,7 +232,7 @@ export class BaseStrategy extends StrategyInterface {
setSelection(
this.inputElement,
selection.start + entryValue.length,
selection.start + entryValue.length
selection.start + entryValue.length,
);

this.postPasteEventHandler();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/strategies/ie9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class IE9Strategy extends BaseStrategy {
setSelection(
input,
formattedState.selection.start,
formattedState.selection.end
formattedState.selection.end,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/strategies/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class IosStrategy extends BaseStrategy {
setSelection(
input,
formattedState.selection.start,
formattedState.selection.end
formattedState.selection.end,
);
}

Expand Down
10 changes: 0 additions & 10 deletions test/.eslintrc

This file was deleted.

17 changes: 17 additions & 0 deletions test/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from "eslint/config";
import globals from "globals";

export default defineConfig([{
files: ["**/*.test.{ts,tsx}"],
languageOptions: {
globals: {
...globals.mocha,
...globals.jest,
},
},

rules: {
"no-invalid-this": 0,
"no-unused-expressions": 0,
},
}]);
6 changes: 0 additions & 6 deletions test/integration/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion test/integration/browserstack-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function startBrowserStackLocal(): Promise<void> {
return reject(error);
}
console.log(
`BrowserStack Local connected with localIdentifier=${localIdentifier}`
`BrowserStack Local connected with localIdentifier=${localIdentifier}`,
);
return resolve();
});
Expand Down
10 changes: 10 additions & 0 deletions test/integration/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "eslint/config";

export default defineConfig([{
languageOptions: {
globals: {
$: false,
browser: false,
},
},
}]);
4 changes: 2 additions & 2 deletions test/integration/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ module.exports = defineConfig({
channel: browser.browserName === "edge" ? "msedge" : "chrome",
connectOptions: {
wsEndpoint: `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(
JSON.stringify(getCaps(browser))
JSON.stringify(getCaps(browser)),
)}`,
},
},
})
}),
) as PlaywrightTestProject[],
webServer: {
command: "npm start",
Expand Down
6 changes: 3 additions & 3 deletions test/integration/restricted-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test.describe("Restricted Input", () => {

await input.fill("");
await input.pressSequentially(
"a12bcdef3ghh4ij56klmn7opqr8stuv9wx0yz !123@#$4%^&*()_=+56"
"a12bcdef3ghh4ij56klmn7opqr8stuv9wx0yz !123@#$4%^&*()_=+56",
);
const value = await input.inputValue();

Expand Down Expand Up @@ -364,7 +364,7 @@ test.describe("Restricted Input", () => {

await input.fill("");
await input.pressSequentially(
"a12bcdef3ghh4ij56klmn7opqr8stuv9wx0yz !123@#$4%^&*()_=+5"
"a12bcdef3ghh4ij56klmn7opqr8stuv9wx0yz !123@#$4%^&*()_=+5",
);
const value = await input.inputValue();

Expand Down Expand Up @@ -679,7 +679,7 @@ test.describe("Restricted Input", () => {

await input.fill("");
await input.pressSequentially(
"a12bcdef3ghh4ij56klmn7opqr8stuv9wx0yz !123@#$4%^&*()_=+56"
"a12bcdef3ghh4ij56klmn7opqr8stuv9wx0yz !123@#$4%^&*()_=+56",
);
const value = await input.inputValue();

Expand Down
3 changes: 0 additions & 3 deletions test/support/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-console */
const express = require("express");
const path = require("path");
const app = express();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/device.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe("device", function () {

it("returns false for Android webviews with newer builds of Chrome", function () {
expect(isKitKatWebview(AGENTS.androidWebviewLollipopAndAbove)).toBe(
false
false,
);
});

Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/formatter/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe("Formatter", function () {
};

expect(formatter.format(options).value).toBe(expectedResult);
}
},
);
});

Expand Down
8 changes: 4 additions & 4 deletions test/unit/lib/formatter/parse-pattern.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("parsePattern", function () {
"creates a regex for digits with %s",
(digit) => {
expect(parsePattern("{{" + digit + "}}")[0].value).toEqual(/\d/);
}
},
);
});

Expand All @@ -37,9 +37,9 @@ describe("parsePattern", function () {
"creates a regex for non-digits with %s",
(character) => {
expect(parsePattern("{{" + character + "}}")[0].value).toEqual(
/[A-Za-z]/
/[A-Za-z]/,
);
}
},
);
});

Expand Down Expand Up @@ -72,7 +72,7 @@ describe("parsePattern", function () {
expect(function () {
parsePattern(pattern);
}).toThrowError(
"Only alphanumeric or wildcard pattern matchers are allowed"
"Only alphanumeric or wildcard pattern matchers are allowed",
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/input-selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("getCurrentSelection", function () {
end: 23,
delta: 13,
});
}
},
);
});
});
13 changes: 6 additions & 7 deletions test/unit/lib/is-backspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ import { isBackspace } from "../../../src/lib/is-backspace";
describe("isBackspace()", function () {
it('returns true if key is "Backspace"', function () {
expect(isBackspace(new KeyboardEvent("keyup", { key: "Backspace" }))).toBe(
true
true,
);
});

it("returns true if keyCode is 8", function () {
expect(
isBackspace(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new KeyboardEvent("keyup", { key: "Not Backspace", keyCode: 8 } as any)
)
new KeyboardEvent("keyup", { key: "Not Backspace", keyCode: 8 } as any),
),
).toBe(true);
});

it('returns false if key is not "Backspace" and keyCode is not 8', function () {
expect(
isBackspace(new KeyboardEvent("keyup", { key: "Not Backspace" }))
isBackspace(new KeyboardEvent("keyup", { key: "Not Backspace" })),
).toBe(false);
// eslint-disable-next-line @typescript-eslint/no-explicit-any

expect(isBackspace(new KeyboardEvent("keyup", { keyCode: 0 } as any))).toBe(
false
false,
);
});
});
Loading
Loading