Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint plugin style fixes #3757

Merged
merged 13 commits into from
Sep 26, 2024
  •  
  •  
  •  
11 changes: 5 additions & 6 deletions e2e/test/cases/cluster/api-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('cluster api', () => {
jobId = job.id();
const { ex_id: exId } = await job.execution();
ex = terasliceHarness.teraslice.executions.wrap(exId);
})
});

it('will not delete a running job', async () => {
await terasliceHarness.waitForExStatus(ex, 'running', 100, 1000);
Expand All @@ -192,28 +192,27 @@ describe('cluster api', () => {

it('will not list a deleted job by default', async () => {
const list = await terasliceHarness.teraslice.jobs.list();
const jobIds = list.map((job) => job.job_id);
const jobIds = list.map((jobConfig) => jobConfig.job_id);
expect(jobIds).toEqual(expect.arrayContaining([expect.not.stringMatching(jobId)]));
});

it('will list a deleted job when passed "{ deleted: true }"', async () => {
const list = await terasliceHarness.teraslice.jobs.list({ deleted: true });
expect(list).toEqual(expect.arrayContaining([expect.objectContaining({ ...jobSpec, job_id: jobId })]));
expect(list).toEqual(
expect.arrayContaining([expect.objectContaining({ ...jobSpec, job_id: jobId })])
);
});

it('will not start a deleted job', async () => {
await expect(terasliceHarness.teraslice.jobs.post(`/jobs/${jobId}/_start`)).rejects.toThrow(`Job ${jobId} has been deleted and cannot be started.`);

});

it('will not update a deleted job', async () => {
await expect(terasliceHarness.teraslice.jobs.put(`/jobs/${jobId}`, { workers: 1 })).rejects.toThrow(`Job ${jobId} has been deleted and cannot be updated.`);

});

it('will not recover a deleted job', async () => {
await expect(terasliceHarness.teraslice.jobs.post(`/jobs/${jobId}/_recover`)).rejects.toThrow(`Job ${jobId} has been deleted and cannot be recovered.`);

});
});
});
3 changes: 3 additions & 0 deletions e2e/test/cases/cluster/job-state-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ describe('job state', () => {
ex1.stop({ blocking: true }),
ex2.stop({ blocking: true }),
]);

