Skip to content

Commit 3bf07b5

Browse files
chore: move CI to GitHub Actions and fix internal complaints (#1888)
* chore: move CI to GitHub Actions * Switch prepare action to npm * workflows/ * Test fill: mergeLintConfigurations * ignore globAsync complaints * npm run format:write * More convertVSCodeConfig tests * Remove branch requirement altogether * More convertVSCodeConfig tests
1 parent fcc517b commit 3bf07b5

File tree

10 files changed

+208
-138
lines changed

10 files changed

+208
-138
lines changed

.circleci/config.yml

Lines changed: 0 additions & 131 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: Prepares the repo for a typical CI job
2+
3+
name: Prepare
4+
5+
runs:
6+
steps:
7+
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
8+
with:
9+
cache: npm
10+
node-version: 24.11.1
11+
- run: npm ci
12+
shell: bash
13+
using: composite

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
jobs:
2+
compile:
3+
name: Compile
4+
runs-on: ubuntu-latest
5+
steps:
6+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
7+
- uses: ./.github/actions/prepare
8+
- run: npm run compile
9+
- run: node bin/tslint-to-eslint-config --version
10+
format:
11+
name: Format
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
15+
- uses: ./.github/actions/prepare
16+
- run: npm run prettier -- --list-different
17+
lint:
18+
name: Lint
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
22+
- uses: ./.github/actions/prepare
23+
- run: npm run eslint
24+
test:
25+
name: Test
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
29+
- uses: ./.github/actions/prepare
30+
- run: npm run test:ci
31+
32+
name: CI
33+
34+
on:
35+
pull_request: ~
36+
push:
37+
branches:
38+
- main

jest.config.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module.exports = {
1313
],
1414
coverageThreshold: {
1515
global: {
16-
branches: 100,
1716
functions: 100,
1817
lines: 100,
1918
statements: 100,

src/adapters/globAsync.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { glob } from "glob";
22

33
export const globAsync = async (pattern: string) => {
44
return new Promise<Error | string[]>((resolve) => {
5+
/* eslint-disable */
6+
// @ts-expect-error -- Will be removed in #1886.
57
glob(pattern, (error, matches) => {
68
resolve(error ?? matches);
79
});
10+
/* eslint-enable */
811
});
912
};
1013

src/binding.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ export type WithDependencies<Args extends any[] = any[], Return = any> = (
33
...args: Args
44
) => Return;
55

6-
export type SansDependencies<Method> = Method extends WithDependencies<infer Args, infer Return>
7-
? (...args: Args) => Return
8-
: never;
6+
export type SansDependencies<Method> =
7+
Method extends WithDependencies<infer Args, infer Return> ? (...args: Args) => Return : never;
98

109
export const bind = <Dependencies = any, Args extends any[] = any[], Return = any>(
1110
method: WithDependencies<Args, Return>,

src/cli/runCli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const createStubRunCliDependencies = (overrides: Partial<RunCliDependencies> = {
1616
({
1717
data: createStubOriginalConfigurationsData(),
1818
status: ResultStatus.Succeeded,
19-
} as const),
19+
}) as const,
2020
...overrides,
2121
logger: createStubLogger(),
2222
});

src/converters/editorConfigs/converters/convertVSCodeConfig.test.ts

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,94 @@ Object {
4141
`);
4242
});
4343

44+
it("does not include eslint.autoFixOnSave when editor.codeActionsOnSave is false", () => {
45+
// Arrange
46+
const editorSettings = {
47+
"editor.codeActionsOnSave": false,
48+
unrelated: true,
49+
};
50+
51+
// Act
52+
const result = convertVSCodeConfig(JSON.stringify(editorSettings, null, 4), stubSettings);
53+
54+
// Assert
55+
expect(result).toMatchInlineSnapshot(`
56+
Object {
57+
"contents": "{
58+
\\"editor.codeActionsOnSave\\": false,
59+
\\"unrelated\\": true
60+
}",
61+
"missing": Array [],
62+
}
63+
`);
64+
});
65+
66+
it("does not include eslint.autoFixOnSave when editor.codeActionsOnSave is null", () => {
67+
// Arrange
68+
const editorSettings = {
69+
"editor.codeActionsOnSave": null,
70+
unrelated: true,
71+
};
72+
73+
// Act
74+
const result = convertVSCodeConfig(JSON.stringify(editorSettings, null, 4), stubSettings);
75+
76+
// Assert
77+
expect(result).toMatchInlineSnapshot(`
78+
Object {
79+
"contents": "{
80+
\\"editor.codeActionsOnSave\\": null,
81+
\\"unrelated\\": true
82+
}",
83+
"missing": Array [],
84+
}
85+
`);
86+
});
87+
88+
it("does not include eslint.autoFixOnSave when editor.codeActionsOnSave is a number", () => {
89+
// Arrange
90+
const editorSettings = {
91+
"editor.codeActionsOnSave": 1,
92+
unrelated: true,
93+
};
94+
95+
// Act
96+
const result = convertVSCodeConfig(JSON.stringify(editorSettings, null, 4), stubSettings);
97+
98+
// Assert
99+
expect(result).toMatchInlineSnapshot(`
100+
Object {
101+
"contents": "{
102+
\\"editor.codeActionsOnSave\\": 1,
103+
\\"unrelated\\": true
104+
}",
105+
"missing": Array [],
106+
}
107+
`);
108+
});
109+
110+
it("does not include eslint.autoFixOnSave when editor.codeActionsOnSave is an empty object", () => {
111+
// Arrange
112+
const editorSettings = {
113+
"editor.codeActionsOnSave": {},
114+
unrelated: true,
115+
};
116+
117+
// Act
118+
const result = convertVSCodeConfig(JSON.stringify(editorSettings, null, 4), stubSettings);
119+
120+
// Assert
121+
expect(result).toMatchInlineSnapshot(`
122+
Object {
123+
"contents": "{
124+
\\"editor.codeActionsOnSave\\": {},
125+
\\"unrelated\\": true
126+
}",
127+
"missing": Array [],
128+
}
129+
`);
130+
});
131+
44132
it("does not include eslint.autoFixOnSave when source.fixAll.tslint is false", () => {
45133
// Arrange
46134
const editorSettings = {
@@ -112,6 +200,23 @@ Object {
112200
});
113201
});
114202

203+
it("does not include configFile when tslint.configFile is a number", () => {
204+
// Arrange
205+
const editorSettings = {
206+
"tslint.configFile": 1,
207+
unrelated: true,
208+
};
209+
210+
// Act
211+
const result = convertVSCodeConfig(JSON.stringify(editorSettings, null, 4), stubSettings);
212+
213+
// Assert
214+
expect(result).toEqual({
215+
contents: JSON.stringify(editorSettings, null, 4),
216+
missing: [],
217+
});
218+
});
219+
115220
it("includes configFile when tslint.configFile matches", () => {
116221
// Arrange
117222
const editorSettings = {
@@ -138,6 +243,28 @@ Object {
138243
`);
139244
});
140245

246+
it("does not include configFile when tslint.configFile does not match", () => {
247+
// Arrange
248+
const editorSettings = {
249+
"tslint.configFile": "../other.json",
250+
unrelated: true,
251+
};
252+
253+
// Act
254+
const result = convertVSCodeConfig(JSON.stringify(editorSettings, null, 4), stubSettings);
255+
256+
// Assert
257+
expect(result).toMatchInlineSnapshot(`
258+
Object {
259+
"contents": "{
260+
\\"tslint.configFile\\": \\"../other.json\\",
261+
\\"unrelated\\": true
262+
}",
263+
"missing": Array [],
264+
}
265+
`);
266+
});
267+
141268
it("includes missing notices when known missing settings are included", () => {
142269
// Arrange
143270
const editorSettings = {

src/errors/configurationError.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { EOL } from "os";
33
import { ErrorSummary } from "./errorSummary";
44

55
export class ConfigurationError implements ErrorSummary {
6-
public constructor(private readonly error: Error, private readonly complaint: string) {}
6+
public constructor(
7+
private readonly error: Error,
8+
private readonly complaint: string,
9+
) {}
710

811
public getSummary(): string {
912
return `${this.complaint}: ${this.error.stack}${EOL}`;

0 commit comments

Comments
 (0)