@teamnovu/kit-shopware-api-client 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { EventEmitter } from './eventEmitter';
1
2
  import { OperationOptions, OperationProp, ShopwareClientOptions } from './types';
2
3
  export declare class ShopwareApiError extends Error {
3
4
  readonly status: number;
@@ -7,13 +8,15 @@ export declare class ShopwareApiError extends Error {
7
8
  export declare class ShopwareClient<Operations extends Record<string, {
8
9
  body?: unknown;
9
10
  response?: unknown;
10
- }>> {
11
+ }>> extends EventEmitter {
11
12
  private options;
12
13
  constructor(options: ShopwareClientOptions);
13
14
  setBaseURL(baseURL: string): void;
14
15
  setApiKey(apiKey: string): void;
15
16
  setLanguage(language: string | undefined): void;
17
+ setContextToken(contextToken: string | undefined): void;
16
18
  setIncludeSeoUrls(includeSeoUrls?: boolean): void;
19
+ setReflectContextToken(reflectContextToken?: boolean): void;
17
20
  private parseOperation;
18
21
  private interpolateUrl;
19
22
  query<OperationKey extends (keyof Operations) & string>(operation: OperationKey, options?: OperationOptions<Operations, OperationKey>): Promise<OperationProp<Operations, OperationKey, 'response'>>;
@@ -0,0 +1,14 @@
1
+ export declare class EventEmitter implements EventTarget {
2
+ private listeners;
3
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
4
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
5
+ dispatchEvent(event: Event): boolean;
6
+ private normalizeOptions;
7
+ private optionsMatch;
8
+ on(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
9
+ off(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
10
+ once(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
11
+ emit(type: string, detail?: unknown): boolean;
12
+ getEventTypes(): string[];
13
+ removeAllListeners(type?: string): void;
14
+ }
package/dist/index.mjs CHANGED
@@ -1,21 +1,104 @@
1
- var h = Object.defineProperty;
2
- var l = (s, e, t) => e in s ? h(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var n = (s, e, t) => l(s, typeof e != "symbol" ? e + "" : e, t);
4
- class o extends Error {
5
- constructor(e, t, r) {
6
- super(e), this.status = t, this.response = r, this.name = "ShopwareApiError";
1
+ var u = Object.defineProperty;
2
+ var p = (o, t, e) => t in o ? u(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var c = (o, t, e) => p(o, typeof t != "symbol" ? t + "" : t, e);
4
+ class d {
5
+ constructor() {
6
+ c(this, "listeners", /* @__PURE__ */ new Map());
7
+ }
8
+ addEventListener(t, e, s) {
9
+ if (!e) return;
10
+ const n = this.normalizeOptions(s), r = {
11
+ listener: e,
12
+ options: n
13
+ };
14
+ if (n.signal) {
15
+ if (n.signal.aborted) return;
16
+ r.signal = n.signal, n.signal.addEventListener("abort", () => {
17
+ this.removeEventListener(t, e, s);
18
+ }, { once: !0 });
19
+ }
20
+ this.listeners.has(t) || this.listeners.set(t, []), this.listeners.get(t).push(r);
21
+ }
22
+ removeEventListener(t, e, s) {
23
+ if (!e) return;
24
+ const n = this.listeners.get(t);
25
+ if (!n) return;
26
+ const r = this.normalizeOptions(s), a = n.findIndex((i) => i.listener === e && this.optionsMatch(i.options, r));
27
+ a !== -1 && (n.splice(a, 1), n.length === 0 && this.listeners.delete(t));
28
+ }
29
+ dispatchEvent(t) {
30
+ var n;
31
+ const e = this.listeners.get(t.type);
32
+ if (!e || e.length === 0) return !0;
33
+ const s = [...e];
34
+ for (const r of s)
35
+ if (!((n = r.signal) != null && n.aborted)) {
36
+ try {
37
+ typeof r.listener == "function" ? r.listener.call(this, t) : r.listener.handleEvent(t);
38
+ } catch (a) {
39
+ console.error("Error in event listener:", a);
40
+ }
41
+ if (r.options.once && this.removeEventListener(t.type, r.listener, r.options), t.cancelBubble) break;
42
+ }
43
+ return !t.defaultPrevented;
44
+ }
45
+ normalizeOptions(t) {
46
+ return typeof t == "boolean" ? { capture: t } : {
47
+ capture: !1,
48
+ once: !1,
49
+ passive: !1,
50
+ ...t
51
+ };
52
+ }
53
+ optionsMatch(t, e) {
54
+ return t.capture === e.capture;
55
+ }
56
+ // Utility methods for easier usage
57
+ on(t, e, s) {
58
+ this.addEventListener(t, e, s);
59
+ }
60
+ off(t, e, s) {
61
+ this.removeEventListener(t, e, s);
62
+ }
63
+ once(t, e, s) {
64
+ const n = typeof s == "boolean" ? {
65
+ capture: s,
66
+ once: !0
67
+ } : {
68
+ ...s,
69
+ once: !0
70
+ };
71
+ this.addEventListener(t, e, n);
72
+ }
73
+ emit(t, e) {
74
+ const s = new CustomEvent(t, { detail: e });
75
+ return this.dispatchEvent(s);
76
+ }
77
+ getEventTypes() {
78
+ return Array.from(this.listeners.keys());
79
+ }
80
+ removeAllListeners(t) {
81
+ t ? this.listeners.delete(t) : this.listeners.clear();
7
82
  }
8
83
  }
9
- const c = /^(?<name>\w+?)\s(?<method>get|post|put|patch|delete)\s+(?<url>\/.*)/i;
10
- class g {
84
+ class h extends Error {
85
+ constructor(t, e, s) {
86
+ super(t), this.status = e, this.response = s, this.name = "ShopwareApiError";
87
+ }
88
+ }
89
+ const f = /^(?<name>\w+?)\s(?<method>get|post|put|patch|delete)\s+(?<url>\/.*)/i;
90
+ class v extends d {
11
91
  constructor(e) {
12
- n(this, "options", {
92
+ super();
93
+ c(this, "options", {
13
94
  baseURL: "",
14
95
  apiKey: "",
15
96
  language: "",
16
- includeSeoUrls: !1
97
+ contextToken: "",
98
+ includeSeoUrls: !1,
99
+ reflectContextToken: !0
17
100
  });
18
- this.setBaseURL(e.baseURL), this.setApiKey(e.apiKey), this.setLanguage(e.language), this.setIncludeSeoUrls(e.includeSeoUrls), this.options = e;
101
+ this.setBaseURL(e.baseURL ?? this.options.baseURL), this.setApiKey(e.apiKey ?? this.options.apiKey), this.setLanguage(e.language ?? this.options.language), this.setContextToken(e.contextToken ?? this.options.contextToken), this.setIncludeSeoUrls(e.includeSeoUrls ?? this.options.includeSeoUrls), this.setReflectContextToken(e.reflectContextToken ?? this.options.reflectContextToken);
19
102
  }
20
103
  setBaseURL(e) {
21
104
  if (typeof e != "string")
@@ -32,58 +115,71 @@ class g {
32
115
  throw new Error("Invalid language: If provided, it must be a string.");
33
116
  this.options.language = e;
34
117
  }
118
+ setContextToken(e) {
119
+ if (e && typeof e != "string")
120
+ throw new Error("Invalid contextToken: If provided, it must be a string.");
121
+ this.options.contextToken = e;
122
+ }
35
123
  setIncludeSeoUrls(e = !0) {
36
124
  this.options.includeSeoUrls = e;
37
125
  }
126
+ setReflectContextToken(e = !0) {
127
+ this.options.reflectContextToken = e;
128
+ }
38
129
  parseOperation(e) {
39
- const t = c.exec(e);
40
- if (!(t != null && t.groups))
130
+ const s = f.exec(e);
131
+ if (!(s != null && s.groups))
41
132
  throw new Error("Invalid operation format");
42
133
  return {
43
- name: t.groups.name,
44
- method: t.groups.method.toUpperCase(),
45
- url: t.groups.url
134
+ name: s.groups.name,
135
+ method: s.groups.method.toUpperCase(),
136
+ url: s.groups.url
46
137
  };
47
138
  }
48
- interpolateUrl(e, t) {
49
- return e.replace(/{([^}]+?)}/g, (r, a) => {
50
- if (!(a in t))
51
- throw new Error(`Missing required URL parameter: ${a}`);
52
- return t[a];
139
+ interpolateUrl(e, s) {
140
+ return e.replace(/{([^}]+?)}/g, (n, r) => {
141
+ if (!(r in s))
142
+ throw new Error(`Missing required URL parameter: ${r}`);
143
+ return s[r];
53
144
  });
54
145
  }
55
- async query(e, t) {
146
+ async query(e, s) {
56
147
  try {
57
- const { method: r, url: a } = this.parseOperation(e), u = this.interpolateUrl(a, (t == null ? void 0 : t.params) ?? {}), i = await fetch(`${this.options.baseURL}/store-api${u}`, {
58
- ...t,
59
- method: r,
148
+ const { method: n, url: r } = this.parseOperation(e), a = this.interpolateUrl(r, (s == null ? void 0 : s.params) ?? {}), i = await fetch(`${this.options.baseURL}/store-api${a}`, {
149
+ ...s,
150
+ method: n,
60
151
  headers: {
61
152
  "Content-Type": "application/json",
62
153
  "sw-access-key": this.options.apiKey,
154
+ ...this.options.contextToken && { "sw-context-token": this.options.contextToken },
63
155
  ...this.options.includeSeoUrls && { "sw-include-seo-urls": "true" },
64
156
  ...this.options.language && { "sw-language-id": this.options.language },
65
- ...t == null ? void 0 : t.headers
157
+ ...s == null ? void 0 : s.headers
66
158
  },
67
- body: t != null && t.body ? JSON.stringify(t.body) : void 0
159
+ body: s != null && s.body ? JSON.stringify(s.body) : void 0
68
160
  });
69
161
  if (!i.ok)
70
- throw new o(
162
+ throw new h(
71
163
  `Shopware API request failed: ${i.statusText}`,
72
164
  i.status,
73
165
  await i.json().catch(() => {
74
166
  })
75
167
  );
168
+ if (this.options.reflectContextToken) {
169
+ const l = i.headers.get("sw-context-token");
170
+ l && (this.setContextToken(l), this.emit("contextToken", l));
171
+ }
76
172
  return await i.json();
77
- } catch (r) {
78
- throw r instanceof o ? r : new o(
173
+ } catch (n) {
174
+ throw n instanceof h ? n : new h(
79
175
  "Failed to communicate with Shopware API",
80
176
  500,
81
- r instanceof Error ? r.message : void 0
177
+ n instanceof Error ? n.message : void 0
82
178
  );
83
179
  }
84
180
  }
85
181
  }
86
182
  export {
87
- o as ShopwareApiError,
88
- g as ShopwareClient
183
+ h as ShopwareApiError,
184
+ v as ShopwareClient
89
185
  };
package/dist/types.d.ts CHANGED
@@ -22,5 +22,17 @@ export interface ShopwareClientOptions {
22
22
  apiKey: string;
23
23
  includeSeoUrls?: boolean;
24
24
  language?: string;
25
+ /**
26
+ * If true, the context token will be reflected in the response headers.
27
+ * @default true
28
+ */
29
+ reflectContextToken?: boolean;
30
+ /**
31
+ * If provided, it will be used as the context token.
32
+ * If reflectContextToken is true, this token will be used only until the first response
33
+ * sends a new context token.
34
+ * @default undefined
35
+ */
36
+ contextToken?: string;
25
37
  }
26
38
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-shopware-api-client",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A client for the Shopware API",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -21,7 +21,6 @@
21
21
  "keywords": [],
22
22
  "author": "Elias Bernhaut",
23
23
  "homepage": "https://kit.novu.ch/packages/shopware-api-client/",
24
- "dependencies": {},
25
24
  "scripts": {
26
25
  "build": "vite build",
27
26
  "watch": "NODE_ENV=development vite build --watch",
package/src/client.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { EventEmitter } from './eventEmitter'
1
2
  import type {
2
3
  OperationOptions,
3
4
  OperationProp,
@@ -20,20 +21,25 @@ const operationRegex = /^(?<name>\w+?)\s(?<method>get|post|put|patch|delete)\s+(
20
21
  export class ShopwareClient<Operations extends Record<string, {
21
22
  body?: unknown
22
23
  response?: unknown
23
- }>> {
24
+ }>> extends EventEmitter {
24
25
  private options: ShopwareClientOptions = {
25
26
  baseURL: '',
26
27
  apiKey: '',
27
28
  language: '',
29
+ contextToken: '',
28
30
  includeSeoUrls: false,
31
+ reflectContextToken: true,
29
32
  }
30
33
 
31
34
  constructor(options: ShopwareClientOptions) {
32
- this.setBaseURL(options.baseURL)
33
- this.setApiKey(options.apiKey)
34
- this.setLanguage(options.language)
35
- this.setIncludeSeoUrls(options.includeSeoUrls)
36
- this.options = options
35
+ super()
36
+
37
+ this.setBaseURL(options.baseURL ?? this.options.baseURL)
38
+ this.setApiKey(options.apiKey ?? this.options.apiKey)
39
+ this.setLanguage(options.language ?? this.options.language)
40
+ this.setContextToken(options.contextToken ?? this.options.contextToken)
41
+ this.setIncludeSeoUrls(options.includeSeoUrls ?? this.options.includeSeoUrls)
42
+ this.setReflectContextToken(options.reflectContextToken ?? this.options.reflectContextToken)
37
43
  }
38
44
 
39
45
  public setBaseURL(baseURL: string) {
@@ -60,10 +66,22 @@ export class ShopwareClient<Operations extends Record<string, {
60
66
  this.options.language = language
61
67
  }
62
68
 
69
+ public setContextToken(contextToken: string | undefined) {
70
+ if (contextToken && typeof contextToken !== 'string') {
71
+ throw new Error('Invalid contextToken: If provided, it must be a string.')
72
+ }
73
+
74
+ this.options.contextToken = contextToken
75
+ }
76
+
63
77
  public setIncludeSeoUrls(includeSeoUrls: boolean = true) {
64
78
  this.options.includeSeoUrls = includeSeoUrls
65
79
  }
66
80
 
81
+ public setReflectContextToken(reflectContextToken: boolean = true) {
82
+ this.options.reflectContextToken = reflectContextToken
83
+ }
84
+
67
85
  private parseOperation(operation: keyof Operations & string): {
68
86
  name: string
69
87
  method: string
@@ -104,6 +122,7 @@ export class ShopwareClient<Operations extends Record<string, {
104
122
  headers: {
105
123
  'Content-Type': 'application/json',
106
124
  'sw-access-key': this.options.apiKey,
125
+ ...(this.options.contextToken && { 'sw-context-token': this.options.contextToken }),
107
126
  ...(this.options.includeSeoUrls && { 'sw-include-seo-urls': 'true' }),
108
127
  ...(this.options.language && { 'sw-language-id': this.options.language }),
109
128
  ...options?.headers,
@@ -119,6 +138,14 @@ export class ShopwareClient<Operations extends Record<string, {
119
138
  )
120
139
  }
121
140
 
141
+ if (this.options.reflectContextToken) {
142
+ const contextToken = response.headers.get('sw-context-token')
143
+ if (contextToken) {
144
+ this.setContextToken(contextToken)
145
+ this.emit('contextToken', contextToken)
146
+ }
147
+ }
148
+
122
149
  const data = await response.json()
123
150
  return data
124
151
  } catch (error) {
@@ -0,0 +1,162 @@
1
+ interface EventListenerEntry {
2
+ listener: EventListenerOrEventListenerObject
3
+ options: AddEventListenerOptions
4
+ signal?: AbortSignal
5
+ }
6
+
7
+ export class EventEmitter implements EventTarget {
8
+ private listeners = new Map<string, EventListenerEntry[]>()
9
+
10
+ addEventListener(
11
+ type: string,
12
+ listener: EventListenerOrEventListenerObject | null,
13
+ options?: boolean | AddEventListenerOptions,
14
+ ): void {
15
+ if (!listener) return
16
+
17
+ const listenerOptions = this.normalizeOptions(options)
18
+ const entry: EventListenerEntry = {
19
+ listener,
20
+ options: listenerOptions,
21
+ }
22
+
23
+ if (listenerOptions.signal) {
24
+ if (listenerOptions.signal.aborted) return
25
+
26
+ entry.signal = listenerOptions.signal
27
+ listenerOptions.signal.addEventListener('abort', () => {
28
+ this.removeEventListener(type, listener, options)
29
+ }, { once: true })
30
+ }
31
+
32
+ if (!this.listeners.has(type)) {
33
+ this.listeners.set(type, [])
34
+ }
35
+
36
+ this.listeners.get(type)!.push(entry)
37
+ }
38
+
39
+ removeEventListener(
40
+ type: string,
41
+ listener: EventListenerOrEventListenerObject | null,
42
+ options?: boolean | EventListenerOptions,
43
+ ): void {
44
+ if (!listener) return
45
+
46
+ const entries = this.listeners.get(type)
47
+ if (!entries) return
48
+
49
+ const listenerOptions = this.normalizeOptions(options)
50
+ const index = entries.findIndex(entry =>
51
+ entry.listener === listener
52
+ && this.optionsMatch(entry.options, listenerOptions))
53
+
54
+ if (index !== -1) {
55
+ entries.splice(index, 1)
56
+ if (entries.length === 0) {
57
+ this.listeners.delete(type)
58
+ }
59
+ }
60
+ }
61
+
62
+ dispatchEvent(event: Event): boolean {
63
+ const entries = this.listeners.get(event.type)
64
+ if (!entries || entries.length === 0) return true
65
+
66
+ const entriesCopy = [...entries]
67
+
68
+ for (const entry of entriesCopy) {
69
+ if (entry.signal?.aborted) continue
70
+
71
+ try {
72
+ if (typeof entry.listener === 'function') {
73
+ entry.listener.call(this, event)
74
+ } else {
75
+ entry.listener.handleEvent(event)
76
+ }
77
+ } catch (error) {
78
+ // In a real implementation, you might want to handle errors differently
79
+ console.error('Error in event listener:', error)
80
+ }
81
+
82
+ // Remove if 'once' option was set
83
+ if (entry.options.once) {
84
+ this.removeEventListener(event.type, entry.listener, entry.options)
85
+ }
86
+
87
+ // Stop if event propagation was stopped
88
+ if (event.cancelBubble) break
89
+ }
90
+
91
+ return !event.defaultPrevented
92
+ }
93
+
94
+ private normalizeOptions(
95
+ options?: boolean | AddEventListenerOptions | EventListenerOptions,
96
+ ): AddEventListenerOptions {
97
+ if (typeof options === 'boolean') {
98
+ return { capture: options }
99
+ }
100
+ return {
101
+ capture: false,
102
+ once: false,
103
+ passive: false,
104
+ ...options,
105
+ }
106
+ }
107
+
108
+ private optionsMatch(a: AddEventListenerOptions, b: AddEventListenerOptions): boolean {
109
+ return a.capture === b.capture
110
+ }
111
+
112
+ // Utility methods for easier usage
113
+ on(
114
+ type: string,
115
+ listener: EventListenerOrEventListenerObject,
116
+ options?: boolean | AddEventListenerOptions,
117
+ ): void {
118
+ this.addEventListener(type, listener, options)
119
+ }
120
+
121
+ off(
122
+ type: string,
123
+ listener: EventListenerOrEventListenerObject,
124
+ options?: boolean | EventListenerOptions,
125
+ ): void {
126
+ this.removeEventListener(type, listener, options)
127
+ }
128
+
129
+ once(
130
+ type: string,
131
+ listener: EventListenerOrEventListenerObject,
132
+ options?: boolean | AddEventListenerOptions,
133
+ ): void {
134
+ const onceOptions = typeof options === 'boolean'
135
+ ? {
136
+ capture: options,
137
+ once: true,
138
+ }
139
+ : {
140
+ ...options,
141
+ once: true,
142
+ }
143
+ this.addEventListener(type, listener, onceOptions)
144
+ }
145
+
146
+ emit(type: string, detail?: unknown): boolean {
147
+ const event = new CustomEvent(type, { detail })
148
+ return this.dispatchEvent(event)
149
+ }
150
+
151
+ getEventTypes(): string[] {
152
+ return Array.from(this.listeners.keys())
153
+ }
154
+
155
+ removeAllListeners(type?: string): void {
156
+ if (type) {
157
+ this.listeners.delete(type)
158
+ } else {
159
+ this.listeners.clear()
160
+ }
161
+ }
162
+ }
package/src/types.ts CHANGED
@@ -15,7 +15,9 @@ export type OperationProp<
15
15
  Operations,
16
16
  OperationKey extends keyof Operations,
17
17
  Prop extends string,
18
- > = Operation<Operations, OperationKey> extends { [K in Prop]?: unknown } ? Operation<Operations, OperationKey>[Prop] : never
18
+ > = Operation<Operations, OperationKey> extends { [K in Prop]?: unknown }
19
+ ? Operation<Operations, OperationKey>[Prop]
20
+ : never
19
21
 
20
22
  export type InferParameters<T extends string> = UrlParamsRecord<ExtractUrlFromOperation<T>>
21
23
 
@@ -37,4 +39,18 @@ export interface ShopwareClientOptions {
37
39
  apiKey: string
38
40
  includeSeoUrls?: boolean
39
41
  language?: string
42
+
43
+ /**
44
+ * If true, the context token will be reflected in the response headers.
45
+ * @default true
46
+ */
47
+ reflectContextToken?: boolean
48
+
49
+ /**
50
+ * If provided, it will be used as the context token.
51
+ * If reflectContextToken is true, this token will be used only until the first response
52
+ * sends a new context token.
53
+ * @default undefined
54
+ */
55
+ contextToken?: string
40
56
  }
package/eslint.config.mjs DELETED
@@ -1,84 +0,0 @@
1
- import js from '@eslint/js'
2
- import pluginStylistic from '@stylistic/eslint-plugin'
3
- import tseslint from 'typescript-eslint'
4
-
5
- export default tseslint.config(
6
- js.configs.recommended,
7
- tseslint.configs.recommended,
8
- pluginStylistic.configs['recommended'],
9
- {
10
- rules: {
11
- // stylistic
12
- // ********************
13
- '@stylistic/newline-per-chained-call': [
14
- 'error',
15
- { ignoreChainWithDepth: 2 },
16
- ],
17
- '@stylistic/nonblock-statement-body-position': 'error',
18
- '@stylistic/one-var-declaration-per-line': 'error',
19
- '@stylistic/operator-linebreak': [
20
- 'error',
21
- 'before',
22
- { overrides: { '=': 'none' } },
23
- ],
24
- '@stylistic/function-paren-newline': ['error', 'multiline-arguments'],
25
- '@stylistic/dot-location': ['error', 'property'],
26
- '@stylistic/no-mixed-operators': ['error', { allowSamePrecedence: true }],
27
- '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
28
- '@stylistic/array-bracket-newline': ['error', { multiline: true }],
29
- '@stylistic/array-element-newline': [
30
- 'error',
31
- {
32
- multiline: true,
33
- consistent: true,
34
- },
35
- ],
36
- '@stylistic/max-len': [
37
- 'warn',
38
- {
39
- code: 150,
40
- tabWidth: 2,
41
- },
42
- ],
43
- '@stylistic/object-curly-newline': [
44
- 'error',
45
- {
46
- multiline: true,
47
- consistent: true,
48
- },
49
- ],
50
- '@stylistic/object-property-newline': [
51
- 'error',
52
- { allowAllPropertiesOnSameLine: false },
53
- ],
54
-
55
- // common
56
- // ********************
57
- 'no-console': ['error', { allow: ['warn', 'error'] }],
58
- 'prefer-destructuring': [
59
- 'error',
60
- {
61
- array: false,
62
- object: true,
63
- },
64
- ],
65
- 'no-unused-vars': 'off',
66
- 'eqeqeq': ['error', 'smart'],
67
- 'no-undef': 'off', // done by typescript
68
- '@typescript-eslint/consistent-type-imports': 'error',
69
- '@typescript-eslint/no-explicit-any': 'warn',
70
- '@typescript-eslint/no-unused-vars': [
71
- 'error',
72
- {
73
- args: 'all',
74
- argsIgnorePattern: '^_',
75
- caughtErrors: 'all',
76
- caughtErrorsIgnorePattern: '^_',
77
- destructuredArrayIgnorePattern: '^_',
78
- varsIgnorePattern: '^_',
79
- ignoreRestSiblings: true,
80
- },
81
- ],
82
- },
83
- },
84
- )