Skip to content

Commit 96cd9f6

Browse files
committed
wip: fix lints
1 parent 6e14182 commit 96cd9f6

26 files changed

+448
-305
lines changed

.mocharc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
process.env.TS_NODE_PROJECT = 'tsconfig.test.json';
2+
13
module.exports = {
24
exclude: '**/*.jest.spec.ts',
3-
require: 'ts-node/register',
5+
require: ['ts-node/register'],
46
timeout: '30000',
57
slow: '5000',
68
exit: true,
7-
require: 'ts-node.js',
89
'check-leaks': true,
910
};

eslint.config.mjs

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,68 @@
1-
// @ts-check
2-
31
import eslint from '@eslint/js';
4-
import tseslint from 'typescript-eslint';
5-
6-
import importPlugin from 'eslint-plugin-import';
7-
import chaiFriendly from 'eslint-plugin-chai-friendly';
8-
import mochaPlugin from 'eslint-plugin-mocha';
9-
import eslintConfigPrettier from 'eslint-config-prettier/flat';
2+
import tsPlugin from '@typescript-eslint/eslint-plugin';
3+
import tsParser from '@typescript-eslint/parser';
104

11-
export default tseslint.config(
5+
export default [
126
eslint.configs.recommended,
13-
tseslint.configs.recommended,
14-
mochaPlugin.configs.recommended,
15-
importPlugin.flatConfigs.recommended,
16-
chaiFriendly.configs.recommendedFlat,
17-
eslintConfigPrettier
18-
);
7+
{
8+
files: ['**/*.ts'],
9+
ignores: ['**/*.d.ts'],
10+
languageOptions: {
11+
parser: tsParser,
12+
globals: {
13+
// Node.js globals
14+
Buffer: 'readonly',
15+
require: 'readonly',
16+
module: 'writable',
17+
exports: 'writable',
18+
process: 'readonly',
19+
console: 'readonly',
20+
__dirname: 'readonly',
21+
__filename: 'readonly',
22+
// Test globals
23+
describe: 'readonly',
24+
context: 'readonly',
25+
it: 'readonly',
26+
before: 'readonly',
27+
after: 'readonly',
28+
beforeEach: 'readonly',
29+
afterEach: 'readonly',
30+
},
31+
},
32+
plugins: {
33+
'@typescript-eslint': tsPlugin,
34+
},
35+
rules: {
36+
'no-unused-vars': 'off',
37+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
38+
'@typescript-eslint/no-explicit-any': 'warn',
39+
'no-redeclare': 'off',
40+
},
41+
},
42+
{
43+
files: ['**/*.js'],
44+
languageOptions: {
45+
sourceType: 'commonjs',
46+
globals: {
47+
module: 'writable',
48+
exports: 'writable',
49+
require: 'readonly',
50+
Buffer: 'readonly',
51+
console: 'readonly',
52+
process: 'readonly',
53+
__dirname: 'readonly',
54+
__filename: 'readonly',
55+
describe: 'readonly',
56+
context: 'readonly',
57+
it: 'readonly',
58+
before: 'readonly',
59+
after: 'readonly',
60+
beforeEach: 'readonly',
61+
afterEach: 'readonly',
62+
},
63+
},
64+
rules: {
65+
'no-unused-vars': ['error', { varsIgnorePattern: '^(VERIFY_PROVIDER_RESPONSE|FfiFunctionResult|FfiLogLevelFilter|FnValidationStatus)$' }],
66+
},
67+
},
68+
];

package-lock.json

Lines changed: 42 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"eslint-plugin-import": "2.31.0",
8686
"eslint-plugin-mocha": "11.1.0",
8787
"express": "5.1.0",
88-
"form-data": "4.0.3",
88+
"form-data": "^4.0.4",
8989
"globals": "^16.2.0",
9090
"grpc-promise": "1.4.0",
9191
"mocha": "11.6.0",

