Skip to content

Commit 22f1586

Browse files
committed
chore: add prettier
1 parent a6e3efb commit 22f1586

File tree

25 files changed

+405
-423
lines changed

25 files changed

+405
-423
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/prod/
2+
/pnpm-lock.yaml
3+
*.json
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
arrowParens: always
2+
bracketSameLine: true
3+
bracketSpacing: true
4+
endOfLine: lf
5+
experimentalOperatorPosition: start
6+
objectWrap: preserve
7+
printWidth: 100
8+
quoteProps: preserve
9+
semi: true
10+
singleQuote: true
11+
tabWidth: 2
12+
trailingComma: all

packages/nx-infra-plugin/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
},
1818
"devDependencies": {
1919
"@types/node": "^18.0.0",
20-
"typescript": "4.9.5"
20+
"typescript": "4.9.5",
21+
"prettier": "catalog:tools",
22+
"@types/jest": "29.5.12",
23+
"ts-jest": "29.1.3"
2124
},
2225
"scripts": {
26+
"format:check": "prettier --check .",
27+
"format": "prettier --write .",
2328
"build": "nx build nx-infra-plugin",
24-
"test": "nx test nx-infra-plugin"
29+
"test": "nx test nx-infra-plugin",
30+
"lint": "pnpm run format:check"
2531
}
2632
}

