Skip to content

Commit

Permalink
chore: add commands for lint:fix, lint & update lint command to use f…
Browse files Browse the repository at this point in the history
…ormat && lint:fix, apply prettier changes

Signed-off-by: Sai Sankeerth <[email protected]>
  • Loading branch information
Sai Sankeerth committed Jan 19, 2024
1 parent f42d2f0 commit 05ca07e
Show file tree
Hide file tree
Showing 95 changed files with 48,388 additions and 48,403 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"plugin:@typescript-eslint/recommended",
"prettier"
],
"plugins": ["@typescript-eslint", "unicorn", "prettier"],
"plugins": ["@typescript-eslint", "unicorn"],
"globals": {},
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down Expand Up @@ -65,7 +65,6 @@
"sonarjs/no-identical-functions": "error",
"no-prototype-builtins": "off",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/no-unused-vars": "error",
"prettier/prettier": "error"
"@typescript-eslint/no-unused-vars": "error"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
if: ${{ inputs.build_type == 'dt' }}
run: |
docker buildx imagetools create -t rudderstack/rudder-transformer:latest ${{ inputs.push_tags }}-amd64 ${{ inputs.push_tags }}-arm64
- name: Create latest ut multi-arch manifest
# To be triggered only for release/hotfix PR merges coming from `prepare-for-prod-ut-deploy.yaml`
if: ${{ inputs.build_type == 'ut' }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/prepare-for-staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
secrets:
DOCKERHUB_PROD_TOKEN: ${{ secrets.DOCKERHUB_PROD_TOKEN }}


create-pull-request:
name: Update Helm Charts For Staging and Create Pull Request
runs-on: ubuntu-latest
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ jobs:

- name: Install Dependencies
run: npm ci

- name: Run Lint Checks
run: |
npm run lint
- run: git diff --exit-code

- name: Error message
if: ${{ failure() }}
run: echo 'Eslint check is failing Ensure you have run `npm run lint || npx eslint --fix . || npx eslint --fix <FILE_PATH>` and committed the files locally.'
run: |
echo 'Eslint check is failing Ensure you have run `npm run lint` and committed the files locally.'
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ test/**/*.js
!test/**/data.js
src/util/lodash-es-core.js
src/util/url-search-params.min.js
dist
2 changes: 1 addition & 1 deletion jest.default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
coverageDirectory: 'reports/coverage',

// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['/node_modules/', '__tests__', 'warehouse/v0' ,'test'],
coveragePathIgnorePatterns: ['/node_modules/', '__tests__', 'warehouse/v0', 'test'],

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: ['json', 'text', 'lcov', 'clover'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"setup": "npm ci",
"setup:swagger": "swagger-cli bundle swagger/api.yaml --outfile dist/swagger.json --type json",
"format": "prettier --write .",
"lint": "eslint . || exit 0",
"lint:fix": "eslint . --fix",
"lint:fix:json": "eslint --ext .json --fix .",
"lint": "npm run format && npm run lint:fix",
"check:merge": "npm run verify || exit 1; codecov",
"start": "cd dist;node ./src/index.js;cd ..",
"build:start": "npm run build && npm run start",
Expand Down
5 changes: 2 additions & 3 deletions src/adapters/networkHandlerFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ SUPPORTED_VERSIONS.forEach((version) => {
// },
// generic: GenericNetworkHandler,
// }
handlers[version][dest] = require(
`../${version}/destinations/${dest}/networkHandler`,
).networkHandler;
handlers[version][dest] =
require(`../${version}/destinations/${dest}/networkHandler`).networkHandler;
} catch {
// Do nothing as exception indicates
// network handler is not defined for that destination
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/bingads_audience/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ steps:
const response = $.defaultRequestConfig();
response.body.JSON = payload;
response
)
)
13 changes: 5 additions & 8 deletions src/cdk/v2/destinations/fullstory/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bindings:
exportAll: true
- name: removeUndefinedAndNullValues
path: ../../../../v0/util

steps:
- name: validateInput
template: |
Expand All @@ -28,7 +28,7 @@ steps:
$.context.payload.uid = .message.userId;
$.context.payload.email = .message.context.traits.email;
$.context.payload.display_name = .message.context.traits.name;
- name: trackPayload
condition: $.context.messageType == "track"
template: |
Expand All @@ -42,9 +42,9 @@ steps:
condition: $.context.messageType == "track"
template: |
$.assert(.message.event, "event is required for track call")
- name: mapContextFieldsForTrack
condition: $.context.messageType == "track"
condition: $.context.messageType == "track"
template: |
$.context.payload.context.browser = {
"url": .message.context.page.url,
Expand All @@ -67,7 +67,7 @@ steps:
"region": .message.properties.region,
"country": .message.properties.country,
};
- name: mapIdsForTrack
condition: $.context.messageType == "track"
template: |
Expand Down Expand Up @@ -99,6 +99,3 @@ steps:
"params": {},
"files": {}
})
1 change: 0 additions & 1 deletion src/cdk/v2/destinations/gladly/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bindings:
path: ../../../../adapters/network
- name: processAxiosResponse
path: ../../../../adapters/utils/networkUtils


