This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 2576eea97b Clean up some eslint rules to better fit what we do (#43093)
2576eea97b is described below

commit 2576eea97b6c28911231108026ffb54d6f3ae405
Author: Brent Bovenzi <[email protected]>
AuthorDate: Thu Oct 17 17:02:43 2024 +0100

    Clean up some eslint rules to better fit what we do (#43093)
---
 airflow/ui/rules/perfectionist.js                | 42 +++++++++++-------------
 airflow/ui/rules/typescript.js                   | 19 ++---------
 airflow/ui/rules/unicorn.js                      | 38 ++++++++++-----------
 airflow/ui/src/pages/Dashboard/HealthSection.tsx |  4 +--
 airflow/ui/src/pages/Dashboard/HealthTag.tsx     |  4 +--
 airflow/ui/src/theme.ts                          |  2 --
 airflow/ui/src/utils/capitalize.ts               |  1 -
 7 files changed, 45 insertions(+), 65 deletions(-)

diff --git a/airflow/ui/rules/perfectionist.js 
b/airflow/ui/rules/perfectionist.js
index fc838f7fdc..40d48cc0a0 100644
--- a/airflow/ui/rules/perfectionist.js
+++ b/airflow/ui/rules/perfectionist.js
@@ -48,13 +48,6 @@ export const perfectionistRules =
        */
       [`${perfectionistNamespace}/sort-array-includes`]: ERROR,
 
-      /**
-       * Enforce sorted attributes in Astro elements.
-       *
-       * @see 
[perfectionist/sort-astro-attributes](https://perfectionist.dev/rules/sort-astro-attributes)
-       */
-      [`${perfectionistNamespace}/sort-astro-attributes`]: ERROR,
-
       /**
        * Enforce sorted class members.
        *
@@ -109,14 +102,12 @@ export const perfectionistRules =
        *
        * @see 
[perfectionist/sort-objects](https://perfectionist.dev/rules/sort-objects)
        */
-      [`${perfectionistNamespace}/sort-objects`]: ERROR,
-
-      /**
-       * Enforce sorted attributes in Svelte elements.
-       *
-       * @see 
[perfectionist/sort-svelte-attributes](https://perfectionist.dev/rules/sort-svelte-attributes)
-       */
-      [`${perfectionistNamespace}/sort-svelte-attributes`]: ERROR,
+      [`${perfectionistNamespace}/sort-objects`]: [
+        ERROR,
+        {
+          type: "natural",
+        },
+      ],
 
       /**
        * Enforce sorted switch case statements.
@@ -128,16 +119,21 @@ export const perfectionistRules =
       /**
        * Enforce sorted TypeScript union types.
        *
-       * @see 
[perfectionist/sort-union-types](https://perfectionist.dev/rules/sort-union-types)
-       */
-      [`${perfectionistNamespace}/sort-union-types`]: ERROR,
-
-      /**
-       * Enforce sorted attributes in Vue elements.
+       * nullish groups will leave null and undefined at the end
        *
-       * @see 
[perfectionist/sort-vue-attributes](https://perfectionist.dev/rules/sort-vue-attributes)
+       * @see 
[perfectionist/sort-union-types](https://perfectionist.dev/rules/sort-union-types)
        */
-      [`${perfectionistNamespace}/sort-vue-attributes`]: ERROR,
+      [`${perfectionistNamespace}/sort-union-types`]: [
+        ERROR,
+        {
+          groups: [
+            ["conditional", "function", "import"],
+            ["intersection", "keyword", "named"],
+            ["literal", "object", "operator", "tuple", "union"],
+            "nullish",
+          ],
+        },
+      ],
 
       ...off("sort-keys"),
     },
diff --git a/airflow/ui/rules/typescript.js b/airflow/ui/rules/typescript.js
index c1964b0c9c..2856e89b5a 100644
--- a/airflow/ui/rules/typescript.js
+++ b/airflow/ui/rules/typescript.js
@@ -1,3 +1,5 @@
+/* eslint-disable max-lines */
+
 /*!
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -1818,21 +1820,6 @@ export const typescriptRules =
        */
       [`${typescriptNamespace}/triple-slash-reference`]: ERROR,
 
-      /**
-       * Bind stuff before using it.
-       *
-       * @example
-       * ```typescript
-       * // ❌ Incorrect
-       * const foo = classInstance.method;
-       *
-       * // ✅ Correct
-       * const foo = classInstance.method.bind(classInstance);
-       * ```
-       * @see 
[@typescript-eslint/unbound-method](https://typescript-eslint.io/rules/unbound-method/)
-       */
-      [`${typescriptNamespace}/unbound-method`]: ERROR,
-
       /**
        * Unify signatures instead of overloading.
        *
@@ -1881,7 +1868,7 @@ export const typescriptRules =
         "camelcase",
         "class-methods-use-this",
         "consistent-return",
-        "constructor-super", // eslint-disable-line max-lines
+        "constructor-super",
         "default-param-last",
         "dot-notation",
         "getter-return",
diff --git a/airflow/ui/rules/unicorn.js b/airflow/ui/rules/unicorn.js
index a11445c285..a53941d053 100644
--- a/airflow/ui/rules/unicorn.js
+++ b/airflow/ui/rules/unicorn.js
@@ -654,25 +654,6 @@ export const unicornRules =
        */
       [`${unicornNamespace}/prefer-array-find`]: ERROR,
 
-      /**
-       * Prefer `Array#flatMap` over `Array#map(…).flat()`.
-       *
-       * @example
-       * ```typescript
-       * // ❌ Incorrect
-       * const foo = bar.map(unicorn).flat();
-       * const foo = bar.map(unicorn).flat(1);
-       *
-       * // ✅ Correct
-       * const foo = bar.flatMap(unicorn);
-       * const foo = bar.map(unicorn).flat(2);
-       * const foo = bar.map(unicorn).foo().flat();
-       * const foo = bar.flat().map(unicorn);
-       * ```
-       * @see 
[unicorn/prefer-array-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md)
-       */
-      [`${unicornNamespace}/prefer-array-flat-map`]: ERROR,
-
       /**
        * Prefer `Array#flat` over legacy techniques to flatten arrays.
        *
@@ -700,6 +681,25 @@ export const unicornRules =
        */
       [`${unicornNamespace}/prefer-array-flat`]: ERROR,
 
+      /**
+       * Prefer `Array#flatMap` over `Array#map(…).flat()`.
+       *
+       * @example
+       * ```typescript
+       * // ❌ Incorrect
+       * const foo = bar.map(unicorn).flat();
+       * const foo = bar.map(unicorn).flat(1);
+       *
+       * // ✅ Correct
+       * const foo = bar.flatMap(unicorn);
+       * const foo = bar.map(unicorn).flat(2);
+       * const foo = bar.map(unicorn).foo().flat();
+       * const foo = bar.flat().map(unicorn);
+       * ```
+       * @see 
[unicorn/prefer-array-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md)
+       */
+      [`${unicornNamespace}/prefer-array-flat-map`]: ERROR,
+
       /**
        * Prefer `Array#indexOf` and `Array#lastIndexOf` over `Array#findIndex` 
and `Array#findLastIndex` when looking for the index of an item.
        *
diff --git a/airflow/ui/src/pages/Dashboard/HealthSection.tsx 
b/airflow/ui/src/pages/Dashboard/HealthSection.tsx
index 85e545c634..70c0468366 100644
--- a/airflow/ui/src/pages/Dashboard/HealthSection.tsx
+++ b/airflow/ui/src/pages/Dashboard/HealthSection.tsx
@@ -25,8 +25,8 @@ export const HealthSection = ({
   title,
 }: {
   readonly isLoading: boolean;
-  readonly latestHeartbeat?: null | string;
-  readonly status?: null | string;
+  readonly latestHeartbeat?: string | null;
+  readonly status?: string | null;
   readonly title: string;
 }) => {
   if (isLoading) {
diff --git a/airflow/ui/src/pages/Dashboard/HealthTag.tsx 
b/airflow/ui/src/pages/Dashboard/HealthTag.tsx
index 335d2f9121..7318f077da 100644
--- a/airflow/ui/src/pages/Dashboard/HealthTag.tsx
+++ b/airflow/ui/src/pages/Dashboard/HealthTag.tsx
@@ -27,8 +27,8 @@ export const HealthTag = ({
   title,
 }: {
   readonly isLoading: boolean;
-  readonly latestHeartbeat?: null | string;
-  readonly status?: null | string;
+  readonly latestHeartbeat?: string | null;
+  readonly status?: string | null;
   readonly title: string;
 }) => {
   if (isLoading) {
diff --git a/airflow/ui/src/theme.ts b/airflow/ui/src/theme.ts
index 0c7146643d..b348c54aed 100644
--- a/airflow/ui/src/theme.ts
+++ b/airflow/ui/src/theme.ts
@@ -19,8 +19,6 @@
 import { tableAnatomy } from "@chakra-ui/anatomy";
 import { createMultiStyleConfigHelpers, extendTheme } from "@chakra-ui/react";
 
-// Chakra has bad types for this util, so is registered as unbound
-// eslint-disable-next-line @typescript-eslint/unbound-method
 const { defineMultiStyleConfig, definePartsStyle } =
   createMultiStyleConfigHelpers(tableAnatomy.keys);
 
diff --git a/airflow/ui/src/utils/capitalize.ts 
b/airflow/ui/src/utils/capitalize.ts
index bd941c4667..0b48e3b654 100644
--- a/airflow/ui/src/utils/capitalize.ts
+++ b/airflow/ui/src/utils/capitalize.ts
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-// eslint-disable-next-line perfectionist/sort-union-types
 export const capitalize = (string: string | null | undefined) =>
   // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
   string ? string.charAt(0).toUpperCase() + string.slice(1).toLowerCase() : "";

Reply via email to