src/consumer/checkErrors.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type BooleanFunctions<T> = {
2626
export const wrapAllWithCheck = <T extends BooleanFunctions<T>>(
2727
o: T
2828
): BooleanFunctions<T> =>
29-
Object.keys(o)
30-
.map((key: string) => ({
31-
[key]: wrapWithCheck(o[key], key),
29+
(Object.keys(o) as Array<keyof T>)
30+
.map((key: keyof T) => ({
31+
[key]: wrapWithCheck(o[key] as BooleanFunction<T[keyof T]>, String(key)),
3232
}))
3333
.reduce((acc, curr) => ({ ...acc, ...curr }), {}) as T;

src/consumer/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ export const makeConsumerPact = (
9494
`${address}:${requestedPort || 0}`,
9595
tls
9696
);
97-
const error: keyof typeof CREATE_MOCK_SERVER_ERRORS | undefined =
98-
Object.keys(CREATE_MOCK_SERVER_ERRORS).find(
99-
(key) => CREATE_MOCK_SERVER_ERRORS[key] === port
100-
) as keyof typeof CREATE_MOCK_SERVER_ERRORS;
97+
const error: keyof typeof CREATE_MOCK_SERVER_ERRORS | undefined = (
98+
Object.keys(CREATE_MOCK_SERVER_ERRORS) as Array<
99+
keyof typeof CREATE_MOCK_SERVER_ERRORS
100+
>
101+
).find((key) => CREATE_MOCK_SERVER_ERRORS[key] === port);
101102
if (error) {
102103
if (error === 'ADDRESS_NOT_VALID') {
103104
logErrorAndThrow(

src/ffi/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function getPlatformArchSpecificPackage() {
4343
resolvedPackagePath = resolvedPackagePath.replace('/package.json', '');
4444
}
4545
return resolvedPackagePath;
46-
} catch (e) {
46+
} catch {
4747
throw new Error(
4848
`Couldn't find npm package ${platformArchSpecificPackage} \n 💡 you can tell Pact where the npm package is located with env var $PACT_PREBUILD_PACKAGE_LOCATION`
4949
);
@@ -151,7 +151,7 @@ const initialiseFfi = (): typeof ffi => {
151151
return false;
152152
}
153153
return true;
154-
} catch (error) {
154+
} catch {
155155
return true;
156156
}
157157
});

src/ffi/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type FfiMessageHandle = number;
88
// TODO: Replace this pattern of type + const + lint disable with enums
99

1010
export type FfiSpecificationVersion = 0 | 1 | 2 | 3 | 4 | 5;
11-
11+
1212
export const FfiSpecificationVersion: Record<string, FfiSpecificationVersion> =
1313
{
1414
SPECIFICATION_VERSION_UNKNOWN: 0,
@@ -20,7 +20,7 @@ export const FfiSpecificationVersion: Record<string, FfiSpecificationVersion> =
2020
};
2121

2222
export type FfiWritePactResponse = 0 | 1 | 2 | 3;
23-
23+
2424
export const FfiWritePactResponse: Record<string, FfiWritePactResponse> = {
2525
SUCCESS: 0,
2626
GENERAL_PANIC: 1,
@@ -29,7 +29,7 @@ export const FfiWritePactResponse: Record<string, FfiWritePactResponse> = {
2929
};
3030

3131
export type FfiWriteMessagePactResponse = 0 | 1 | 2;
32-
32+
3333
export const FfiWriteMessagePactResponse: Record<
3434
string,
3535
FfiWriteMessagePactResponse
@@ -40,7 +40,7 @@ export const FfiWriteMessagePactResponse: Record<
4040
};
4141

4242
export type FfiConfigurePluginResponse = 0 | 1 | 2 | 3;
43-
43+
4444
export const FfiConfigurePluginResponse: Record<
4545
string,
4646
FfiConfigurePluginResponse
@@ -52,7 +52,7 @@ export const FfiConfigurePluginResponse: Record<
5252
};
5353

5454
export type FfiPluginInteractionResponse = 0 | 1 | 2 | 3 | 4 | 5 | 6;
55-
55+
5656
export const FfiPluginInteractionResponse: Record<
5757
string,
5858
FfiPluginInteractionResponse
@@ -87,7 +87,7 @@ export const CREATE_MOCK_SERVER_ERRORS = {
8787
-5 The address is not valid
8888
-6 Could not create the TLS configuration with the self-signed certificate
8989
*/
90-
90+
9191
export enum VERIFY_PROVIDER_RESPONSE {
9292
VERIFICATION_SUCCESSFUL = 0,
9393
VERIFICATION_FAILED,

src/index.spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import * as chai from 'chai';
2-
import index from './index';
1+
import { expect } from 'chai';
2+
import pact from './index';
33

4-
const { expect } = chai;
5-
6-
describe('Index Spec', function() {
7-
it('Typescript import should work', function() {
8-
expect(index).to.be.ok;
4+
describe('Index Spec', function () {
5+
it('Typescript import should work', function () {
6+
expect(pact).to.be.ok;
97
});
108
});

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pact from './pact';
22

3-
43
module.exports = exports = pact;
54

65
export default pact;

0 commit comments

Comments
 (0)