Skip to content

Commit c6fe8d2

Browse files
authored
refactor: format code using deno's configuration (#146)
1 parent b32a305 commit c6fe8d2

36 files changed

+386
-207
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
## Our Pledge
44

5-
In the interest of fostering an open and welcoming environment, we as
6-
contributors and maintainers pledge to making participation in our project and
7-
our community a harassment-free experience for everyone, regardless of age, body
8-
size, disability, ethnicity, sex characteristics, gender identity and expression,
9-
level of experience, education, socio-economic status, nationality, personal
10-
appearance, race, religion, or sexual identity and orientation.
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making
6+
participation in our project and our community a harassment-free experience for everyone, regardless of age, body size,
7+
disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education,
8+
socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
119

1210
## Our Standards
1311

14-
Examples of behavior that contributes to creating a positive environment
15-
include:
12+
Examples of behavior that contributes to creating a positive environment include:
1613

1714
- Using welcoming and inclusive language
1815
- Being respectful of differing viewpoints and experiences
@@ -22,56 +19,44 @@ include:
2219

2320
Examples of unacceptable behavior by participants include:
2421

25-
- The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
22+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
2723
- Trolling, insulting/derogatory comments, and personal or political attacks
2824
- Public or private harassment
29-
- Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
- Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
26+
- Other conduct which could reasonably be considered inappropriate in a professional setting
3327

3428
## Our Responsibilities
3529

36-
Project maintainers are responsible for clarifying the standards of acceptable
37-
behavior and are expected to take appropriate and fair corrective action in
38-
response to any instances of unacceptable behavior.
30+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
31+
appropriate and fair corrective action in response to any instances of unacceptable behavior.
3932

40-
Project maintainers have the right and responsibility to remove, edit, or
41-
reject comments, commits, code, wiki edits, issues, and other contributions
42-
that are not aligned to this Code of Conduct, or to ban temporarily or
43-
permanently any contributor for other behaviors that they deem inappropriate,
44-
threatening, offensive, or harmful.
33+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
34+
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
35+
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
4536

4637
## Scope
4738

48-
This Code of Conduct applies both within project spaces and in public spaces
49-
when an individual is representing the project or its community. Examples of
50-
representing a project or community include using an official project e-mail
51-
address, posting via an official social media account, or acting as an appointed
52-
representative at an online or offline event. Representation of a project may be
53-
further defined and clarified by project maintainers.
39+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
40+
project or its community. Examples of representing a project or community include using an official project e-mail
41+
address, posting via an official social media account, or acting as an appointed representative at an online or offline
42+
event. Representation of a project may be further defined and clarified by project maintainers.
5443

5544
## Enforcement
5645

57-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported
58-
by contacting the project team on twitter via direct message at
59-
[https://twitter.com/DavidSherret](https://twitter.com/DavidSherret) (DMs open). All
60-
complaints will be reviewed and investigated and will result in a response that
61-
is deemed necessary and appropriate to the circumstances. The project team is
62-
obligated to maintain confidentiality with regard to the reporter of an incident.
46+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team on
47+
twitter via direct message at [https://twitter.com/DavidSherret](https://twitter.com/DavidSherret) (DMs open). All
48+
complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to
49+
the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
6350
Further details of specific enforcement policies may be posted separately.
6451

65-
Project maintainers who do not follow or enforce the Code of Conduct in good
66-
faith may face temporary or permanent repercussions as determined by other
67-
members of the project's leadership.
52+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
53+
repercussions as determined by other members of the project's leadership.
6854

6955
## Attribution
7056

71-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
72-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
57+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at
58+
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
7359

7460
[homepage]: https://www.contributor-covenant.org
7561

76-
For answers to common questions about this code of conduct, see
77-
https://www.contributor-covenant.org/faq
62+
For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq

deno.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
]
1313
},
1414
"fmt": {
15+
"lineWidth": 120,
1516
"exclude": [
17+
"src/resources",
1618
"**/*.generated.ts"
1719
]
1820
},

dprint.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
{
2-
"lineWidth": 160,
2+
"typescript": {
3+
"lineWidth": 120,
4+
"deno": true
5+
},
6+
"json": {
7+
"lineWidth": 120,
8+
"deno": true
9+
},
10+
"markdown": {
11+
"lineWidth": 120,
12+
"deno": true
13+
},
314
"excludes": [
415
"**/node_modules",
516
"**/*-lock.json",
617
"dist",
718
"src/resources"
819
],
920
"plugins": [
10-
"https://plugins.dprint.dev/typescript-0.89.3.wasm",
21+
"https://plugins.dprint.dev/typescript-0.90.2.wasm",
1122
"https://plugins.dprint.dev/json-0.19.2.wasm",
1223
"https://plugins.dprint.dev/markdown-0.16.4.wasm",
13-
"https://plugins.dprint.dev/prettier-0.39.0.json@896b70f29ef8213c1b0ba81a93cee9c2d4f39ac2194040313cd433906db7bc7c"
24+
"https://plugins.dprint.dev/prettier-0.40.0.json@68c668863ec834d4be0f6f5ccaab415df75336a992aceb7eeeb14fdf096a9e9c"
1425
]
1526
}

