Skip to content

Commit 55e7a08

Browse files
authored
Merge pull request #17 from maks-rafalko/feature/line-width-120
Use 120 line width
2 parents d4a7664 + d8ea680 commit 55e7a08

File tree

7 files changed

+30
-84
lines changed

7 files changed

+30
-84
lines changed

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@
4747
"@typescript-eslint/semi": ["error", "always"],
4848
"@typescript-eslint/type-annotation-spacing": "error",
4949
"@typescript-eslint/unbound-method": "error",
50-
"prettier/prettier": ["error", { "semi": true }]
50+
"prettier/prettier": [
51+
"error",
52+
{
53+
"semi": true,
54+
"printWidth": 120
55+
}
56+
]
5157
},
5258
"env": {
5359
"node": true,

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 80,
2+
"printWidth": 120,
33
"tabWidth": 2,
44
"useTabs": false,
55
"semi": true,

__tests__/main.test.ts

Lines changed: 13 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import {expect, test} from '@jest/globals';
22

3-
import {
4-
getTouchedSourceFilesRequireTests,
5-
getTouchedTestFiles,
6-
File
7-
} from '../src/fileFilters';
3+
import {getTouchedSourceFilesRequireTests, getTouchedTestFiles, File} from '../src/fileFilters';
84

95
test('getTouchedSourceFilesRequireTests should filter out files by file extensions', () => {
10-
const files: File[] = [
11-
{filename: 'README.md'},
12-
{filename: 'foo.php'},
13-
{filename: 'bar.ts'}
14-
];
6+
const files: File[] = [{filename: 'README.md'}, {filename: 'foo.php'}, {filename: 'bar.ts'}];
157
const extensions = ['.php'];
168

179
const filteredFiles = getTouchedSourceFilesRequireTests(files, extensions);
@@ -37,54 +29,24 @@ test('getTouchedTestFiles should return test files from the list of different fi
3729
expect(filteredFilesTestDir[0].filename).toBe('lib/tests/bar1.ts');
3830
expect(filteredFilesTestDir[1].filename).toBe('lib/tests/foo1.ts');
3931

40-
const filteredFilesTestPatternSimple = getTouchedTestFiles(
41-
files,
42-
'',
43-
'*_test.ts'
44-
);
32+
const filteredFilesTestPatternSimple = getTouchedTestFiles(files, '', '*_test.ts');
4533
expect(filteredFilesTestPatternSimple.length).toBe(1);
4634
expect(filteredFilesTestPatternSimple[0].filename).toBe('test_test.ts');
4735

48-
const filteredFilesTestPatternSubdir = getTouchedTestFiles(
49-
files,
50-
'',
51-
'*/test/*.ts'
52-
);
36+
const filteredFilesTestPatternSubdir = getTouchedTestFiles(files, '', '*/test/*.ts');
5337
expect(filteredFilesTestPatternSubdir.length).toBe(1);
5438
expect(filteredFilesTestPatternSubdir[0].filename).toBe('a/test/bar3.ts');
5539

56-
const filteredFilesTestPatternAllInTests = getTouchedTestFiles(
57-
files,
58-
'',
59-
'**/tests/*.ts'
60-
);
40+
const filteredFilesTestPatternAllInTests = getTouchedTestFiles(files, '', '**/tests/*.ts');
6141
expect(filteredFilesTestPatternAllInTests.length).toBe(3);
62-
expect(filteredFilesTestPatternAllInTests[0].filename).toBe(
63-
'lib/tests/bar1.ts'
64-
);
65-
expect(filteredFilesTestPatternAllInTests[1].filename).toBe(
66-
'lib/tests/foo1.ts'
67-
);
68-
expect(filteredFilesTestPatternAllInTests[2].filename).toBe(
69-
'a/tests/bar4.ts'
70-
);
42+
expect(filteredFilesTestPatternAllInTests[0].filename).toBe('lib/tests/bar1.ts');
43+
expect(filteredFilesTestPatternAllInTests[1].filename).toBe('lib/tests/foo1.ts');
44+
expect(filteredFilesTestPatternAllInTests[2].filename).toBe('a/tests/bar4.ts');
7145

72-
const filteredFilesTestBothDirAndPattern = getTouchedTestFiles(
73-
files,
74-
'lib/testsxxx',
75-
'**/tests/*.ts'
76-
);
46+
const filteredFilesTestBothDirAndPattern = getTouchedTestFiles(files, 'lib/testsxxx', '**/tests/*.ts');
7747
expect(filteredFilesTestBothDirAndPattern.length).toBe(4);
78-
expect(filteredFilesTestBothDirAndPattern[0].filename).toBe(
79-
'lib/testsxxx/bar2.ts'
80-
);
81-
expect(filteredFilesTestBothDirAndPattern[1].filename).toBe(
82-
'lib/tests/bar1.ts'
83-
);
84-
expect(filteredFilesTestBothDirAndPattern[2].filename).toBe(
85-
'lib/tests/foo1.ts'
86-
);
87-
expect(filteredFilesTestBothDirAndPattern[3].filename).toBe(
88-
'a/tests/bar4.ts'
89-
);
48+
expect(filteredFilesTestBothDirAndPattern[0].filename).toBe('lib/testsxxx/bar2.ts');
49+
expect(filteredFilesTestBothDirAndPattern[1].filename).toBe('lib/tests/bar1.ts');
50+
expect(filteredFilesTestBothDirAndPattern[2].filename).toBe('lib/tests/foo1.ts');
51+
expect(filteredFilesTestBothDirAndPattern[3].filename).toBe('a/tests/bar4.ts');
9052
});

dist/index.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/fileFilters.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,15 @@ export type File = {
44
filename: string;
55
};
66

7-
export function getTouchedSourceFilesRequireTests(
8-
files: File[],
9-
fileExtensions: string[]
10-
): File[] {
7+
export function getTouchedSourceFilesRequireTests(files: File[], fileExtensions: string[]): File[] {
118
return files.filter(file => {
129
return fileExtensions.find((fileExtension: string) => {
1310
return file.filename.endsWith(fileExtension);
1411
});
1512
});
1613
}
1714

18-
export function getTouchedTestFiles(
19-
files: File[],
20-
testDir: string,
21-
testPattern: string
22-
): File[] {
15+
export function getTouchedTestFiles(files: File[], testDir: string, testPattern: string): File[] {
2316
let filtered: File[] = [];
2417

2518
if (testDir) {

src/main.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import * as core from '@actions/core';
22
import * as github from '@actions/github';
3-
import {
4-
getTouchedSourceFilesRequireTests,
5-
getTouchedTestFiles
6-
} from './fileFilters';
3+
import {getTouchedSourceFilesRequireTests, getTouchedTestFiles} from './fileFilters';
74

85
function getFileExtensions(): string[] {
96
const fileExtensionsInput = core.getInput('fileExtensions');
@@ -20,18 +17,14 @@ async function run(): Promise<void> {
2017
const {context} = github;
2118

2219
const config = {
23-
comment:
24-
core.getInput('comment') ||
25-
'Could you please add tests to make sure this change works as expected?',
20+
comment: core.getInput('comment') || 'Could you please add tests to make sure this change works as expected?',
2621
fileExtensions: getFileExtensions(),
2722
testDir: core.getInput('testDir') || 'tests',
2823
testPattern: core.getInput('testPattern') || ''
2924
};
3025

3126
if (context.payload.pull_request == null) {
32-
core.debug(
33-
'This action is supposed to be run on pull_request event only.'
34-
);
27+
core.debug('This action is supposed to be run on pull_request event only.');
3528
}
3629

3730
const githubToken: string = core.getInput('GITHUB_TOKEN');
@@ -56,21 +49,14 @@ async function run(): Promise<void> {
5649
res => res.data
5750
);
5851

59-
const sourceFilesRequireTests = getTouchedSourceFilesRequireTests(
60-
allFiles,
61-
config.fileExtensions
62-
);
52+
const sourceFilesRequireTests = getTouchedSourceFilesRequireTests(allFiles, config.fileExtensions);
6353

6454
if (sourceFilesRequireTests.length === 0) {
6555
core.debug('No source files require tests, exiting');
6656
return;
6757
}
6858

69-
const testFiles = getTouchedTestFiles(
70-
allFiles,
71-
config.testDir,
72-
config.testPattern
73-
);
59+
const testFiles = getTouchedTestFiles(allFiles, config.testDir, config.testPattern);
7460

7561
if (testFiles.length !== 0) {
7662
core.debug('Test files were touched, exiting');

0 commit comments

Comments
 (0)