Skip to content

Commit d17b96f

Browse files
authored
style: move to Biome for linting (#3648)
2 parents cf18353 + 5f31671 commit d17b96f

File tree

274 files changed

+2013
-5301
lines changed

Some content is hidden

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

274 files changed

+2013
-5301
lines changed

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/run-distributed-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
- id: generate-matrix
4848
run: |
4949
RESULT=$(node .github/workflows/scripts/get-tests-in-package-location.js)
50+
echo $RESULT
5051
echo "matrix=$RESULT" >> $GITHUB_OUTPUT
5152
5253
run-tests:
@@ -99,7 +100,7 @@ jobs:
99100
echo "ECR_IMAGE_VERSION=${{ inputs.COMMIT_SHA }}" >> $GITHUB_ENV
100101
echo "LAMBDA_IMAGE_VERSION=${{ inputs.COMMIT_SHA }}" >> $GITHUB_ENV
101102
# runs the single test file from `package` workspace in the `file`, as defined in the matrix output
102-
- run: npm run test:aws:ci --workspace ${{fromJson(needs.generate-test-matrix.outputs.matrix).namesToFiles[matrix.testName].package }} -- --files ${{ fromJson(needs.generate-test-matrix.outputs.matrix).namesToFiles[matrix.testName].file }}
103+
- run: npm run test:aws:ci --workspace ${{fromJson(needs.generate-test-matrix.outputs.matrix).namesToFiles[matrix.testName].packageName }} -- --files ${{ fromJson(needs.generate-test-matrix.outputs.matrix).namesToFiles[matrix.testName].file }}
103104
env:
104105
FORCE_COLOR: 1
105106

.github/workflows/scripts/get-all-packages-by-name.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fs = require('fs');
1+
const fs = require('node:fs');
22

33
const packageNames = [];
44
fs.readdirSync('packages').forEach((pkg) => {

.github/workflows/scripts/get-tests-in-package-location.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const fs = require('fs');
2-
const path = require('path');
1+
const fs = require('node:fs');
2+
const path = require('node:path');
33

44
/**
55
* This script is used to discover all the tests in different test directories that match a specific suffix
@@ -9,17 +9,17 @@ const path = require('path');
99
const testLocations = [
1010
{
1111
location: 'test/cloud-e2e/fargate',
12-
package: 'artillery',
12+
packageName: 'artillery',
1313
suffix: '.test.js'
1414
},
1515
{
1616
location: 'test/cloud-e2e/lambda',
17-
package: 'artillery',
17+
packageName: 'artillery',
1818
suffix: '.test.js'
1919
},
2020
{
2121
location: 'test',
22-
package: 'artillery-engine-playwright',
22+
packageName: 'artillery-engine-playwright',
2323
suffix: '.aws.js'
2424
}
2525
];
@@ -38,7 +38,7 @@ const addTest = (fileName, baseLocation, packageName, suffix) => {
3838
tests.names.push(jobName);
3939
tests.namesToFiles[jobName] = {
4040
file: `${baseLocation}/${fileName}`,
41-
package: packageName
41+
packageName: packageName
4242
};
4343
};
4444

@@ -55,9 +55,9 @@ function scanDirectory(location, baseLocation, packageName, suffix) {
5555
}
5656

5757
// Scan all the test locations
58-
for (const { package, location, suffix } of testLocations) {
59-
const fullLocation = `packages/${package}/${location}`;
60-
scanDirectory(fullLocation, location, package, suffix);
58+
for (const { packageName, location, suffix } of testLocations) {
59+
const fullLocation = `packages/${packageName}/${location}`;
60+
scanDirectory(fullLocation, location, packageName, suffix);
6161
}
6262

6363
// Output the tests object as a JSON string to be used by Github Actions

.github/workflows/scripts/replace-package-versions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
const fs = require('fs');
2-
const path = require('path');
1+
const fs = require('node:fs');
2+
const path = require('node:path');
33

44
const packagesDir = '../../../packages';
55
const commitSha = process.env.COMMIT_SHA;
66

77
const getNewVersion = (version) => {
8-
if (!commitSha || commitSha == 'null') {
8+
if (!commitSha || commitSha === 'null') {
99
return version;
1010
}
1111

1212
const shortSha = commitSha.slice(0, 7);
1313
return `${version}-${shortSha}`;
1414
};
1515

16-
let versionMapping = {};
16+
const versionMapping = {};
1717

1818
/**
1919
* This script iterates through every folder in ./packages and replaces their package.version with VERSION-COMMIT_SHA.
@@ -61,7 +61,7 @@ const updateDependencies = (pkg) => {
6161
} = pkg;
6262

6363
for (const packageNameToReplace of Object.keys(versionMapping)) {
64-
if (dependencies && dependencies[packageNameToReplace]) {
64+
if (dependencies?.[packageNameToReplace]) {
6565
//replace the dependency we care about in this package with its corrected canary version
6666
dependencies[packageNameToReplace] =
6767
versionMapping[packageNameToReplace].content.version;

biome.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.3.3/schema.json",
3+
"formatter": {
4+
"enabled": false
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"suspicious": {
10+
"noThenProperty": "off",
11+
"noExplicitAny": "off"
12+
}
13+
}
14+
},
15+
"files": {
16+
"includes": [
17+
"**",
18+
"!**/packages/types",
19+
"!**/packages/artillery-engine-playwright/test/**/*.ts",
20+
"!**/examples/browser-playwright-reuse-typescript/**/*.ts",
21+
"!**/node_modules",
22+
"!**/dist",
23+
"!**/build"
24+
]
25+
}
26+
}

