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 esm changes #3729

Merged
merged 20 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .eslintignore

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ lastUpdateCheck 1687468484367
prefer-offline true
progress false
workspaces-experimental true
yarn-path ".yarn/releases/yarn-1.22.19.js"
yarn-path ".yarn/releases/yarn-1.22.19.cjs"
31 changes: 1 addition & 30 deletions e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-import-module-exports */
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import { URL } from 'node:url';

const dirPath = fileURLToPath(new URL('.', import.meta.url));
const configModulePath = path.join(dirPath, '../jest.config.base.js');
Expand All @@ -16,33 +16,4 @@ config.testPathIgnorePatterns = process.env.CLUSTERING_TYPE !== 'native' ? ['dat
config.collectCoverage = false;
config.testTimeout = 3 * 60 * 1000;

config.extensionsToTreatAsEsm = ['.ts'];
config.moduleNameMapper = {
'^(\\.{1,2}/.*)\\.js$': '$1',
};
config.transform = {};
config.transform['^.+\\.(t|j)sx?$'] = ['@swc/jest', {
jsc: {
loose: true,
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
target: 'esnext'
},
module: {
type: 'es6',
strictMode: false,
noInterop: false,
ignoreDynamic: true
}
}];
config.transformIgnorePatterns = [];
config.preset = '';

export default config;
6 changes: 3 additions & 3 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ms": "^2.1.3"
},
"devDependencies": {
"@terascope/types": "^1.0.0",
"@terascope/types": "^1.0.1",
"bunyan": "^1.8.15",
"elasticsearch-store": "^1.0.4",
"fs-extra": "^11.2.0",
Expand All @@ -54,8 +54,8 @@
"uuid": "^9.0.1"
},
"engines": {
"node": ">=14.17.0",
"yarn": ">=1.16.0"
"node": ">=18.18.0",
"yarn": ">=1.22.19"
},
"terascope": {
"testSuite": "e2e"
Expand Down
1 change: 0 additions & 1 deletion e2e/test/cases/assets/simple-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/no-disabled-tests */
import 'jest-extended';
import fs from 'node:fs';
import os from 'os';
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/cases/cluster/api-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('cluster api', () => {
try {
await p;
return false;
} catch (err) {
} catch (_err) {
return true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintConfig from '@terascope/eslint-config';

export default eslintConfig
8 changes: 2 additions & 6 deletions examples/k8s/example-asset/asset/example/processor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
import { BatchProcessor } from '@terascope/job-components';

const { BatchProcessor } = require('@terascope/job-components');

class Example extends BatchProcessor {
export default class Example extends BatchProcessor {
onBatch(dataArray) {
// example code, processor code goes here
dataArray.forEach((doc) => {
Expand All @@ -11,5 +9,3 @@ class Example extends BatchProcessor {
return dataArray;
}
}

module.exports = Example;
8 changes: 2 additions & 6 deletions examples/k8s/example-asset/asset/example/schema.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
import { ConvictSchema } from '@terascope/job-components';

const { ConvictSchema } = require('@terascope/job-components');

class Schema extends ConvictSchema {
export default class Schema extends ConvictSchema {
build() {
return {
type: {
Expand All @@ -13,5 +11,3 @@ class Schema extends ConvictSchema {
};
}
}

module.exports = Schema;
16 changes: 7 additions & 9 deletions examples/k8s/example-asset/asset/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
'use strict';

/* eslint-disable */

// NOTE: This code is auto-generated by `teraslice-cli assets init --registry`
// any manual changes will be lost next time this gets auto-generated.
import exampleProcessor from './example/processor.js';
import examplePSchema from './example/schema.js';

module.exports = {
export default {
ASSETS: {
example: {
Processor: require('./example/processor.js'),
Schema: require('./example/schema.js'),
},
}
Processor: exampleProcessor,
Schema: examplePSchema,
},
}
};
8 changes: 2 additions & 6 deletions examples/ops/processors/summarize/processor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
import { BatchProcessor } from '@terascope/job-components';

const { BatchProcessor } = require('@terascope/job-components');

class Summarize extends BatchProcessor {
export default class Summarize extends BatchProcessor {
async initialize() {
this.logger.debug('summarizing...');
}
Expand Down Expand Up @@ -51,5 +49,3 @@ class Summarize extends BatchProcessor {
}
}
}

module.exports = Summarize;
8 changes: 2 additions & 6 deletions examples/ops/processors/summarize/schema.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use strict';
import { ConvictSchema } from '@terascope/job-components';

const { ConvictSchema } = require('@terascope/job-components');

class Schema extends ConvictSchema {
export default class Schema extends ConvictSchema {
build() {
return {};
}
}

module.exports = Schema;
78 changes: 41 additions & 37 deletions jest.config.base.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { isCI } from '@terascope/utils';

const fs = require('fs');
const path = require('path');
const dirname = path.dirname(fileURLToPath(import.meta.url));

const isCI = process.env.CI === 'true';

module.exports = (projectDir) => {
export default (projectDir) => {
let parentFolder;
let workspaceName;
let packageRoot;
let rootDir;

const name = path.basename(projectDir);
const runInDir = process.cwd() !== __dirname;
const runInDir = process.cwd() !== dirname;

if (name === 'e2e') {
parentFolder = name;
Expand All @@ -31,8 +31,6 @@ module.exports = (projectDir) => {
rootDir = '../../';
}

const isTypescript = fs.existsSync(path.join(projectDir, 'tsconfig.json'));

const coverageReporters = ['lcov', 'html'];
if (!isCI) {
coverageReporters.push('text-summary');
Expand All @@ -50,17 +48,47 @@ module.exports = (projectDir) => {
`<rootDir>/${parentFolder}/*/dist`,
`<rootDir>/${parentFolder}/teraslice-cli/test/fixtures/`
],
transformIgnorePatterns: ['^.+\\.js$'],
moduleNameMapper: {},
transformIgnorePatterns: [],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
moduleFileExtensions: ['ts', 'js', 'json', 'node', 'pegjs', 'mjs'],
extensionsToTreatAsEsm: ['.ts'],
collectCoverage: true,
coveragePathIgnorePatterns: ['/node_modules/', '/test/'],
watchPathIgnorePatterns: [],
coverageReporters,
coverageDirectory: `${packageRoot}/coverage`,
preset: 'ts-jest',
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
workerIdleMemoryLimit: '200MB'
workerIdleMemoryLimit: '200MB',
testTimeout: 60 * 1000,
globals: {
availableExtensions: ['.js', '.ts', '.mjs', 'cjs']
},
transform: {
['^.+\\.(t|j)sx?$']: ['@swc/jest', {
jsc: {
loose: true,
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
target: 'esnext'
},
module: {
type: 'es6',
strictMode: false,
noInterop: false,
ignoreDynamic: true
}
}]
},
roots: [`${packageRoot}/test`]
};

if (fs.existsSync(path.join(projectDir, 'test/global.setup.js'))) {
Expand All @@ -79,30 +107,6 @@ module.exports = (projectDir) => {
config.setupFilesAfterEnv.push(`${packageRoot}/test/test.setup.js`);
}

config.globals = {
availableExtensions: ['.js', '.ts', '.mjs']
};
config.transform = {};

if (isTypescript) {
config.transform['\\.[jt]sx?$'] = ['ts-jest', {
isolatedModules: true,
tsconfig: runInDir ? './tsconfig.json' : `./${workspaceName}/tsconfig.json`,
diagnostics: true,
pretty: true,
useESM: true
}];
} else {
config.transform['\\.[jt]sx?$'] = ['ts-jest', {
isolatedModules: true,
diagnostics: true,
pretty: true,
useESM: true
}];
}

config.roots = [`${packageRoot}/test`];

if (fs.existsSync(path.join(projectDir, 'lib'))) {
config.roots.push(`${packageRoot}/lib`);
} else if (fs.existsSync(path.join(projectDir, 'index.js'))) {
Expand Down
Loading
Loading