Merge branch 'feat/classnames-sort' into chore/infrastructure-upgrade2

This commit is contained in:
NFish 2025-03-19 16:11:12 +08:00
commit d8290beabe
2 changed files with 51 additions and 29 deletions

View File

@ -2,22 +2,12 @@ import {
GLOB_TESTS, combine, javascript, node, GLOB_TESTS, combine, javascript, node,
stylistic, typescript, unicorn, stylistic, typescript, unicorn,
} from '@antfu/eslint-config' } from '@antfu/eslint-config'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'
import globals from 'globals' import globals from 'globals'
import storybook from 'eslint-plugin-storybook' import storybook from 'eslint-plugin-storybook'
import { fixupConfigRules } from '@eslint/compat' // import { fixupConfigRules } from '@eslint/compat'
import tailwind from 'eslint-plugin-tailwindcss' import tailwind from 'eslint-plugin-tailwindcss'
import reactHooks from 'eslint-plugin-react-hooks'
const __filename = fileURLToPath(import.meta.url) import reactRefresh from 'eslint-plugin-react-refresh'
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})
export default combine( export default combine(
stylistic({ stylistic({
@ -73,10 +63,10 @@ export default combine(
node(), node(),
// use nextjs config will break @eslint/config-inspector // use nextjs config will break @eslint/config-inspector
// use `ESLINT_CONFIG_INSPECTOR=true pnpx @eslint/config-inspector` to check the config // use `ESLINT_CONFIG_INSPECTOR=true pnpx @eslint/config-inspector` to check the config
...process.env.ESLINT_CONFIG_INSPECTOR // ...process.env.ESLINT_CONFIG_INSPECTOR
? [] // ? []
// TODO: remove this when upgrade to nextjs 15 // TODO: remove this when upgrade to nextjs 15
: fixupConfigRules(compat.extends('next')), // : fixupConfigRules(compat.extends('next')),
{ {
rules: { rules: {
// performance issue, and not used. // performance issue, and not used.
@ -86,7 +76,6 @@ export default combine(
{ {
ignores: [ ignores: [
'**/node_modules/*', '**/node_modules/*',
'**/node_modules/',
'**/dist/', '**/dist/',
'**/build/', '**/build/',
'**/out/', '**/out/',
@ -141,6 +130,13 @@ export default combine(
}, },
}, },
storybook.configs['flat/recommended'], storybook.configs['flat/recommended'],
reactRefresh.configs.recommended,
{
rules: reactHooks.configs.recommended.rules,
plugins: {
'react-hooks': reactHooks,
},
},
// need futher research // need futher research
{ {
rules: { rules: {
@ -169,15 +165,40 @@ export default combine(
}, },
tailwind.configs['flat/recommended'], tailwind.configs['flat/recommended'],
{ {
settings: {
tailwindcss: {
// These are the default values but feel free to customize
callees: ['classnames', 'clsx', 'ctl', 'cn'],
config: 'tailwind.config.js', // returned from `loadConfig()` utility if not provided
cssFiles: [
'**/*.css',
'!**/node_modules',
'!**/.*',
'!**/dist',
'!**/build',
'!**/.storybook',
'!**/.next',
'!**/.public',
],
cssFilesRefreshRate: 5_000,
removeDuplicates: true,
skipClassAttribute: false,
whitelist: [],
tags: [], // can be set to e.g. ['tw'] for use in tw`bg-blue`
classRegex: '^class(Name)?$', // can be modified to support custom attributes. E.g. "^tw$" for `twin.macro`
},
},
rules: { rules: {
// due to 1k lines of tailwind config, these rule have performance issue // due to 1k lines of tailwind config, these rule have performance issue
'tailwindcss/no-contradicting-classname': 'off', 'tailwindcss/no-contradicting-classname': 'off',
'tailwindcss/no-unnecessary-arbitrary-value': 'off',
'tailwindcss/enforces-shorthand': 'off', 'tailwindcss/enforces-shorthand': 'off',
'tailwindcss/no-custom-classname': 'off', 'tailwindcss/no-custom-classname': 'off',
'tailwindcss/no-unnecessary-arbitrary-value': 'off',
// in the future 'tailwindcss/classnames-order': 'warn',
'tailwindcss/classnames-order': 'off', 'tailwindcss/enforces-negative-arbitrary-values': 'warn',
'tailwindcss/no-arbitrary-value': 'warn',
'tailwindcss/migration-from-tailwind-2': 'warn',
}, },
}, },
) )

View File

@ -130,11 +130,11 @@
"zustand": "^4.5.2" "zustand": "^4.5.2"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^3.8.0", "@antfu/eslint-config": "^4.1.1",
"@eslint/js": "^9.20.0",
"@chromatic-com/storybook": "^3.1.0", "@chromatic-com/storybook": "^3.1.0",
"@eslint-react/eslint-plugin": "^1.15.0", "@eslint-react/eslint-plugin": "^1.15.0",
"@eslint/eslintrc": "^3.1.0", "@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@faker-js/faker": "^9.0.3", "@faker-js/faker": "^9.0.3",
"@next/eslint-plugin-next": "15.2.3", "@next/eslint-plugin-next": "15.2.3",
"@rgrove/parse-xml": "^4.1.0", "@rgrove/parse-xml": "^4.1.0",
@ -172,12 +172,12 @@
"bing-translate-api": "^4.0.2", "bing-translate-api": "^4.0.2",
"code-inspector-plugin": "^0.18.1", "code-inspector-plugin": "^0.18.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^9.13.0", "eslint": "^9.20.1",
"eslint-config-next": "15.2.3", "eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.19",
"eslint-plugin-react-refresh": "^0.4.13", "eslint-plugin-storybook": "^0.11.2",
"eslint-plugin-storybook": "^0.10.1", "eslint-plugin-tailwindcss": "^3.18.0",
"eslint-plugin-tailwindcss": "^3.17.5", "eslint-config-next": "^15.0.0",
"husky": "^9.1.6", "husky": "^9.1.6",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
@ -189,6 +189,7 @@
"tailwindcss": "^3.4.14", "tailwindcss": "^3.4.14",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "4.9.5", "typescript": "4.9.5",
"typescript-eslint": "^8.23.0",
"uglify-js": "^3.19.3" "uglify-js": "^3.19.3"
}, },
"resolutions": { "resolutions": {