Skip to content

Commit

Permalink
chore: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
tianenpang committed Sep 23, 2023
0 parents commit 223dc1d
Show file tree
Hide file tree
Showing 27 changed files with 4,667 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .commitlintrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { rules as defaultRules } from '@commitlint/config-conventional';

/**
* Commit Lint Config
*/
const commitLintConfig = {
extends: ['@commitlint/config-conventional'],
helpUrl: '',
plugins: ['commitlint-plugin-function-rules'],
rules: {
...defaultRules,
'function-rules/header-max-length': [0],
'type-enum': [
2,
'always',
['feat', 'feature', 'fix', 'refactor', 'docs', 'build', 'test', 'ci', 'chore']
]
}
};

export default commitLintConfig;
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root=true

[*]
tab_width=2
indent_size=2
charset=utf-8
end_of_line=unset
indent_style=space
max_line_length=100
insert_final_newline=true
trim_trailing_whitespace=true

[*.md]
max_line_length=off
trim_trailing_whitespace=false
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
.husky
dist
node_modules
pnpm-lock.yaml
!.vscode
!.*.js
!.*.cjs
!.*.mjs
!.*.ts
103 changes: 103 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"$schema": "https://json.schemastore.org/eslintrc.json",
"root": true,
"env": {
"node": true,
"es2024": true
},
"parser": "@typescript-eslint/parser",
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"plugins": [
"@typescript-eslint",
"import",
"unused-imports",
"sort-keys-fix",
"sort-destructure-keys",
"prettier"
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": "latest"
},
"settings": {
"import/resolver": {
"node": true,
"typescript": true
}
},
"rules": {
"no-console": "warn",
"prettier/prettier": "error",
"import/no-duplicates": "error",
"sort-keys-fix/sort-keys-fix": "error",
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"import/newline-after-import": ["error", { "count": 1 }],
"no-unused-vars": "off",
"unused-imports/no-unused-vars": [
"error",
{
"args": "after-used",
"argsIgnorePattern": "^_",
"vars": "all",
"varsIgnorePattern": "^_"
}
],
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": "directive", "next": "*" },
{ "blankLine": "any", "prev": "directive", "next": "directive" },
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] },
{ "blankLine": "always", "prev": "*", "next": "return" }
],
"sort-destructure-keys/sort-destructure-keys": [
"error",
{
"caseSensitive": true
}
],
"sort-keys": [
"error",
"asc",
{
"minKeys": 2,
"natural": false,
"caseSensitive": true
}
],
"sort-imports": [
"error",
{
"ignoreCase": false,
"ignoreMemberSort": false,
"allowSeparatedGroups": true,
"ignoreDeclarationSort": true,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
}
],
"import/order": [
"error",
{
"groups": [
"type",
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"unknown",
"object"
],
"pathGroupsExcludedImportTypes": ["type"],
"newlines-between": "always",
"warnOnUnassignedImports": true,
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @tianenpang @jrgarciadev
41 changes: 41 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Commitlint

on:
push:
branches: [main, next]
pull_request:
branches: [main, next]

jobs:
commitlint:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout codebase
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
run_install: false
- name: Setup node
uses: actions/setup-node@v3
with:
cache: 'pnpm'
check-latest: true
node-version-file: '.nvmrc'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run commitlint
id: run_commitlint
uses: wagoid/commitlint-github-action@v5
with:
configFile: .commitlintrc.js
env:
NODE_PATH: ${{ github.workspace }}/node_modules
- name: Show outputs
if: ${{ always() }}
run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }}
32 changes: 32 additions & 0 deletions .github/workflows/script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Script

on:
push:
branches: [main, next]
pull_request:
branches: [main, next]

jobs:
next:
strategy:
matrix:
os: [ubuntu-latest]
script: [build]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout codebase
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
run_install: false
- name: Setup node
uses: actions/setup-node@v3
with:
cache: 'pnpm'
check-latest: true
node-version-file: '.nvmrc'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run script
run: pnpm ${{ matrix.script }}
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# output
/dist

# ide
/.idea

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/.swc
/coverage
__snapshots__


# misc
.DS_Store
*.pem

# logs
*.log

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# typescript
*.tsbuildinfo

# lock
yarn.lock
package-lock.json
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm commitlint --config .commitlintrc.ts --edit ${1}
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

if [ -t 2 ]; then exec >/dev/tty 2>&1; fi

pnpm lint-staged -c .lintstagedrc.mjs
33 changes: 33 additions & 0 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

import { relative } from 'path';

import { ESLint } from 'eslint';

const removeIgnoredFiles = async (files) => {
const cwd = process.cwd();
const eslint = new ESLint();
const relativePaths = files.map((file) => relative(cwd, file));
const isIgnored = await Promise.all(relativePaths.map((file) => eslint.isPathIgnored(file)));
const filteredFiles = files.filter((_, i) => !isIgnored[i]);

return filteredFiles.join(' ');
};

/**
* Lint Staged Config
*/
const lintStaged = {
'**/*.{cjs,mjs,js,ts}': async (files) => {
const filesToLint = await removeIgnoredFiles(files);

return [`eslint -c .eslintrc --max-warnings=0 --fix ${filesToLint}`];
},
'**/*.{json,md}': async (files) => {
const filesToLint = await removeIgnoredFiles(files);

return [`prettier --config .prettierrc --ignore-path --write ${filesToLint}`];
}
};

export default lintStaged;
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lockfile=true
save-exact=true
engine-strict=true
auto-install-peers=true
enable-pre-post-scripts=true
strict-peer-dependencies=false
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.1
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
.husky
dist
node_modules
pnpm-lock.yaml
!.vscode
!.*.js
!.*.cjs
!.*.mjs
!.*.ts
18 changes: 18 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"tabWidth": 2,
"printWidth": 100,
"semi": true,
"useTabs": false,
"singleQuote": true,
"editorconfig": true,
"bracketSpacing": true,
"jsxSingleQuote": false,
"bracketSameLine": false,
"pluginSearchDirs": false,
"endOfLine": "auto",
"arrowParens": "always",
"trailingComma": "none",
"plugins": [],
"overrides": []
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"npm.packageManager": "pnpm",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
Loading

0 comments on commit 223dc1d

Please sign in to comment.