steps:
- name: checkIfProcessed
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/gladly/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ steps:
)[]
- name: finalPayload
template: |
[...$.outputs.successfulEvents, ...$.outputs.failedEvents]
[...$.outputs.successfulEvents, ...$.outputs.failedEvents]
2 changes: 0 additions & 2 deletions src/cdk/v2/destinations/heap/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,3 @@ steps:
"Content-Type": "application/json"
};
response
1 change: 0 additions & 1 deletion src/cdk/v2/destinations/kochava/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ bindings:
- path: ../../bindings/jsontemplate
- path: ./config.js


steps:
- name: validateInput
template: |
Expand Down
3 changes: 1 addition & 2 deletions src/cdk/v2/destinations/lytics/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ steps:
$.context.payload._e = .message.event;
- name: pageOrScreenPayload
condition: $.context.messageType === {{$.EventType.PAGE}} ||
$.context.messageType === {{$.EventType.SCREEN}}
$.context.messageType === {{$.EventType.SCREEN}}
template: |
$.context.payload.event = .message.name
- name: cleanPaylod
Expand All @@ -66,4 +66,3 @@ steps:
"Content-Type": "application/json"
};
response
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@ steps:
},
"params": $.outputs.checkSendTestEventConfig,
"files": {}
})[]
})[]
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/pinterest_tag/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ steps:
If sendTestEvent is enabled, we send test event to the destination
ref: https://help.pinterest.com/en/business/article/track-conversions-with-the-conversions-api
template: |
^[0].destination.Config.sendAsTestEvent ? {"test": true} : {}
^[0].destination.Config.sendAsTestEvent ? {"test": true} : {}
- name: transform
externalWorkflow:
Expand Down
2 changes: 0 additions & 2 deletions src/cdk/v2/destinations/sprig/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,3 @@ steps:
"authorization": "API-Key " + .destination.Config.apiKey
};
response
1 change: 0 additions & 1 deletion src/cdk/v2/destinations/statsig/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ steps:
"content-type": "application/json"
};
response
2 changes: 0 additions & 2 deletions src/cdk/v2/destinations/tiktok_audience/procWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

