Skip to content

Commit

Permalink
let there be lint
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Dec 2, 2023
1 parent a11b939 commit cc2e4bf
Show file tree
Hide file tree
Showing 9 changed files with 1,550 additions and 156 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env node */
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
root: true,
ignorePatterns: ["dist/"],
rules: {
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
},
};
17 changes: 10 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: "18"
- name: TypeCheck and Test
shell: bash
run: |
npm install
npm run gen
npm run tsc
npm test
- name: npm install
run: npm install
- name: Generate client
run: npm run gen
- name: TypeCheck
run: npm run tsc
- name: Lint
run: npx eslint .
- name: Test
run: npm test
4 changes: 2 additions & 2 deletions generator/client/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { OpenAPIV3 } from "openapi-types";
import { snakeToPascal, topologicalSort } from "../util";
import { topologicalSort } from "../util";
import { IO } from "../io";
import { Schema } from "../schema/base";
import { OpenAPIV3 as O } from "openapi-types";
Expand Down Expand Up @@ -76,7 +76,7 @@ export function iterPathConfig(paths: OpenAPIV3.Document["paths"]) {
path,
conf,
method,
opId: conf?.operationId!,
opId: conf!.operationId!,
};
});
})
Expand Down
2 changes: 1 addition & 1 deletion generator/client/msw-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export function generateMSWHandlers(spec: OpenAPIV3.Document) {
bodyTypeRef && (method === "post" || method === "put")
? `schema.${refToSchemaName(bodyTypeRef)}`
: "null";
const paramSchema = !!conf.parameters?.length
const paramSchema = conf.parameters?.length
? `schema.${snakeToPascal(opId)}Params`
: "null";

Expand Down
2 changes: 1 addition & 1 deletion generator/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const processParamName = (s: string) => snakeToCamel(renameParam(s));

/** `{project_name}` -> `${projectName}`. if no brackets, leave it alone */
const segmentToInterpolation = (s: string) =>
s.startsWith("{") ? `\$\{path.${processParamName(s.slice(1, -1))}\}` : s;
s.startsWith("{") ? `$\{path.${processParamName(s.slice(1, -1))}}` : s;

export const pathToTemplateStr = (s: string) =>
"`" + s.split("/").map(segmentToInterpolation).join("/") + "`";
Expand Down
Loading

0 comments on commit cc2e4bf

Please sign in to comment.