Skip to content

Commit

Permalink
feat(core): Project bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseLion committed Jan 2, 2024
1 parent 196f007 commit efcc7b9
Show file tree
Hide file tree
Showing 20 changed files with 9,925 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Dependencies
.yarn/
node_modules/

# Auto-generated
build/
dist/
229 changes: 229 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"root": true,
"env": {
"es6": true,
"node": true
},
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
}
}
},
"parserOptions": {
"ecmaVersion": "latest",
"project": "./tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"eslint-plugin-import",
"eslint-plugin-jsdoc",
"etc",
"sonarjs"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:etc/recommended",
"plugin:import/typescript",
"plugin:sonarjs/recommended"
],
"overrides": [{
"files": "*.ts?(x)",
"parser": "@typescript-eslint/parser"
}, {
"files": "*.test.ts?(x)",
"rules": {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"etc/throw-error": "off",
"import/no-namespace": "off"
}
}, {
"files": "*.typetest.ts?(x)",
"rules": {
"@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": false }],
"etc/throw-error": "off",
"import/no-namespace": "off"
}
}, {
"files": "*.js?(x)",
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off"
}
}],
"rules": {
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/member-ordering": ["error", {
"classes": [
"static-field",
"field",
"constructor",
"static-method",
"abstract-method",
"protected-method",
"public-method",
"private-method"
],
"interfaces": { "order": "alphabetically" },
"typeLiterals": { "order": "alphabetically" }
}],
"@typescript-eslint/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": true
}
}],
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": ["error", { "ignoreRestArgs": true }],
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-inferrable-types": ["error", {
"ignoreParameters": true,
"ignoreProperties": true
}],
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-redundant-type-constituents": "error",
"@typescript-eslint/no-shadow": ["error", { "hoist": "all" }],
"@typescript-eslint/no-unused-expressions": ["error", { "allowTernary": true }],
"@typescript-eslint/no-unused-vars": ["error", {
"destructuredArrayIgnorePattern": "^_",
"ignoreRestSiblings": true
}],
"@typescript-eslint/no-use-before-define": ["error", {
"functions": false,
"classes": false
}],
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/parameter-properties": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": ["error", "double", {
"avoidEscape": true,
"allowTemplateLiterals": false
}],
"@typescript-eslint/restrict-template-expressions": ["error", {
"allowNumber": true,
"allowBoolean": true,
"allowNullish": true
}],
"@typescript-eslint/semi": "error",
"@typescript-eslint/space-infix-ops": "error",
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": ["error", { "ignoreStatic": true }],
"@typescript-eslint/unified-signatures": "error",
"array-bracket-spacing": "error",
"arrow-parens": ["error", "as-needed"],
"arrow-spacing": "error",
"brace-style": "error",
"camelcase": "error",
"comma-spacing": "error",
"computed-property-spacing": "error",
"constructor-super": "error",
"curly": "error",
"etc/no-commented-out-code": "error",
"etc/throw-error": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
"import/newline-after-import": "error",
"import/no-absolute-path": "error",
"import/no-cycle": ["error", {
"allowUnsafeDynamicCyclicDependency": true,
"ignoreExternal": true
}],
"import/no-duplicates": "error",
"import/no-import-module-exports": "error",
"import/no-namespace": "error",
"import/no-relative-packages": "error",
"import/no-unresolved": "error",
"import/no-useless-path-segments": "error",
"import/order": ["error", {
"alphabetize": {
"caseInsensitive": false,
"order": "asc"
},
"newlines-between": "always",
"groups": ["external", "parent", "sibling"]
}],
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": ["error", { "excludeTags": ["example", "param", "returns"] }],
"jsdoc/tag-lines": ["error", "any", { "startLines": 1 }],
"keyword-spacing": "error",
"linebreak-style": "error",
"max-classes-per-file": ["error", 1],
"max-len": ["error", {
"code": 120,
"comments": 80,
"ignoreRegExpLiterals": true,
"ignorePattern": "^import (\\{ )?\\w+( \\})? from \".+\";$",
"ignoreUrls": true,
"tabWidth": 2
}],
"new-parens": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "error",
"no-duplicate-imports": "error",
"no-empty-function": "error",
"no-eval": "error",
"no-extra-boolean-cast": ["error", { "enforceForLogicalOperands": true }],
"no-invalid-this": "error",
"no-labels": "error",
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
"no-multi-spaces": "error",
"no-new-wrappers": "error",
"no-param-reassign": "error",
"no-tabs": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-underscore-dangle": "error",
"no-use-before-define": "off",
"no-useless-computed-key": ["error", { "enforceForClassMembers": true }],
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-const": "error",
"quote-props": ["error", "as-needed"],
"radix": "error",
"rest-spread-spacing": "error",
"semi-spacing": "error",
"sonarjs/cognitive-complexity": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-inverted-boolean-check": "error",
"sort-keys": "error",
"space-before-blocks": "error",
"space-in-parens": "error",
"spaced-comment": "error",
"switch-colon-spacing": "error"
}
}
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_call:

