Skip to content

Commit

Permalink
upgrade prettier + misc dangling TS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fbartho committed Feb 1, 2022
1 parent 3cee6a0 commit bc614e7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"git add"
],
"*.@(ts|tsx)": [
"eslint --fix",
"yarn lint:fix",
"yarn prettier --write",
"git add"
]
Expand Down Expand Up @@ -131,7 +131,7 @@
"madge": "^3.2.0",
"nock": "^10.0.6",
"pkg": "^4.4.2",
"prettier": "^1.14.2",
"prettier": "^2.5.1",
"release-it": "^13.5.2",
"shx": "^0.3.2",
"ts-jest": "^24.0.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-danger-dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (allDiagnostics.length) {
console.log(
"\nIf you've added something new to the DSL, and the errors are about something missing, you may need to add an interface in `source/dsl/*`."
)
allDiagnostics.forEach(diagnostic => {
allDiagnostics.forEach((diagnostic) => {
if (diagnostic.file) {
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!)
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
Expand Down
20 changes: 8 additions & 12 deletions scripts/danger-dts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import * as fs from "fs"
import * as prettier from "prettier"

const mapLines = (s: string, func: (s: string) => string) =>
s
.split("\n")
.map(func)
.join("\n")
const mapLines = (s: string, func: (s: string) => string) => s.split("\n").map(func).join("\n")

const createDTS = () => {
const header = `//
Expand All @@ -23,10 +19,10 @@ import { File } from "parse-diff"

const dslFiles = fs
.readdirSync("source/dsl")
.filter(f => !f.startsWith("_tests"))
.map(f => `source/dsl/${f}`)
.filter((f) => !f.startsWith("_tests"))
.map((f) => `source/dsl/${f}`)

dslFiles.forEach(file => {
dslFiles.forEach((file) => {
// Sometimes they have more stuff, in those cases
// offer a way to crop the file.
const content = fs.readFileSync(file).toString()
Expand Down Expand Up @@ -72,7 +68,7 @@ import { File } from "parse-diff"
const chainDefs = fs.readFileSync("distribution/commands/utils/chainsmoker.d.ts", "utf8")
const chainDefsMinusDefaultExport = chainDefs
.split("\n")
.filter(line => {
.filter((line) => {
return !line.startsWith("export default function")
})
.join("\n")
Expand All @@ -82,10 +78,10 @@ import { File } from "parse-diff"
// Remove all JS-y bits
fileOutput = fileOutput
.split("\n")
.filter(line => {
.filter((line) => {
return !line.startsWith("import") && !line.includes("* @type ")
})
.filter(line => {
.filter((line) => {
return !line.includes("Please don't have")
})
.join("\n")
Expand All @@ -94,7 +90,7 @@ import { File } from "parse-diff"
const noRedundantExports = trimmedWhitespaceLines
.replace(/export interface/g, "interface")
.replace(/export type/g, "type")
const indentedBody = mapLines(noRedundantExports, line => (line.length ? line : ""))
const indentedBody = mapLines(noRedundantExports, (line) => (line.length ? line : ""))

const def = header + indentedBody + footer

Expand Down
8 changes: 4 additions & 4 deletions source/platforms/git/localLogGitCommits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const fieldMap = {
export type GitLogOptions = {
number: number
branch: string
fields: Array<Partial<keyof typeof fieldMap>>
fields: ReadonlyArray<Partial<keyof typeof fieldMap>>
}

export type GitLogCommit = {
Expand All @@ -44,7 +44,7 @@ const createCommandArguments = (options: GitLogOptions) => {

// Iterating through the fields and adding them to the custom format
if (options.fields) {
options.fields.forEach(field => {
options.fields.forEach((field) => {
prettyArgument += delimiter + fieldMap[field]
})
}
Expand All @@ -61,8 +61,8 @@ const createCommandArguments = (options: GitLogOptions) => {
return command
}

const parseCommits = (commits: string[], fields: string[]) =>
commits.map(rawCommit => {
const parseCommits = (commits: readonly string[], fields: readonly string[]) =>
commits.map((rawCommit) => {
const parts = rawCommit.split("@end@")
const commit = parts[0].split(delimiter)

Expand Down
4 changes: 2 additions & 2 deletions source/platforms/gitlab/GitLabAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ class GitLabAPI {
const api = this.api.MergeRequestDiscussions

try {
const result: string = await api.create(this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, content, {
const result = await api.create(this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, content, {
position: position,
})
this.d("createMergeRequestDiscussion", result)
return result
return result as unknown as string // not sure why?
} catch (e) {
this.d("createMergeRequestDiscussion", e)
throw e
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["scripts", "node_modules", "distribution", "types"]
"exclude": ["node_modules", "distribution", "types"]
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7538,10 +7538,10 @@ prepend-http@^2.0.0:
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=

prettier@^1.14.2:
version "1.14.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895"
integrity sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==
prettier@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==

pretty-format@^23.6.0:
version "23.6.0"
Expand Down

0 comments on commit bc614e7

Please sign in to comment.