index.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
<head>
44
<script>
55
// redirect to new domain if on the old one
6-
if (/dsherret\.github\.io/i.test(window.location.host)) window.location.href = "https://ts-ast-viewer.com";
6+
if (/dsherret\.github\.io/i.test(window.location.host))
7+
window.location.href = "https://ts-ast-viewer.com";
78
</script>
89

910
<meta charset="utf-8" />
10-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
11+
<meta
12+
name="viewport"
13+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
14+
/>
1115
<meta name="theme-color" content="#FFFFFF" />
12-
<meta name="description" content="Interactive viewer to help visualize the TypeScript Compiler API's AST." />
16+
<meta
17+
name="description"
18+
content="Interactive viewer to help visualize the TypeScript Compiler API's AST."
19+
/>
1320
<link rel="manifest" href="manifest.json" />
1421
<title>TypeScript AST Viewer</title>
1522
</head>

readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Source code for https://ts-ast-viewer.com
66

77
## Developing
88

9-
Install [Deno](https://deno.com) (this currently requires `canary`—run `deno upgrade --canary`) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
9+
Install [Deno](https://deno.com) (this currently requires `canary`—run `deno upgrade --canary`) and
10+
[npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
1011

1112
```
1213
# install packages
@@ -21,4 +22,5 @@ deno task test
2122

2223
### Factory Code Generation
2324

24-
The code that code generates the factory code is automatically maintained by [ts-factory-code-generator-generator](https://github.com/dsherret/ts-factory-code-generator-generator/).
25+
The code that code generates the factory code is automatically maintained by
26+
[ts-factory-code-generator-generator](https://github.com/dsherret/ts-factory-code-generator-generator/).

scripts/addTypeScriptVersions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ async function getTypeScriptVersionsToInstall() {
2121
// get the highest version for each minor
2222
for (const version of versions) {
2323
if (
24-
version == null
25-
|| version.prerelease.length > 0
26-
|| version.build.length > 0
24+
version == null ||
25+
version.prerelease.length > 0 ||
26+
version.build.length > 0
2727
) {
2828
continue;
2929
}
@@ -34,12 +34,12 @@ async function getTypeScriptVersionsToInstall() {
3434
}
3535
const finalVersions = Object.values(highestMinors).sort(semver.compare);
3636
// select the most recent 9 versions
37-
return finalVersions.slice(-9).map(v => semver.format(v));
37+
return finalVersions.slice(-9).map((v) => semver.format(v));
3838
}
3939

4040
async function getAllTypeScriptVersions() {
4141
// { "x.x.x": "time", ... }
4242
const data = await $`npm show typescript time --json`.json();
4343
const versions = Object.keys(data);
44-
return versions.filter(v => semver.canParse(v)).map(v => semver.parse(v)).sort(semver.compare);
44+
return versions.filter((v) => semver.canParse(v)).map((v) => semver.parse(v)).sort(semver.compare);
4545
}

scripts/copyLibFiles.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ for (const version of versions) {
2828
const fileText = fs.readFileSync(filePath).toString("utf8");
2929
fs.writeFileSync(
3030
newFilePath,
31-
`const fileData = {\n`
32-
+ ` fileName: \`/${path.basename(filePath)}\`,\n`
33-
+ ` // File text is copyright Microsoft Corporation and is distributed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)\n`
34-
+ ` text: \"${minifier.minify(fileText).replace(/\r?\n/g, "\\n").replace(/"/g, "\\\"")}\"\n`
35-
+ `};\n\n`
36-
+ `export default fileData;`,
31+
`const fileData = {\n` +
32+
` fileName: \`/${path.basename(filePath)}\`,\n` +
33+
` // File text is copyright Microsoft Corporation and is distributed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)\n` +
34+
` text: \"${minifier.minify(fileText).replace(/\r?\n/g, "\\n").replace(/"/g, '\\"')}\"\n` +
35+
`};\n\n` +
36+
`export default fileData;`,
3737
{ encoding: "utf8" },
3838
);
3939
}
4040

4141
fs.writeFileSync(
4242
libVersionDir + "index.ts",
4343
filePaths
44-
.map(p => path.basename(p, ".d.ts"))
45-
.map((p, i) => "export { default as export" + i + " } from \"./" + p + ".js\";").join("\n") + "\n",
44+
.map((p) => path.basename(p, ".d.ts"))
45+
.map((p, i) => "export { default as export" + i + ' } from "./' + p + '.js";').join("\n") + "\n",
4646
{ encoding: "utf8" },
4747
);
4848
}

0 commit comments

Comments
 (0)