concurrency:
group: ci-${{ github.ref_name }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
nodejs: [18, 19, 20, 21]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodejs }}
cache: yarn
- run: yarn install --immutable
- run: yarn compile
- run: yarn lint
- run: yarn test

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn
- run: yarn install --immutable
- run: yarn docs
- uses: tj-actions/verify-changed-files@v17
id: verify-changed-files
with:
files: |
**/docs/**
- name: Fail on missing docs
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "::error::The API reference docs have uncommitted changes:"
echo "::error::${{ steps.verify-changed-files.outputs.changed_files }}"
exit 1
35 changes: 35 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CodeQL

on:
push:
branches: main
pull_request:
branches: main
schedule:
- cron: 23 2 * * 0

concurrency:
group: codeql-${{ github.ref_name }}
cancel-in-progress: true

jobs:
analyze:
runs-on: ubuntu-latest
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn
- uses: github/codeql-action/init@v2
with:
languages: javascript-typescript
- uses: github/codeql-action/analyze@v2
with:
category: /language:javascript-typescript
14 changes: 14 additions & 0 deletions .github/workflows/owner-approve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Auto approve for owner

on:
pull_request:
types: [opened, reopened]

jobs:
approve:
if: github.actor == github.repository_owner
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Node.js
node_modules/
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Generated
build/
dist/

# VSCode
.vscode/

# Logs
*.log
11 changes: 11 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json.schemastore.org/mocharc",
"exit": true,
"extension": ["ts", "tsx"],
"recursive": true,
"require": [
"ts-node/register",
"test/hooks.ts"
],
"spec": ["test/**/*.test.*"]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.5.0
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-engines.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-engines",
factory: function (require) {
var plugin=(()=>{var P=Object.create,f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var b=n=>f(n,"__esModule",{value:!0});var i=n=>{if(typeof require!="undefined")return require(n);throw new Error('Dynamic require of "'+n+'" is not supported')};var T=(n,e)=>{for(var r in e)f(n,r,{get:e[r],enumerable:!0})},V=(n,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of N(e))!Y.call(n,t)&&t!=="default"&&f(n,t,{get:()=>e[t],enumerable:!(r=R(e,t))||r.enumerable});return n},s=n=>V(b(f(n!=null?P(j(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var U={};T(U,{default:()=>q});var o=s(i("@yarnpkg/core")),c;(function(r){r.Yarn="Yarn",r.Console="Console"})(c||(c={}));var h=class{constructor(e){this.throwWrongEngineError=(e,r)=>{let t=this.formatErrorMessage(e,r);this.throwError(t)};this.throwError=e=>{switch(this.errorReporter){case c.Yarn:this.reportYarnError(e);break;case c.Console:default:this.reportConsoleError(e);break}};this.reportYarnError=e=>{throw new o.ReportError(o.MessageName.UNNAMED,e)};this.reportConsoleError=e=>{console.error(e),process.exit(1)};this.formatErrorMessage=(e,r)=>{let{configuration:t}=this.project,p=o.formatUtils.applyStyle(t,o.formatUtils.pretty(t,this.engine,"green"),2),g=o.formatUtils.pretty(t,e,"cyan"),d=o.formatUtils.pretty(t,r,"cyan"),w=`The current ${p} version ${g} does not satisfy the required version ${d}.`;return o.formatUtils.pretty(t,w,"red")};this.project=e.project,this.errorReporter=e.errorReporter}};var m=s(i("fs")),y=s(i("path")),l=s(i("semver")),k=s(i("@yarnpkg/fslib")),a=s(i("@yarnpkg/core"));var v=class extends h{constructor(){super(...arguments);this.resolveNvmRequiredVersion=()=>{let{configuration:e,cwd:r}=this.project,t=(0,y.resolve)(k.npath.fromPortablePath(r),".nvmrc"),p=a.formatUtils.applyStyle(e,a.formatUtils.pretty(e,this.engine,"green"),2);if(!(0,m.existsSync)(t)){this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The .nvmrc file does not exist.`,"red"));return}let g=(0,m.readFileSync)(t,"utf-8").trim();if((0,l.validRange)(g))return g;let d=a.formatUtils.pretty(e,".nvmrc","yellow");this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The ${d} file contains an invalid semver range.`,"red"))}}get engine(){return"Node"}verifyEngine(e){let r=e.node;r!=null&&(r===".nvmrc"&&(r=this.resolveNvmRequiredVersion()),(0,l.satisfies)(process.version,r,{includePrerelease:!0})||this.throwWrongEngineError(process.version.replace(/^v/i,""),r.replace(/^v/i,"")))}};var x=s(i("semver")),E=s(i("@yarnpkg/core"));var u=class extends h{get engine(){return"Yarn"}verifyEngine(e){let r=e.yarn;r!=null&&((0,x.satisfies)(E.YarnVersion,r,{includePrerelease:!0})||this.throwWrongEngineError(E.YarnVersion,r))}};var C=n=>e=>{if(process.env.PLUGIN_YARN_ENGINES_DISABLE!=null)return;let{engines:r={}}=e.getWorkspaceByCwd(e.cwd).manifest.raw,t={project:e,errorReporter:n};[new v(t),new u(t)].forEach(g=>g.verifyEngine(r))},S={hooks:{validateProject:C(c.Yarn),setupScriptEnvironment:C(c.Console)}},q=S;return U;})();
return plugin;
}
};
Loading

0 comments on commit efcc7b9

Please sign in to comment.