examples/artillery-engine-example/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class ExampleEngine {
2929
if (!opts.mandatoryString) {
3030
throw new Error('mandatoryString setting must be set');
3131
}
32-
33-
return this;
3432
}
3533

3634
// For each scenario in the script using this engine, Artillery calls this function
@@ -71,7 +69,7 @@ class ExampleEngine {
7169

7270
if (rs.log) {
7371
return function log(context, callback) {
74-
return process.nextTick(function () {
72+
return process.nextTick(() => {
7573
callback(null, context);
7674
});
7775
};
@@ -82,17 +80,15 @@ class ExampleEngine {
8280
}
8381

8482
if (rs.function) {
85-
return function (context, callback) {
86-
let func = self.script.config.processor[rs.function];
83+
return (context, callback) => {
84+
const func = self.script.config.processor[rs.function];
8785
if (!func) {
88-
return process.nextTick(function () {
86+
return process.nextTick(() => {
8987
callback(null, context);
9088
});
9189
}
9290

93-
return func(context, ee, function () {
94-
return callback(null, context);
95-
});
91+
return func(context, ee, () => callback(null, context));
9692
};
9793
}
9894

examples/artillery-engine-example/test/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
'use strict';
6-
75
const { test } = require('tap');
8-
const EventEmitter = require('events');
6+
const EventEmitter = require('node:events');
97

108
const ExampleEngine = require('..');
119

@@ -31,7 +29,7 @@ const script = {
3129
]
3230
};
3331

34-
test('Engine interface', async function (t) {
32+
test('Engine interface', async (t) => {
3533
const events = new EventEmitter();
3634
const engine = new ExampleEngine(script, events, {});
3735
const scenario = engine.createScenario(script.scenarios[0], events);

examples/artillery-plugin-hello-world/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ function ArtilleryHelloWorldPlugin(script, events) {
2222
const pluginConfig = script.config.plugins['hello-world'];
2323
this.greeting = pluginConfig.greeting || 'hello, world';
2424

25-
const self = this;
26-
2725
// But we could also read anything else defined in the test
2826
// script, e.g.:
2927
debug('target is:', script.config.target);
@@ -35,16 +33,16 @@ function ArtilleryHelloWorldPlugin(script, events) {
3533
// Create processor object if needed to hold our custom function:
3634
script.config.processor = script.config.processor || {};
3735
// Add our custom function:
38-
script.config.processor['pluginHelloWorldBeforeRequestHook'] = function (
39-
req,
40-
vuContext,
36+
script.config.processor.pluginHelloWorldBeforeRequestHook = (
37+
_req,
38+
_vuContext,
4139
events,
4240
next
43-
) {
41+
) => {
4442
// This a beforeRequest handler function:
4543
// https://artillery.io/docs/guides/guides/http-reference.html#beforeRequest
4644

47-
console.log(self.greeting); // print greeting
45+
console.log(this.greeting); // print greeting
4846
events.emit('counter', 'greeting_count', 1); // increase custom counter
4947
return next(); // the hook is done, go on to the next one (or let Artillery make the request)
5048
};
@@ -60,7 +58,7 @@ function ArtilleryHelloWorldPlugin(script, events) {
6058
// Artillery will call this before it exits to give plugins
6159
// a chance to clean up, e.g. by flushing any in-flight data,
6260
// writing something to disk etc.
63-
ArtilleryHelloWorldPlugin.prototype.cleanup = function (done) {
61+
ArtilleryHelloWorldPlugin.prototype.cleanup = (done) => {
6462
debug('cleaning up');
6563
done(null);
6664
};

0 commit comments

Comments
 (0)