Skip to content

Commit 13bc89f

Browse files
authored
chore: update deps, use commitlint, husky (#3)
* chore: use commitlint, husky * chore: bump-up bee-js and dev deps * chore: add ci check step
1 parent 1ea8de0 commit 13bc89f

18 files changed

Lines changed: 4015 additions & 417 deletions

.depcheckrc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"ignores": [
3+
"@types/*",
4+
"@commitlint/*",
5+
"@eslint/*",
6+
"eslint*",
7+
"husky",
8+
"prettier",
9+
"typescript*",
10+
"ts-node",
11+
"vite*"
12+
]
13+
}

.github/workflows/check.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
pull-requests: read
17+
18+
strategy:
19+
matrix:
20+
node-version: [24.x]
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- uses: pnpm/action-setup@v4
27+
with:
28+
version: 11
29+
- name: Use Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- name: Setup pnpm cache
35+
uses: actions/cache@v3
36+
with:
37+
path: ~/.pnpm-store
38+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
39+
restore-keys: |
40+
${{ runner.os }}-pnpm-
41+
42+
- name: Install dependencies
43+
run: pnpm install --frozen-lockfile
44+
45+
- name: Commit linting
46+
uses: wagoid/commitlint-github-action@v6
47+
with:
48+
configFile: ./commitlint.config.cjs
49+
50+
- name: Code linting
51+
run: pnpm run lint
52+
env:
53+
CI: true
54+
55+
- name: Dependency check
56+
run: pnpm run depcheck
57+
58+
- name: Types check
59+
run: pnpm run check:types
60+
61+
- name: Build
62+
run: pnpm run build

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm exec commitlint --edit "$1"

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm run lint && pnpm run check:types && pnpm run depcheck

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v24

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
yarn.lock
3+
package-lock.json
4+
dist
5+
pnpm-lock.yaml

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"printWidth": 120,
6+
"tabWidth": 2
7+
}

commitlint.config.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'body-max-line-length': [1, 'always', 120],
5+
'header-max-length': [2, 'always', 160],
6+
},
7+
}

eslint-compat.cjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// CommonJS wrapper for ESLint configuration
2+
const js = require("@eslint/js");
3+
const ts = require("@typescript-eslint/eslint-plugin");
4+
const tsParser = require("@typescript-eslint/parser");
5+
const prettier = require("eslint-config-prettier");
6+
const importPlugin = require("eslint-plugin-import");
7+
const pluginJest = require("eslint-plugin-jest");
8+
const prettierPlugin = require("eslint-plugin-prettier");
9+
const simpleImportSort = require("eslint-plugin-simple-import-sort");
10+
11+
// Export the required modules that the ESM config can import
12+
module.exports = {
13+
js,
14+
ts,
15+
tsParser,
16+
prettier,
17+
importPlugin,
18+
pluginJest,
19+
prettierPlugin,
20+
simpleImportSort,
21+
};

eslint.config.mjs

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import * as path from 'path';
2+
import { fileURLToPath } from 'url';
3+
4+
// Calculate current directory for proper file path resolution
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
// Import the modules from our CommonJS compatibility wrapper
8+
const compat = await import(`${__dirname}/eslint-compat.cjs`);
9+
const js = compat.default.js;
10+
const ts = compat.default.ts;
11+
const tsParser = compat.default.tsParser;
12+
const prettier = compat.default.prettier;
13+
const importPlugin = compat.default.importPlugin;
14+
const pluginJest = compat.default.pluginJest;
15+
const prettierPlugin = compat.default.prettierPlugin;
16+
const simpleImportSort = compat.default.simpleImportSort;
17+
18+
// Recreate eslint:recommended
19+
const eslintRecommended = js.configs.recommended;
20+
21+
// Recreate plugin:@typescript-eslint/recommended
22+
const typescriptRecommended = {
23+
plugins: {
24+
'@typescript-eslint': ts,
25+
},
26+
rules: {
27+
...ts.configs.recommended.rules,
28+
},
29+
};
30+
31+
// Recreate plugin:import/errors, plugin:import/warnings, plugin:import/typescript
32+
const importRules = {
33+
plugins: {
34+
import: importPlugin,
35+
},
36+
rules: {
37+
...importPlugin.configs.errors.rules,
38+
...importPlugin.configs.warnings.rules,
39+
...importPlugin.configs.typescript.rules,
40+
},
41+
};
42+
43+
// Recreate plugin:prettier/recommended
44+
const prettierRecommended = {
45+
plugins: {
46+
prettier: prettierPlugin,
47+
},
48+
rules: {
49+
'prettier/prettier': 'error',
50+
...prettier.rules,
51+
},
52+
};
53+
54+
export default [
55+
{
56+
ignores: ['**/node_modules/**', '**/dist/**', 'eslint.config.mjs', 'eslint-compat.cjs', 'commitlint.config.cjs'],
57+
},
58+
{
59+
files: ['**/*.ts', '**/*.mjs', '**/*.cjs', '**/*.js'],
60+
settings: {
61+
'import/resolver': {
62+
typescript: {
63+
alwaysTryTypes: true,
64+
},
65+
},
66+
},
67+
languageOptions: {
68+
ecmaVersion: 2022,
69+
sourceType: 'module',
70+
parser: tsParser,
71+
globals: {
72+
// Browser environment
73+
window: 'readonly',
74+
document: 'readonly',
75+
navigator: 'readonly',
76+
console: 'readonly',
77+
module: 'readonly',
78+
__dirname: 'readonly',
79+
process: 'readonly',
80+
Buffer: 'readonly',
81+
setTimeout: 'readonly',
82+
setInterval: 'readonly',
83+
clearTimeout: 'readonly',
84+
clearInterval: 'readonly',
85+
TextEncoder: 'readonly',
86+
TextDecoder: 'readonly',
87+
ImportMetaEnv: 'readonly',
88+
fetch: 'readonly',
89+
},
90+
},
91+
},
92+
{
93+
files: ['tests/**/*.ts'],
94+
plugins: {
95+
jest: pluginJest,
96+
},
97+
languageOptions: {
98+
globals: pluginJest.environments.globals.globals,
99+
},
100+
rules: {
101+
'jest/no-disabled-tests': 'warn',
102+
'jest/no-focused-tests': 'error',
103+
'jest/no-identical-title': 'error',
104+
'jest/prefer-to-have-length': 'warn',
105+
'jest/valid-expect': 'error',
106+
},
107+
},
108+
// Include all the extended configs
109+
eslintRecommended,
110+
typescriptRecommended,
111+
importRules,
112+
prettierRecommended,
113+
prettier, // Additional prettier config
114+
{
115+
// Plugin and rule configurations
116+
plugins: {
117+
'@typescript-eslint': ts,
118+
'simple-import-sort': simpleImportSort,
119+
},
120+
rules: {
121+
'@typescript-eslint/no-explicit-any': 'off',
122+
'@typescript-eslint/explicit-function-return-type': 'error',
123+
'@typescript-eslint/no-non-null-assertion': 'off',
124+
'@typescript-eslint/no-unused-vars': [
125+
'warn',
126+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
127+
],
128+
'simple-import-sort/imports': [
129+
'error',
130+
{
131+
groups: [
132+
['^@?\\w'], // Packages
133+
['^\\u0000'], // Side effect imports
134+
['^\\.\\.(?!/?$)', '^\\.\\./?$'], // Parent imports
135+
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], // Other relative imports
136+
['^.+\\.?(css)$'], // Style imports
137+
],
138+
},
139+
],
140+
},
141+
},
142+
];

0 commit comments

Comments
 (0)