Basic setup of the project.

This commit is contained in:
2024-08-14 19:40:05 +02:00
parent 0fc0f6ac82
commit 1341427590
12 changed files with 7417 additions and 0 deletions

11
.eslintignore Normal file
View File

@@ -0,0 +1,11 @@
node_modules/
main.js
**/*.js
*.js
**/*.mjs
*.mjs
dist/*

299
.eslintrc Normal file
View File

@@ -0,0 +1,299 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": {
"node": true
},
"plugins": [
"@typescript-eslint",
"deprecation",
"prettier",
"import",
"jsdoc",
"override"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jsdoc/recommended-typescript"
],
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"override/require-override": "error",
"override/require-static-override": "off",
"prettier/prettier": "warn",
"array-callback-return": [
"error"
],
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"args": "none"
}
],
"no-warning-comments": [
"warn",
{
"terms": [
"@todo"
],
"location": "anywhere"
}
],
"no-unused-vars": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off",
"deprecation/deprecation": "warn",
"no-console": "error",
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "classProperty",
"modifiers": [
"private"
],
"format": [],
"custom": {
"regex": "^(_{1,2}I[A-Z][a-zA-Z0-9]*_?|_{1,2}[a-z][a-zA-Z0-9]*)$",
"match": true,
"message": "Private class properties should be prefixed with an underscore. Exceptions are private class properties that are interfaces. These should be prefixed with '_I'."
}
},
{
"selector": "classProperty",
"modifiers": [
"protected"
],
"format": [],
"custom": {
"regex": "^(_{1,2}I[A-Z][a-zA-Z0-9]*_?|_{1,2}[a-z][a-zA-Z0-9]*)$",
"match": true,
"message": "Protected class properties should be prefixed with an underscore. Exceptions are protected class properties that are interfaces. These should be prefixed with '_I'."
}
},
{
"selector": [
"typeProperty",
"classProperty"
],
"types": [
"boolean"
],
"format": [
"PascalCase"
],
"prefix": [
"is",
"has",
"can",
"did",
"will",
"should"
],
"leadingUnderscore": "allow"
},
{
"selector": "memberLike",
"modifiers": [
"public"
],
"format": [
"camelCase"
],
"leadingUnderscore": "forbid",
"filter": {
"regex": "^(Events|Styles|Classes|Then)$",
"match": false
}
},
{
"selector": "typeProperty",
"modifiers": [
"public"
],
"format": null,
"filter": {
"regex": ".*-event$",
"match": true
},
"custom": {
"regex": "^[a-z]+(-[a-z]+)*-event$",
"match": true
}
},
{
"selector": "typeProperty",
"modifiers": [
"public"
],
"format": [
"camelCase"
],
"filter": {
"regex": ".*-event$|^(Events|Styles|Classes|Then)$",
"match": false
}
}
],
"@typescript-eslint/padding-line-between-statements": [
"warn",
{
"blankLine": "always",
"prev": "*",
"next": [
"return",
"if",
"multiline-const",
"function",
"multiline-expression",
"multiline-let",
"block-like"
]
},
{
"blankLine": "always",
"prev": [
"function"
],
"next": "*"
}
],
"import/order": [
"warn",
{
"groups": [
[
"builtin",
"external"
],
[
"internal"
],
[
"parent",
"sibling"
]
],
"newlines-between": "never",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"jsdoc/no-undefined-types": [
"warn",
{
"disableReporting": true,
"markVariablesAsUsed": true
}
],
"jsdoc/require-jsdoc": [
"warn",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": false,
"FunctionExpression": false
},
"minLineCount": 10
}
],
"jsdoc/require-param": [
"warn",
{
"exemptedBy": [
"deprecated",
"inheritdoc"
]
}
],
"jsdoc/require-description": [
"warn",
{
"contexts": [
"FunctionDeclaration",
"MethodDefinition",
"ClassDeclaration",
"ClassExpression"
],
"descriptionStyle": "body",
"exemptedBy": [
"deprecated",
"inheritdoc"
]
}
],
"jsdoc/require-returns": [
"warn",
{
"checkGetters": false,
"exemptedBy": [
"deprecated",
"inheritdoc"
]
}
],
"jsdoc/check-tag-names": [
"warn",
{
"definedTags": [
"remarks",
"jest-environment",
"singleton"
]
}
],
"jsdoc/check-alignment": "warn",
"jsdoc/check-indentation": "warn",
"jsdoc/no-restricted-syntax": [
"error",
{
"contexts": [
{
"context": "MethodDefinition[kind='get']",
"comment": "JsdocBlock:has(JsdocTag[tag='returns'])",
"message": "JSDoc @returns comments are not allowed in getters."
}
]
}
],
"@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/explicit-function-return-type": [
"warn",
{
"allowExpressions": true,
"allowTypedFunctionExpressions": true,
"allowHigherOrderFunctions": true
}
],
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
"@typescript-eslint/no-misused-promises": "warn",
"@typescript-eslint/prefer-optional-chain": "warn"
},
"overrides": [
{
"files": [
"*.test.ts",
"*.spec.ts"
],
"rules": {
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-description": "off",
"jsdoc/require-returns": "off",
"@typescript-eslint/explicit-function-return-type": "off"
}
}
]
}

12
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
open-pull-requests-limit: 10
schedule:
interval: "weekly"

30
.github/workflows/PullRequestTest.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Run Build and Tests on Pull Request
on:
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.8.0'
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm run test:verbose
- name: Build the Project
run: npm run build:tsc

View File

@@ -0,0 +1,23 @@
name: Validate Branch Name on Pull Request
on:
pull_request:
branches:
- main
jobs:
validate-branch-name-on-pull-request:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Validate Branch Name on Pull Request
run: |
BRANCH_NAME=${GITHUB_HEAD_REF}
if [[ ! "$BRANCH_NAME" =~ ^(feature\/|fix\/|refactoring\/|testing\/|dependabot\/|gh-pages) ]]; then
echo "Invalid branch name: $BRANCH_NAME"
echo "Branch name must start with 'feature/', 'fix/', 'refactoring/', 'testing/', dependabot/" or "gh-pages"
exit 1
fi

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
# Internal
.vscode
.locale
.VSCodeCounter
*.ignore.*
dist/*
node_modules/*

20
.prettierrc.json Normal file
View File

@@ -0,0 +1,20 @@
{
"printWidth": 80,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"useTabs": false,
"tabWidth": 4,
"endOfLine": "auto",
"overrides": [
{
"files": [
".prettierrc",
".eslintrc"
],
"options": {
"parser": "json"
}
}
]
}

22
jest.config.js Normal file
View File

@@ -0,0 +1,22 @@
module.exports = {
setupFilesAfterEnv: ['./scripts/jest.setup.js'],
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.test.ts', '**/?(*.)+(test).ts'],
testPathIgnorePatterns: ['\\.spec\\.ts$', '\\.performance\\.test\\.ts$'],
moduleDirectories: ['node_modules', 'src'],
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1',
},
collectCoverage: true,
coverageDirectory: '.locale/coverage',
coverageReporters: ['text', 'lcov'],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
};

