Skip to content

Commit 65079fb

Browse files
authored
chore: eslint flat config (#2742)
* feat(eslint-config)!: flat config * feat(eslint-plugin)!: flat config * chore: eslint 9 flat config * docs: changeset * fix(tools): update typescript types * chore: tweak eslint config * fix(eslint-config): config * chore: decruft scripts * style: lint allll the files * test(card): fix assertions assertion labels go in the expect call, not in the getComputedStyle call * test(chip): fix suite setup for keyboard nav tab to chip group instead of calling focus on it this may indicate breakage in delegatesFocus * fix(eslint-config): html plugin * style: lint html
1 parent afac682 commit 65079fb

File tree

155 files changed

+7271
-4720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+7271
-4720
lines changed

.changeset/chilly-plums-shake.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@patternfly/eslint-config-elements": major
3+
"@patternfly/eslint-plugin-elements": major
4+
---
5+
6+
Provide ESLint flat config. Upgrade to ESLint 9.0 to use.

.changeset/rude-kiwis-live.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
"@patternfly/pfe-tools": patch
3+
---
4+
Update typescript types

.commitlintrc.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const fs = require("fs");
2-
const path = require("path");
1+
const fs = require('fs');
2+
const path = require('path');
33
const normalizeWorkspace = x =>
44
fs.readdirSync(path.join(__dirname, x)).map(x => x.replace('pf-', ''));
55

@@ -23,5 +23,5 @@ module.exports = {
2323
...normalizeWorkspace('core'),
2424
...normalizeWorkspace('tools'),
2525
]],
26-
}
26+
},
2727
};

.eslintignore

Lines changed: 0 additions & 45 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ tools/*/test/**/*.png
7070
!scripts/**/*.js
7171

7272
!tools/eslint-plugin/index.js
73+
!tools/eslint-config/**/*.js
7374

7475
*.tgz
7576
custom-elements.json

core/pfe-core/controllers/cascade-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class CascadeController<E extends ReactiveElement> implements ReactiveCon
2020

2121
private logger: Logger;
2222

23-
static instances: WeakMap<ReactiveElement, CascadeController<ReactiveElement>> = new WeakMap();
23+
static instances = new WeakMap<ReactiveElement, CascadeController<ReactiveElement>>();
2424

2525
mo = new MutationObserver(this.parse);
2626

core/pfe-core/controllers/css-variable-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export class CssVariableController implements ReactiveController {
1515
return this.style.getPropertyValue(this.parseProperty(name)).trim() || null;
1616
}
1717

18-
hostConnected?(): void
18+
hostConnected?(): void;
1919
}

core/pfe-core/controllers/floating-dom-controller.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
offset as offsetMiddleware,
1212
shift as shiftMiddleware,
1313
flip as flipMiddleware,
14-
arrow as arrowMiddleware
14+
arrow as arrowMiddleware,
1515
} from '@floating-ui/dom';
1616

1717
type Lazy<T> = T | (() => T | null | undefined);
@@ -110,7 +110,12 @@ export class FloatingDOMController implements ReactiveController {
110110
this.#cleanup?.();
111111
}
112112

