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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: blocknumber setup #9

Merged
merged 9 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "turbo run build",
"test": "turbo run test",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add the test coverage script here too

"prepare": "husky",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"format": "turbo run format",
"build": "turbo run build"
"format:fix": "turbo run format:fix"
},
"keywords": [],
"author": "",
Expand Down
Empty file removed packages/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions packages/blocknumber/.gitignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add this on the root .gitignore with a wildcard to avoid having a gitignore per package

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
4 changes: 4 additions & 0 deletions packages/blocknumber/.prettierignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto,

pnpm-lock.yaml shouldn't be generated on pnpm install i think

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated files
pnpm-lock.yaml
node_modules
dist
17 changes: 17 additions & 0 deletions packages/blocknumber/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "blocknumber",
"version": "1.0.0",
"description": "",
"main": "index.ts",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add "type": "module" to ensure we are using esm

"scripts": {
"build": "tsc -p tsconfig.build.json",
"lint": "eslint .",
"lint:fix": "pnpm lint --fix",
"format": "prettier --check .",
"format:fix": "prettier --write .",
"test": "vitest run"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto regarding test coverage

},
"keywords": [],
"author": "",
"license": "ISC"
}
11 changes: 11 additions & 0 deletions packages/blocknumber/src/helloWorld.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, expect, it } from "vitest";

import foo from "./helloWorld";

describe("test", () => {
it("pass", () => {
const result = foo();

expect(result).toBe("bar");
});
});
3 changes: 3 additions & 0 deletions packages/blocknumber/src/helloWorld.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function foo() {
return "bar";
}
8 changes: 8 additions & 0 deletions packages/blocknumber/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"compilerOptions": {
"compilerOptions": {
"declaration": true,

"outDir": "dist"
},
"include": ["src/**/*"],
"exclude": ["**/*.spec.ts"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"exclude": ["**/*.spec.ts"]
"exclude": ["node_modules", "build", "tests", "vitest.config.ts"]

}
4 changes: 4 additions & 0 deletions packages/blocknumber/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"]
}
21 changes: 21 additions & 0 deletions packages/blocknumber/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import path from "path";
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
globals: true, // Use Vitest's global API without importing it in each file
environment: "node", // Use the Node.js environment
include: ["src/**/*.spec.ts"], // Include test files
exclude: ["node_modules", "dist"], // Exclude certain directories
coverage: {
reporter: ["text", "json", "html"], // Coverage reporters
exclude: ["node_modules", "dist", "src/**/*.d.ts"], // Files to exclude from coverage
},
},
resolve: {
alias: {
// Setup path alias based on tsconfig paths
"@": path.resolve(__dirname, "src"),
},
},
});
23 changes: 23 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Based on total-typescript no-dom app config */
{
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"verbatimModuleSyntax": false,
/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
/* If transpiling with TypeScript: */
"module": "NodeNext",
"sourceMap": true,
/* If your code doesn't run in the DOM: */
"lib": ["es2022"]
}
}
7 changes: 7 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"noEmit": false
}
}
23 changes: 2 additions & 21 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
/* Based on total-typescript no-dom app config */
{
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"verbatimModuleSyntax": true,
/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
/* If transpiling with TypeScript: */
"module": "NodeNext",
"sourceMap": true,
/* If your code doesn't run in the DOM: */
"lib": ["es2022"]
}
"extends": "./tsconfig.base.json",
"include": ["**/*", ".*.js"]
}