Skip to content

Commit 998d4b7

Browse files
committed
🏷️ Convert examples and tests to ESM
1 parent 883b69b commit 998d4b7

Some content is hidden

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

71 files changed

+139
-159
lines changed

.eslintrc.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
parser: "@typescript-eslint/parser"
1+
parser: '@typescript-eslint/parser'
22
extends:
33
- airbnb-base
4+
- prettier
45
parserOptions:
56
ecmaVersion: 2018
67
project: ./tsconfig.lint.json
@@ -10,7 +11,7 @@ env:
1011
node: true
1112
browser: true
1213
rules:
13-
"@typescript-eslint/lines-between-class-members": off
14+
'@typescript-eslint/lines-between-class-members': off
1415
arrow-parens:
1516
- error
1617
- as-needed
@@ -37,7 +38,7 @@ rules:
3738
padding-line-between-statements:
3839
- error
3940
- blankLine: always
40-
prev: "*"
41+
prev: '*'
4142
next:
4243
- block
4344
- block-like
@@ -59,7 +60,7 @@ rules:
5960
- import
6061
- let
6162
- var
62-
next: "*"
63+
next: '*'
6364
- blankLine: any
6465
prev:
6566
- const
@@ -86,5 +87,5 @@ rules:
8687
- export
8788
settings:
8889
import/parsers:
89-
"@typescript-eslint/parser":
90+
'@typescript-eslint/parser':
9091
- .ts

examples/src/addFixVersion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Version3Client } from 'jira.js';
2-
import { createIssue } from './utils';
3-
import { apiToken, email, host } from './credentials';
2+
import { createIssue } from './utils/index.js';
3+
import { apiToken, email, host } from './credentials.js';
44

