Fix lint violations (vol.2) (#6300)

* Fix lint violations

* Refactor code for clarity and consistency

- Updated various components to improve readability and maintainability, including:
  - Changed `while (1)` to `while (true)` for better clarity.
  - Simplified conditional checks by removing unnecessary boolean casts.
  - Added missing `key` props in mapped elements to ensure proper rendering in lists.
  - Adjusted the handling of hidden states in budget components for clearer logic.
  - Cleaned up linting rules in `.oxlintrc.json` to streamline configuration.

* Fix unused variable warning in electronApp fixture

* Fix linting comment in fixtures.ts
This commit is contained in:
Matiss Janis Aboltins
2025-12-08 16:39:27 +00:00
committed by GitHub
parent 9a9de5ee09
commit 1117451b69
16 changed files with 49 additions and 37 deletions

View File

@@ -10,12 +10,7 @@
"jsx-a11y/prefer-tag-over-role": "off",
"jsx-a11y/role-has-required-aria-props": "off",
"jsx-a11y/tabindex-no-positive": "off",
"no-async-promise-executor": "off",
"no-autofocus": "off",
"no-constant-condition": "off",
"no-empty-pattern": "off",
"no-extra-boolean-cast": "off",
"react/jsx-key": "off",
},
"overrides": [
{

View File

@@ -88,7 +88,7 @@ export function diff(trie1: TrieNode, trie2: TrieNode): number | null {
// where the hashes differ, or otherwise when there are no leaves
// left (this shouldn't happen, if that's the case the hash check at
// the top of this function should pass)
while (1) {
while (true) {
const keyset = new Set([...getKeys(node1), ...getKeys(node2)]);
const keys = [...keyset.values()];
keys.sort();

View File

@@ -185,7 +185,7 @@ export function CommandBar() {
items: navigationItems,
onSelect: ({ id }) => {
const item = navigationItems.find(item => item.id === id);
if (!!item) handleNavigate(item.path);
if (item) handleNavigate(item.path);
},
},
{

View File

@@ -157,6 +157,7 @@ function defaultRenderItems<T extends AutocompleteItem>(
const name = getItemName(item);
return (
<div
key={name}
{...getItemProps({ item })}
// Downshift calls `setTimeout(..., 250)` in the `onMouseMove`
// event handler they set on this element. When this code runs
@@ -180,7 +181,6 @@ function defaultRenderItems<T extends AutocompleteItem>(
// * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebCore/page/ios/ContentChangeObserver.cpp
// * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L783
role="button"
key={name}
className={css({
padding: 5,
cursor: 'default',

View File

@@ -31,8 +31,8 @@ export function FilterList<T extends { id: string; name: string }>({
{items.map((item, idx) => {
return [
<div
{...(getItemProps ? getItemProps({ item }) : null)}
key={item.id}
{...(getItemProps ? getItemProps({ item }) : null)}
style={{
backgroundColor:
highlightedIndex === idx

View File

@@ -31,8 +31,8 @@ export function ReportList<T extends { id: string; name: string }>({
{items.map((item, idx) => {
return [
<div
{...(getItemProps ? getItemProps({ item }) : null)}
key={item.id}
{...(getItemProps ? getItemProps({ item }) : null)}
style={{
backgroundColor:
highlightedIndex === idx

View File

@@ -244,7 +244,7 @@ export function BudgetPage() {
const group = categoryGroups.find(g => g.id === groupId);
onSaveGroup({
...group,
hidden: !!!group.hidden,
hidden: group.hidden ? false : true,
});
dispatch(collapseModals({ rootModalName: 'category-group-menu' }));
},
@@ -301,7 +301,7 @@ export function BudgetPage() {
const category = categories.find(c => c.id === categoryId);
onSaveCategory({
...category,
hidden: !!!category.hidden,
hidden: category.hidden ? false : true,
});
dispatch(collapseModals({ rootModalName: 'category-menu' }));
},

View File

@@ -258,7 +258,7 @@ export function IncomeCategoryListItem({
paddingLeft: 5,
paddingRight: 5,
borderBottomWidth: 1,
opacity: !!category.hidden ? 0.5 : undefined,
opacity: category.hidden ? 0.5 : undefined,
backgroundColor: monthUtils.isCurrentMonth(month)
? theme.budgetCurrentMonth
: theme.budgetOtherMonth,

View File

@@ -133,7 +133,7 @@ function IncomeGroupHeader({
justifyContent: 'space-between',
paddingLeft: 5,
paddingRight: 5,
opacity: !!group.hidden ? 0.5 : undefined,
opacity: group.hidden ? 0.5 : undefined,
backgroundColor: monthUtils.isCurrentMonth(month)
? theme.budgetHeaderCurrentMonth
: theme.budgetHeaderOtherMonth,

View File

@@ -17,6 +17,7 @@ type ElectronFixtures = {
// Create the extended test with fixtures
export const test = base.extend<ElectronFixtures>({
// oxlint-disable-next-line no-empty-pattern
electronApp: async ({}, use, testInfo: TestInfo) => {
const uniqueTestId = testInfo.testId.replace(/[^\w-]/g, '-');
const testDataDir = path.join('e2e/data/', uniqueTestId);

View File

@@ -9,7 +9,10 @@ export default function APIList({ title, sections }) {
{sections.map(name => {
let id = name.replace(/[ -]/g, '-').toLowerCase();
return (
<li className="list-none m-0 mt-1 pl-4 text-sm link-color-inherit text-gray-700">
<li
key={id}
className="list-none m-0 mt-1 pl-4 text-sm link-color-inherit text-gray-700"
>
<a className="no-underline" href={'#' + id}>
{name}
</a>

View File

@@ -522,7 +522,9 @@ function Table({ style, headers, className, children }) {
<thead>
<tr>
{headers.map(header => (
<th className="text-gray-900 font-thin">{header}</th>
<th key={header} className="text-gray-900 font-thin">
{header}
</th>
))}
</tr>
</thead>
@@ -537,6 +539,7 @@ export function PrimitiveTypeList() {
{Object.keys(types).map(name => {
return (
<PrimitiveType
key={name}
name={types[name].name}
type={types[name].type}
description={types[name].description}
@@ -571,7 +574,7 @@ export function StructType({ fields }) {
>
{fields.map(field => {
return (
<tr>
<tr key={field.name}>
<td valign="top">
<code>{field.name}</code>
</td>
@@ -598,7 +601,9 @@ function Argument({ arg }) {
<span>
{arg.name ? arg.name + ': ' : ''}
{'{ '}
{arg.properties.map(prop => <Argument arg={prop} />).map(insertCommas)}
{arg.properties
.map(prop => <Argument key={prop.name} arg={prop} />)
.map(insertCommas)}
{' }'}
</span>
);
@@ -628,8 +633,11 @@ export function Method({ name, args, returns = 'Promise<null>', children }) {
<p className="method">
<div className="p-4 pb-6 rounded border-b bg-gray-100 overflow-auto">
<code className="text-blue-800">
{name}({args.map(arg => <Argument arg={arg} />).map(insertCommas)}){' '}
<span className="text-gray-500">&rarr; {returns}</span>
{name}(
{args
.map(arg => <Argument key={arg.name} arg={arg} />)
.map(insertCommas)}
) <span className="text-gray-500">&rarr; {returns}</span>
</code>
</div>
{children && React.cloneElement(children, {})}

View File

@@ -53,17 +53,15 @@ export default function Key({ mod, fixed, mods = [], k, arrow }) {
return (
<div style={{ display: 'inline-flex' }}>
{keys.map(
(key, idx) => (
<div
className={classes.key}
style={{ marginLeft: idx === 0 ? 0 : '0.25rem' }}
>
{key}
</div>
),
[],
)}
{keys.map((key, idx) => (
<div
key={idx}
className={classes.key}
style={{ marginLeft: idx === 0 ? 0 : '0.25rem' }}
>
{key}
</div>
))}
</div>
);
}

View File

@@ -203,15 +203,16 @@ describe('Budget', () => {
test('budget updates when changing a category', async () => {
const spreadsheet = await sheet.loadSpreadsheet(db);
function captureChangedCells(func) {
return new Promise<unknown[]>(async resolve => {
return new Promise<unknown[]>(resolve => {
let changed = [];
const remove = spreadsheet.addEventListener('change', ({ names }) => {
changed = changed.concat(names);
});
await func();
remove();
spreadsheet.onFinish(() => {
resolve(changed);
func().then(() => {
remove();
spreadsheet.onFinish(() => {
resolve(changed);
});
});
});
}

View File

@@ -245,7 +245,7 @@ async function findStartDate(schedule) {
const dateCond = conditions.find(c => c.field === 'date');
let currentConfig = dateCond.value;
while (1) {
while (true) {
const prevConfig = currentConfig;
currentConfig = { ...prevConfig };

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---
Fix various lint issues