diff --git a/.prettierrc b/.prettierrc index 963354f..856eb3e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,4 @@ { - "printWidth": 120 + "printWidth": 120, + "trailingComma": "all" } diff --git a/src/generateZwo.ts b/src/generateZwo.ts index 6d3c394..0e1493a 100644 --- a/src/generateZwo.ts +++ b/src/generateZwo.ts @@ -5,7 +5,7 @@ import { Interval, Workout } from "./ast"; const generateRangeInterval = ( tagName: "Warmup" | "Cooldown", - { duration, intensity, cadence }: Interval + { duration, intensity, cadence }: Interval, ): xml.XmlObject => { return { [tagName]: [ @@ -57,6 +57,6 @@ export const generateZwo = ({ name, author, description, intervals }: Workout): ...intervals.map(generateInterval), ], }, - { indent: " " } + { indent: " " }, ); }; diff --git a/src/parser/parser.test.ts b/src/parser/parser.test.ts index e2cc13d..79c10ec 100644 --- a/src/parser/parser.test.ts +++ b/src/parser/parser.test.ts @@ -3,11 +3,11 @@ import { parse } from "."; describe("Parser", () => { it("throws error for empty file", () => { expect(() => parse("")).toThrowErrorMatchingInlineSnapshot( - `"Workout is missing a name. Use \`Name:\` to declare one. at line 1 char 1"` + `"Workout is missing a name. Use \`Name:\` to declare one. at line 1 char 1"`, ); expect(() => parse(" \n \n \t")).toThrowErrorMatchingInlineSnapshot( - `"Workout is missing a name. Use \`Name:\` to declare one. at line 1 char 1"` + `"Workout is missing a name. Use \`Name:\` to declare one. at line 1 char 1"`, ); }); @@ -32,7 +32,7 @@ Description: Do it when you dare, it'll cause lots of pain. -`) +`), ).toMatchInlineSnapshot(` Object { "author": "John Doe", @@ -56,7 +56,7 @@ Rest: 5:00 50% Interval: 10:00 80% 90rpm Rest: 5:00 45% -`).intervals +`).intervals, ).toMatchInlineSnapshot(` Array [ Object { @@ -97,7 +97,7 @@ Name: My Workout Warmup: 5:30 50%..80% 100rpm Cooldown: 5:30 70%..45% -`).intervals +`).intervals, ).toMatchInlineSnapshot(` Array [ Object { @@ -126,13 +126,13 @@ Cooldown: 5:30 70%..45% it("requires duration and power parameters to be specified", () => { expect(() => parseInterval("Interval: 50%")).toThrowErrorMatchingInlineSnapshot( - `"Duration not specified at line 2 char 1"` + `"Duration not specified at line 2 char 1"`, ); expect(() => parseInterval("Interval: 30:00")).toThrowErrorMatchingInlineSnapshot( - `"Power not specified at line 2 char 1"` + `"Power not specified at line 2 char 1"`, ); expect(() => parseInterval("Interval: 10rpm")).toThrowErrorMatchingInlineSnapshot( - `"Duration not specified at line 2 char 1"` + `"Duration not specified at line 2 char 1"`, ); }); @@ -210,34 +210,34 @@ Cooldown: 5:30 70%..45% it("throws error for incorrect duration formats", () => { expect(() => parseInterval("Interval: 10 50%")).toThrowErrorMatchingInlineSnapshot( - `"Unrecognized interval parameter \\"10\\" at line 2 char 11"` + `"Unrecognized interval parameter \\"10\\" at line 2 char 11"`, ); expect(() => parseInterval("Interval: :10 50%")).toThrowErrorMatchingInlineSnapshot( - `"Unrecognized interval parameter \\":10\\" at line 2 char 11"` + `"Unrecognized interval parameter \\":10\\" at line 2 char 11"`, ); expect(() => parseInterval("Interval: 0:100 50%")).toThrowErrorMatchingInlineSnapshot( - `"Unrecognized interval parameter \\"0:100\\" at line 2 char 11"` + `"Unrecognized interval parameter \\"0:100\\" at line 2 char 11"`, ); expect(() => parseInterval("Interval: 00:00:00:10 50%")).toThrowErrorMatchingInlineSnapshot( - `"Unrecognized interval parameter \\"00:00:00:10\\" at line 2 char 11"` + `"Unrecognized interval parameter \\"00:00:00:10\\" at line 2 char 11"`, ); }); it("throws error for unexpected interval parameter", () => { expect(() => parseInterval("Interval: 10:00 50% foobar")).toThrowErrorMatchingInlineSnapshot( - `"Unrecognized interval parameter \\"foobar\\" at line 2 char 21"` + `"Unrecognized interval parameter \\"foobar\\" at line 2 char 21"`, ); expect(() => parseInterval("Interval: 10:00 50% 123blah")).toThrowErrorMatchingInlineSnapshot( - `"Unrecognized interval parameter \\"123blah\\" at line 2 char 21"` + `"Unrecognized interval parameter \\"123blah\\" at line 2 char 21"`, ); expect(() => parseInterval("Interval: 10:00 50% ^*&")).toThrowErrorMatchingInlineSnapshot( - `"Unrecognized interval parameter \\"^*&\\" at line 2 char 21"` + `"Unrecognized interval parameter \\"^*&\\" at line 2 char 21"`, ); }); it("throws error for unexpected type of interval", () => { expect(() => parseInterval("Interval: 30:00 5% \n CustomInterval: 15:00 10%")).toThrowErrorMatchingInlineSnapshot( - `"Unexpected token [text CustomInterval: 15:00 10%] at line 3 char 1"` + `"Unexpected token [text CustomInterval: 15:00 10%] at line 3 char 1"`, ); }); }); diff --git a/src/stats/normalizedIntensity.ts b/src/stats/normalizedIntensity.ts index 22f0717..5af676f 100644 --- a/src/stats/normalizedIntensity.ts +++ b/src/stats/normalizedIntensity.ts @@ -30,6 +30,6 @@ export const normalizedIntensity = (intervals: Interval[]): number => { rollingAverages, (averages) => averages.map(fourthPower), average, - fourthRoot + fourthRoot, )(intervals); };