55
async function addFixVersion() {
66
const client = new Version3Client({

examples/src/addWorklog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Version3Client } from 'jira.js';
2-
import { createIssue } from './utils';
3-
import { apiToken, email, host } from './credentials';
2+
import { createIssue } from './utils/index.js';
3+
import { apiToken, email, host } from './credentials.js';
44

55
async function addWorklog() {
66
const client = new Version3Client({

examples/src/basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Version3Client } from 'jira.js';
2-
import { apiToken, email, host } from './credentials';
2+
import { apiToken, email, host } from './credentials.js';
33

44
const client = new Version3Client({
55
host,

examples/src/getAllWorklogs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Version3Client } from 'jira.js';
22
import type { Worklog } from 'jira.js/out/version3/models';
3-
import { apiToken, email, host } from './credentials';
4-
import { addWorklog, createIssue } from './utils';
3+
import { apiToken, email, host } from './credentials.js';
4+
import { addWorklog, createIssue } from './utils/index.js';
55

66
async function getAllWorklogs() {
77
const client = new Version3Client({

examples/src/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './addWorklog';
2-
export * from './createIssue';
1+
export * from './addWorklog.js';
2+
export * from './createIssue.js';

tests/integration/agile/sprint.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import { AgileModels } from '@jirajs';
3-
import { Constants } from '@tests/integration/constants';
4-
import {
5-
createAgileProject,
6-
deleteAgileProject,
7-
getAgileClient,
8-
getVersion3Client,
9-
} from '@tests/integration/utils';
2+
import { AgileModels } from '../../../src/index.js';
3+
import { Constants } from '../constants.js';
4+
import { createAgileProject, deleteAgileProject, getAgileClient, getVersion3Client } from '../utils/index.js';
105

116
const client = getAgileClient();
127

@@ -22,7 +17,9 @@ afterAll(async () => {
2217
});
2318

2419
test.sequential('should create new sprint', async ({ expect }) => {
25-
const boards = await client.board.getAllBoards({ name: Constants.testAgileProjectKey });
20+
const boards = await client.board.getAllBoards({
21+
name: Constants.testAgileProjectKey,
22+
});
2623

2724
expect(boards.total).toBe(1);
2825

tests/integration/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from '@tests/constants';
2-
export * as Utils from '@tests/utils';
1+
export * from './constants.js';
2+
export * as Utils from './utils/index.js';

tests/integration/utils/cleanupEnvironment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { deleteSoftwareProject } from './deleteSoftwareProject';
1+
import { deleteSoftwareProject } from './deleteSoftwareProject.js';
22

33
export const cleanupEnvironment = async () => {
44
await deleteSoftwareProject();

tests/integration/utils/createAgileProject.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Constants } from '@tests/integration/constants';
2-
import { getVersion3Client } from './getClient';
1+
import { Constants } from '../constants.js';
2+
import { getVersion3Client } from './getClient.js';
33

44
export const createAgileProject = async () => {
55
const client = getVersion3Client();
@@ -11,6 +11,7 @@ export const createAgileProject = async () => {
1111
name: Constants.testAgileProjectName,
1212
leadAccountId: myself.accountId,
1313
projectTypeKey: 'software',
14-
projectTemplateKey: 'com.pyxis.greenhopper.jira:gh-simplified-agility-scrum',
14+
projectTemplateKey:
15+
'com.pyxis.greenhopper.jira:gh-simplified-agility-scrum',
1516
});
1617
};

tests/integration/utils/createIssue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Constants } from '@tests/integration/constants';
2-
import { getVersion2Client } from './getClient';
1+
import { Constants } from '../constants.js';
2+
import { getVersion2Client } from './getClient.js';
33

44
export const createIssue = async () => {
55
const client = getVersion2Client();

tests/integration/utils/createSoftwareProject.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { AxiosError } from 'axios';
2-
import { Constants } from '@tests/integration/constants';
3-
import { getVersion2Client } from './getClient';
2+
import { Constants } from '../constants.js';
3+
import { getVersion2Client } from './getClient.js';
44

55
export const createSoftwareProject = async () => {
66
const client = getVersion2Client();
77
const currentUser = await client.myself.getCurrentUser();
88

9-
if (!currentUser.accountId) throw new Error("Couldn't get the current user's account ID", { cause: { currentUser } });
9+
if (!currentUser.accountId)
10+
throw new Error("Couldn't get the current user's account ID", {
11+
cause: { currentUser },
12+
});
1013

1114
return client.projects
1215
.createProject({

tests/integration/utils/deleteAgileProject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Constants } from '@tests/integration/constants';
2-
import { getVersion3Client } from './getClient';
1+
import { Constants } from '../constants.js';
2+
import { getVersion3Client } from './getClient.js';
33

44
export const deleteAgileProject = async () => {
55
const client = getVersion3Client();

tests/integration/utils/deleteSoftwareProject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AxiosError } from 'axios';
2-
import { Constants } from '@tests/integration/constants';
3-
import { getVersion2Client } from './getClient';
2+
import { Constants } from '../constants.js';
3+
import { getVersion2Client } from './getClient.js';
44

55
export const deleteSoftwareProject = async () => {
66
const client = getVersion2Client();

tests/integration/utils/getClient.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ClientType, type Config, createClient } from '@jirajs';
1+
import { ClientType, createClient, type Config } from '../../../src/index.js';
22

33
const config = {
44
host: process.env.HOST!,
@@ -10,6 +10,9 @@ const config = {
1010
},
1111
};
1212

13-
export const getAgileClient = (customConfig?: Partial<Config>) => createClient(ClientType.Agile, { ...config, ...customConfig });
14-
export const getVersion2Client = (customConfig?: Partial<Config>) => createClient(ClientType.Version2, { ...config, ...customConfig });
15-
export const getVersion3Client = (customConfig?: Partial<Config>) => createClient(ClientType.Version3, { ...config, ...customConfig });
13+
export const getAgileClient = (customConfig?: Partial<Config>) =>
14+
createClient(ClientType.Agile, { ...config, ...customConfig });
15+
export const getVersion2Client = (customConfig?: Partial<Config>) =>
16+
createClient(ClientType.Version2, { ...config, ...customConfig });
17+
export const getVersion3Client = (customConfig?: Partial<Config>) =>
18+
createClient(ClientType.Version3, { ...config, ...customConfig });

tests/integration/utils/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export * from './cleanupEnvironment';
2-
export * from './createAgileProject';
3-
export * from './createIssue';
4-
export * from './createSoftwareProject';
5-
export * from './deleteAgileProject';
6-
export * from './deleteSoftwareProject';
7-
export * from './getClient';
8-
export * from './prepareEnvironment';
1+
export * from './cleanupEnvironment.js';
2+
export * from './createAgileProject.js';
3+
export * from './createIssue.js';
4+
export * from './createSoftwareProject.js';
5+
export * from './deleteAgileProject.js';
6+
export * from './deleteSoftwareProject.js';
7+
export * from './getClient.js';
8+
export * from './prepareEnvironment.js';

tests/integration/utils/prepareEnvironment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createSoftwareProject } from './createSoftwareProject';
1+
import { createSoftwareProject } from './createSoftwareProject.js';
22

33
export const prepareEnvironment = async () => {
44
await createSoftwareProject();

tests/integration/version2/avatars.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test } from 'vitest';
2-
import type { Avatar } from '@jirajs/version3/models';
3-
import { getVersion2Client } from '@tests/integration/utils';
2+
import type { Avatar } from '../../../src/version3/models/index.js';
3+
import { getVersion2Client } from '../utils/index.js';
44

55
const client = getVersion2Client();
66

tests/integration/version2/dashboards.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test } from 'vitest';
2-
import { Version2Models } from '@jirajs';
3-
import { Constants } from '@tests/integration/constants';
4-
import { getVersion2Client } from '@tests/integration/utils';
2+
import { Version2Models } from '../../../src/index.js';
3+
import { Constants } from '../constants.js';
4+
import { getVersion2Client } from '../utils/index.js';
55

66
let dashboard: Version2Models.Dashboard;
77
const client = getVersion2Client();

tests/integration/version2/groups.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test } from 'vitest';
2-
import { Constants } from '@tests/integration/constants';
3-
import { getVersion2Client } from '@tests/integration/utils';
2+
import { Constants } from '../constants.js';
3+
import { getVersion2Client } from '../utils/index.js';
44

55
const client = getVersion2Client();
66

tests/integration/version2/issueAttachments.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as fs from 'fs';
22
import { afterAll, beforeAll, test } from 'vitest';
3-
import type { Attachment, Issue } from '@jirajs/version2/models';
4-
import { Constants } from '@tests/integration/constants';
5-
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/integration/utils';
3+
import type { Attachment, Issue } from '../../../src/version2/models/index.js';
4+
import { Constants } from '../constants.js';
5+
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '../utils/index.js';
66

77
const client = getVersion2Client({ noCheckAtlassianToken: true });
88

tests/integration/version2/issueComments.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AxiosError } from 'axios';
22
import { afterAll, beforeAll, test } from 'vitest';
3-
import { Constants } from '@tests/integration/constants';
4-
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/integration/utils';
3+
import { Constants } from '../constants.js';
4+
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '../utils/index.js';
55

66
beforeAll(async () => {
77
await prepareEnvironment();

tests/integration/version2/issueSearch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/integration/utils';
2+
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '../utils/index.js';
33

44
beforeAll(async () => {
55
await prepareEnvironment();

tests/integration/version2/issueVotes.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import type { CreatedIssue } from '@jirajs/version2/models';
3-
import {
4-
cleanupEnvironment, createIssue, getVersion2Client, prepareEnvironment,
5-
} from '@tests/integration/utils';
2+
import type { CreatedIssue } from '../../../src/version2/models/index.js';
3+
import { cleanupEnvironment, createIssue, getVersion2Client, prepareEnvironment } from '../utils/index.js';
64

75
const client = getVersion2Client();
86
let createdIssue: CreatedIssue;

tests/integration/version2/issues.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import { Version2Models } from '@jirajs';
3-
import { Constants } from '@tests/integration/constants';
4-
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/integration/utils';
2+
import { Version2Models } from '../../../src/index.js';
3+
import { Constants } from '../constants.js';
4+
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '../utils/index.js';
55

66
let createdIssue: Version2Models.CreatedIssue;
77
const client = getVersion2Client();

tests/integration/version2/projectRoles.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import { Constants } from '@tests/integration/constants';
3-
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/integration/utils';
2+
import { Constants } from '../constants.js';
3+
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '../utils/index.js';
44

55
const client = getVersion2Client();
66

tests/integration/version2/projects.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import { Constants } from '@tests/integration/constants';
3-
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/integration/utils';
2+
import { Constants } from '../constants.js';
3+
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '../utils/index.js';
44

55
beforeAll(async () => {
66
await prepareEnvironment();

tests/integration/version3/avatars.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test } from 'vitest';
2-
import type { Avatar } from '@jirajs/version3/models';
3-
import { getVersion3Client } from '@tests/integration/utils';
2+
import type { Avatar } from '../../../src/version3/models/index.js';
3+
import { getVersion3Client } from '../utils/index.js';
44

55
const client = getVersion3Client();
66

tests/integration/version3/dashboards.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test } from 'vitest';
2-
import { Version3Models } from '@jirajs';
3-
import { Constants } from '@tests/integration/constants';
4-
import { getVersion3Client } from '@tests/integration/utils';
2+
import { Version3Models } from '../../../src/index.js';
3+
import { Constants } from '../constants.js';
4+
import { getVersion3Client } from '../utils/index.js';
55

66
let dashboard: Version3Models.Dashboard;
77
const client = getVersion3Client();

tests/integration/version3/groups.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test } from 'vitest';
2-
import { Constants } from '@tests/integration/constants';
3-
import { getVersion3Client } from '@tests/integration/utils';
2+
import { Constants } from '../constants.js';
3+
import { getVersion3Client } from '../utils/index.js';
44

55
const client = getVersion3Client();
66

tests/integration/version3/issueAttachments.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as fs from 'fs';
22
import { afterAll, beforeAll, test } from 'vitest';
3-
import type { Attachment, Issue } from '@jirajs/version3/models';
4-
import { Constants } from '@tests/integration/constants';
5-
import { cleanupEnvironment, getVersion3Client, prepareEnvironment } from '@tests/integration/utils';
3+
import type { Attachment, Issue } from '../../../src/version3/models/index.js';
4+
import { Constants } from '../constants.js';
5+
import { cleanupEnvironment, getVersion3Client, prepareEnvironment } from '../utils/index.js';
66

77
const client = getVersion3Client({ noCheckAtlassianToken: true });
88

tests/integration/version3/issueComments.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import { Constants } from '@tests/integration/constants';
3-
import { cleanupEnvironment, getVersion3Client, prepareEnvironment } from '@tests/integration/utils';
2+
import { Constants } from '../constants.js';
3+
import { cleanupEnvironment, getVersion3Client, prepareEnvironment } from '../utils/index.js';
44

55
beforeAll(async () => {
66
await prepareEnvironment();

tests/integration/version3/issueSearch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import { cleanupEnvironment, getVersion3Client, prepareEnvironment } from '@tests/integration/utils';
2+
import { cleanupEnvironment, getVersion3Client, prepareEnvironment } from '../utils/index.js';
33

44
beforeAll(async () => {
55
await prepareEnvironment();

tests/integration/version3/issueVotes.test.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { afterAll, beforeAll, test } from 'vitest';
2-
import type { CreatedIssue } from '@jirajs/version3/models';
3-
import {
4-
cleanupEnvironment,
5-
createIssue,
6-
getVersion3Client,
7-
prepareEnvironment,
8-
} from '@tests/integration/utils';
2+
import type { CreatedIssue } from '../../../src/version3/models/index.js';
3+
import { cleanupEnvironment, createIssue, getVersion3Client, prepareEnvironment } from '../utils/index.js';
94

105
const client = getVersion3Client();
116
let createdIssue: CreatedIssue;

0 commit comments

Comments
 (0)