Skip to content

Commit

Permalink
add scaffold for basic template
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 committed Sep 5, 2024
1 parent e7b8f1c commit d4d1439
Show file tree
Hide file tree
Showing 26 changed files with 387 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
build/
dist/
node_modules/
*.tsbuildinfo
scratchpad/*
!scratchpad/tsconfig.json
*.tsbuildinfo
1 change: 1 addition & 0 deletions templates/basic/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
12 changes: 12 additions & 0 deletions templates/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
coverage/
*.tsbuildinfo
node_modules/
.DS_Store
tmp/
dist/
build/
docs/
scratchpad/*
!scratchpad/tsconfig.json
.direnv/
.idea/
7 changes: 7 additions & 0 deletions templates/basic/.madgerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"detectiveOptions": {
"ts": {
"skipTypeImports": true
}
}
}
3 changes: 3 additions & 0 deletions templates/basic/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.js
*.ts
*.cjs
4 changes: 4 additions & 0 deletions templates/basic/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"trailingComma": "none"
}
5 changes: 5 additions & 0 deletions templates/basic/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
}
1 change: 1 addition & 0 deletions templates/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Effect Basic Package Template
3 changes: 3 additions & 0 deletions templates/basic/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"unstable": ["byonm"]
}
122 changes: 122 additions & 0 deletions templates/basic/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { fixupPluginRules } from "@eslint/compat"
import { FlatCompat } from "@eslint/eslintrc"
import js from "@eslint/js"
import tsParser from "@typescript-eslint/parser"
import codegen from "eslint-plugin-codegen"
import deprecation from "eslint-plugin-deprecation"
import _import from "eslint-plugin-import"
import simpleImportSort from "eslint-plugin-simple-import-sort"
import sortDestructureKeys from "eslint-plugin-sort-destructure-keys"
import path from "node:path"
import { fileURLToPath } from "node:url"

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
})

export default [
{
ignores: ["**/dist", "**/build", "**/docs", "**/*.md"]
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@effect/recommended"
),
{
plugins: {
deprecation,
import: fixupPluginRules(_import),
"sort-destructure-keys": sortDestructureKeys,
"simple-import-sort": simpleImportSort,
codegen
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2018,
sourceType: "module"
},

settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},

"import/resolver": {
typescript: {
alwaysTryTypes: true
}
}
},

rules: {
"codegen/codegen": "error",
"no-fallthrough": "off",
"no-irregular-whitespace": "off",
"object-shorthand": "error",
"prefer-destructuring": "off",
"sort-imports": "off",

"no-restricted-syntax": ["error", {
selector: "CallExpression[callee.property.name='push'] > SpreadElement.arguments",
message: "Do not use spread arguments in Array.push"
}],

"no-unused-vars": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"import/no-unresolved": "off",
"import/order": "off",
"simple-import-sort/imports": "off",
"sort-destructure-keys/sort-destructure-keys": "error",
"deprecation/deprecation": "off",

"@typescript-eslint/array-type": ["warn", {
default: "generic",
readonly: "generic"
}],

"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/consistent-type-imports": "warn",

"@typescript-eslint/no-unused-vars": ["error", {
argsIgnorePattern: "^_",
varsIgnorePattern: "^_"
}],

"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-namespace": "off",

"@effect/dprint": ["error", {
config: {
indentWidth: 2,
lineWidth: 120,
semiColons: "asi",
quoteStyle: "alwaysDouble",
trailingCommas: "never",
operatorPosition: "maintain",
"arrowFunction.useParentheses": "force"
}
}]
}
}
]
27 changes: 27 additions & 0 deletions templates/basic/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions templates/basic/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};
outputs = {nixpkgs, ...}: let
forAllSystems = function:
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed
(system: function nixpkgs.legacyPackages.${system});
in {
formatter = forAllSystems (pkgs: pkgs.alejandra);
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
bun
corepack
deno
nodejs
python3
];
};
});
};
}
29 changes: 29 additions & 0 deletions templates/basic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@template/basic",
"version": "0.0.0",
"type": "module",
"private": true,
"scripts": {
"codegen": "build-utils prepare-v2",
"build": "pnpm build-esm && pnpm build-annotate && pnpm build-cjs && build-utils pack-v2",
"build-esm": "tsc -b tsconfig.build.json",
"build-cjs": "babel build/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir build/cjs --source-maps",
"build-annotate": "babel build/esm --plugins annotate-pure-calls --out-dir build/esm --source-maps",
"check": "tsc -b tsconfig.json",
"test": "vitest",
"coverage": "vitest --coverage"
},
"devDependencies": {},
"effect": {
"generateExports": {
"include": [
"**/*.ts"
]
},
"generateIndex": {
"include": [
"**/*.ts"
]
}
}
}
13 changes: 13 additions & 0 deletions templates/basic/patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/index.js b/lib/index.js
index 2182884e21874ebb37261e2375eec08ad956fc9a..ef5630199121c2830756e00c7cc48cf1078c8207 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -78,7 +78,7 @@ const isInAssignmentContext = path => {

parentPath = _ref.parentPath;

- if (parentPath.isVariableDeclaration() || parentPath.isAssignmentExpression()) {
+ if (parentPath.isVariableDeclaration() || parentPath.isAssignmentExpression() || parentPath.isClassDeclaration()) {
return true;
}
} while (parentPath !== statement);
10 changes: 10 additions & 0 deletions templates/basic/scratchpad/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"noEmit": true,
"declaration": false,
"declarationMap": false,
"composite": false,
"incremental": false
}
}
3 changes: 3 additions & 0 deletions templates/basic/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as it from "@effect/vitest"

