Skip to content

Commit ac1eab4

Browse files
committed
Replace TSLint with ESLint (#1230)
>[!Note] > >This PR is against the `version-8` branch. ## Description TSLint has been EOL for several years. This replaces it with typeScript-eslint and provides a comparable configuration for minimal changes to the code. ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [ ] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.
1 parent 56df3f8 commit ac1eab4

File tree

11 files changed

+66
-33
lines changed

11 files changed

+66
-33
lines changed

eslint.config.mjs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import jestPlugin from 'eslint-plugin-jest';
6+
import n from 'eslint-plugin-n';
7+
8+
const ignores = [
9+
'**/*.snap',
10+
'coverage',
11+
'node_modules',
12+
'dist',
13+
'build',
14+
'lib',
15+
];
16+
17+
const tests = ['**/*.spec.{js,ts}'];
18+
19+
export default tseslint.config(
20+
{
21+
ignores,
22+
},
23+
{ linterOptions: { reportUnusedDisableDirectives: 'error' } },
24+
eslint.configs.recommended,
25+
tseslint.configs.recommended,
26+
n.configs['flat/recommended'],
27+
{
28+
rules: {
29+
'@typescript-eslint/no-explicit-any': 'off',
30+
'@typescript-eslint/no-unused-vars': 'off',
31+
'@typescript-eslint/no-require-imports': 'off',
32+
'n/no-missing-import': 'off',
33+
'n/no-unsupported-features/node-builtins': 'off',
34+
},
35+
},
36+
{
37+
files: tests,
38+
extends: [jestPlugin.configs['flat/recommended']],
39+
rules: {
40+
'no-undef': 'off',
41+
'jest/no-alias-methods': 'off',
42+
'jest/no-identical-title': 'off',
43+
'jest/no-disabled-tests': 'off',
44+
'jest/no-conditional-expect': 'off',
45+
'jest/valid-expect': 'off',
46+
},
47+
},
48+
);

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"scripts": {
3030
"clean": "rm -rf lib",
3131
"build": "tsc -p .",
32-
"lint": "tslint -p tsconfig.json -c tslint.json",
32+
"lint": "eslint",
3333
"test": "jest",
3434
"test:watch": "jest --watch",
3535
"test:worker": "jest src/worker.spec.ts",
@@ -45,19 +45,24 @@
4545
"qs": "6.14.0"
4646
},
4747
"devDependencies": {
48+
"@eslint/js": "^9.21.0",
4849
"@peculiar/webcrypto": "^1.4.5",
4950
"@types/jest": "29.5.3",
5051
"@types/node": "14.18.54",
5152
"@types/pluralize": "0.0.30",
53+
"@typescript-eslint/parser": "^8.25.0",
54+
"eslint": "^9.21.0",
55+
"eslint-plugin-jest": "^28.11.0",
56+
"eslint-plugin-n": "^17.15.1",
5257
"jest": "29.6.2",
5358
"jest-environment-miniflare": "^2.14.2",
5459
"jest-fetch-mock": "^3.0.3",
5560
"nock": "^13.5.5",
5661
"prettier": "2.8.8",
5762
"supertest": "6.3.3",
5863
"ts-jest": "29.1.3",
59-
"tslint": "6.1.3",
60-
"typescript": "5.1.6"
64+
"typescript": "5.1.6",
65+
"typescript-eslint": "^8.25.0"
6166
},
6267
"exports": {
6368
"types": "./lib/index.d.ts",

src/common/net/node-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ export class NodeHttpClientResponse
328328
_res: http_.IncomingMessage;
329329

330330
constructor(res: http_.IncomingMessage) {
331+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
331332
// @ts-ignore
332333
super(res.statusCode, res.headers || {});
333334
this._res = res;

src/common/utils/pagination.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { List, PaginationOptions } from '../interfaces';
22

33
export class AutoPaginatable<T> {
4-
readonly object: 'list' = 'list';
4+
readonly object = 'list' as const;
55
readonly options: PaginationOptions;
66

77
constructor(

src/common/utils/test-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fetch, { MockParams } from 'jest-fetch-mock';
22

33
export function fetchOnce(
4-
response: {} = {},
4+
response = {},
55
{ status = 200, headers, ...rest }: MockParams = {},
66
) {
77
return fetch.once(JSON.stringify(response), {

src/common/utils/unreachable.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
export const unreachable = (
1111
condition: never,
12-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1312
message = `Entered unreachable code. Received '${condition}'.`,
1413
): never => {
1514
throw new TypeError(message);

src/organizations/interfaces/create-organization-options.interface.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ export interface SerializedCreateOrganizationOptions {
3333
domains?: string[];
3434
}
3535

36-
export interface CreateOrganizationRequestOptions
37-
extends Pick<PostOptions, 'idempotencyKey'> {}
36+
export type CreateOrganizationRequestOptions = Pick<
37+
PostOptions,
38+
'idempotencyKey'
39+
>;

src/user-management/interfaces/refresh-and-seal-session-data.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export enum RefreshAndSealSessionDataFailureReason {
66
* @deprecated To be removed in a future major version.
77
*/
88
INVALID_SESSION_COOKE = 'invalid_session_cookie',
9+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
910
INVALID_SESSION_COOKIE = 'invalid_session_cookie',
1011
NO_SESSION_COOKIE_PROVIDED = 'no_session_cookie_provided',
1112

src/workos.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ describe('WorkOS', () => {
394394
const fetchFn = globalThis.fetch;
395395

396396
beforeEach(() => {
397-
// @ts-ignore
398-
delete globalThis.fetch;
397+
delete (globalThis as any).fetch;
399398
});
400399

401400
afterEach(() => {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3+
"baseUrl": ".",
34
"allowSyntheticDefaultImports": true,
45
"alwaysStrict": true,
56
"esModuleInterop": true,

0 commit comments

Comments
 (0)