// we are testing to see if errors come from transitions, not any end results
expect(true).toBe(true);
});
});
6 changes: 3 additions & 3 deletions e2e/test/cases/cluster/state-spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jest/expect-expect */
import { pDelay, flatten } from '@terascope/utils';
import signale from '../../signale.js';
import { TerasliceHarness } from '../../teraslice-harness.js';
Expand Down Expand Up @@ -33,7 +34,7 @@ describe('cluster state', () => {

function verifyClusterMaster(state: any) {
// verify that the cluster master worker exists within the state
const nodes = Object.values(state).filter((node:any) => {
const nodes = Object.values(state).filter((node: any) => {
const cms = findWorkers(node.active, 'cluster_master');
return cms.length > 0;
}) as any;
Expand Down Expand Up @@ -91,8 +92,7 @@ describe('cluster state', () => {
verifyClusterState(await terasliceHarness.scaleWorkersAndWait());
});

// eslint-disable-next-line jest/no-focused-tests
fit('should be correct for running job with 1 worker', async () => {
it('should be correct for running job with 1 worker', async () => {
const jobSpec = terasliceHarness.newJob('reindex');
const specIndex = terasliceHarness.newSpecIndex('state');
// Set resource constraints on workers within CI
Expand Down
1 change: 1 addition & 0 deletions e2e/test/cases/cluster/worker-allocation-spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable jest/expect-expect */
import { TerasliceHarness } from '../../teraslice-harness.js';
import { TEST_PLATFORM } from '../../config.js';

Expand Down
2 changes: 1 addition & 1 deletion e2e/test/cases/data/id-reader-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TEST_PLATFORM } from '../../config.js';
* - https://github.com/terascope/elasticsearch-assets/issues/12
*/
// eslint-disable-next-line jest/no-disabled-tests
xdescribe('id reader', () => {
describe.skip('id reader', () => {
let terasliceHarness: TerasliceHarness;

beforeAll(async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/docker-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function dockerUp() {
throw new Error('Node version check failed to return a result.');
}
return version;
})
});

const scriptsNodeVersion = semver.coerce(NODE_VERSION);
const parsedVersion = semver.parse(e2eNodeVersion);
Expand Down
5 changes: 2 additions & 3 deletions e2e/test/download-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type AssetInfo = {
bundle: boolean;
fileName: string;
assetNodeVersion: string;
}
};

/**
* This will get the correct teraslice node version so
Expand Down Expand Up @@ -51,7 +51,6 @@ export const defaultAssetBundles = [
];

function assetFileInfo(assetName: string): AssetInfo {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [name, version, _, assetNodeVersion] = assetName.split('-');
return {
name,
Expand Down Expand Up @@ -207,7 +206,7 @@ function getMSUntilRetry(err: HTTPError): number {
* @param {any} err The response error
* @returns {number|undefined} Delay in milliseconds or undefined
*/
function calculateDelay(err: any): number|undefined {
function calculateDelay(err: any): number | undefined {
const MAX_WAIT_MS = 180_000;

if (err instanceof HTTPError) {
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/setup-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const baseConfig = {
environment: 'development',
log_level: [
{ console: 'warn' },
{ file: process.env.DEBUG_LOG_LEVEL || 'info', }
{ file: process.env.DEBUG_LOG_LEVEL || 'info' }
],
logging: [
'console',
Expand Down
1 change: 1 addition & 0 deletions e2e/test/teraslice-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class TerasliceHarness {
const errors = await ex.errors();
this.warn(`waitForStatus: ${exId} errors`, errors);
}

// TODO: look at types here
warn(msg: string, obj: any) {
if (isEmpty(obj)) return;
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import eslintConfig from '@terascope/eslint-config';

export default eslintConfig
export default eslintConfig;
45 changes: 23 additions & 22 deletions jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,32 @@ export default (projectDir) => {
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
workerIdleMemoryLimit: '200MB',
testTimeout: 60 * 1000,
globals: {
availableExtensions: ['.js', '.ts', '.mjs', 'cjs']
globals: {
availableExtensions: ['.js', '.ts', '.mjs', 'cjs'],
},
transform: {
['^.+\\.(t|j)sx?$']: ['@swc/jest', {
jsc: {
loose: true,
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
['^.+\\.(t|j)sx?$']: ['@swc/jest',
{
jsc: {
loose: true,
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
target: 'esnext'
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
target: 'esnext'
},
module: {
type: 'es6',
strictMode: false,
noInterop: false,
ignoreDynamic: true
}
}]
module: {
type: 'es6',
strictMode: false,
noInterop: false,
ignoreDynamic: true
}
}]
},
roots: [`${packageRoot}/test`]
};
Expand Down
45 changes: 23 additions & 22 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
verbose: true,
projects,
globals: {
availableExtensions: ['.js', '.ts', '.mjs', '.cjs']
availableExtensions: ['.js', '.ts', '.mjs', '.cjs'],
},
testMatch: [
'<rootDir>/packages/*/test/**/*-spec.{ts,js}',
Expand Down Expand Up @@ -73,26 +73,27 @@ export default {
},
extensionsToTreatAsEsm: ['.ts'],
transform: {
['^.+\\.(t|j)sx?$']: ['@swc/jest', {
jsc: {
loose: true,
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
['^.+\\.(t|j)sx?$']: ['@swc/jest',
{
jsc: {
loose: true,
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
target: 'esnext'
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
target: 'esnext'
},
module: {
type: 'es6',
strictMode: false,
noInterop: false,
ignoreDynamic: true
}
}]
}
module: {
type: 'es6',
strictMode: false,
noInterop: false,
ignoreDynamic: true
}
}]
},
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"nan": "^2.19.0"
},
"devDependencies": {
"@eslint/js": "^9.9.1",
"@eslint/js": "^9.10.0",
"@swc/core": "1.4.0",
"@swc/jest": "^0.2.36",
"@types/bluebird": "^3.5.42",
Expand All @@ -59,7 +59,7 @@
"@types/lodash": "^4.17.7",
"@types/node": "^18.14.2",
"@types/uuid": "^9.0.8",
"eslint": "^9.9.1",
"eslint": "^9.10.0",
"jest": "^29.7.0",
"jest-extended": "^3.2.4",
"jest-watch-typeahead": "^2.2.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/data-mate/bench/build-column-perf-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { config, data } from './fixtures/data.json';
import { Column } from '../dist/src/index.js';

Expand All @@ -6,16 +7,15 @@ const fieldConfig = config.fields[name];
const values = data.map((row) => row[name]);

const startRSS = process.memoryUsage().rss;
// eslint-disable-next-line no-console
console.log(`Building ${values.length} rows`,);
console.log(`Building ${values.length} rows`);

console.time(`Built ${values.length} rows`);

const column = Column.fromJSON(name, fieldConfig, values);
console.timeEnd(`Built ${values.length} rows`);

const endRSS = process.memoryUsage().rss;
// eslint-disable-next-line no-console

console.log('DONE', endRSS - startRSS);

setTimeout(() => console.error('exiting...'), 5000);
Expand Down
13 changes: 8 additions & 5 deletions packages/data-mate/bench/generate-data.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { times, random } from '@terascope/utils';
import { FieldType } from '@terascope/types';
import fs from 'node:fs';
Expand Down Expand Up @@ -97,10 +98,12 @@ let records = times(numRecords, () => {
return {
type: age > 20 ? 'parent' : 'child',
number_of_friends: random(1, 2000),
requests: random(0, 20) ? {
total: random(10, maxInt),
last: chance.date().toISOString()
} : null,
requests: random(0, 20)
? {
total: random(10, maxInt),
last: chance.date().toISOString()
}
: null,
};
}
return {
Expand Down Expand Up @@ -133,14 +136,14 @@ function randNull(fn, arg) {
return fn.call(chance, arg);
}

// eslint-disable-next-line no-console
console.dir({
dataTypeConfig,
records,
}, {
maxArrayLength: 1,
depth: 5
});

(async function writeRow() {
console.time('write row');
await new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/data-mate/bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function start(name, dir) {

async function run() {
const list = await pMap(benchmarks, async (file) => {
return import(path.join(dir, file))
return import(path.join(dir, file));
});

for (const initSuite of list) {
Expand Down
12 changes: 9 additions & 3 deletions packages/data-mate/bench/serialize-perf-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,22 @@ async function deserializeStream(iterator) {
async function runTest(times) {
let start;
return Promise.resolve()
.then(() => { start = Date.now(); })
.then(() => {
start = Date.now();
})
.then(readFile('data.json'))
.then(fromJSON)
.then(() => times.set('row', Date.now() - start))
.then(() => pDelay(100))
.then(() => { start = Date.now(); })
.then(() => {
start = Date.now();
})
.then(readFile('data.dfjson'))
.then(deserialize)
.then(() => times.set('column', Date.now() - start))
.then(() => { start = Date.now(); })
.then(() => {
start = Date.now();
})
.then(readFileStream('data.dfjson'))
.then(deserializeStream)
.then(() => times.set('column stream', Date.now() - start));
Expand Down
6 changes: 4 additions & 2 deletions packages/data-mate/scripts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ function generateFunctionDoc(fnDef) {

**Type:** \`${fnDef.type}\`
${generateAliases(fnDef)}
> ${firstToUpper(trimEnd(fnDef.description.trim(), '.')).split('\n').join('\n>')}`.trim(),
> ${firstToUpper(trimEnd(fnDef.description.trim(), '.')).split('\n')
.join('\n>')}`.trim(),
...generateArgDocs(fnDef),
...generateAccepts(fnDef),
...generateExamples(fnDef, fnDef.examples)
Expand All @@ -144,7 +145,8 @@ function generateDocsForCategory([category, fnsByType]) {

return [
`## CATEGORY: ${category === 'JSON'
? category : toTitleCase(category.toLowerCase())}`,
? category
: toTitleCase(category.toLowerCase())}`,
...fns.map(generateFunctionDoc)
];
}
Expand Down
Loading