-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48e1af1
Showing
22 changed files
with
2,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "perlon monorepo template", | ||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"features": { | ||
"ghcr.io/devcontainers/features/node:1": { | ||
"nodeGypDependencies": true, | ||
"version": "20.11.1", | ||
"nvmVersion": "latest" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
"editorconfig.editorconfig", | ||
"vitest.explorer", | ||
"github.vscode-github-actions", | ||
"github.vscode-pull-request-github" | ||
] | ||
} | ||
}, | ||
"postCreateCommand": "corepack enable && pnpm install" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
es2022: true, | ||
node: true, | ||
}, | ||
plugins: ['@typescript-eslint', 'promise'], | ||
extends: ['perlon'], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './packages/*/tsconfig.json'], | ||
}, | ||
settings: { | ||
n: { | ||
allowModules: ['vitest'], | ||
resolvePaths: [__dirname], | ||
tryExtensions: ['.js', '.json', '.node', '.ts'], | ||
}, | ||
}, | ||
ignorePatterns: ['dist', '*.cjs'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
dist | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node-linker=hoisted | ||
strict-peer-dependencies=false | ||
enable-pre-post-scripts=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.11.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"bracketSameLine": true, | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"proseWrap": "preserve", | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"overrides": [ | ||
{ "files": "*.md", "options": { "printWidth": 100, "proseWrap": "always" } }, | ||
{ "files": "*.json", "options": { "trailingComma": "none" } }, | ||
{ "files": "*.{yaml,yml}", "options": { "singleQuote": false, "printWidth": 100, "proseWrap": "never" } } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"editorconfig.editorconfig", | ||
"esbenp.prettier-vscode", | ||
"vitest.explorer" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "always", | ||
"source.organizeImports": "always" | ||
}, | ||
"editor.wordWrap": "on", | ||
"editor.guides.bracketPairs": "active", | ||
"editor.tabSize": 2, | ||
"npm.scriptExplorerAction": "open", | ||
"npm.autoDetect": "on", | ||
"npm.packageManager": "pnpm", | ||
"typescript.tsdk": "./node_modules/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "perlon-monorepo", | ||
"private": true, | ||
"type": "module", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"format": "prettier --cache -w .", | ||
"lint": "eslint . --cache --cache-location \"./node_modules/.cache/eslint/\"", | ||
"clean": "rm -rf node_modules", | ||
"test": "vitest", | ||
"test:coverage": "vitest --coverage", | ||
"build": "pnpm --filter context build", | ||
"preinstall": "npx only-allow pnpm" | ||
}, | ||
"devDependencies": { | ||
"@vitest/coverage-v8": "^1.3.1", | ||
"eslint": "^8.57.0", | ||
"eslint-config-perlon": "workspace:^", | ||
"prettier": "^3.2.5", | ||
"tsx": "^4.7.1", | ||
"typescript": "^5.4.2", | ||
"vitest": "^1.3.1" | ||
}, | ||
"engines": { | ||
"node": "^20.0.0", | ||
"pnpm": ">=8" | ||
}, | ||
"pnpm": { | ||
"overrides": { | ||
"esbuild": "0.20.1" | ||
} | ||
}, | ||
"packageManager": "pnpm@8.15.4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "context", | ||
"private": true, | ||
"type": "module", | ||
"license": "Apache-2.0", | ||
"author": "falsepopsky", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"clean:build": "rm -rf dist", | ||
"prebuild": "pnpm run clean:build", | ||
"build": "tsc --project tsconfig.build.json", | ||
"test": "vitest --coverage" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.11.25", | ||
"typescript": "^5.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const createContext = <T>(initialState: T): { getState: () => T; setState: (newState: T) => void } => { | ||
let state = initialState; | ||
|
||
const getState = (): T => state; | ||
|
||
function setState(newState: T): void { | ||
state = newState; | ||
} | ||
|
||
return { getState, setState }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { createContext } from '../src/index.js'; | ||
|
||
describe('context function', () => { | ||
const context = createContext({ monster: 'Black Magician' }); | ||
|
||
it('should return Black magician monster', () => { | ||
const name = context.getState(); | ||
|
||
expect(name.monster).toBe('Black Magician'); | ||
expect(name).not.toBe('Blue Eyes White Dragon'); | ||
}); | ||
|
||
it('should change the name monster', () => { | ||
context.setState({ monster: 'Blue Eyes White Dragon' }); | ||
const name = context.getState(); | ||
|
||
expect(name.monster).toBe('Blue Eyes White Dragon'); | ||
expect(name.monster).not.toBe('Black Magician'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { "rootDir": "./src", "outDir": "./dist", "noEmit": false }, | ||
"include": ["src"], | ||
"exclude": ["node_modules", "**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "." | ||
}, | ||
"include": ["src", "tests"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module.exports = { | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/strict-type-checked', | ||
'plugin:@typescript-eslint/stylistic-type-checked', | ||
'plugin:n/recommended', | ||
'plugin:promise/recommended', | ||
'prettier', | ||
], | ||
overrides: [ | ||
{ | ||
plugins: ['vitest'], | ||
extends: ['plugin:vitest/recommended'], | ||
files: ['packages/*/tests/*.test.ts'], | ||
}, | ||
], | ||
rules: { | ||
'@typescript-eslint/no-use-before-define': [ | ||
'error', | ||
{ | ||
functions: false, | ||
classes: false, | ||
enums: false, | ||
variables: false, | ||
typedefs: false, | ||
}, | ||
], | ||
'@typescript-eslint/return-await': ['error', 'always'], | ||
'@typescript-eslint/consistent-type-exports': [ | ||
'error', | ||
{ | ||
fixMixedExportsWithInlineTypeSpecifier: true, | ||
}, | ||
], | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ | ||
prefer: 'type-imports', | ||
disallowTypeAnnotations: true, | ||
fixStyle: 'inline-type-imports', | ||
}, | ||
], | ||
'@typescript-eslint/explicit-function-return-type': [ | ||
'error', | ||
{ | ||
allowExpressions: true, | ||
allowHigherOrderFunctions: true, | ||
allowTypedFunctionExpressions: true, | ||
allowDirectConstAssertionInArrowFunctions: true, | ||
}, | ||
], | ||
'@typescript-eslint/method-signature-style': 'error', | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
selector: 'variableLike', | ||
leadingUnderscore: 'allow', | ||
trailingUnderscore: 'allow', | ||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'], | ||
}, | ||
], | ||
'@typescript-eslint/no-confusing-void-expression': [ | ||
'error', | ||
{ ignoreArrowShorthand: false, ignoreVoidOperator: false }, | ||
], | ||
'@typescript-eslint/prefer-readonly': 'error', | ||
'@typescript-eslint/promise-function-async': 'error', | ||
'@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }], | ||
'@typescript-eslint/strict-boolean-expressions': 'error', | ||
'@typescript-eslint/no-import-type-side-effects': 'error', | ||
'n/no-missing-import': 'off', | ||
}, | ||
reportUnusedDisableDirectives: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "eslint-config-perlon", | ||
"description": "ESLint configuration", | ||
"private": true, | ||
"type": "module", | ||
"author": "falsepopsky", | ||
"license": "Apache-2.0", | ||
"version": "1.0.0", | ||
"main": "./index.cjs", | ||
"exports": "./index.cjs", | ||
"dependencies": { | ||
"@typescript-eslint/eslint-plugin": "^7.1.1", | ||
"@typescript-eslint/parser": "^7.1.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-n": "^16.6.2", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-vitest": "^0.3.24" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.57.0" | ||
} | ||
} |
Oops, something went wrong.