6894
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

37
package.json Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "ts-injex",
"version": "0.0.1",
"description": "",
"main": "dist/index.js",
"scripts": {
"build:tsc": "tsc",
"lint": "eslint --ext .ts .",
"lint:fix": "eslint --fix --ext .ts .",
"test:file": "jest --watch --onlyChanged --coverage=true --verbose",
"test:verbose": "jest --verbose"
},
"repository": {
"type": "git",
"url": "https://github.com/PxaMMaxP/TSinjex.git"
},
"keywords": [],
"author": "Max P. (@Github: PxaMMaxP)",
"license": "MIT",
"devDependencies": {
"typescript": "^5.5.4",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.11",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/parser": "^5.29.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.8.3",
"eslint-plugin-override": "https://github.com/PxaMMaxP/eslint-plugin-override",
"jest": "^29.7.0",
"ts-jest": "^29.2.3"
},
"dependencies": {
"eslint-plugin-prettier": "^5.2.1",
"jest-environment-jsdom": "^29.7.0"
}
}

17
scripts/jest.setup.js Normal file
View File

@@ -0,0 +1,17 @@
// jest.setup.js
const getCircularReplacer = () => {
const seen = new WeakSet();
return (key, value) => {
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
global.customJSONStringify = (object) => {
return JSON.stringify(object, getCircularReplacer());
};

43
tsconfig.json Normal file
View File

@@ -0,0 +1,43 @@
{
"compilerOptions": {
"baseUrl": ".",
"inlineSourceMap": false,
"sourceMap": true,
"inlineSources": true,
"declaration": true,
"declarationMap": true,
"outDir": "./dist",
"module": "ESNext",
"target": "ES6",
"allowJs": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitAny": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"isolatedModules": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"lib": [
"DOM",
"ES5",
"ES6",
"ES7",
"ES2021.WeakRef"
],
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}