Skip to content

Commit 275f6bf

Browse files
committed
MERGE: main
2 parents db3c662 + d09152c commit 275f6bf

193 files changed

Lines changed: 12027 additions & 12803 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Code Quality Control Workflow"
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
code_quality_matrix:
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
cmd: ["format:check", "lint:check", "build"]
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
- name: Cache node modules
19+
id: cache-npm
20+
uses: actions/cache@v4
21+
env:
22+
cache-name: cache-node-modules
23+
with:
24+
# npm cache files are stored in `~/.npm` on Linux/macOS
25+
path: ~/.npm
26+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-build-${{ env.cache-name }}-
29+
${{ runner.os }}-build-
30+
${{ runner.os }}-
31+
32+
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
33+
name: List the state of node modules
34+
continue-on-error: true
35+
run: npm list
36+
37+
- name: "Install Node Modules"
38+
run: npm install -D
39+
40+
- name: "Running ${{ matrix.cmd }}"
41+
run: npm run ${{ matrix.cmd }}
42+
continue-on-error: ${{ matrix.cmd == 'lint:check' }}
43+
44+
- name: Annotate Code Linting Results
45+
if: ${{ matrix.cmd == 'lint:check' }}
46+
uses: ataylorme/eslint-annotate-action@v3
47+
with:
48+
report-json: "eslint_report.json"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ npm-debug.log
1818
# dist
1919
dist
2020

21+
# temporary reports
22+
eslint_report.json
23+
2124
#yarn
2225
.pnp.*
2326
.yarn/*

.prettierrc

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

CHANGELOG.md

Whitespace-only changes.

eslint.config.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
sourceType: 'module',
5+
},
6+
plugins: ['@typescript-eslint/eslint-plugin', 'import', '@stylistic/ts'],
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/eslint-recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'prettier',
12+
'plugin:sonarjs/recommended-legacy',
13+
'plugin:import/recommended',
14+
'plugin:import/typescript',
15+
],
16+
root: true,
17+
env: {
18+
node: true,
19+
jest: true,
20+
},
21+
ignorePatterns: [
22+
'**/node_modules/*',
23+
'dist',
24+
'tests',
25+
'scripts',
26+
'resources',
27+
'.dev',
28+
'.devops',
29+
'.debug',
30+
],
31+
rules: {
32+
'no-console': 'error',
33+
'@typescript-eslint/no-explicit-any': 'off',
34+
'@typescript-eslint/no-inferrable-types': 'error',
35+
'@typescript-eslint/interface-name-prefix': 'off',
36+
'@typescript-eslint/explicit-function-return-type': 'off',
37+
'no-eval': 'error',
38+
'no-implied-eval': 'error',
39+
'prefer-promise-reject-errors': 'warn',
40+
complexity: ['error', 20],
41+
'import/no-unresolved': 'error',
42+
'import/order': [
43+
'error',
44+
{
45+
alphabetize: {
46+
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
47+
order: 'asc',
48+
/* ignore case. Options: [true, false] */
49+
caseInsensitive: true,
50+
},
51+
},
52+
],
53+
},
54+
settings: {
55+
'import/resolver': {
56+
typescript: {
57+
project: './tsconfig.json',
58+
},
59+
},
60+
},
61+
};

lib/cache/cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { CacheDriver } from "./interfaces";
2-
import { CacheService } from "./service";
3-
import { genKeyFromObj } from "./utils/genKey";
1+
import { CacheDriver } from './interfaces';
2+
import { CacheService } from './service';
3+
import { genKeyFromObj } from './utils/genKey';
44

55
export class Cache {
66
static store(store?: string): CacheDriver {

lib/cache/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const CACHE_OPTIONS = "_intentjs_cache_options__";
1+
export const CACHE_OPTIONS = '_intentjs_cache_options__';

lib/cache/drivers/inMemory.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { GenericFunction } from "../../interfaces";
2-
import { Package } from "../../utils/packageLoader";
3-
import { CacheDriver, InMemoryDriverOption } from "../interfaces";
1+
import { GenericFunction } from '../../interfaces';
2+
import { Package } from '../../utils/packageLoader';
3+
import { CacheDriver, InMemoryDriverOption } from '../interfaces';
44

55
export class InMemoryDriver implements CacheDriver {
66
private client: any;
77

88
constructor(private options: InMemoryDriverOption) {
9-
const NodeCache = Package.load("node-cache");
9+
const NodeCache = Package.load('node-cache');
1010

1111
this.client = new NodeCache({ stdTTL: 100, checkperiod: 120 });
1212
}
@@ -19,7 +19,7 @@ export class InMemoryDriver implements CacheDriver {
1919
async set(
2020
key: string,
2121
value: string | Record<string, any>,
22-
ttlInSec?: number | undefined
22+
ttlInSec?: number | undefined,
2323
): Promise<boolean> {
2424
const cacheKey = `${this.options.prefix}:::${key}`;
2525

@@ -38,7 +38,7 @@ export class InMemoryDriver implements CacheDriver {
3838
async remember<T = any>(
3939
key: string,
4040
cb: GenericFunction,
41-
ttlInSec: number
41+
ttlInSec: number,
4242
): Promise<T> {
4343
const exists = await this.has(key);
4444
if (exists) return this.get(key);

lib/cache/drivers/redis.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { GenericFunction } from "../../interfaces";
2-
import { Package } from "../../utils";
3-
import { CacheDriver, RedisDriverOption } from "../interfaces";
1+
import { GenericFunction } from '../../interfaces';
2+
import { Package } from '../../utils';
3+
import { CacheDriver, RedisDriverOption } from '../interfaces';
44

55
export class RedisDriver implements CacheDriver {
66
private client: any;
77

88
constructor(private options: RedisDriverOption) {
9-
const IORedis = Package.load("ioredis");
9+
const IORedis = Package.load('ioredis');
1010
if (options.url) {
1111
this.client = new IORedis(options.url, { db: options.database || 0 });
1212
} else {
@@ -33,12 +33,12 @@ export class RedisDriver implements CacheDriver {
3333
async set(
3434
key: string,
3535
value: string | number | Record<string, any>,
36-
ttlInSec?: number
36+
ttlInSec?: number,
3737
): Promise<boolean> {
3838
try {
3939
const redisKey = `${this.options.prefix}:::${key}`;
4040
ttlInSec
41-
? await this.client.set(redisKey, JSON.stringify(value), "EX", ttlInSec)
41+
? await this.client.set(redisKey, JSON.stringify(value), 'EX', ttlInSec)
4242
: await this.client.set(redisKey, JSON.stringify(value));
4343
return true;
4444
} catch {
@@ -54,7 +54,7 @@ export class RedisDriver implements CacheDriver {
5454
async remember<T = any>(
5555
key: string,
5656
cb: GenericFunction,
57-
ttlInSec: number
57+
ttlInSec: number,
5858
): Promise<T> {
5959
const value = await this.get(key);
6060
if (value) return value;

lib/cache/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from "./service";
2-
export * from "./interfaces";
3-
export * from "./cache";
1+
export * from './service';
2+
export * from './interfaces';
3+
export * from './cache';

0 commit comments

Comments
 (0)