Skip to content

Commit 71488a0

Browse files
DrJKLactions-user
authored andcommitted
Lint: Add tailwind linter (#5984)
Adds the [tailwind lint plugin](https://github.com/francoismassart/eslint-plugin-tailwindcss/?tab=readme-ov-file#eslint-plugin-tailwindcss) and fixes the currently fixable rules ([v4 is still in beta](https://github.com/francoismassart/eslint-plugin-tailwindcss/?tab=readme-ov-file#about-tailwind-css-4-support)). - **What**: Enforces things like consistent class order, and eventually can prohibit extra classes that could be utilities instead - **Dependencies**: The plugin and its types ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5984-Lint-Add-tailwind-linter-2866d73d365081d89db0d998232533bb) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <[email protected]>
1 parent faa9228 commit 71488a0

File tree

177 files changed

+730
-667
lines changed

Some content is hidden

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

177 files changed

+730
-667
lines changed

eslint.config.ts

Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,67 @@ import pluginI18n from '@intlify/eslint-plugin-vue-i18n'
44
import { importX } from 'eslint-plugin-import-x'
55
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
66
import storybook from 'eslint-plugin-storybook'
7+
import tailwind from 'eslint-plugin-tailwindcss'
78
import unusedImports from 'eslint-plugin-unused-imports'
89
import pluginVue from 'eslint-plugin-vue'
910
import { defineConfig } from 'eslint/config'
1011
import globals from 'globals'
11-
import tseslint from 'typescript-eslint'
12+
import {
13+
configs as tseslintConfigs,
14+
parser as tseslintParser
15+
} from 'typescript-eslint'
1216
import vueParser from 'vue-eslint-parser'
1317

1418
const extraFileExtensions = ['.vue']
1519

20+
const commonGlobals = {
21+
...globals.browser,
22+
__COMFYUI_FRONTEND_VERSION__: 'readonly'
23+
} as const
24+
25+
const settings = {
26+
'import/resolver': {
27+
typescript: true,
28+
node: true
29+
},
30+
tailwindcss: {
31+
config: `${import.meta.dirname}/packages/design-system/src/css/style.css`,
32+
functions: ['cn', 'clsx', 'tw']
33+
}
34+
} as const
35+
36+
const commonParserOptions = {
37+
parser: tseslintParser,
38+
projectService: true,
39+
tsConfigRootDir: import.meta.dirname,
40+
ecmaVersion: 2020,
41+
sourceType: 'module',
42+
extraFileExtensions
43+
} as const
44+
1645
export default defineConfig([
1746
{
1847
ignores: [
19-
'src/scripts/*',
20-
'src/extensions/core/*',
21-
'src/types/vue-shim.d.ts',
22-
'packages/registry-types/src/comfyRegistryTypes.ts',
23-
'src/types/generatedManagerTypes.ts',
48+
'.i18nrc.cjs',
49+
'components.d.ts',
50+
'lint-staged.config.js',
51+
'vitest.setup.ts',
2452
'**/vite.config.*.timestamp*',
2553
'**/vitest.config.*.timestamp*',
26-
'lint-staged.config.js',
27-
'vitest.litegraph.config.ts'
54+
'packages/registry-types/src/comfyRegistryTypes.ts',
55+
'src/extensions/core/*',
56+
'src/scripts/*',
57+
'src/types/generatedManagerTypes.ts',
58+
'src/types/vue-shim.d.ts'
2859
]
2960
},
30-
{
31-
files: ['./**/*.js'],
32-
languageOptions: {
33-
globals: {
34-
...globals.browser,
35-
__COMFYUI_FRONTEND_VERSION__: 'readonly'
36-
},
37-
ecmaVersion: 2020,
38-
sourceType: 'module'
39-
},
40-
rules: {
41-
'@typescript-eslint/no-floating-promises': 'off'
42-
}
43-
},
4461
{
4562
files: ['./**/*.{ts,mts}'],
63+
settings,
4664
languageOptions: {
47-
globals: {
48-
...globals.browser,
49-
__COMFYUI_FRONTEND_VERSION__: 'readonly'
50-
},
65+
globals: commonGlobals,
5166
parserOptions: {
52-
parser: tseslint.parser,
67+
...commonParserOptions,
5368
projectService: {
5469
allowDefaultProject: [
5570
'vite.config.mts',
@@ -58,47 +73,26 @@ export default defineConfig([
5873
'playwright.config.ts',
5974
'playwright.i18n.config.ts'
6075
]
61-
},
62-
tsConfigRootDir: import.meta.dirname,
63-
ecmaVersion: 2020,
64-
sourceType: 'module',
65-
extraFileExtensions
66-
}
67-
},
68-
settings: {
69-
'import/resolver': {
70-
typescript: true,
71-
node: true
76+
}
7277
}
7378
}
7479
},
7580
{
7681
files: ['./**/*.vue'],
82+
settings,
7783
languageOptions: {
78-
globals: {
79-
...globals.browser,
80-
__COMFYUI_FRONTEND_VERSION__: 'readonly'
81-
},
84+
globals: commonGlobals,
8285
parser: vueParser,
83-
parserOptions: {
84-
parser: tseslint.parser,
85-
projectService: true,
86-
tsConfigRootDir: import.meta.dirname,
87-
ecmaVersion: 2020,
88-
sourceType: 'module',
89-
extraFileExtensions
90-
}
91-
},
92-
settings: {
93-
'import/resolver': {
94-
typescript: true,
95-
node: true
96-
}
86+
parserOptions: commonParserOptions
9787
}
9888
},
9989
pluginJs.configs.recommended,
100-
// eslint-disable-next-line import-x/no-named-as-default-member
101-
tseslint.configs.recommended,
90+
91+
tseslintConfigs.recommended,
92+
// Difference in typecheck on CI vs Local
93+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
94+
// @ts-ignore Bad types in the plugin
95+
tailwind.configs['flat/recommended'],
10296
pluginVue.configs['flat/recommended'],
10397
eslintPluginPrettierRecommended,
10498
storybook.configs['flat/recommended'],
@@ -130,6 +124,7 @@ export default defineConfig([
130124
'import-x/no-relative-packages': 'error',
131125
'unused-imports/no-unused-imports': 'error',
132126
'no-console': ['error', { allow: ['warn', 'error'] }],
127+
'tailwindcss/no-custom-classname': 'off', // TODO: fix
133128
'vue/no-v-html': 'off',
134129
// Enforce dark-theme: instead of dark: prefix
135130
'vue/no-restricted-class': ['error', '/^dark:/'],

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@storybook/vue3-vite": "catalog:",
5858
"@tailwindcss/vite": "catalog:",
5959
"@trivago/prettier-plugin-sort-imports": "catalog:",
60+
"@types/eslint-plugin-tailwindcss": "catalog:",
6061
"@types/fs-extra": "catalog:",
6162
"@types/jsdom": "catalog:",
6263
"@types/node": "catalog:",
@@ -73,6 +74,7 @@
7374
"eslint-plugin-import-x": "catalog:",
7475
"eslint-plugin-prettier": "catalog:",
7576
"eslint-plugin-storybook": "catalog:",
77+
"eslint-plugin-tailwindcss": "catalog:",
7678
"eslint-plugin-unused-imports": "catalog:",
7779
"eslint-plugin-vue": "catalog:",
7880
"fs-extra": "^11.2.0",

pnpm-lock.yaml

Lines changed: 48 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ catalog:
2929
'@storybook/vue3-vite': ^9.1.1
3030
'@tailwindcss/vite': ^4.1.12
3131
'@trivago/prettier-plugin-sort-imports': ^5.2.0
32+
'@types/eslint-plugin-tailwindcss': ^3.17.0
3233
'@types/fs-extra': ^11.0.4
3334
'@types/jsdom': ^21.1.7
3435
'@types/node': ^20.14.8
@@ -50,6 +51,7 @@ catalog:
5051
eslint-plugin-import-x: ^4.16.1
5152
eslint-plugin-prettier: ^5.5.4
5253
eslint-plugin-storybook: ^9.1.6
54+
eslint-plugin-tailwindcss: 4.0.0-beta.0
5355
eslint-plugin-unused-imports: ^4.2.0
5456
eslint-plugin-vue: ^10.4.0
5557
firebase: ^11.6.0
@@ -95,6 +97,9 @@ catalog:
9597

9698
cleanupUnusedCatalogs: true
9799

100+
overrides:
101+
'@types/eslint': '-'
102+
98103
ignoredBuiltDependencies:
99104
- '@firebase/util'
100105
- protobufjs

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<router-view />
33
<ProgressSpinner
44
v-if="isLoading"
5-
class="absolute inset-0 flex justify-center items-center h-[unset]"
5+
class="absolute inset-0 flex h-[unset] items-center justify-center"
66
/>
77
<GlobalDialog />
88
<BlockUI full-screen :blocked="isLoading" />

src/components/bottomPanel/BottomPanel.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<template>
2-
<div class="flex flex-col h-full">
2+
<div class="flex h-full flex-col">
33
<Tabs
44
:key="$i18n.locale"
55
v-model:value="bottomPanelStore.activeBottomPanelTabId"
66
>
77
<TabList pt:tab-list="border-none">
8-
<div class="w-full flex justify-between">
8+
<div class="flex w-full justify-between">
99
<div class="tabs-container">
1010
<Tab
1111
v-for="tab in bottomPanelStore.bottomPanelTabs"
1212
:key="tab.id"
1313
:value="tab.id"
14-
class="p-3 border-none"
14+
class="border-none p-3"
1515
>
1616
<span class="font-bold">
1717
{{ getTabDisplayTitle(tab) }}
@@ -41,7 +41,7 @@
4141
</TabList>
4242
</Tabs>
4343
<!-- h-0 to force the div to grow -->
44-
<div class="grow h-0">
44+
<div class="h-0 grow">
4545
<ExtensionSlot
4646
v-if="
4747
bottomPanelStore.bottomPanelVisible &&

src/components/bottomPanel/tabs/shortcuts/EssentialsPanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
2-
<div class="h-full flex flex-col p-4">
3-
<div class="flex-1 min-h-0 overflow-auto">
2+
<div class="flex h-full flex-col p-4">
3+
<div class="min-h-0 flex-1 overflow-auto">
44
<ShortcutsList
55
:commands="essentialsCommands"
66
:subcategories="essentialsSubcategories"

0 commit comments

Comments
 (0)