Skip to content

Commit

Permalink
chore: add lint for js (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem authored Aug 25, 2023
2 parents 1c36d7c + 37d8ad6 commit fb4c0c3
Show file tree
Hide file tree
Showing 27 changed files with 1,265 additions and 267 deletions.
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@antfu",
"rules": {
"yml/no-empty-mapping-value": "off"
},
"ignorePatterns": [
"generated"
]
}
15 changes: 0 additions & 15 deletions .eslintrc.js

This file was deleted.

24 changes: 20 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ jobs:
- name: Check Diff
run: docker run --rm --volume "$(pwd)/Protos/V1:/workspace" --workdir /workspace bufbuild/buf:1.8.0 format -d --exit-code

lint-js:
name: Lint JS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 20
cache: pnpm

- run: pnpm install --frozen-lockfile

- run: pnpm run lint

build-web:
name: Build Web
runs-on: ubuntu-latest
Expand Down Expand Up @@ -210,14 +227,14 @@ jobs:

- name: pip update and add build package
run: bash proto2python.sh ~/pyvenv

- name: Install dependencies
run: pip install "$(echo pkg/armonik*.whl)[tests]"

- name: Run tests
run: python -m pytest tests --cov=armonik --cov-config=.coveragerc --cov-report=term-missing --cov-report xml:coverage.xml --cov-report html:coverage_report
- name: Get Cover

