Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump prettier from 2.8.8 to 3.0.0 #132

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -10,6 +10,7 @@
"sideEffects": "false",
"scripts": {
"test": "jest",
"format": "prettier --write src/**/*.ts",
"lint": "eslint --max-warnings 0 ./src",
"build": "tsc -p tsconfig.json",
"clean": "rm -rf dist build",
Expand Down Expand Up @@ -64,9 +65,9 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.4",
"eslint-plugin-jsdoc": "^46.2.6",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"jest": "^29.0.0",
"prettier": "^2.5.1",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"typescript": "^5.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/main.test.ts
Expand Up @@ -11,7 +11,7 @@ describe("parseAllPacks", () => {
parseAllPacks(packsRoot).map((p) => ({
name: p.name,
songs: p.songCount,
}))
})),
).toMatchInlineSnapshot(`
[
{
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/parseSimfile.test.ts
Expand Up @@ -172,7 +172,7 @@ describe("parseSong", () => {

test("single varied bpm song", () => {
const simfile = parseSong(
path.join(packsRoot, "A20-(beta)", "Silly Love")
path.join(packsRoot, "A20-(beta)", "Silly Love"),
)!;
scrubDataForSnapshot(simfile);
expect(simfile).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -1448,7 +1448,7 @@ describe("parseSong", () => {

test("single new song", () => {
const simfile = parseSong(
path.join(packsRoot, "Club Fantastic Season 2", "TerpZone")
path.join(packsRoot, "Club Fantastic Season 2", "TerpZone"),
)!;
scrubDataForSnapshot(simfile);
expect(simfile).toMatchInlineSnapshot(`
Expand Down
4 changes: 2 additions & 2 deletions src/calculateStats.ts
Expand Up @@ -21,7 +21,7 @@ function isFreeze(d: Arrow["direction"]): boolean {
function isGallop(
d: Arrow,
p: Arrow | undefined,
g: Arrow | undefined
g: Arrow | undefined,
): boolean {
if (!p) {
return false;
Expand Down Expand Up @@ -79,7 +79,7 @@ export function calculateStats(chart: Stepchart): Stats {
const jumps = chart.arrows.filter((a) => isJump(a.direction));
const freezes = chart.arrows.filter((a) => isFreeze(a.direction));
const gallops = chart.arrows.filter((a, i, array) =>
isGallop(a, array[i - 1], array[i - 2])
isGallop(a, array[i - 1], array[i - 2]),
);
const jacks = chart.arrows.filter((a, i, array) => isJack(a, array[i - 1]));

Expand Down
5 changes: 4 additions & 1 deletion src/fraction.ts
Expand Up @@ -21,7 +21,10 @@ function gcd(a: number, b: number) {
}

export class Fraction {
constructor(public n: number, public d: number = 1) {}
constructor(
public n: number,
public d: number = 1,
) {}

add(f: Fraction) {
if (f.d === this.d) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Expand Up @@ -66,7 +66,7 @@ export function parsePack(dir: string): PackWithSongs {
}
} catch (e) {
reportError(
`parseStepchart failed for '${songFolder}': ${printMaybeError(e)}`
`parseStepchart failed for '${songFolder}': ${printMaybeError(e)}`,
);
}
});
Expand Down
16 changes: 8 additions & 8 deletions src/parseDwi.ts
Expand Up @@ -49,7 +49,7 @@ type ArrowParseResult = {
*/
function combinePadsIntoOneStream(
p1: ArrowParseResult,
p2: ArrowParseResult
p2: ArrowParseResult,
): ArrowParseResult {
const arrows = p1.arrows
.concat(p2.arrows)
Expand Down Expand Up @@ -106,7 +106,7 @@ function combinePadsIntoOneStream(
*/
function findFirstNonEmptyMeasure(
p1Notes: string,
p2Notes: string | undefined
p2Notes: string | undefined,
): number {
let i = 0;

Expand All @@ -129,7 +129,7 @@ function findFirstNonEmptyMeasure(
*/
function parseArrowStream(
notes: string,
firstNonEmptyMeasureIndex: number
firstNonEmptyMeasureIndex: number,
): ArrowParseResult {
const arrows: Arrow[] = [];
const freezes: FreezeLocation[] = [];
Expand Down Expand Up @@ -174,7 +174,7 @@ function parseArrowStream(
const of = openFreezes[d as FreezeLocation["direction"]];
if (!of) {
reportError(
"error parsing dwi freezes, tried to close a freeze that never opened"
"error parsing dwi freezes, tried to close a freeze that never opened",
);
} else {
of.endOffset = curOffset.n / curOffset.d + 0.25;
Expand Down Expand Up @@ -210,7 +210,7 @@ function parseArrowStream(
arrows.push({
direction: dwiToSMDirection[note].replace(
/1/g,
"2"
"2",
) as Arrow["direction"],
quantization: determineBeat(curOffset),
offset: curOffset.n / curOffset.d,
Expand Down Expand Up @@ -260,7 +260,7 @@ function findBanner(titlePath: string): string | null {
const files = fs.readdirSync(titlePath);

const bannerFile = files.find(
(f) => f.endsWith(".png") && !f.endsWith("-bg.png")
(f) => f.endsWith(".png") && !f.endsWith("-bg.png"),
);

return bannerFile ?? null;
Expand Down Expand Up @@ -303,15 +303,15 @@ export function parseDwi(dwi: string, titlePath?: string): RawSimfile {

const firstNonEmptyMeasureIndex = findFirstNonEmptyMeasure(
notes,
playerTwoNotes
playerTwoNotes,
);

let arrowResult = parseArrowStream(notes, firstNonEmptyMeasureIndex);

if (mode === "double") {
const playerTwoResult = parseArrowStream(
playerTwoNotes,
firstNonEmptyMeasureIndex
firstNonEmptyMeasureIndex,
);

arrowResult = combinePadsIntoOneStream(arrowResult, playerTwoResult);
Expand Down
18 changes: 9 additions & 9 deletions src/parseSm.ts
Expand Up @@ -75,7 +75,7 @@ function isRest(line: string): boolean {
function findFirstNonEmptyMeasure(
mode: "single" | "double",
lines: string[],
i: number
i: number,
): { firstNonEmptyMeasureIndex: number; numMeasuresSkipped: number } {
let numMeasuresSkipped = 0;
let measureIndex = i;
Expand All @@ -98,7 +98,7 @@ function findFirstNonEmptyMeasure(
}

throw new Error(
"findFirstNonEmptyMeasure, failed to find a non-empty measure in entire song"
"findFirstNonEmptyMeasure, failed to find a non-empty measure in entire song",
);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ export function parseSm(sm: string): RawSimfile {
*/
function parseStops(
stopsString: string | null,
emptyOffsetInMeasures: number
emptyOffsetInMeasures: number,
) {
if (!stopsString) {
return [];
Expand Down Expand Up @@ -187,7 +187,7 @@ export function parseSm(sm: string): RawSimfile {
lines: string[],
i: number,
mode: string,
difficulty: string
difficulty: string,
): FreezeLocation[] {
const freezes: FreezeLocation[] = [];
const open: Record<number, Partial<FreezeLocation> | undefined> = {};
Expand All @@ -205,7 +205,7 @@ export function parseSm(sm: string): RawSimfile {
if (line[0] === ",") {
curMeasureFraction = new Fraction(
1,
getMeasureLength(lines, i + 1) || 1
getMeasureLength(lines, i + 1) || 1,
);
continue;
}
Expand All @@ -225,7 +225,7 @@ export function parseSm(sm: string): RawSimfile {
if (cleanedLine[d] === "2" || cleanedLine[d] === "4") {
if (open[d]) {
reportError(
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, found a new starting freeze before a previous one finished`
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, found a new starting freeze before a previous one finished`,
);
} else {
const startBeatFraction = curOffset;
Expand All @@ -238,7 +238,7 @@ export function parseSm(sm: string): RawSimfile {
const thisFreeze = open[d];
if (!thisFreeze) {
reportError(
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, tried to close a freeze that never opened`
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, tried to close a freeze that never opened`,
);
} else {
const endBeatFraction = curOffset.add(new Fraction(1, 4));
Expand Down Expand Up @@ -302,7 +302,7 @@ export function parseSm(sm: string): RawSimfile {
if (line.startsWith(",")) {
curMeasureFraction = new Fraction(
1,
getMeasureLength(lines, i + 1) || 1
getMeasureLength(lines, i + 1) || 1,
);
continue;
}
Expand Down Expand Up @@ -393,7 +393,7 @@ export function parseSm(sm: string): RawSimfile {
return sc as RawSimfile;
} catch (e) {
throw new Error(
`error parsing ${sm.substring(0, 300)}\n${printMaybeError(e)}`
`error parsing ${sm.substring(0, 300)}\n${printMaybeError(e)}`,
);
}
}
4 changes: 2 additions & 2 deletions src/parseSong.ts
Expand Up @@ -115,12 +115,12 @@ export function parseSong(songDirPath: string): Omit<Simfile, "mix"> | null {
const fileContents = fs.readFileSync(stepchartPath);
const { images, ...rawStepchart } = parser(
fileContents.toString(),
songDirPath
songDirPath,
);

if (!Object.keys(rawStepchart.charts).length) {
throw new Error(
`Failed to parse any charts from song: ${rawStepchart.title}`
`Failed to parse any charts from song: ${rawStepchart.title}`,
);
}

Expand Down
22 changes: 11 additions & 11 deletions src/parseSsc.ts
Expand Up @@ -86,7 +86,7 @@ function isRest(line: string): boolean {
function findFirstNonEmptyMeasure(
mode: "single" | "double",
lines: string[],
i: number
i: number,
): { firstNonEmptyMeasureIndex: number; numMeasuresSkipped: number } {
let numMeasuresSkipped = 0;
let measureIndex = i;
Expand All @@ -109,7 +109,7 @@ function findFirstNonEmptyMeasure(
}

throw new Error(
"findFirstNonEmptyMeasure, failed to find a non-empty measure in entire song"
"findFirstNonEmptyMeasure, failed to find a non-empty measure in entire song",
);
}

Expand Down Expand Up @@ -144,7 +144,7 @@ export function parseSsc(ssc: string): RawSimfile {
*/
function parseStops(
stopsString: string | null,
emptyOffsetInMeasures: number
emptyOffsetInMeasures: number,
) {
if (!stopsString) {
return [];
Expand Down Expand Up @@ -198,7 +198,7 @@ export function parseSsc(ssc: string): RawSimfile {
lines: string[],
i: number,
mode: string,
difficulty: string
difficulty: string,
): FreezeLocation[] {
const freezes: FreezeLocation[] = [];
const open: Record<number, Partial<FreezeLocation> | undefined> = {};
Expand All @@ -216,7 +216,7 @@ export function parseSsc(ssc: string): RawSimfile {
if (line[0] === ",") {
curMeasureFraction = new Fraction(
1,
getMeasureLength(lines, i + 1) || 1
getMeasureLength(lines, i + 1) || 1,
);
continue;
}
Expand All @@ -236,7 +236,7 @@ export function parseSsc(ssc: string): RawSimfile {
if (cleanedLine[d] === "2" || cleanedLine[d] === "4") {
if (open[d]) {
reportError(
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, found a new starting freeze before a previous one finished`
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, found a new starting freeze before a previous one finished`,
);
} else {
const startBeatFraction = curOffset;
Expand All @@ -249,7 +249,7 @@ export function parseSsc(ssc: string): RawSimfile {
const thisFreeze = open[d];
if (!thisFreeze) {
reportError(
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, tried to close a freeze that never opened`
`${sc.title}, ${mode}, ${difficulty} -- error parsing freezes, tried to close a freeze that never opened`,
);
} else {
const endBeatFraction = curOffset.add(new Fraction(1, 4));
Expand All @@ -276,7 +276,7 @@ export function parseSsc(ssc: string): RawSimfile {
function parseNotes(lines: string[], i: number, bpmString: string): number {
if (!currentChart || !currentChart.mode || !currentChart.difficulty) {
throw new Error(
"parseSsc: Can't parse notes before mode and difficulty are ready"
"parseSsc: Can't parse notes before mode and difficulty are ready",
);
}
// move past #NOTES into the note metadata
Expand Down Expand Up @@ -307,7 +307,7 @@ export function parseSsc(ssc: string): RawSimfile {
if (line.startsWith(",")) {
curMeasureFraction = new Fraction(
1,
getMeasureLength(lines, i + 1) || 1
getMeasureLength(lines, i + 1) || 1,
);
continue;
}
Expand All @@ -327,7 +327,7 @@ export function parseSsc(ssc: string): RawSimfile {
lines,
firstMeasureIndex,
currentChart.mode,
currentChart.difficulty
currentChart.difficulty,
);

currentChart.chart = {
Expand Down Expand Up @@ -446,7 +446,7 @@ export function parseSsc(ssc: string): RawSimfile {
return sc as RawSimfile;
} catch (e) {
throw new Error(
`error parsing ${ssc.substring(0, 300)}\n${printMaybeError(e)}`
`error parsing ${ssc.substring(0, 300)}\n${printMaybeError(e)}`,
);
}
}