packages/nx-infra-plugin/prod/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"devDependencies": {
1919
"@types/node": "^18.0.0",
2020
"typescript": "4.9.5",
21-
"prettier": "catalog:tools"
21+
"prettier": "catalog:tools",
22+
"@types/jest": "29.5.12",
23+
"ts-jest": "29.1.3"
2224
},
2325
"scripts": {
2426
"format:check": "prettier --check .",

packages/nx-infra-plugin/project.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
}
3535
},
3636
"lint": {
37-
"executor": "@nx/eslint:lint"
37+
"executor": "nx:run-script",
38+
"options": {
39+
"script": "lint"
40+
}
3841
},
3942
"test": {
4043
"executor": "@nx/jest:jest",

packages/nx-infra-plugin/src/executors/add-license-headers/executor.e2e.spec.ts

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import * as fs from 'fs';
22
import * as path from 'path';
33
import executor from './executor';
44
import { AddLicenseHeadersExecutorSchema } from './schema';
5-
import {
6-
createTempDir,
7-
cleanupTempDir,
8-
createMockContext,
9-
} from '../../utils/test-utils';
5+
import { createTempDir, cleanupTempDir, createMockContext } from '../../utils/test-utils';
106
import { writeFileText, writeJson, readFileText } from '../../utils';
117

128
describe('AddLicenseHeadersExecutor E2E', () => {
@@ -29,23 +25,20 @@ describe('AddLicenseHeadersExecutor E2E', () => {
2925

3026
await writeFileText(
3127
path.join(npmDir, 'index.js'),
32-
`export function hello() {\n return 'Hello';\n}\n`
28+
`export function hello() {\n return 'Hello';\n}\n`,
3329
);
3430

35-
await writeFileText(
36-
path.join(npmDir, 'utils.js'),
37-
`export const add = (a, b) => a + b;\n`
38-
);
31+
await writeFileText(path.join(npmDir, 'utils.js'), `export const add = (a, b) => a + b;\n`);
3932

4033
fs.mkdirSync(path.join(npmDir, 'components'), { recursive: true });
4134
await writeFileText(
4235
path.join(npmDir, 'components', 'button.js'),
43-
`export const Button = () => {};\n`
36+
`export const Button = () => {};\n`,
4437
);
4538

4639
await writeFileText(
4740
path.join(npmDir, 'types.ts'),
48-
`export interface Config { name: string; }\n`
41+
`export interface Config { name: string; }\n`,
4942
);
5043
});
5144

@@ -90,9 +83,7 @@ describe('AddLicenseHeadersExecutor E2E', () => {
9083
expect(result.success).toBe(true);
9184

9285
const npmDir = path.join(tempDir, 'packages', 'test-lib', 'npm');
93-
const buttonContent = await readFileText(
94-
path.join(npmDir, 'components', 'button.js')
95-
);
86+
const buttonContent = await readFileText(path.join(npmDir, 'components', 'button.js'));
9687

9788
expect(buttonContent).toMatch(/^\/\*!/);
9889
expect(buttonContent).toContain('test-package');
@@ -148,7 +139,7 @@ describe('AddLicenseHeadersExecutor E2E', () => {
148139

149140
await writeFileText(
150141
path.join(npmDir, 'with-header.js'),
151-
`/*!\n * Existing header\n */\nexport const foo = 'bar';\n`
142+
`/*!\n * Existing header\n */\nexport const foo = 'bar';\n`,
152143
);
153144

154145
const options: AddLicenseHeadersExecutorSchema = {
@@ -241,10 +232,7 @@ describe('AddLicenseHeadersExecutor E2E', () => {
241232
it('should fail gracefully with invalid package.json', async () => {
242233
const projectDir = path.join(tempDir, 'packages', 'test-lib');
243234

244-
await writeFileText(
245-
path.join(projectDir, 'package.json'),
246-
'not valid json {{{}'
247-
);
235+
await writeFileText(path.join(projectDir, 'package.json'), 'not valid json {{{}');
248236

249237
const options: AddLicenseHeadersExecutorSchema = {
250238
targetDirectory: './npm',
@@ -278,10 +266,7 @@ describe('AddLicenseHeadersExecutor E2E', () => {
278266
const customDir = path.join(projectDir, 'dist');
279267
fs.mkdirSync(customDir, { recursive: true });
280268

281-
await writeFileText(
282-
path.join(customDir, 'custom.js'),
283-
`export const custom = true;\n`
284-
);
269+
await writeFileText(path.join(customDir, 'custom.js'), `export const custom = true;\n`);
285270

286271
const options: AddLicenseHeadersExecutorSchema = {
287272
targetDirectory: './dist',
@@ -300,13 +285,10 @@ describe('AddLicenseHeadersExecutor E2E', () => {
300285
it('should work with custom package.json path', async () => {
301286
const projectDir = path.join(tempDir, 'packages', 'test-lib');
302287

303-
await writeJson(
304-
path.join(projectDir, 'custom-package.json'),
305-
{
306-
name: 'custom-package-name',
307-
version: '2.0.0',
308-
}
309-
);
288+
await writeJson(path.join(projectDir, 'custom-package.json'), {
289+
name: 'custom-package-name',
290+
version: '2.0.0',
291+
});
310292

311293
const options: AddLicenseHeadersExecutorSchema = {
312294
targetDirectory: './npm',
@@ -325,10 +307,10 @@ describe('AddLicenseHeadersExecutor E2E', () => {
325307
});
326308
});
327309

328-
it('should preserve formatting and whitespace', async () => {
329-
const npmDir = path.join(tempDir, 'packages', 'test-lib', 'npm');
310+
it('should preserve formatting and whitespace', async () => {
311+
const npmDir = path.join(tempDir, 'packages', 'test-lib', 'npm');
330312

331-
const originalContent = `export function complex() {
313+
const originalContent = `export function complex() {
332314
if (true) {
333315
return 'formatted';
334316
}

packages/nx-infra-plugin/src/executors/add-license-headers/executor.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,31 @@ const EMPTY_LINE = '';
1919

2020
const GITHUB_URL = 'https://github.com/DevExpress/devextreme-react';
2121

22-
const COPYRIGHT_START = ' * Copyright (c) 2012 - <%= year %> Developer Express Inc. ALL RIGHTS RESERVED';
22+
const COPYRIGHT_START =
23+
' * Copyright (c) 2012 - <%= year %> Developer Express Inc. ALL RIGHTS RESERVED';
2324

2425
const BANNER_PKG_NAME = COMMENT_PREFIX + ' ' + '<%= pkg.name %>';
2526
const BANNER_VERSION = COMMENT_PREFIX + ' ' + 'Version: <%= pkg.version %>';
2627
const BANNER_BUILD_DATE = COMMENT_PREFIX + ' ' + 'Build date: <%= date %>';
27-
const BANNER_LICENSE_LINE1 = COMMENT_PREFIX + ' ' + 'This software may be modified and distributed under the terms';
28-
const BANNER_LICENSE_LINE2 = COMMENT_PREFIX + ' ' + 'of the MIT license. See the LICENSE file in the root of the project for details.';
28+
const BANNER_LICENSE_LINE1 =
29+
COMMENT_PREFIX + ' ' + 'This software may be modified and distributed under the terms';
30+
const BANNER_LICENSE_LINE2 =
31+
COMMENT_PREFIX
32+
+ ' '
33+
+ 'of the MIT license. See the LICENSE file in the root of the project for details.';
2934
const BANNER_GITHUB = COMMENT_PREFIX + ' ' + GITHUB_URL;
3035

3136
const TEMPLATE_REGEX = /<%=\s*(\w+(?:\.\w+)*)\s*%>/g;
3237

33-
const runExecutor: PromiseExecutor<AddLicenseHeadersExecutorSchema> = async (
34-
options,
35-
context
36-
) => {
38+
const runExecutor: PromiseExecutor<AddLicenseHeadersExecutorSchema> = async (options, context) => {
3739
const absoluteProjectRoot = resolveProjectPath(context);
3840
const targetDirectory = path.join(
3941
absoluteProjectRoot,
40-
options.targetDirectory || DEFAULT_TARGET_DIR
42+
options.targetDirectory || DEFAULT_TARGET_DIR,
4143
);
4244
const packageJsonPath = path.join(
4345
absoluteProjectRoot,
44-
options.packageJsonPath || DEFAULT_PACKAGE_JSON
46+
options.packageJsonPath || DEFAULT_PACKAGE_JSON,
4547
);
4648

4749
let pkg;
@@ -92,7 +94,7 @@ const runExecutor: PromiseExecutor<AddLicenseHeadersExecutorSchema> = async (
9294
}
9395

9496
await writeFileText(file, banner + NEWLINE + content);
95-
})
97+
}),
9698
);
9799

98100
logger.info('License headers added successfully');

packages/nx-infra-plugin/src/executors/build-typescript/executor.e2e.spec.ts

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import * as fs from 'fs';
22
import * as path from 'path';
33
import executor from './executor';
44
import { BuildTypescriptExecutorSchema } from './schema';
5-
import {
6-
createTempDir,
7-
cleanupTempDir,
8-
createMockContext,
9-
} from '../../utils/test-utils';
5+
import { createTempDir, cleanupTempDir, createMockContext } from '../../utils/test-utils';
106
import { writeFileText, writeJson, readFileText } from '../../utils';
117

128
describe('BuildTypescriptExecutor E2E', () => {
@@ -24,59 +20,53 @@ describe('BuildTypescriptExecutor E2E', () => {
2420

2521
await writeFileText(
2622
path.join(srcDir, 'index.ts'),
27-
`export function hello(name: string): string {\n return \`Hello, \${name}!\`;\n}\n`
23+
`export function hello(name: string): string {\n return \`Hello, \${name}!\`;\n}\n`,
2824
);
2925

3026
await writeFileText(
3127
path.join(srcDir, 'utils.ts'),
32-
`export const add = (a: number, b: number): number => a + b;\n`
28+
`export const add = (a: number, b: number): number => a + b;\n`,
3329
);
3430

3531
fs.mkdirSync(path.join(srcDir, '__tests__'), { recursive: true });
3632
await writeFileText(
3733
path.join(srcDir, '__tests__', 'index.spec.ts'),
38-
`import { hello } from '../index';\ntest('hello', () => {});\n`
34+
`import { hello } from '../index';\ntest('hello', () => {});\n`,
3935
);
4036

41-
await writeJson(
42-
path.join(projectDir, 'tsconfig.esm.json'),
43-
{
44-
compilerOptions: {
45-
target: 'ES2020',
46-
module: 'ESNext',
47-
declaration: true,
48-
declarationMap: true,
49-
sourceMap: true,
50-
outDir: './npm/esm',
51-
rootDir: './src',
52-
strict: true,
53-
esModuleInterop: true,
54-
skipLibCheck: true,
55-
},
56-
include: ['src/**/*'],
57-
exclude: ['**/*.spec.ts', '**/__tests__/**'],
58-
}
59-
);
37+
await writeJson(path.join(projectDir, 'tsconfig.esm.json'), {
38+
compilerOptions: {
39+
target: 'ES2020',
40+
module: 'ESNext',
41+
declaration: true,
42+
declarationMap: true,
43+
sourceMap: true,
44+
outDir: './npm/esm',
45+
rootDir: './src',
46+
strict: true,
47+
esModuleInterop: true,
48+
skipLibCheck: true,
49+
},
50+
include: ['src/**/*'],
51+
exclude: ['**/*.spec.ts', '**/__tests__/**'],
52+
});
6053

61-
await writeJson(
62-
path.join(projectDir, 'tsconfig.json'),
63-
{
64-
compilerOptions: {
65-
target: 'ES2020',
66-
module: 'CommonJS',
67-
declaration: true,
68-
declarationMap: true,
69-
sourceMap: true,
70-
outDir: './npm/cjs',
71-
rootDir: './src',
72-
strict: true,
73-
esModuleInterop: true,
74-
skipLibCheck: true,
75-
},
76-
include: ['src/**/*'],
77-
exclude: ['**/*.spec.ts', '**/__tests__/**'],
78-
}
79-
);
54+
await writeJson(path.join(projectDir, 'tsconfig.json'), {
55+
compilerOptions: {
56+
target: 'ES2020',
57+
module: 'CommonJS',
58+
declaration: true,
59+
declarationMap: true,
60+
sourceMap: true,
61+
outDir: './npm/cjs',
62+
rootDir: './src',
63+
strict: true,
64+
esModuleInterop: true,
65+
skipLibCheck: true,
66+
},
67+
include: ['src/**/*'],
68+
exclude: ['**/*.spec.ts', '**/__tests__/**'],
69+
});
8070
});
8171

8272
afterEach(() => {

0 commit comments

Comments
 (0)