Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
falsepopsky authored Mar 10, 2024
0 parents commit 48e1af1
Show file tree
Hide file tree
Showing 22 changed files with 2,318 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
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"
}
12 changes: 12 additions & 0 deletions .editorconfig
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
24 changes: 24 additions & 0 deletions .eslintrc.cjs
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'],
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
3 changes: 3 additions & 0 deletions .npmrc
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.1
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
pnpm-lock.yaml
13 changes: 13 additions & 0 deletions .prettierrc
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" } }
]
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
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"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
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
}
34 changes: 34 additions & 0 deletions package.json
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"
}
27 changes: 27 additions & 0 deletions packages/context/package.json
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"
}
}
11 changes: 11 additions & 0 deletions packages/context/src/index.ts
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 };
};
21 changes: 21 additions & 0 deletions packages/context/tests/index.test.ts
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');
});
});
6 changes: 6 additions & 0 deletions packages/context/tsconfig.build.json
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"]
}
8 changes: 8 additions & 0 deletions packages/context/tsconfig.json
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"]
}
74 changes: 74 additions & 0 deletions packages/eslint-config-perlon/index.cjs
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,
};
22 changes: 22 additions & 0 deletions packages/eslint-config-perlon/package.json
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"
}
}
Loading

0 comments on commit 48e1af1

Please sign in to comment.