113-
async #update(placement: Placement = 'top', offset?: Offset, flip = true, fallbackPlacements?: Placement[]) {
113+
async #update(
114+
placement: Placement = 'top',
115+
offset?: Offset,
116+
flip = true,
117+
fallbackPlacements?: Placement[],
118+
) {
114119
const { padding, shift } = this.#options;
115120

116121
const invoker = this.#invoker;
@@ -119,15 +124,20 @@ export class FloatingDOMController implements ReactiveController {
119124
if (!invoker || !content) {
120125
return;
121126
}
122-
const { x, y, placement: _placement, middlewareData } = await computePosition(invoker, content, {
127+
const {
128+
x,
129+
y,
130+
placement: _placement,
131+
middlewareData,
132+
} = await computePosition(invoker, content, {
123133
strategy: 'absolute',
124134
placement,
125135
middleware: [
126136
offsetMiddleware(offset),
127137
shift && shiftMiddleware({ padding }),
128138
arrow && arrowMiddleware({ element: arrow, padding: arrow.offsetHeight / 2 }),
129139
flip && flipMiddleware({ padding, fallbackPlacements }),
130-
].filter(Boolean)
140+
].filter(Boolean),
131141
});
132142

133143
if (arrow) {

core/pfe-core/controllers/internals-controller.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ function isARIAMixinProp(key: string): key is keyof ARIAMixin {
44
return key === 'role' || key.startsWith('aria');
55
}
66

7+
type FACE = HTMLElement & {
8+
formDisabledCallback?(disabled: boolean): void;
9+
};
10+
711
const protos = new WeakMap();
812

913
let constructingAllowed = false;
@@ -38,7 +42,7 @@ function aria(
3842
// @ts-expect-error: shamone!
3943
this.attach()[key] = value;
4044
this.host.requestUpdate();
41-
}
45+
},
4246
});
4347
protos.get(target).add(key);
4448
}
@@ -63,14 +67,17 @@ export class InternalsController implements ReactiveController, ARIAMixin {
6367
declare readonly willValidate: ElementInternals['willValidate'];
6468
declare readonly validationMessage: ElementInternals['validationMessage'];
6569

66-
public static of(host: ReactiveControllerHost, options?: InternalsControllerOptions): InternalsController {
70+
public static of(
71+
host: ReactiveControllerHost,
72+
options?: InternalsControllerOptions,
73+
): InternalsController {
6774
constructingAllowed = true;
6875
// implement the singleton pattern
6976
// using a public static constructor method is much easier to manage,
7077
// due to the quirks of our typescript config
7178
const instance: InternalsController =
72-
InternalsController.instances.get(host) ??
73-
new InternalsController(host, options);
79+
InternalsController.instances.get(host)
80+
?? new InternalsController(host, options);
7481
instance.initializeOptions(options);
7582
constructingAllowed = false;
7683
return instance;
@@ -152,10 +159,10 @@ export class InternalsController implements ReactiveController, ARIAMixin {
152159

153160
/** A best-attempt based on observed behaviour in FireFox 115 on fedora 38 */
154161
get computedLabelText() {
155-
return this.internals.ariaLabel ||
156-
Array.from(this.internals.labels as NodeListOf<HTMLElement>)
157-
.reduce((acc, label) =>
158-
`${acc}${getLabelText(label)}`, '');
162+
return this.internals.ariaLabel
163+
|| Array.from(this.internals.labels as NodeListOf<HTMLElement>)
164+
.reduce((acc, label) =>
165+
`${acc}${getLabelText(label)}`, '');
159166
}
160167

161168
private get element() {
@@ -174,7 +181,9 @@ export class InternalsController implements ReactiveController, ARIAMixin {
174181
throw new Error('InternalsController must be constructed with `InternalsController.for()`');
175182
}
176183
if (!this.element) {
177-
throw new Error('InternalsController must be instantiated with an HTMLElement or a `getHTMLElement` function');
184+
throw new Error(
185+
`InternalsController must be instantiated with an HTMLElement or a \`getHTMLElement\` function`,
186+
);
178187
}
179188
this.attach();
180189
this.initializeOptions(options);
@@ -190,8 +199,8 @@ export class InternalsController implements ReactiveController, ARIAMixin {
190199
// START polyfill-disabled
191200
// We need to polyfill :disabled
192201
// see https://github.com/calebdwilliams/element-internals-polyfill/issues/88
193-
const orig = (this.element as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback;
194-
(this.element as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback = disabled => {
202+
const orig = (this.element as FACE).formDisabledCallback;
203+
(this.element as FACE).formDisabledCallback = disabled => {
195204
this._formDisabled = disabled;
196205
orig?.call(this.host, disabled);
197206
// END polyfill-disabled
@@ -223,7 +232,7 @@ export class InternalsController implements ReactiveController, ARIAMixin {
223232
}
224233
}
225234

226-
hostConnected?(): void
235+
hostConnected?(): void;
227236

228237
setFormValue(...args: Parameters<ElementInternals['setFormValue']>) {
229238
return this.internals.setFormValue(...args);

0 commit comments

Comments
 (0)