- name: Get Cover
uses: orgoro/coverage@6d7a2607343d2abeab89ef40b54ec9785134e313
with:
coverageFile: packages/python/coverage.xml
Expand Down Expand Up @@ -258,4 +275,3 @@ jobs:
if-no-files-found: error
path: packages/cpp/tools/packaging/*.${{ matrix.type }}
name: libarmonik.${{ matrix.type }}

10 changes: 5 additions & 5 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
id-token: write

concurrency:
group: "pages"
group: pages
cancel-in-progress: true

jobs:
Expand All @@ -28,8 +28,8 @@ jobs:
- name: Setup Node
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
with:
node-version: "18"
cache: "pnpm"
node-version: '18'
cache: pnpm

- name: Install dependencies
run: nci
Expand Down Expand Up @@ -80,8 +80,8 @@ jobs:
- name: Setup Node
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
with:
node-version: "18"
cache: "pnpm"
node-version: '18'
cache: pnpm

- name: Install dependencies
run: cd .docs && nci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
id: genver
run: echo "VERSION=$(npx @aneoconsultingfr/generate-next-version@latest --edge)" >> "$GITHUB_OUTPUT"
- name: Summary version
# Print to the summary
# Print to the summary
run: echo "VERSION=${{ steps.genver.outputs.version }}" >> $GITHUB_STEP_SUMMARY

version:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
# We need to verify the version in some packages with the tag in order to have the same version in all packages (python, csharp, angular, web).
Expand Down Expand Up @@ -197,7 +197,6 @@ jobs:
run: |
gh release upload ${{ github.ref_name }} packages/cpp/tools/packaging/*.${{ matrix.type }}
update-changelog:
needs: [verify-versions]
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Lint PR"
name: Lint PR

on:
pull_request_target:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/validate-docs-generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
with:
node-version: 18
cache: "pnpm"
cache-dependency-path: ".docs/pnpm-lock.yaml"
cache: pnpm
cache-dependency-path: .docs/pnpm-lock.yaml

- name: Install dependencies
run: cd .docs && nci
Expand All @@ -35,7 +35,6 @@ jobs:
- name: Static HTML export with Nuxt
run: cd .docs && nr generate


lint-markdown:
name: Lint Markdown
runs-on: ubuntu-latest
Expand All @@ -48,7 +47,7 @@ jobs:
with:
node-version: 18
cache: pnpm
cache-dependency-path: ".docs/pnpm-lock.yaml"
cache-dependency-path: .docs/pnpm-lock.yaml

- run: cd .docs && nci

Expand All @@ -66,7 +65,7 @@ jobs:
with:
node-version: 18
cache: pnpm
cache-dependency-path: ".docs/pnpm-lock.yaml"
cache-dependency-path: .docs/pnpm-lock.yaml

- run: cd .docs && nci

Expand Down
4 changes: 2 additions & 2 deletions examples/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "armonik-api-angular",
"description": "This project is a demo of the ArmoniK API Angular library",
"version": "0.0.0",
"private": true,
"description": "This project is a demo of the ArmoniK API Angular library",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@aneoconsultingfr/armonik.api.angular": "^3.8.1",
"@angular/animations": "^16.0.0",
Expand Down
58 changes: 29 additions & 29 deletions examples/angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { AfterViewInit, Component, inject } from '@angular/core';
import { PartitionsGrpcService } from './services/partitions-grpc.service';
import { PartitionRaw } from '@aneoconsultingfr/armonik.api.angular';
import { Subject, merge, startWith, switchMap } from 'rxjs';
import { NgFor, NgIf } from '@angular/common';
import type { AfterViewInit } from '@angular/core'
import { Component, inject } from '@angular/core'
import type { PartitionRaw } from '@aneoconsultingfr/armonik.api.angular'
import { Subject, merge, startWith, switchMap } from 'rxjs'
import { NgFor, NgIf } from '@angular/common'
import { PartitionsGrpcService } from './services/partitions-grpc.service'

@Component({
selector: 'app-root',
Expand All @@ -21,47 +22,46 @@ import { NgFor, NgIf } from '@angular/common';
`],
standalone: true,
providers: [
PartitionsGrpcService
PartitionsGrpcService,
],
imports: [
NgIf,
NgFor,
],
})
export class AppComponent implements AfterViewInit {
#partitionsGrpcService = inject(PartitionsGrpcService);
#partitionsGrpcService = inject(PartitionsGrpcService)

#refresh$ = new Subject<void>();
#refresh$ = new Subject<void>()

loading = true;
partitions: PartitionRaw.AsObject[] = [];
loading = true
partitions: PartitionRaw.AsObject[] = []

ngAfterViewInit(): void {
merge(
this.#refresh$,
)
.pipe(
startWith({}),
switchMap(() => {
this.loading = true;
return this.#partitionsGrpcService.list$();
}),
).subscribe(
(response) => {
this.loading = false;
merge(
this.#refresh$,
)
.pipe(
startWith({}),
switchMap(() => {
this.loading = true
return this.#partitionsGrpcService.list$()
}),
).subscribe(
(response) => {
this.loading = false

if (response.partitions) {
this.partitions = response.partitions;
}
}
);
if (response.partitions)
this.partitions = response.partitions
},
)
}

refresh(): void {
this.#refresh$.next();
this.#refresh$.next()
}

trackByPartition(_index_: number, partition: PartitionRaw.AsObject): string {
return partition.id;
return partition.id
}
}
13 changes: 7 additions & 6 deletions examples/angular/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { GrpcCoreModule } from '@ngx-grpc/core';
import { GrpcWebClientModule } from '@ngx-grpc/grpc-web-client';
import type { ApplicationConfig } from '@angular/core'
import { importProvidersFrom } from '@angular/core'
import { GrpcCoreModule } from '@ngx-grpc/core'
import { GrpcWebClientModule } from '@ngx-grpc/grpc-web-client'

export const appConfig: ApplicationConfig = {
providers: [
importProvidersFrom(GrpcCoreModule.forRoot()),
importProvidersFrom(GrpcWebClientModule.forRoot({ settings: { host: '' } }))
]
};
importProvidersFrom(GrpcWebClientModule.forRoot({ settings: { host: '' } })),
],
}
17 changes: 9 additions & 8 deletions examples/angular/src/app/services/partitions-grpc.service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { Injectable, inject } from '@angular/core';
import { ListPartitionsRequest, ListPartitionsResponse, PartitionsClient } from '@aneoconsultingfr/armonik.api.angular';
import { Observable } from 'rxjs';
import { Injectable, inject } from '@angular/core'
import type { ListPartitionsResponse } from '@aneoconsultingfr/armonik.api.angular'
import { ListPartitionsRequest, PartitionsClient } from '@aneoconsultingfr/armonik.api.angular'
import type { Observable } from 'rxjs'

@Injectable()
export class PartitionsGrpcService {
readonly #client = inject(PartitionsClient);
readonly #client = inject(PartitionsClient)

list$(): Observable<ListPartitionsResponse> {
const options = new ListPartitionsRequest({
page: 0,
pageSize: 10,
sort: {
direction: ListPartitionsRequest.OrderDirection.ORDER_DIRECTION_ASC,
field: ListPartitionsRequest.OrderByField.ORDER_BY_FIELD_ID
field: ListPartitionsRequest.OrderByField.ORDER_BY_FIELD_ID,
},
filter: {
id: '',
Expand All @@ -21,9 +22,9 @@ export class PartitionsGrpcService {
podReserved: 0,
preemptionPercentage: 0,
priority: 0,
}
});
},
})

return this.#client.listPartitions(options);
return this.#client.listPartitions(options)
}
}
8 changes: 4 additions & 4 deletions examples/angular/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
import { bootstrapApplication } from '@angular/platform-browser'
import { appConfig } from './app/app.config'
import { AppComponent } from './app/app.component'

bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));
.catch(err => console.error(err))
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
"ci:publish": "zx scripts/publish.mjs",
"ci:publish-edge": "zx scripts/publish-edge.mjs",
"update-versions": "jiti ./scripts/update-versions.ts",
"verify-versions": "jiti ./scripts/verify-versions.ts"
"verify-versions": "jiti ./scripts/verify-versions.ts",
"lint": "eslint .",
"lint:fix": "eslint --fix ."
},
"devDependencies": {
"@antfu/eslint-config": "^0.41.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"consola": "^2.15.3",
"eslint": "^8.47.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "armonik.api.angular",
"private": true,
"packageManager": "[email protected]",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -8,8 +10,6 @@
"test": "ng test",
"proto:generate:linux": "protoc --plugin=protoc-gen-ng=$(which protoc-gen-ng) --ng_out=./projects/aneoconsultingfr/armonik.api.angular/src/lib/generated -I ../../Protos/V1 ../../Protos/V1/*.proto"
},
"packageManager": "[email protected]",
"private": true,
"dependencies": {
"@angular/animations": "^16.2.1",
"@angular/common": "^16.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"lib": {
"entryFile": "src/public-api.ts"
}
}
}
Loading

0 comments on commit fb4c0c3

Please sign in to comment.