bindings:
- name: EventType
path: ../../../../constants
Expand Down Expand Up @@ -48,7 +47,6 @@ steps:
"action": $.ACTION_MAP[action],
})[]
- name: buildResponseForProcessTransformation
description: build response
template: |
Expand Down
1 change: 0 additions & 1 deletion src/cdk/v2/destinations/zapier/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ steps:
"content-type": "application/json"
};
response
2 changes: 1 addition & 1 deletion src/controllers/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ControllerUtility {

private static convertSourceInputv0Tov1(sourceEvents: unknown[]): SourceInput[] {
return sourceEvents.map(
(sourceEvent) => ({ event: sourceEvent, source: undefined }) as SourceInput,
(sourceEvent) => ({ event: sourceEvent, source: undefined } as SourceInput),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/destination/nativeIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class NativeIntegrationDestinationService implements DestinationService {
error: JSON.stringify(v0Response.destinationResponse?.response),
statusCode: v0Response.status,
metadata,
}) as DeliveryJobState,
} as DeliveryJobState),
);
responseProxy = {
response: jobStates,
Expand Down
2 changes: 1 addition & 1 deletion src/services/userTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class UserTransformService {
statusCode: status,
metadata: e.metadata,
error: errorString,
}) as ProcessorTransformationResponse,
} as ProcessorTransformationResponse),
),
);
stats.counter('user_transform_errors', eventsToProcess.length, {
Expand Down
8 changes: 4 additions & 4 deletions src/util/customTransformer-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function userTransformHandlerV1(
testMode = false,
) {
if (!userTransformation.versionId) {
return { transformedEvents : events };
return { transformedEvents: events };

Check warning on line 58 in src/util/customTransformer-v1.js

View check run for this annotation

Codecov / codecov/patch

src/util/customTransformer-v1.js#L58

Added line #L58 was not covered by tests
}

const isolatevmFactory = await getFactory(
Expand Down Expand Up @@ -88,9 +88,9 @@ async function userTransformHandlerV1(
const tags = {
identifier: 'v1',
errored: transformationError ? true : false,
...events.length && events[0].metadata ? getMetadata(events[0].metadata) : {},
...events.length && events[0].metadata ? getTransformationMetadata(events[0].metadata) : {}
}
...(events.length && events[0].metadata ? getMetadata(events[0].metadata) : {}),
...(events.length && events[0].metadata ? getTransformationMetadata(events[0].metadata) : {}),
};
stats.counter('user_transform_function_input_events', events.length, tags);
stats.timing('user_transform_function_latency', invokeTime, tags);
}
Expand Down
6 changes: 3 additions & 3 deletions src/util/customTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ async function runUserTransform(
const tags = {
identifier: 'v0',
errored: transformationError ? true : false,
...events.length && events[0].metadata ? getMetadata(events[0].metadata) : {},
...events.length && events[0].metadata ? getTransformationMetadata(events[0].metadata) : {}
}
...(events.length && events[0].metadata ? getMetadata(events[0].metadata) : {}),
...(events.length && events[0].metadata ? getTransformationMetadata(events[0].metadata) : {}),
};

stats.counter('user_transform_function_input_events', events.length, tags);
stats.timing('user_transform_function_latency', invokeTime, tags);
Expand Down
24 changes: 4 additions & 20 deletions src/util/customTransformerFactory.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
const {
setOpenFaasUserTransform,
runOpenFaasUserTransform,
} = require('./customTransformer-faas');
const { setOpenFaasUserTransform, runOpenFaasUserTransform } = require('./customTransformer-faas');

const {
userTransformHandlerV1,
setUserTransformHandlerV1,
} = require('./customTransformer-v1');
const { userTransformHandlerV1, setUserTransformHandlerV1 } = require('./customTransformer-v1');

const UserTransformHandlerFactory = (userTransformation) => {
return {
Expand All @@ -23,20 +17,10 @@ const UserTransformHandlerFactory = (userTransformation) => {
switch (userTransformation.language) {
case 'pythonfaas':
case 'python':
return runOpenFaasUserTransform(
events,
userTransformation,
libraryVersionIds,
testMode
);
return runOpenFaasUserTransform(events, userTransformation, libraryVersionIds, testMode);

default:
return userTransformHandlerV1(
events,
userTransformation,
libraryVersionIds,
testMode
);
return userTransformHandlerV1(events, userTransformation, libraryVersionIds, testMode);
}
},
};
Expand Down
10 changes: 7 additions & 3 deletions src/util/ivmFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ async function evaluateModule(isolate, context, moduleCode) {
}

async function loadModule(isolateInternal, contextInternal, moduleName, moduleCode) {
const module = await isolateInternal.compileModule(moduleCode, { filename: `library ${moduleName}` });
const module = await isolateInternal.compileModule(moduleCode, {
filename: `library ${moduleName}`,
});
await module.instantiate(contextInternal, () => {});
return module;
}
Expand Down Expand Up @@ -256,7 +258,7 @@ async function createIvm(code, libraryVersionIds, versionId, secrets, testMode)
}
});

await jail.set('extractStackTrace', function(trace, stringLiterals) {
await jail.set('extractStackTrace', function (trace, stringLiterals) {
return extractStackTraceUptoLastSubstringMatch(trace, stringLiterals);
});

Expand Down Expand Up @@ -346,7 +348,9 @@ async function createIvm(code, libraryVersionIds, versionId, secrets, testMode)
// Now we can execute the script we just compiled:
const bootstrapScriptResult = await bootstrap.run(context);
// const customScript = await isolate.compileScript(`${library} ;\n; ${code}`);
const customScriptModule = await isolate.compileModule(`${codeWithWrapper}`, { filename: 'base transformation' });
const customScriptModule = await isolate.compileModule(`${codeWithWrapper}`, {
filename: 'base transformation',
});
await customScriptModule.instantiate(context, async (spec) => {
if (librariesMap[spec]) {
return compiledModules[spec].module;
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/adobe_analytics/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function escapeToHTML(inputString) {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
})[match],
}[match]),
);
}

Expand Down
Loading

0 comments on commit 05ca07e

Please sign in to comment.