it.addEqualityTesters()
3 changes: 3 additions & 0 deletions templates/basic/src/Program.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as Effect from "effect/Effect"

Effect.runPromise(Effect.log("Hello, World!"))
7 changes: 7 additions & 0 deletions templates/basic/test/Dummy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, expect, it } from "@effect/vitest"

describe("Dummy", () => {
it("should pass", () => {
expect(true).toBe(true)
})
})
40 changes: 40 additions & 0 deletions templates/basic/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"compilerOptions": {
"strict": true,
"exactOptionalPropertyTypes": true,
"moduleDetection": "force",
"composite": true,
"downlevelIteration": true,
"resolveJsonModule": true,
"esModuleInterop": false,
"declaration": true,
"skipLibCheck": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "NodeNext",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"types": [],
"isolatedModules": true,
"sourceMap": true,
"declarationMap": true,
"noImplicitReturns": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"noEmitOnError": false,
"noErrorTruncation": false,
"allowJs": false,
"checkJs": false,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUncheckedIndexedAccess": false,
"strictNullChecks": true,
"baseUrl": ".",
"target": "ES2022",
"module": "NodeNext",
"incremental": true,
"removeComments": false,
"plugins": [{ "name": "@effect/language-service" }]
}
}
10 changes: 10 additions & 0 deletions templates/basic/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.src.json",
"compilerOptions": {
"types": ["node"],
"tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo",
"outDir": "build/esm",
"declarationDir": "build/dts",
"stripInternal": true
}
}
8 changes: 8 additions & 0 deletions templates/basic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"include": [],
"references": [
{ "path": "tsconfig.src.json" },
{ "path": "tsconfig.test.json" }
]
}
10 changes: 10 additions & 0 deletions templates/basic/tsconfig.src.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"types": ["node"],
"outDir": "build/src",
"tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo",
"rootDir": "src"
}
}
13 changes: 13 additions & 0 deletions templates/basic/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"include": ["test"],
"references": [
{ "path": "tsconfig.src.json" }
],
"compilerOptions": {
"types": ["node"],
"tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo",
"rootDir": "test",
"noEmit": true
}
}
Loading

0 comments on commit d4d1439

Please sign in to comment.