Skip to content

Commit

Permalink
chore: migrate to eslint v9 flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
k-genov committed Feb 3, 2025
1 parent 83a9647 commit baccbd4
Show file tree
Hide file tree
Showing 32 changed files with 835 additions and 1,353 deletions.
110 changes: 0 additions & 110 deletions .eslintrc.json

This file was deleted.

35 changes: 20 additions & 15 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ jobs:
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci
lint:
name: 'Linting'
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Restoring NPM modules from cache'
uses: actions/cache@v4
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- run: npm run lint
build-solace-message-client:
name: 'Building solace-message-client'
needs: install
Expand Down Expand Up @@ -68,6 +53,26 @@ jobs:
with:
name: solace-message-client-api
path: dist/solace-message-client-api
lint:
name: 'Linting'
needs: build-solace-message-client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Restoring NPM modules from cache'
uses: actions/cache@v4
with:
path: ./node_modules
key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Downloading solace-message-client'
uses: actions/download-artifact@v4
with:
name: solace-message-client
path: dist/@solace-community/angular-solace-message-client
- run: npm run lint
build-tryme-app:
name: 'Building TryMe App'
needs: build-solace-message-client
Expand Down
6 changes: 4 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"lintFilePatterns": [
"projects/solace-message-client/**/*.ts",
"projects/solace-message-client/**/*.html"
]
],
"eslintConfig": "projects/solace-message-client/eslint.config.js"
}
}
}
Expand Down Expand Up @@ -133,7 +134,8 @@
"lintFilePatterns": [
"apps/solace-message-client-testing-app/**/*.ts",
"apps/solace-message-client-testing-app/**/*.html"
]
],
"eslintConfig": "apps/solace-message-client-testing-app/eslint.config.js"
}
}
}
Expand Down
44 changes: 0 additions & 44 deletions apps/solace-message-client-testing-app/.eslintrc.json

This file was deleted.

32 changes: 32 additions & 0 deletions apps/solace-message-client-testing-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @ts-check
const tseslint = require("typescript-eslint");
const rootConfig = require("../../eslint.config.js");

