Skip to content

Commit 12252f3

Browse files
committed
Add prettier
1 parent 538a528 commit 12252f3

28 files changed

+522
-223
lines changed

.eslintrc.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ module.exports = {
99
"@typescript-eslint/ban-types": [
1010
"error",
1111
{
12-
"extendDefaults": true,
13-
"types": {
14-
"{}": false
15-
}
16-
}
12+
extendDefaults: true,
13+
types: {
14+
"{}": false,
15+
},
16+
},
1717
],
1818
// We're using ES2015 syntax
1919
"@typescript-eslint/no-namespace": "off",
2020
"@typescript-eslint/no-unused-vars": "error",
21-
"@typescript-eslint/no-var-requires": "off"
22-
}
21+
"@typescript-eslint/no-var-requires": "off",
22+
},
2323
};

.github/workflows/ci.yml

+53-53
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ on:
44
push:
55
branches:
66
- master
7-
- 'v*' # older version branches
7+
- "v*" # older version branches
88
tags:
9-
- '*'
9+
- "*"
1010
pull_request: {}
1111
schedule:
12-
- cron: '0 6 * * 0' # weekly, on sundays
12+
- cron: "0 6 * * 0" # weekly, on sundays
1313

1414
concurrency:
1515
group: ${{ github.head_ref || github.run_id }}
@@ -20,24 +20,24 @@ jobs:
2020
name: Lint
2121
runs-on: ubuntu-latest
2222
steps:
23-
- name: Ensure long path support
24-
run: git config --global core.longpaths true
25-
- uses: actions/checkout@v1
26-
- uses: volta-cli/action@v1
27-
with:
28-
node-version: 16
29-
- name: Cache
30-
uses: actions/cache@v2
31-
with:
32-
path: node-modules
33-
key: ${{ runner.os }}-16-${{ hashFiles('**/package-lock.json') }}-default
34-
restore-keys: |
35-
${{ runner.os }}-16-${{ hashFiles('**/package-lock.json') }}-default
36-
${{ runner.os }}-16-${{ hashFiles('**/package-lock.json') }}
37-
${{ runner.os }}-16-
38-
- name: install dependencies
39-
run: yarn install --frozen-lockfile
40-
- run: yarn lint
23+
- name: Ensure long path support
24+
run: git config --global core.longpaths true
25+
- uses: actions/checkout@v1
26+
- uses: volta-cli/action@v1
27+
with:
28+
node-version: 16
29+
- name: Cache
30+
uses: actions/cache@v2
31+
with:
32+
path: node-modules
33+
key: ${{ runner.os }}-16-${{ hashFiles('**/package-lock.json') }}-default
34+
restore-keys: |
35+
${{ runner.os }}-16-${{ hashFiles('**/package-lock.json') }}-default
36+
${{ runner.os }}-16-${{ hashFiles('**/package-lock.json') }}
37+
${{ runner.os }}-16-
38+
- name: install dependencies
39+
run: yarn install --frozen-lockfile
40+
- run: yarn lint
4141

4242
test:
4343
name: "Node ${{ matrix.node }} / TS: ${{ matrix.typescript }} - ${{ matrix.os }}"
@@ -47,9 +47,9 @@ jobs:
4747
strategy:
4848
fail-fast: false
4949
matrix:
50-
node: ['12', '14', '16']
51-
os: ['windows', 'ubuntu']
52-
typescript: ['default']
50+
node: ["12", "14", "16"]
51+
os: ["windows", "ubuntu"]
52+
typescript: ["default"]
5353
yarn-flags: ["--frozen-lockfile"]
5454
include:
5555
- node: 12
@@ -66,32 +66,32 @@ jobs:
6666
yarn-flags: "--no-lockfile"
6767

