Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]biome CI #15

Merged
merged 4 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:

jobs:
build:
permissions:
contents: read
pull-requests: write

runs-on: ubuntu-latest

Expand All @@ -15,7 +18,7 @@ jobs:

steps:
- name: repository checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: node.js setup
uses: actions/setup-node@v3
Expand All @@ -33,7 +36,7 @@ jobs:
- name: dependency install
run: npm ci

- name: testing
- name: angular test
run: npm run test

- name: angular building
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Code quality

on:
pull_request:
types:
- opened
- ready_for_review
- synchronize

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci ./projects/ngrx-extension/src
24 changes: 24 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: reviewdog
on:
pull_request:
types:
- opened
- ready_for_review
- synchronize
jobs:
biome:
name: runner / Biome
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: mongolyy/reviewdog-action-biome@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
filter_mode: nofilter
fail_on_error: true
biome_flags: './projects/ngrx-extension/src'
7 changes: 6 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"complexity": {
"noBannedTypes": {
"level": "off"
}
}
}
},
"javascript": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('withStorageSync', () => {
...initialAppState,
products: {
...initialAppState.products,
items: JSON.parse(localStorage.getItem('products-items')!),
items: JSON.parse(localStorage.getItem('products-items') ?? '[]'),
},
});
});
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('withStorageSync', () => {
...initialAppState,
products: {
...initialAppState.products,
items: JSON.parse(localStorage.getItem('products-items')!),
items: JSON.parse(localStorage.getItem('products-items') ?? '[]'),
},
});
});
Expand Down Expand Up @@ -210,7 +210,9 @@ describe('withStorageSync', () => {
...initialAppState,
products: {
...initialAppState.products,
items: JSON.parse(localStorage.getItem(`${prefix}-products-items`)!),
items: JSON.parse(
localStorage.getItem(`${prefix}-products-items`) ?? '[]',
),
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function withStorageSync({
prefix,
(key, fullKeyPath, objectState) => {
// If the store does not have the specified key
if (!(objectState as Record<string, object>).hasOwnProperty(key)) {
if (!Object.hasOwn(objectState as Record<string, object>, key)) {
throw new Error(`[${key}] ${key} not found`);
}

Expand Down Expand Up @@ -131,7 +131,7 @@ function writeDfs(
prefix: string,
callback: (key: string, fullKeyPath: string, objectState: unknown) => void,
): void {
nodes.forEach((node) => {
for (const node of nodes) {
if (typeof node === 'string') {
const fullKeyPath = prefix === '' ? node : `${prefix}-${node}`;
// If the current node is the end, call the callback to write data to storage
Expand All @@ -144,7 +144,7 @@ function writeDfs(
writeDfs(nestedState, childNode, newPrefix, callback);
}
}
});
}
}

/**
Expand All @@ -160,7 +160,7 @@ function readDfs(
prefix: string,
callback: (fullKeyPath: string) => void,
): void {
nodes.forEach((node) => {
for (const node of nodes) {
if (typeof node === 'string') {
const fullPathKey = prefix === '' ? node : `${prefix}-${node}`;
callback(fullPathKey);
Expand All @@ -170,7 +170,16 @@ function readDfs(
readDfs(childNode, newPrefix, callback);
}
}
});
if (typeof node === 'string') {
const fullPathKey = prefix === '' ? node : `${prefix}-${node}`;
callback(fullPathKey);
} else {
for (const [key, childNode] of Object.entries(node)) {
const newPrefix = prefix === '' ? key : `${prefix}-${node}`;
readDfs(childNode, newPrefix, callback);
}
}
}
}

/**
Expand Down
Loading