module.exports = tseslint.config(
...rootConfig,
{
files: ["**/*.ts"],
rules: {
"@angular-eslint/directive-selector": [
"error",
{
type: "attribute",
prefix: ["app"],
style: "camelCase",
},
],
"@angular-eslint/component-selector": [
"error",
{
type: "element",
prefix: ["app"],
style: "kebab-case",
},
],
},
},
{
files: ["**/*.html"],
rules: {},
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {asyncScheduler} from 'rxjs';
/**
* Use this directive to set the focus to the host element.
*/
@Directive({
selector: '[appAutoFocus]'
})
@Directive({selector: '[appAutoFocus]'})
export class AutofocusDirective {

constructor(private _host: ElementRef<HTMLElement>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export class LocationService {
if (options.clearConnectProperties) {
SessionConfigStore.clear();
}
this._router.navigate(['/']).then(() => location.reload());
void this._router.navigate(['/']).then(() => location.reload());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ export class LoginComponent implements OnDestroy {
public onLogin(): void {
const oAuthEnabled = this.form.get(AUTHENTICATION_SCHEME)!.value === AuthenticationScheme.OAUTH2;
const sessionConfig: SolaceMessageClientConfig = {
url: this.form.get(URL)!.value ?? undefined,
vpnName: this.form.get(VPN_NAME)!.value ?? undefined,
userName: this.form.get(USER_NAME)!.value ?? undefined,
password: this.form.get(PASSWORD)!.value ?? undefined,
reapplySubscriptions: this.form.get(REAPPLY_SUBSCRIPTIONS)!.value ?? undefined,
reconnectRetries: this.form.get(RECONNECT_RETRIES)!.value ?? undefined,
connectRetries: this.form.get(RECONNECT_RETRIES)!.value ?? undefined,
authenticationScheme: this.form.get(AUTHENTICATION_SCHEME)!.value ?? undefined,
url: this.form.get(URL)!.value as string | string[],
vpnName: this.form.get(VPN_NAME)!.value as string,
userName: this.form.get(USER_NAME)!.value as string,
password: this.form.get(PASSWORD)!.value as string,
reapplySubscriptions: this.form.get(REAPPLY_SUBSCRIPTIONS)!.value as boolean,
reconnectRetries: this.form.get(RECONNECT_RETRIES)!.value as number,
connectRetries: this.form.get(RECONNECT_RETRIES)!.value as number,
authenticationScheme: this.form.get(AUTHENTICATION_SCHEME)!.value as AuthenticationScheme,
accessToken: oAuthEnabled ? promptForAccessToken : undefined,
};

Expand Down Expand Up @@ -108,4 +108,3 @@ export class LoginComponent implements OnDestroy {
this._destroy$.next();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,17 @@ function formatMessageType(messageType: MessageType): string {
return `MAP (${messageType})`;
case MessageType.STREAM:
return `STREAM (${messageType})`;
default:
return `UNKNOWN (${messageType})`;
}
}

function getContent(envelope: MessageEnvelope): string | undefined {
const encoding = envelope.headers.get('Content-Encoding');
const encoding = envelope.headers.get('Content-Encoding') as string;

switch (envelope.message.getType()) {
case MessageType.BINARY:
return decode(envelope.message.getBinaryAttachment(), encoding);
case MessageType.TEXT:
return decode(envelope.message.getSdtContainer()!.getValue(), encoding);
return decode(envelope.message.getSdtContainer()!.getValue() as string, encoding);
default:
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class PublisherComponent implements OnDestroy {
takeUntil(this._destroy$),
)
.subscribe({
error: error => this.publishError = error,
error: (error: unknown) => this.publishError = `${error}`, // eslint-disable-line @typescript-eslint/restrict-template-expressions
});
}

Expand All @@ -107,8 +107,8 @@ export class PublisherComponent implements OnDestroy {

private publish$(): Observable<any> {
try {
const destination = this.form.get(DESTINATION)!.value;
const destinationType: DestinationType = this.form.get(DESTINATION_TYPE)!.value;
const destination = this.form.get(DESTINATION)!.value as string;
const destinationType = this.form.get(DESTINATION_TYPE)!.value as DestinationType;
const message: Data | undefined = this.readMessageFromUI();
const publishOptions: PublishOptions = this.readPublishOptionsFromUI();

Expand Down Expand Up @@ -148,7 +148,7 @@ export class PublisherComponent implements OnDestroy {
}

public get requestReply(): boolean {
return this.form.get(REQUEST_REPLY)!.value;
return this.form.get(REQUEST_REPLY)!.value as boolean;
}

public get publishing(): boolean {
Expand All @@ -158,12 +158,12 @@ export class PublisherComponent implements OnDestroy {
private readPublishOptionsFromUI(): PublishOptions {
return {
headers: this.readHeadersFromUI(),
deliveryMode: this.form.get(DELIVERY_MODE)!.value,
deliveryMode: this.form.get(DELIVERY_MODE)!.value as MessageDeliveryModeType,
};
}

private readMessageFromUI(): Data | undefined {
const message = this.form.get(MESSAGE)!.value;
const message = this.form.get(MESSAGE)!.value as string | undefined;
if (!message) {
return undefined;
}
Expand All @@ -176,13 +176,13 @@ export class PublisherComponent implements OnDestroy {
}
}

private readHeadersFromUI(): Map<string, any> | undefined {
const headers: string = this.form.get(HEADERS)!.value;
private readHeadersFromUI(): Map<string, string | boolean | number> | undefined {
const headers = this.form.get(HEADERS)!.value as string;
if (!headers.length) {
return undefined;
}

const headerMap = new Map();
const headerMap = new Map<string, string | boolean | number>();
headers.split(';').forEach(keyValue => {
const [key, value] = keyValue.split('->');
if (value === 'true' || value === 'false') {
Expand Down
Loading

0 comments on commit baccbd4

Please sign in to comment.