6868
steps:
69-
- name: Ensure long path support
70-
run: git config --global core.longpaths true
71-
- uses: actions/checkout@v1
72-
- uses: volta-cli/action@v1
73-
with:
74-
node-version: ${{ matrix.node }}
75-
- name: Cache
76-
uses: actions/cache@v2
77-
with:
78-
path: node-modules
79-
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}-${{ matrix.typescript }}
80-
restore-keys: |
81-
${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}-${{ matrix.typescript }}
82-
${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
83-
${{ runner.os }}-${{ matrix.node }}-
84-
- name: install dependencies
85-
run: yarn install ${{ matrix.yarn-flags }}
86-
- run: |
87-
git submodule init
88-
git submodule update --depth 1
89-
- name: Switch to alternate TS
90-
if: matrix.typescript != 'default'
91-
run: |
92-
yarn upgrade typescript@${{ matrix.typescript }}
93-
version=$(yarn tsc -v | grep Version | cut -d ' ' -f 2 | cut -d '.' -f 1,2)
94-
cd vendor/typescript
95-
git fetch origin release-${version} --depth 1
96-
git checkout FETCH_HEAD
97-
- run: yarn test:no-update
69+
- name: Ensure long path support
70+
run: git config --global core.longpaths true
71+
- uses: actions/checkout@v1
72+
- uses: volta-cli/action@v1
73+
with:
74+
node-version: ${{ matrix.node }}
75+
- name: Cache
76+
uses: actions/cache@v2
77+
with:
78+
path: node-modules
79+
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}-${{ matrix.typescript }}
80+
restore-keys: |
81+
${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}-${{ matrix.typescript }}
82+
${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
83+
${{ runner.os }}-${{ matrix.node }}-
84+
- name: install dependencies
85+
run: yarn install ${{ matrix.yarn-flags }}
86+
- run: |
87+
git submodule init
88+
git submodule update --depth 1
89+
- name: Switch to alternate TS
90+
if: matrix.typescript != 'default'
91+
run: |
92+
yarn upgrade typescript@${{ matrix.typescript }}
93+
version=$(yarn tsc -v | grep Version | cut -d ' ' -f 2 | cut -d '.' -f 1,2)
94+
cd vendor/typescript
95+
git fetch origin release-${version} --depth 1
96+
git checkout FETCH_HEAD
97+
- run: yarn test:no-update

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist
2+
node_modules
3+
src/generated
4+
tests/cases
5+
tests/expectations
6+
vendor

.vscode/launch.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"request": "launch",
88
"protocol": "inspector",
99
"program": "${workspaceRoot}/node_modules/qunitjs/bin/qunit",
10-
"args": [ "dist/tests.js" ],
11-
"runtimeArgs": [ "--no-lazy" ],
10+
"args": ["dist/tests.js"],
11+
"runtimeArgs": ["--no-lazy"],
1212
"cwd": "${workspaceRoot}",
1313
"preLaunchTask": "build",
1414
"env": { "NODE_ENV": "development" },

.vscode/tasks.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
{
88
"label": "test",
99
"type": "shell",
10-
"args": [
11-
"run",
12-
"test"
13-
],
10+
"args": ["run", "test"],
1411
"problemMatcher": [],
1512
"group": {
1613
"_id": "test",
@@ -20,10 +17,7 @@
2017
{
2118
"label": "build",
2219
"type": "shell",
23-
"args": [
24-
"run",
25-
"build"
26-
],
20+
"args": ["run", "build"],
2721
"problemMatcher": "$tsc",
2822
"group": {
2923
"_id": "build",

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ An optional string, which when provide should be a descriptive annotation. Usefu
5050

5151
An optional boolean, defaulting to `false`. If set to `true`, will cause the build to break on errors.
5252

53-
*note: if `process.env.NODE_ENV === 'production'` is true, `throwOnError` will default to `true`.*
53+
_note: if `process.env.NODE_ENV === 'production'` is true, `throwOnError` will default to `true`._
5454

5555
### Ways to use:
5656

package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@
3434
"build:tests": "tsc -p tests/tsconfig.json",
3535
"generate-tsconfig-interface": "yarn build:scripts && node scripts/build-tsconfig-interface.js",
3636
"link-self": "yarn link && yarn link broccoli-typescript-compiler",
37-
"lint": "eslint . --cache",
38-
"lint:fix": "eslint . --fix",
37+
"lint": "npm-run-all --continue-on-error --aggregate-output --parallel \"lint:!(fix)\"",
38+
"lint:fix": "npm-run-all lint:*:fix",
39+
"lint:eslint": "eslint . --cache",
40+
"lint:eslint:fix": "eslint . --fix",
41+
"lint:prettier": "prettier . --check",
42+
"lint:prettier:fix": "prettier . --write",
3943
"prepare": "npm run build",
4044
"test": "git submodule update --init && yarn test:no-update",
4145
"test:no-update": "qunit dist/tests/*-test.js"
@@ -62,7 +66,8 @@
6266
"json-schema": "^0.4.0",
6367
"json-schema-to-typescript": "^9.1.0",
6468
"mkdirp": "^1.0.3",
65-
"prettier": "^1.19.1",
69+
"npm-run-all": "^4.1.5",
70+
"prettier": "^2.5.1",
6671
"qunit": "^2.9.3",
6772
"rimraf": "^3.0.2",
6873
"rollup": "^1.31.1",

rollup.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import sourcemaps from "rollup-plugin-sourcemaps";
22

33
export default {
44
input: "dist/index.js",
5-
plugins: [
6-
sourcemaps(),
7-
],
5+
plugins: [sourcemaps()],
86
external: ["typescript", "fs", "crypto"],
97
output: { sourcemap: true, file: "dist/index.cjs.js", format: "cjs" },
108
};

scripts/build-expectations.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const formatDiagnosticsHost: ts.FormatDiagnosticsHost = {
2121
getNewLine,
2222
};
2323

24-
export function formatDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>): string {
24+
export function formatDiagnostics(
25+
diagnostics: ReadonlyArray<ts.Diagnostic>
26+
): string {
2527
return ts.formatDiagnostics(diagnostics, formatDiagnosticsHost);
2628
}
2729

@@ -30,7 +32,7 @@ const outputPath = path.resolve("tests/expectations", ts.versionMajorMinor);
3032
rimraf.sync(outputPath);
3133

3234
const testCases = fs.readdirSync("tests/cases");
33-
testCases.forEach(testCaseName => {
35+
testCases.forEach((testCaseName) => {
3436
console.log("test case", testCaseName);
3537
const basePath = path.resolve(path.join("tests/cases", testCaseName));
3638
console.log("basePath", basePath);

scripts/build-tsconfig-interface.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ http.get(
88
host: "json.schemastore.org",
99
path: "/tsconfig",
1010
},
11-
res => {
11+
(res) => {
1212
const chunks: Buffer[] = [];
13-
res.on("data", chunk => chunks.push(chunk as Buffer));
13+
res.on("data", (chunk) => chunks.push(chunk as Buffer));
1414
res.on("end", () => {
1515
const schema = JSON.parse(Buffer.concat(chunks).toString("utf8"));
1616
schema.title = "Typescript Config";
17-
schema.allOf = schema.allOf.filter(def => {
17+
schema.allOf = schema.allOf.filter((def) => {
1818
return (
1919
def.$ref !== "#/definitions/compileOnSaveDefinition" &&
2020
def.$ref !== "#/definitions/typeAcquisitionDefinition"
2121
);
2222
});
23-
compile(schema, "tsconfig").then(code => {
23+
compile(schema, "tsconfig").then((code) => {
2424
fs.writeFileSync(
2525
path.join(__dirname, "../src/generated/typescript-config.ts"),
2626
"// tslint:disable\n" + code

scripts/tsconfig.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@
44
"moduleResolution": "node",
55
"target": "es2015"
66
},
7-
"files": [
8-
"build-expectations.ts",
9-
"build-tsconfig-interface.ts"
10-
]
7+
"files": ["build-expectations.ts", "build-tsconfig-interface.ts"]
118
}

src/cache/directory-entries-cache-delegate.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
} from "../interfaces";
88

99
export default class DirEntriesCacheDelegate
10-
implements CacheDelegate<CanonicalPath, CanonicalPath, DirEntries> {
10+
implements CacheDelegate<CanonicalPath, CanonicalPath, DirEntries>
11+
{
1112
constructor(private resolver: PathResolver) {}
1213

1314
public cacheKey(path: CanonicalPath): CanonicalPath {

src/cache/path-info-cache-delegate.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
} from "../interfaces";
99

1010
export default class PathInfoCacheDelegate
11-
implements CacheDelegate<string, CanonicalPath, PathInfo> {
11+
implements CacheDelegate<string, CanonicalPath, PathInfo>
12+
{
1213
constructor(
1314
private rootPath: AbsolutePath,
1415
private inputPath: AbsolutePath

src/cache/resolution-cache-delegate.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
} from "../interfaces";
88

99
export default class ResolutionCacheDelegate
10-
implements CacheDelegate<PathInfo, CanonicalPath, Resolution> {
10+
implements CacheDelegate<PathInfo, CanonicalPath, Resolution>
11+
{
1112
public cacheKey(pathInfo: PathInfo): CanonicalPath {
1213
return pathInfo.canonicalPath;
1314
}

src/compiler/create-compiler-host.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ export default function createCompilerHost(
2424
): CompilerHost {
2525
const newLine = getNewLine(compilerOptions);
2626
return {
27-
directoryExists: path => input.directoryExists(path),
28-
fileExists: path => input.fileExists(path),
27+
directoryExists: (path) => input.directoryExists(path),
28+
fileExists: (path) => input.fileExists(path),
2929
getCanonicalFileName,
3030
getCurrentDirectory: () => workingPath,
31-
getDefaultLibFileName: options =>
31+
getDefaultLibFileName: (options) =>
3232
toCanonicalPath(getDefaultLibFileName(options), defaultLibLocation),
3333
getDefaultLibLocation: () => defaultLibLocation,
34-
getDirectories: path => input.getDirectories(path),
34+
getDirectories: (path) => input.getDirectories(path),
3535
getNewLine: () => newLine,
36-
getSourceFile: fileName =>
36+
getSourceFile: (fileName) =>
3737
sourceCache.getSourceFile(fileName) as SourceFile,
3838
getSourceFileByPath: (fileName, path) =>
3939
sourceCache.getSourceFileByPath(fileName, path) as SourceFile,
40-
readFile: path => input.readFile(path) as string,
41-
realpath: path => input.realpath(path) as string,
42-
trace: s => sys.write(s + newLine),
40+
readFile: (path) => input.readFile(path) as string,
41+
realpath: (path) => input.realpath(path) as string,
42+
trace: (s) => sys.write(s + newLine),
4343
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
4444
writeFile: () => {
4545
// we provide a write file on emit.

src/compiler/create-parse-config-host.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function createParseConfigHost(
1111
return input.getFileSystemEntries(path);
1212
}
1313

14-
function realpath(path: string): string {
14+
function realpath(path: string): string {
1515
return input.realpath(path) || path;
1616
}
1717

@@ -66,6 +66,6 @@ declare module "typescript" {
6666
currentDirectory: string,
6767
depth: number | undefined,
6868
getFileSystemEntries: (path: string) => FileSystemEntries,
69-
realpath: (path: string) => string,
69+
realpath: (path: string) => string
7070
): string[];
7171
}

src/compiler/output-patcher.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class OutputPatcher {
5151
lastTree = FSTree.fromEntries(walkSync.entries(outputPath));
5252
}
5353
const patch = lastTree.calculatePatch(nextTree, isUnchanged);
54-
patch.forEach(change => {
54+
patch.forEach((change) => {
5555
const op = change[0];
5656
const path = change[1];
5757
const entry = change[2];

0 commit comments

Comments
 (0)