Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(tooling): centralize lint and format maintenance (#44404)
Stephen Zhou77df1226c7db
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERSindex 006e3fd55ba..41ecda9747a 100644--- a/.github/CODEOWNERS+++ b/.github/CODEOWNERS@@ -145,7 +145,7 @@/web/ @iamjoel# Frontend - Tooling-/lint.config.ts @hyoban @lyzno1+/packages/tooling/ @hyoban @lyzno1/eslint.config.mjs @hyoban @lyzno1/knip.config.ts @hyoban @lyzno1/vite.config.ts @hyoban @lyzno1diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.ymlindex ec658b9a559..92973d5057d 100644--- a/.github/workflows/main-ci.yml+++ b/.github/workflows/main-ci.yml@@ -95,7 +95,7 @@ jobs:- 'package.json'- 'pnpm-lock.yaml'- 'pnpm-workspace.yaml'- - 'lint.config.ts'+ - 'packages/tooling/**'- '.npmrc'- '.github/workflows/cli-tests.yml'- '.github/actions/setup-web/**'@@ -198,7 +198,6 @@ jobs:- 'pnpm-lock.yaml'- 'pnpm-workspace.yaml'- 'knip.config.ts'- - 'scripts/check-web-production-unused-after-knip-fix.mjs'- '.npmrc'- '.github/workflows/main-ci.yml'- '.github/workflows/web-bundle-size.yml'@@ -216,10 +215,8 @@ jobs:- 'pnpm-workspace.yaml'- 'tsconfig.json'- 'vite.config.ts'- - 'lint.config.ts'- 'eslint.config.mjs'- 'knip.config.ts'- - 'scripts/check-web-production-unused-after-knip-fix.mjs'- 'oxlint-suppressions.json'- 'eslint-suppressions.json'- '.vscode/**'diff --git a/.github/workflows/style.yml b/.github/workflows/style.ymlindex 160785626b6..7d4f7da0d98 100644--- a/.github/workflows/style.yml+++ b/.github/workflows/style.yml@@ -239,6 +239,9 @@ jobs:- name: Static checkrun: vp run -w check+ - name: Tooling rule tests+ run: vp run @dify/tooling#test run+- name: Save static check task cacheif: success() && github.event_name != 'merge_group'uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0diff --git a/eslint.config.mjs b/eslint.config.mjsindex dc37477345f..e4cc152e505 100644--- a/eslint.config.mjs+++ b/eslint.config.mjs@@ -1,432 +1 @@-// @ts-check-/// <reference types="node" />--import markdown from '@eslint/markdown'-import gitignore from 'eslint-config-flat-gitignore'-import md from 'eslint-markdown'-import jsonc from 'eslint-plugin-jsonc'-import markdownPreferences from 'eslint-plugin-markdown-preferences'-import pnpm from 'eslint-plugin-pnpm'-import yml from 'eslint-plugin-yml'-import { defineConfig, globalIgnores } from 'eslint/config'-import dify from './web/plugins/eslint/index.js'--const codeFiles = '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'-const mdPlugin = /** @type {import('eslint').ESLint.Plugin} */ (/** @type {unknown} */ (md))--/**- * Migration tradeoff: ESLint is intentionally restricted to non-code files.- *- * Disabled code-only checks:- * - Core: `no-control-regex`, `no-octal`, `no-octal-escape`, `no-undef-init`,- * `no-unreachable-loop`, and `one-var`.- * - JavaScript: `dot-notation`.- * - Declarations: the former 223-rule snapshot and CLI `no-restricted-imports` override.- * - Dify UI: the three `better-tailwindcss` rules and stricter unused-directive severity.- *- * These checks are documentation only and do not appear in the executable config below.- */--const tsconfigCompilerOptionsOrder = [- 'incremental',- 'composite',- 'tsBuildInfoFile',- 'disableSourceOfProjectReferenceRedirect',- 'disableSolutionSearching',- 'disableReferencedProjectLoad',- 'target',- 'jsx',- 'jsxFactory',- 'jsxFragmentFactory',- 'jsxImportSource',- 'lib',- 'moduleDetection',- 'noLib',- 'reactNamespace',- 'useDefineForClassFields',- 'emitDecoratorMetadata',- 'experimentalDecorators',- 'libReplacement',- 'baseUrl',- 'rootDir',- 'rootDirs',- 'customConditions',- 'module',- 'moduleResolution',- 'moduleSuffixes',- 'noResolve',- 'paths',- 'resolveJsonModule',- 'resolvePackageJsonExports',- 'resolvePackageJsonImports',- 'typeRoots',- 'types',- 'allowArbitraryExtensions',- 'allowImportingTsExtensions',- 'allowUmdGlobalAccess',- 'allowJs',- 'checkJs',- 'maxNodeModuleJsDepth',- 'strict',- 'strictBindCallApply',- 'strictFunctionTypes',- 'strictNullChecks',- 'strictPropertyInitialization',- 'allowUnreachableCode',- 'allowUnusedLabels',- 'alwaysStrict',- 'exactOptionalPropertyTypes',- 'noFallthroughCasesInSwitch',- 'noImplicitAny',- 'noImplicitOverride',- 'noImplicitReturns',- 'noImplicitThis',- 'noPropertyAccessFromIndexSignature',- 'noUncheckedIndexedAccess',- 'noUnusedLocals',- 'noUnusedParameters',- 'useUnknownInCatchVariables',- 'declaration',- 'declarationDir',- 'declarationMap',- 'downlevelIteration',- 'emitBOM',- 'emitDeclarationOnly',- 'importHelpers',- 'importsNotUsedAsValues',- 'inlineSourceMap',- 'inlineSources',- 'mapRoot',- 'newLine',- 'noEmit',- 'noEmitHelpers',- 'noEmitOnError',- 'outDir',- 'outFile',- 'preserveConstEnums',- 'preserveValueImports',- 'removeComments',- 'sourceMap',- 'sourceRoot',- 'stripInternal',- 'allowSyntheticDefaultImports',- 'esModuleInterop',- 'forceConsistentCasingInFileNames',- 'isolatedDeclarations',- 'isolatedModules',- 'preserveSymlinks',- 'verbatimModuleSyntax',- 'erasableSyntaxOnly',- 'skipDefaultLibCheck',- 'skipLibCheck',-]--const pnpmWorkspaceOrder = [- 'allowBuilds',- 'autoInstallPeers',- 'blockExoticSubdeps',- 'cacheDir',- 'catalogMode',- 'catalogPrune',- 'cleanupUnusedCatalogs',- 'dedupeDirectDeps',- 'deployAllFiles',- 'enablePrePostScripts',- 'engineStrict',- 'extendNodePath',- 'hoist',- 'hoistPattern',- 'hoistWorkspacePackages',- 'ignoreCompatibilityDb',- 'ignoreDepScripts',- 'ignoreScripts',- 'ignoreWorkspaceRootCheck',- 'managePackageManagerVersions',- 'minimumReleaseAge',- 'minimumReleaseAgeExclude',- 'modulesDir',- 'nodeLinker',- 'nodeVersion',- 'optimisticRepeatInstall',- 'packageManagerStrict',- 'packageManagerStrictVersion',- 'preferSymlinkedExecutables',- 'preferWorkspacePackages',- 'publicHoistPattern',- 'registrySupportsTimeField',- 'requiredScripts',- 'resolutionMode',- 'saveExact',- 'savePrefix',- 'scriptShell',- 'shamefullyHoist',- 'shellEmulator',- 'stateDir',- 'strictDepBuilds',- 'supportedArchitectures',- 'symlink',- 'tag',- 'trustPolicy',- 'trustPolicyExclude',- 'updateNotifier',- 'verifyDepsBeforeRun',- 'packages',- 'overrides',- 'patchedDependencies',- 'catalog',- 'catalogs',- 'allowedDeprecatedVersions',- 'allowNonAppliedPatches',- 'configDependencies',- 'ignoredBuiltDependencies',- 'ignoredOptionalDependencies',- 'neverBuiltDependencies',- 'onlyBuiltDependencies',- 'onlyBuiltDependenciesFile',- 'packageExtensions',- 'peerDependencyRules',-]--export default defineConfig([- globalIgnores(- [- '**/*',- '!cli/',- '!cli/**/*',- '!e2e/',- '!e2e/**/*',- '!packages/',- '!packages/**/*',- '!sdks/',- '!sdks/nodejs-client/',- '!sdks/nodejs-client/package.json',- '!sdks/nodejs-client/src/',- '!sdks/nodejs-client/src/**/*',- '!sdks/nodejs-client/tests/',- '!sdks/nodejs-client/tests/**/*',- '!web/',- '!web/**/*',- '!eslint.config.mjs',- '!lint.config.ts',- '!package.json',- '!pnpm-workspace.yaml',- '!vite.config.ts',- ],- 'Project lint scope',- ),- gitignore({- cwd: import.meta.dirname,- root: true,- recursive: { skipDirs: ['.venv', 'volumes'] },- }),- globalIgnores([codeFiles], 'Migration tradeoff: code files are handled by Oxlint only'),- globalIgnores(- [- '**/.git/**',- '**/node_modules/**',- 'cli/context/**',- 'cli/coverage/**',- 'cli/dist/**',- 'cli/docs/**',- '**/.next/**',- '**/.vinext/**',- '**/coverage/**',- '**/dist/**',- '**/storybook-static/**',- 'e2e/.auth/**',- 'e2e/cucumber-report/**',- 'packages/contracts/**/*',- '!packages/contracts/package.json',- 'web/next/**',- 'web/next-env.d.ts',- 'web/public/**',- 'web/types/doc-paths.ts',- ],- 'Generated and external files',- ),- {- linterOptions: {- reportUnusedDisableDirectives: 'warn',- },- },- {- files: ['**/*.{json,json5,jsonc}'],- language: 'jsonc/x',- plugins: {- jsonc,- },- rules: {- 'no-unused-expressions': 'off',- 'no-unused-vars': 'off',- strict: 'off',- 'jsonc/no-bigint-literals': 'error',- 'jsonc/no-binary-expression': 'error',- 'jsonc/no-binary-numeric-literals': 'error',- 'jsonc/no-dupe-keys': 'error',- 'jsonc/no-escape-sequence-in-identifier': 'error',- 'jsonc/no-floating-decimal': 'error',- 'jsonc/no-hexadecimal-numeric-literals': 'error',- 'jsonc/no-infinity': 'error',- 'jsonc/no-multi-str': 'error',- 'jsonc/no-nan': 'error',- 'jsonc/no-number-props': 'error',- 'jsonc/no-numeric-separators': 'error',- 'jsonc/no-octal': 'error',- 'jsonc/no-octal-escape': 'error',- 'jsonc/no-octal-numeric-literals': 'error',- 'jsonc/no-parenthesized': 'error',- 'jsonc/no-plus-sign': 'error',- 'jsonc/no-regexp-literals': 'error',- 'jsonc/no-sparse-arrays': 'error',- 'jsonc/no-template-literals': 'error',- 'jsonc/no-undefined-value': 'error',- 'jsonc/no-unicode-codepoint-escapes': 'error',- 'jsonc/no-useless-escape': 'error',- 'jsonc/valid-json-number': 'error',- 'jsonc/vue-custom-block/no-parsing-error': 'error',- },- },- {- files: ['**/package.json'],- rules: {- 'jsonc/sort-array-values': [- 'error',- {- order: { type: 'asc' },- pathPattern: '^files$',- },- ],- },- },- {- files: ['**/[jt]sconfig.json', '**/[jt]sconfig.*.json'],- rules: {- 'jsonc/sort-keys': [- 'error',- {- order: ['extends', 'compilerOptions', 'references', 'files', 'include', 'exclude'],- pathPattern: '^$',- },- {- order: tsconfigCompilerOptionsOrder,- pathPattern: '^compilerOptions$',- },- ],- },- },- {- files: ['package.json', '**/package.json'],- plugins: {- pnpm,- },- rules: {- 'pnpm/json-enforce-catalog': [- 'error',- {- allowedProtocols: ['workspace'],- autofix: true,- conflicts: 'error',- fields: ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'],- },- ],- 'pnpm/json-prefer-workspace-settings': ['error', { autofix: true }],- 'pnpm/json-valid-catalog': ['error', { autofix: true }],- },- },- {- files: ['**/*.{yml,yaml}'],- language: 'yml/yaml',- plugins: {- yml,- },- rules: {- 'no-irregular-whitespace': 'off',- 'no-unused-vars': 'off',- 'spaced-comment': 'off',- 'yml/no-empty-key': 'error',- 'yml/no-empty-sequence-entry': 'error',- 'yml/no-irregular-whitespace': 'error',- 'yml/vue-custom-block/no-parsing-error': 'error',- },- },- {- files: ['pnpm-workspace.yaml'],- plugins: {- pnpm,- },- rules: {- 'pnpm/yaml-enforce-settings': [- 'error',- {- settings: {- catalogMode: 'strict',- shellEmulator: true,- trustPolicy: 'no-downgrade',- },- },- ],- 'pnpm/yaml-no-duplicate-catalog-item': 'error',- 'pnpm/yaml-no-unused-catalog-item': 'error',- 'yml/sort-keys': [- 'error',- {- order: pnpmWorkspaceOrder,- pathPattern: '^$',- },- {- order: { type: 'asc' },- pathPattern: '.*',- },- ],- },- },- {- files: ['**/*.md'],- language: 'markdown/gfm',- plugins: {- markdown,- 'markdown-preferences': markdownPreferences,- md: mdPlugin,- },- rules: {- 'markdown/fenced-code-language': 'off',- 'markdown/heading-increment': 'error',- 'markdown/no-duplicate-definitions': 'error',- 'markdown/no-empty-definitions': 'error',- 'markdown/no-empty-images': 'error',- 'markdown/no-empty-links': 'error',- 'markdown/no-invalid-label-refs': 'error',- 'markdown/no-missing-atx-heading-space': 'error',- 'markdown/no-missing-label-refs': 'off',- 'markdown/no-missing-link-fragments': 'error',- 'markdown/no-multiple-h1': 'error',- 'markdown/no-reference-like-urls': 'error',- 'markdown/no-reversed-media-syntax': 'error',- 'markdown/no-space-in-emphasis': 'error',- 'markdown/no-unused-definitions': 'error',- 'markdown/require-alt-text': 'error',- 'markdown/table-column-count': 'error',- 'markdown-preferences/definitions-last': 'error',- 'markdown-preferences/prefer-link-reference-definitions': [- 'error',- {- minLinks: 1,- },- ],- 'markdown-preferences/sort-definitions': 'error',- 'md/no-url-trailing-slash': 'error',- },- },- {- files: ['web/i18n/locales/**/*.json'],- plugins: {- dify,- },- rules: {- 'dify/consistent-placeholders': 'error',- 'dify/i18n-flat-key': 'error',- 'dify/no-extra-keys': 'error',- 'jsonc/sort-keys': 'error',- },- },-])+export { default } from '@dify/tooling/eslint'diff --git a/knip.config.ts b/knip.config.tsindex d7bbb3a42d7..2a58d326288 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -1,60 +1 @@-import type { KnipConfig } from 'knip'--/**- * @see https://knip.dev/reference/configuration- */-const config: KnipConfig = {- compilers: {- mdx: true,- },- workspaces: {- web: {- entry: [- 'scripts/**/*.{js,ts,mjs}',- 'bin/**/*.{js,ts,mjs}',- 'tsslint.config.ts',- 'dev-proxy.config.ts',- 'plugins/eslint/index.js',- // Public surface consumed by the standalone Marketplace host.- // The `!` suffix keeps these entries in `knip --production`.- 'app/components/plugins/marketplace/detail-dialog/image-preview-message.ts!',- 'app/components/plugins/marketplace/standalone/server.ts!',- 'app/components/plugins/marketplace/standalone/client.ts!',- ],- project: [- '**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts,css,mdx}!',- '!**/__mocks__/**!',- '!**/__tests__/**!',- '!**/*.stories.{js,jsx,ts,tsx,mdx}!',- '!.storybook/**!',- '!plugins/**!',- '!test/**!',- '!vitest.browser.setup.ts!',- '!vitest.setup.ts!',- ],- ignore: ['public/**'],- ignoreFiles: ['i18n/locale-resources/*.ts'],- ignoreDependencies: ['@iconify-json/*', '@storybook/addon-onboarding'],- },- },- /// keep-sorted- rules: {- binaries: 'warn',- catalog: 'error',- dependencies: 'error',- devDependencies: 'warn',- duplicates: 'error',- enumMembers: 'error',- exports: 'error',- files: 'error',- namespaceMembers: 'error',- nsExports: 'error',- nsTypes: 'error',- optionalPeerDependencies: 'error',- types: 'error',- unlisted: 'error',- unresolved: 'error',- },-}--export default config+export { default } from '@dify/tooling/knip'diff --git a/package.json b/package.jsonindex 706337856dd..a17d95c57ee 100644--- a/package.json+++ b/package.json@@ -8,7 +8,7 @@"dev": "concurrently -k -n vinext,proxy \"vp run dify-web#dev\" \"vp run dify-web#dev:proxy\"","knip": "knip --workspace web","knip:production": "knip --workspace web --production --include files",- "knip:production-unused-check": "node ./scripts/check-web-production-unused-after-knip-fix.mjs",+ "knip:production-unused-check": "node ./packages/tooling/scripts/check-web-production-unused-after-knip-fix.mjs","prepare": "vp config","lint:oxlint": "vp lint","lint:oxlint:fix": "vp lint --fix",@@ -20,31 +20,13 @@"lint:eslint:quiet": "eslint --quiet --concurrency=auto"},"devDependencies": {- "@eslint-react/eslint-plugin": "catalog:",- "@eslint/markdown": "catalog:",+ "@dify/tooling": "workspace:*","@iconify-json/heroicons": "catalog:","@iconify-json/ri": "catalog:",- "@shadcn/lint": "catalog:",- "@tanstack/eslint-plugin-query": "catalog:","@types/node": "catalog:",- "@typescript-eslint/parser": "catalog:","@typescript/native": "catalog:","concurrently": "catalog:","eslint": "catalog:",- "eslint-config-flat-gitignore": "catalog:",- "eslint-markdown": "catalog:",- "eslint-plugin-antfu": "catalog:",- "eslint-plugin-better-tailwindcss": "catalog:",- "eslint-plugin-jsdoc": "catalog:",- "eslint-plugin-jsonc": "catalog:",- "eslint-plugin-markdown-preferences": "catalog:",- "eslint-plugin-n": "catalog:",- "eslint-plugin-no-barrel-files": "catalog:",- "eslint-plugin-perfectionist": "catalog:",- "eslint-plugin-pnpm": "catalog:",- "eslint-plugin-regexp": "catalog:",- "eslint-plugin-storybook": "catalog:",- "eslint-plugin-yml": "catalog:","knip": "catalog:","typescript": "catalog:","vite": "catalog:",diff --git a/packages/tooling/README.md b/packages/tooling/README.mdnew file mode 100644index 00000000000..00526cfcf25--- /dev/null+++ b/packages/tooling/README.md@@ -0,0 +1,184 @@+# Repository Tooling++Vite+ provides the primary static check through `vp check`, which combines Oxfmt formatting, Oxlint code-quality rules, and TypeScript diagnostics. The root command also runs ESLint for non-code file types that Oxlint cannot parse.++`@dify/tooling` is the private workspace package that owns JS/TS linting, formatting,+custom rules, and dead-code tooling. Edit the implementations here:++- `repository.config.ts`: repository Vite+ lint, format, staged checks, and cached check task.+- `lint.config.ts`, `eslint.mjs`, and `tsslint.config.ts`: rule configurations.+- `plugins/`: custom rules, their fixtures, and tests.+- `knip.config.ts`, `a11y.config.ts`, `oxlint.unused.config.json`, and `scripts/`: targeted checks.+- `package.json`: plugin dependencies and the tooling package's test and type-check scripts.++The root `vite.config.ts`, `eslint.config.mjs`, `knip.config.ts`, and+`web/tsslint.config.ts` are discovery entry points. Globs and suppression paths+remain relative to the repository or Web project as before. The Oxlint suppression+baseline stays at the root for automatic discovery by both `vp check` and `vp lint`.+ESLint and Knip remain root dev dependencies; the TSSLint CLI remains a Web dev dependency.+Their existing scripts call the dependency CLIs directly. Tooling declares ESLint and Knip+as peers for its configuration and rule tests. Vite+ remains a direct dependency of+packages that use its build, dev, or test commands.+Python rule configurations and dependencies remain with their existing projects;+the shared staged configuration continues to invoke their existing commands.++Run the tooling tests with `vp run @dify/tooling#test run`. CI runs them in TS Common.+The tests use Node and do not load Web's application mocks.++## Check++Run the complete repository check from the root before committing or pushing:++```sh+vp run -w check+```++Apply safe fixes before running the same checks:++```sh+vp run -w check:fix+```++CI and local development use the same root `vite.config.ts` configuration.++The root `check` script delegates to the `check:cached` Vite Task. Formatting, linting,+and type checking reuse successful results when their tracked inputs are unchanged.+`CI`, `NODE_ENV`, and `TAILWIND_CANONICAL_CLASSES` are included in the cache key;+check results never restore files into the working tree. Fix commands remain uncached.+To force a fresh check, run `vp run -w --no-cache check`.++The TS Common CI job restores the task cache after dependency installation and saves+it after a successful check. This is separate from the package-manager cache in+`setup-web`. When evaluating CI performance, compare cache transfer time with the+time saved in the Vite Task summary.++Reuse successful checks for the same final changes. Repeat or expand checks only when subsequent edits, failures, or unresolved concerns require it.++To narrow formatting and linting, pass paths directly to Vite+. Type checking remains repository-wide:++```sh+vp check web/app/components packages/dify-ui/src/button+vp check --fix web/app/components packages/dify-ui/src/button+```++Run only the Web JSX accessibility rules for selected files or directories with+`lint:a11y`. Quote paths that contain shell metacharacters such as parentheses:++```sh+vp run dify-web#lint:a11y 'app/(commonLayout)/app/(appDetailLayout)/layout.tsx'+```++Use dependency mode to resolve an entry file's transitive local imports, including path aliases,+re-exports, and dynamic imports, and then lint the resulting JSX and TSX files:++```sh+vp run dify-web#lint:a11y --deps 'app/(commonLayout)/app/(appDetailLayout)/layout.tsx'+```++This is a local page-scoped diagnostic. The repository-wide accessibility rule baseline remains+owned by `packages/tooling/lint.config.ts` and is also enforced by the normal `vp check` path.++Run the ESLint fallback separately when targeting JSON, JSONC, JSON5, YAML, or Markdown:++```sh+vp run -w lint:eslint package.json pnpm-workspace.yaml web/docs+vp run -w lint:eslint:fix package.json pnpm-workspace.yaml web/docs+```++Oxlint and Vite+ type-check scope is defined by `packages/tooling/lint.config.ts` `ignorePatterns`, and ESLint's scope is defined by `packages/tooling/eslint.mjs` global ignores.++The primary rule baseline lives in `packages/tooling/lint.config.ts` and is connected through the root `vite.config.ts` `lint` block. Oxlint-native rules are preferred, and compatible ESLint rules can run through Oxlint's `jsPlugins` support. The rules are explicit snapshots of the ESLint configurations that were active at migration time. Do not import an upstream preset wholesale: enable a new rule intentionally and review its existing violations first.++Tailwind canonical class cleanup is optional because loading the JavaScript plugin adds noticeable lint startup time. The default `vp run -w check` command does not load it. Run `vp run -w lint:tailwind` to inspect `web/` and `packages/dify-ui/`, or `vp run -w lint:tailwind:fix` to apply safe replacements. Both commands run the complete lint configuration with the additional `better-tailwindcss/enforce-canonical-classes` rule, using `web/app/styles/globals.css` and a 16px root font size.++The non-code baseline and its repository-wide file scope live in `packages/tooling/eslint.mjs`. ESLint checks JSON, JSONC, JSON5, YAML, and Markdown only. The configuration globally ignores JavaScript, JSX, TypeScript, TSX, and declaration files; a comment-only inventory records the removed code checks as a migration tradeoff. It does not import or depend on the Antfu ESLint config.++### Type-aware Linting++The root configuration enables both `typeAware` and `typeCheck`, so `vp check` runs type-aware rules and full diagnostics through the repository's `@typescript/native` compiler.++The shared `packages/tsconfig/base.json` enforces erasable TypeScript syntax through+`erasableSyntaxOnly`. Root tooling and TypeScript packages inherit this contract; enum+declarations, runtime namespaces, parameter properties, and import assignments are checked+by the compiler without a separate lint plugin.++The web package still runs its existing TSSLint rule separately:++```sh+vp run dify-web#lint:tss+```++### Bulk Suppressions++Existing Oxlint error diagnostics are tracked in the root `oxlint-suppressions.json` baseline. Oxlint reports newly added errors beyond that per-file rule baseline. ESLint has no bulk-suppression baseline. Warnings remain visible and do not fail the normal lint command.++The bulk-suppression flags are available in the bundled Oxlint version but are currently hidden from `vp lint --help`. Run them from the repository root so every package uses the same baseline:++```sh+vp run -w lint:oxlint --suppress-all+vp run -w lint:oxlint --prune-suppressions+```++The Oxc editor extension does not yet apply the bulk-suppression baseline, so the editor may still display findings that the CLI suppresses.++### Known Migration Gaps++ESLint is intentionally limited to non-code files. The remaining limitations and accepted migration tradeoffs are:++| Area | Current status |+| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| Code-only fallback rules | ESLint globally ignores all code files. Six core fallback rules, JS `dot-notation`, and other code-only ESLint checks are listed only in comments rather than executable configuration. |+| Declaration files | Oxlint excludes declaration files and ESLint no longer processes code. The former 223-rule declaration snapshot and CLI declaration import restriction are not enforced. |+| Generated contracts | Both linters and Vite+ type checking ignore `packages/contracts/**`; Oxfmt remains the only staged quality step for the contracts package. |+| Non-JavaScript formats | Oxlint plugins cannot provide custom parsers or file languages. ESLint covers JSON, JSONC, YAML, and Markdown semantic rules, while Oxfmt remains responsible for their formatting. |+| Markdown code blocks | ESLint validates the Markdown document, but fenced JavaScript and TypeScript blocks are not passed through the former overlapping preset. This remains deferred rather than duplicating the Oxlint rule set. |+| Override-scoped settings | The three Dify UI Tailwind rules are disabled with the rest of ESLint's code path. Oxlint still applies the web `react-x.additionalStateHooks` setting globally because it cannot scope settings to an override. |++Suppression comments belong to exactly one linter. Use `oxlint-disable` for code rules from `packages/tooling/lint.config.ts`, and use `eslint-disable` only for non-code rules from `packages/tooling/eslint.mjs`. Oxlint deliberately sets `respectEslintDisableDirectives` to `false`, so an ESLint comment cannot hide an Oxlint finding.++### Inline Disable Comments++Prefer fixing the finding. When an exception is necessary, name the specific rule and use `oxlint-disable-next-line` at the affected statement. For a shared exception spanning several statements, use a bounded disable/enable pair. File-wide disable comments are forbidden, including in tests. `dify/no-file-wide-disable` reports an error when a block disable has any rules left disabled at the end of the file; a matching enable must restore every disabled rule. The native `unicorn/no-abusive-eslint-disable` rule also rejects disables without rule names, which would otherwise suppress the custom check itself.++For existing violations that cannot be fixed in the current change, remove the file-wide comment and record a scoped bulk-suppression baseline instead of turning the rule off for the file:++```sh+vp run -w lint:oxlint path/to/file.spec.tsx --suppress-all+```++Review the `oxlint-suppressions.json` diff and retain only the intended file/rule counts. The rule remains active and findings beyond the recorded count are reported; this is a count baseline, not a list of specific suppressed lines. Avoid repository-wide `--suppress-all` for a scoped cleanup. After fixing violations, use `--prune-suppressions` as described above.++Use `packages/tooling/lint.config.ts` overrides only when a rule is intentionally inapplicable to a file, and `ignorePatterns` only when the entire file must be excluded, such as generated output. Explain the reason next to the configuration. Do not migrate existing violations to a blanket rule-off override or broaden exceptions to future files with a directory glob.++Explain the concrete reason after `--`: which external contract, lifecycle, or rule limitation makes the exception necessary. A description that merely repeats the rule or says "fix lint" is insufficient. New or modified disables must include this explanation; existing test typing exceptions can be addressed incrementally.++`dify/require-disable-directive-description` uses Oxlint's parsed directives to report missing explanations, including JSX comments. It runs at `error`; existing undescribed exceptions are tracked in the bulk-suppression baseline for incremental cleanup. Enable comments do not need a repeated explanation. This rule does not assess whether a reason is valid and does not replace review. Do not add generic descriptions just to silence it.++`reportUnusedDisableDirectives` runs at `error` repository-wide. Remove an exception when the finding no longer exists. Keep both checks active: a described disable may still be unused, and a used disable may still lack a reason.++### Translation Function Types++`dify/require-i18n-namespace` requires translation hook calls to use non-empty+inline namespace arrays, including single namespaces: `useTranslation(['common'])`.+Strings and indirect arguments are rejected; only calls reading the `i18n`+instance alone may omit namespaces. Both `react-i18next` and `#i18n` are checked.+The shared client/server adapter accepts typed non-empty tuples and forwards them+through one documented lint exception in its client implementation.++`dify/require-t-function-namespace` requires i18next `TFunction` types to declare a+non-empty inline tuple of namespace string literals. Use `TFunction<['common']>`+or `TFunction<['common', 'workflow']>`; readonly tuples are also supported.+Omitted arguments, single strings, broad namespace types, tuple aliases, and+unions or rest elements inside the tuple are rejected. Named import aliases,+namespace imports, and inline `import('i18next').TFunction` types are checked.++Declare the namespaces the helper or component actually uses. TypeScript checks+translation keys and compatibility with callers; the lint rule does not infer+transitive dependencies or detect unused namespaces. Keep the first namespace+compatible with the caller because it defines the default translation namespace.+The rule has no automatic fix because choosing the dependencies requires reading+the translation calls.++### Introducing New Plugins or Rules++Prefer a native Oxlint rule. If none exists, verify that the rule works through an Oxlint JS plugin on representative files. Record unsupported code rules as migration gaps instead of adding them to ESLint; reserve the ESLint configuration for non-code languages that Oxlint cannot parse. Do not add the Antfu ESLint config as a dependency or enable rules already covered by Oxlint.diff --git a/web/scripts/a11y/oxlint.config.ts b/packages/tooling/a11y.config.tssimilarity index 77%rename from web/scripts/a11y/oxlint.config.tsrename to packages/tooling/a11y.config.tsindex 498ec50e834..e2c517cd94a 100644--- a/web/scripts/a11y/oxlint.config.ts+++ b/packages/tooling/a11y.config.ts@@ -1,5 +1,5 @@import type { OxlintConfig } from 'vite-plus/lint'-import { jsxA11yRules } from '../../../lint.config.ts'+import { jsxA11yRules } from './lint.config.ts'export default {categories: {diff --git a/packages/tooling/eslint.mjs b/packages/tooling/eslint.mjsnew file mode 100644index 00000000000..93bfcd04389--- /dev/null+++ b/packages/tooling/eslint.mjs@@ -0,0 +1,432 @@+// @ts-check+/// <reference types="node" />++import markdown from '@eslint/markdown'+import gitignore from 'eslint-config-flat-gitignore'+import md from 'eslint-markdown'+import jsonc from 'eslint-plugin-jsonc'+import markdownPreferences from 'eslint-plugin-markdown-preferences'+import pnpm from 'eslint-plugin-pnpm'+import yml from 'eslint-plugin-yml'+import { defineConfig, globalIgnores } from 'eslint/config'+import { repositoryRoot } from './paths.ts'+import dify from './plugins/eslint/index.js'++const codeFiles = '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'+const mdPlugin = /** @type {import('eslint').ESLint.Plugin} */ (/** @type {unknown} */ (md))++/**+ * Migration tradeoff: ESLint is intentionally restricted to non-code files.+ *+ * Disabled code-only checks:+ * - Core: `no-control-regex`, `no-octal`, `no-octal-escape`, `no-undef-init`,+ * `no-unreachable-loop`, and `one-var`.+ * - JavaScript: `dot-notation`.+ * - Declarations: the former 223-rule snapshot and CLI `no-restricted-imports` override.+ * - Dify UI: the three `better-tailwindcss` rules and stricter unused-directive severity.+ *+ * These checks are documentation only and do not appear in the executable config below.+ */++const tsconfigCompilerOptionsOrder = [+ 'incremental',+ 'composite',+ 'tsBuildInfoFile',+ 'disableSourceOfProjectReferenceRedirect',+ 'disableSolutionSearching',+ 'disableReferencedProjectLoad',+ 'target',+ 'jsx',+ 'jsxFactory',+ 'jsxFragmentFactory',+ 'jsxImportSource',+ 'lib',+ 'moduleDetection',+ 'noLib',+ 'reactNamespace',+ 'useDefineForClassFields',+ 'emitDecoratorMetadata',+ 'experimentalDecorators',+ 'libReplacement',+ 'baseUrl',+ 'rootDir',+ 'rootDirs',+ 'customConditions',+ 'module',+ 'moduleResolution',+ 'moduleSuffixes',+ 'noResolve',+ 'paths',+ 'resolveJsonModule',+ 'resolvePackageJsonExports',+ 'resolvePackageJsonImports',+ 'typeRoots',+ 'types',+ 'allowArbitraryExtensions',+ 'allowImportingTsExtensions',+ 'allowUmdGlobalAccess',+ 'allowJs',+ 'checkJs',+ 'maxNodeModuleJsDepth',+ 'strict',+ 'strictBindCallApply',+ 'strictFunctionTypes',+ 'strictNullChecks',+ 'strictPropertyInitialization',+ 'allowUnreachableCode',+ 'allowUnusedLabels',+ 'alwaysStrict',+ 'exactOptionalPropertyTypes',+ 'noFallthroughCasesInSwitch',+ 'noImplicitAny',+ 'noImplicitOverride',+ 'noImplicitReturns',+ 'noImplicitThis',+ 'noPropertyAccessFromIndexSignature',+ 'noUncheckedIndexedAccess',+ 'noUnusedLocals',+ 'noUnusedParameters',+ 'useUnknownInCatchVariables',+ 'declaration',+ 'declarationDir',+ 'declarationMap',+ 'downlevelIteration',+ 'emitBOM',+ 'emitDeclarationOnly',+ 'importHelpers',+ 'importsNotUsedAsValues',+ 'inlineSourceMap',+ 'inlineSources',+ 'mapRoot',+ 'newLine',+ 'noEmit',+ 'noEmitHelpers',+ 'noEmitOnError',+ 'outDir',+ 'outFile',+ 'preserveConstEnums',+ 'preserveValueImports',+ 'removeComments',+ 'sourceMap',+ 'sourceRoot',+ 'stripInternal',+ 'allowSyntheticDefaultImports',+ 'esModuleInterop',+ 'forceConsistentCasingInFileNames',+ 'isolatedDeclarations',+ 'isolatedModules',+ 'preserveSymlinks',+ 'verbatimModuleSyntax',+ 'erasableSyntaxOnly',+ 'skipDefaultLibCheck',+ 'skipLibCheck',+]++const pnpmWorkspaceOrder = [+ 'allowBuilds',+ 'autoInstallPeers',+ 'blockExoticSubdeps',+ 'cacheDir',+ 'catalogMode',+ 'catalogPrune',+ 'cleanupUnusedCatalogs',+ 'dedupeDirectDeps',+ 'deployAllFiles',+ 'enablePrePostScripts',+ 'engineStrict',+ 'extendNodePath',+ 'hoist',+ 'hoistPattern',+ 'hoistWorkspacePackages',+ 'ignoreCompatibilityDb',+ 'ignoreDepScripts',+ 'ignoreScripts',+ 'ignoreWorkspaceRootCheck',+ 'managePackageManagerVersions',+ 'minimumReleaseAge',+ 'minimumReleaseAgeExclude',+ 'modulesDir',+ 'nodeLinker',+ 'nodeVersion',+ 'optimisticRepeatInstall',+ 'packageManagerStrict',+ 'packageManagerStrictVersion',+ 'preferSymlinkedExecutables',+ 'preferWorkspacePackages',+ 'publicHoistPattern',+ 'registrySupportsTimeField',+ 'requiredScripts',+ 'resolutionMode',+ 'saveExact',+ 'savePrefix',+ 'scriptShell',+ 'shamefullyHoist',+ 'shellEmulator',+ 'stateDir',+ 'strictDepBuilds',+ 'supportedArchitectures',+ 'symlink',+ 'tag',+ 'trustPolicy',+ 'trustPolicyExclude',+ 'updateNotifier',+ 'verifyDepsBeforeRun',+ 'packages',+ 'overrides',+ 'patchedDependencies',+ 'catalog',+ 'catalogs',+ 'allowedDeprecatedVersions',+ 'allowNonAppliedPatches',+ 'configDependencies',+ 'ignoredBuiltDependencies',+ 'ignoredOptionalDependencies',+ 'neverBuiltDependencies',+ 'onlyBuiltDependencies',+ 'onlyBuiltDependenciesFile',+ 'packageExtensions',+ 'peerDependencyRules',+]++export default defineConfig([+ globalIgnores(+ [+ '**/*',+ '!cli/',+ '!cli/**/*',+ '!e2e/',+ '!e2e/**/*',+ '!packages/',+ '!packages/**/*',+ '!sdks/',+ '!sdks/nodejs-client/',+ '!sdks/nodejs-client/package.json',+ '!sdks/nodejs-client/src/',+ '!sdks/nodejs-client/src/**/*',+ '!sdks/nodejs-client/tests/',+ '!sdks/nodejs-client/tests/**/*',+ '!web/',+ '!web/**/*',+ '!eslint.config.mjs',+ '!package.json',+ '!pnpm-workspace.yaml',+ '!vite.config.ts',+ ],+ 'Project lint scope',+ ),+ gitignore({+ cwd: repositoryRoot,+ root: true,+ recursive: { skipDirs: ['.venv', 'volumes'] },+ }),+ globalIgnores([codeFiles], 'Migration tradeoff: code files are handled by Oxlint only'),+ globalIgnores(+ [+ '**/.git/**',+ '**/node_modules/**',+ 'cli/context/**',+ 'cli/coverage/**',+ 'cli/dist/**',+ 'cli/docs/**',+ '**/.next/**',+ '**/.vinext/**',+ '**/coverage/**',+ '**/dist/**',+ '**/storybook-static/**',+ 'e2e/.auth/**',+ 'e2e/cucumber-report/**',+ 'packages/contracts/**/*',+ '!packages/contracts/package.json',+ 'web/next/**',+ 'web/next-env.d.ts',+ 'web/public/**',+ 'web/types/doc-paths.ts',+ ],+ 'Generated and external files',+ ),+ {+ linterOptions: {+ reportUnusedDisableDirectives: 'warn',+ },+ },+ {+ files: ['**/*.{json,json5,jsonc}'],+ language: 'jsonc/x',+ plugins: {+ jsonc,+ },+ rules: {+ 'no-unused-expressions': 'off',+ 'no-unused-vars': 'off',+ strict: 'off',+ 'jsonc/no-bigint-literals': 'error',+ 'jsonc/no-binary-expression': 'error',+ 'jsonc/no-binary-numeric-literals': 'error',+ 'jsonc/no-dupe-keys': 'error',+ 'jsonc/no-escape-sequence-in-identifier': 'error',+ 'jsonc/no-floating-decimal': 'error',+ 'jsonc/no-hexadecimal-numeric-literals': 'error',+ 'jsonc/no-infinity': 'error',+ 'jsonc/no-multi-str': 'error',+ 'jsonc/no-nan': 'error',+ 'jsonc/no-number-props': 'error',+ 'jsonc/no-numeric-separators': 'error',+ 'jsonc/no-octal': 'error',+ 'jsonc/no-octal-escape': 'error',+ 'jsonc/no-octal-numeric-literals': 'error',+ 'jsonc/no-parenthesized': 'error',+ 'jsonc/no-plus-sign': 'error',+ 'jsonc/no-regexp-literals': 'error',+ 'jsonc/no-sparse-arrays': 'error',+ 'jsonc/no-template-literals': 'error',+ 'jsonc/no-undefined-value': 'error',+ 'jsonc/no-unicode-codepoint-escapes': 'error',+ 'jsonc/no-useless-escape': 'error',+ 'jsonc/valid-json-number': 'error',+ 'jsonc/vue-custom-block/no-parsing-error': 'error',+ },+ },+ {+ files: ['**/package.json'],+ rules: {+ 'jsonc/sort-array-values': [+ 'error',+ {+ order: { type: 'asc' },+ pathPattern: '^files$',+ },+ ],+ },+ },+ {+ files: ['**/[jt]sconfig.json', '**/[jt]sconfig.*.json'],+ rules: {+ 'jsonc/sort-keys': [+ 'error',+ {+ order: ['extends', 'compilerOptions', 'references', 'files', 'include', 'exclude'],+ pathPattern: '^$',+ },+ {+ order: tsconfigCompilerOptionsOrder,+ pathPattern: '^compilerOptions$',+ },+ ],+ },+ },+ {+ files: ['package.json', '**/package.json'],+ plugins: {+ pnpm,+ },+ rules: {+ 'pnpm/json-enforce-catalog': [+ 'error',+ {+ allowedProtocols: ['workspace'],+ autofix: true,+ conflicts: 'error',+ fields: ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'],+ },+ ],+ 'pnpm/json-prefer-workspace-settings': ['error', { autofix: true }],+ 'pnpm/json-valid-catalog': ['error', { autofix: true }],+ },+ },+ {+ files: ['**/*.{yml,yaml}'],+ language: 'yml/yaml',+ plugins: {+ yml,+ },+ rules: {+ 'no-irregular-whitespace': 'off',+ 'no-unused-vars': 'off',+ 'spaced-comment': 'off',+ 'yml/no-empty-key': 'error',+ 'yml/no-empty-sequence-entry': 'error',+ 'yml/no-irregular-whitespace': 'error',+ 'yml/vue-custom-block/no-parsing-error': 'error',+ },+ },+ {+ files: ['pnpm-workspace.yaml'],+ plugins: {+ pnpm,+ },+ rules: {+ 'pnpm/yaml-enforce-settings': [+ 'error',+ {+ settings: {+ catalogMode: 'strict',+ shellEmulator: true,+ trustPolicy: 'no-downgrade',+ },+ },+ ],+ 'pnpm/yaml-no-duplicate-catalog-item': 'error',+ 'pnpm/yaml-no-unused-catalog-item': 'error',+ 'yml/sort-keys': [+ 'error',+ {+ order: pnpmWorkspaceOrder,+ pathPattern: '^$',+ },+ {+ order: { type: 'asc' },+ pathPattern: '.*',+ },+ ],+ },+ },+ {+ files: ['**/*.md'],+ language: 'markdown/gfm',+ plugins: {+ markdown,+ 'markdown-preferences': markdownPreferences,+ md: mdPlugin,+ },+ rules: {+ 'markdown/fenced-code-language': 'off',+ 'markdown/heading-increment': 'error',+ 'markdown/no-duplicate-definitions': 'error',+ 'markdown/no-empty-definitions': 'error',+ 'markdown/no-empty-images': 'error',+ 'markdown/no-empty-links': 'error',+ 'markdown/no-invalid-label-refs': 'error',+ 'markdown/no-missing-atx-heading-space': 'error',+ 'markdown/no-missing-label-refs': 'off',+ 'markdown/no-missing-link-fragments': 'error',+ 'markdown/no-multiple-h1': 'error',+ 'markdown/no-reference-like-urls': 'error',+ 'markdown/no-reversed-media-syntax': 'error',+ 'markdown/no-space-in-emphasis': 'error',+ 'markdown/no-unused-definitions': 'error',+ 'markdown/require-alt-text': 'error',+ 'markdown/table-column-count': 'error',+ 'markdown-preferences/definitions-last': 'error',+ 'markdown-preferences/prefer-link-reference-definitions': [+ 'error',+ {+ minLinks: 1,+ },+ ],+ 'markdown-preferences/sort-definitions': 'error',+ 'md/no-url-trailing-slash': 'error',+ },+ },+ {+ files: ['web/i18n/locales/**/*.json'],+ plugins: {+ dify,+ },+ rules: {+ 'dify/consistent-placeholders': 'error',+ 'dify/i18n-flat-key': 'error',+ 'dify/no-extra-keys': 'error',+ 'jsonc/sort-keys': 'error',+ },+ },+])diff --git a/web/scripts/check-i18n-plurals.ts b/packages/tooling/i18n-plurals.tssimilarity index 100%rename from web/scripts/check-i18n-plurals.tsrename to packages/tooling/i18n-plurals.tsdiff --git a/packages/tooling/knip.config.ts b/packages/tooling/knip.config.tsnew file mode 100644index 00000000000..b9c79e0b994--- /dev/null+++ b/packages/tooling/knip.config.ts@@ -0,0 +1,59 @@+import type { KnipConfig } from 'knip'++/**+ * @see https://knip.dev/reference/configuration+ */+const config: KnipConfig = {+ compilers: {+ mdx: true,+ },+ workspaces: {+ web: {+ entry: [+ 'scripts/**/*.{js,ts,mjs}',+ 'bin/**/*.{js,ts,mjs}',+ 'tsslint.config.ts',+ 'dev-proxy.config.ts',+ // Public surface consumed by the standalone Marketplace host.+ // The `!` suffix keeps these entries in `knip --production`.+ 'app/components/plugins/marketplace/detail-dialog/image-preview-message.ts!',+ 'app/components/plugins/marketplace/standalone/server.ts!',+ 'app/components/plugins/marketplace/standalone/client.ts!',+ ],+ project: [+ '**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts,css,mdx}!',+ '!**/__mocks__/**!',+ '!**/__tests__/**!',+ '!**/*.stories.{js,jsx,ts,tsx,mdx}!',+ '!.storybook/**!',+ '!plugins/**!',+ '!test/**!',+ '!vitest.browser.setup.ts!',+ '!vitest.setup.ts!',+ ],+ ignore: ['public/**'],+ ignoreFiles: ['i18n/locale-resources/*.ts'],+ ignoreDependencies: ['@iconify-json/*', '@storybook/addon-onboarding'],+ },+ },+ /// keep-sorted+ rules: {+ binaries: 'warn',+ catalog: 'error',+ dependencies: 'error',+ devDependencies: 'warn',+ duplicates: 'error',+ enumMembers: 'error',+ exports: 'error',+ files: 'error',+ namespaceMembers: 'error',+ nsExports: 'error',+ nsTypes: 'error',+ optionalPeerDependencies: 'error',+ types: 'error',+ unlisted: 'error',+ unresolved: 'error',+ },+}++export default configdiff --git a/lint.config.ts b/packages/tooling/lint.config.tssimilarity index 99%rename from lint.config.tsrename to packages/tooling/lint.config.tsindex 2d623989777..a43be5ebc55 100644--- a/lint.config.ts+++ b/packages/tooling/lint.config.ts@@ -2,8 +2,10 @@import type { OxlintConfig } from 'vite-plus/lint'import path from 'node:path'+import { fileURLToPath } from 'node:url'+import { repositoryRoot } from './paths.ts'-const rootDir = import.meta.dirname+const rootDir = repositoryRootconst webPackageJson = path.resolve(rootDir, 'web/package.json')const difyUiPackageJson = path.resolve(rootDir, 'packages/dify-ui/package.json')const enableTailwindCanonicalClasses = process.env.TAILWIND_CANONICAL_CLASSES === 'true'@@ -229,7 +231,6 @@ export const lintConfig = {'docker/**','docs/**','scripts/**/*',- '!scripts/check-web-production-unused-after-knip-fix.mjs','sdks/php-client/**','sdks/python-client/**','**/.next/**',@@ -256,7 +257,7 @@ export const lintConfig = {...(enableTailwindCanonicalClasses ? ['eslint-plugin-better-tailwindcss'] : []),{name: 'dify',- specifier: './web/plugins/eslint/index.js',+ specifier: './plugins/eslint/index.js',},{name: 'eslint-react',@@ -274,7 +275,11 @@ export const lintConfig = {'eslint-plugin-perfectionist','eslint-plugin-regexp','eslint-plugin-storybook',- ],+ ].map((plugin) =>+ typeof plugin === 'string'+ ? fileURLToPath(import.meta.resolve(plugin))+ : { ...plugin, specifier: fileURLToPath(import.meta.resolve(plugin.specifier)) },+ ),options: {reportUnusedDisableDirectives: 'error',respectEslintDisableDirectives: false,diff --git a/web/oxlint.unused.config.json b/packages/tooling/oxlint.unused.config.jsonsimilarity index 100%rename from web/oxlint.unused.config.jsonrename to packages/tooling/oxlint.unused.config.jsondiff --git a/packages/tooling/package.json b/packages/tooling/package.jsonnew file mode 100644index 00000000000..46c3b2eae13--- /dev/null+++ b/packages/tooling/package.json@@ -0,0 +1,53 @@+{+ "name": "@dify/tooling",+ "version": "0.0.0-private",+ "private": true,+ "type": "module",+ "exports": {+ "./eslint": "./eslint.mjs",+ "./oxlint": "./lint.config.ts",+ "./tsslint": "./tsslint.config.ts",+ "./knip": "./knip.config.ts",+ "./repository": "./repository.config.ts",+ "./eslint-plugin": "./plugins/eslint/index.js",+ "./i18n-plurals": "./i18n-plurals.ts"+ },+ "scripts": {+ "test": "vp test",+ "type-check": "tsc --noEmit"+ },+ "dependencies": {+ "@eslint-react/eslint-plugin": "catalog:",+ "@eslint/markdown": "catalog:",+ "@shadcn/lint": "catalog:",+ "@tanstack/eslint-plugin-query": "catalog:",+ "@tsslint/compat-eslint": "catalog:",+ "@tsslint/config": "catalog:",+ "@typescript-eslint/parser": "catalog:",+ "eslint-config-flat-gitignore": "catalog:",+ "eslint-markdown": "catalog:",+ "eslint-plugin-antfu": "catalog:",+ "eslint-plugin-better-tailwindcss": "catalog:",+ "eslint-plugin-jsdoc": "catalog:",+ "eslint-plugin-jsonc": "catalog:",+ "eslint-plugin-markdown-preferences": "catalog:",+ "eslint-plugin-n": "catalog:",+ "eslint-plugin-no-barrel-files": "catalog:",+ "eslint-plugin-perfectionist": "catalog:",+ "eslint-plugin-pnpm": "catalog:",+ "eslint-plugin-regexp": "catalog:",+ "eslint-plugin-storybook": "catalog:",+ "eslint-plugin-yml": "catalog:",+ "typescript": "catalog:",+ "vite-plus": "catalog:"+ },+ "devDependencies": {+ "@dify/tsconfig": "workspace:*",+ "@types/node": "catalog:",+ "vite": "catalog:"+ },+ "peerDependencies": {+ "eslint": "catalog:",+ "knip": "catalog:"+ }+}diff --git a/packages/tooling/paths.ts b/packages/tooling/paths.tsnew file mode 100644index 00000000000..f882deb1716--- /dev/null+++ b/packages/tooling/paths.ts@@ -0,0 +1,3 @@+import path from 'node:path'++export const repositoryRoot = path.resolve(import.meta.dirname, '../..')diff --git a/web/plugins/eslint/hint-content.test.ts b/packages/tooling/plugins/eslint/hint-content.test.tssimilarity index 99%rename from web/plugins/eslint/hint-content.test.tsrename to packages/tooling/plugins/eslint/hint-content.test.tsindex e873e98ed1e..65ec1d4ca2b 100644--- a/web/plugins/eslint/hint-content.test.ts+++ b/packages/tooling/plugins/eslint/hint-content.test.ts@@ -4,7 +4,7 @@ import { createRequire } from 'node:module'import { tmpdir } from 'node:os'import { dirname, join } from 'node:path'import { expect, it } from 'vite-plus/test'-import { stylingContractRules } from '../../../lint.config'+import { stylingContractRules } from '../../lint.config'function lintFixture(source: string) {const require = createRequire(import.meta.url)diff --git a/web/plugins/eslint/index.js b/packages/tooling/plugins/eslint/index.jssimilarity index 100%rename from web/plugins/eslint/index.jsrename to packages/tooling/plugins/eslint/index.jsdiff --git a/web/plugins/eslint/rules/consistent-placeholders.js b/packages/tooling/plugins/eslint/rules/consistent-placeholders.jssimilarity index 98%rename from web/plugins/eslint/rules/consistent-placeholders.jsrename to packages/tooling/plugins/eslint/rules/consistent-placeholders.jsindex 9340cb17eb7..0c08eae5a15 100644--- a/web/plugins/eslint/rules/consistent-placeholders.js+++ b/packages/tooling/plugins/eslint/rules/consistent-placeholders.js@@ -1,6 +1,6 @@import fs from 'node:fs'import path, { normalize, sep } from 'node:path'-import { getTranslationSourceKey } from '../../../scripts/check-i18n-plurals.ts'+import { getTranslationSourceKey } from '../../../i18n-plurals.ts'import { cleanJsonText } from '../utils.js'function extractPlaceholders(str) {diff --git a/web/plugins/eslint/rules/fixtures/truncation.module.css b/packages/tooling/plugins/eslint/rules/fixtures/truncation.module.csssimilarity index 100%rename from web/plugins/eslint/rules/fixtures/truncation.module.cssrename to packages/tooling/plugins/eslint/rules/fixtures/truncation.module.cssdiff --git a/web/plugins/eslint/rules/i18n-flat-key.js b/packages/tooling/plugins/eslint/rules/i18n-flat-key.jssimilarity index 100%rename from web/plugins/eslint/rules/i18n-flat-key.jsrename to packages/tooling/plugins/eslint/rules/i18n-flat-key.jsdiff --git a/web/plugins/eslint/rules/no-extra-keys.js b/packages/tooling/plugins/eslint/rules/no-extra-keys.jssimilarity index 96%rename from web/plugins/eslint/rules/no-extra-keys.jsrename to packages/tooling/plugins/eslint/rules/no-extra-keys.jsindex 7e2302b816f..439bbda6394 100644--- a/web/plugins/eslint/rules/no-extra-keys.js+++ b/packages/tooling/plugins/eslint/rules/no-extra-keys.js@@ -1,6 +1,6 @@import fs from 'node:fs'import path, { normalize, sep } from 'node:path'-import { getTranslationSourceKey } from '../../../scripts/check-i18n-plurals.ts'+import { getTranslationSourceKey } from '../../../i18n-plurals.ts'/** @type {import('eslint').Rule.RuleModule} */export default {diff --git a/web/plugins/eslint/rules/no-extra-keys.test.js b/packages/tooling/plugins/eslint/rules/no-extra-keys.test.jssimilarity index 100%rename from web/plugins/eslint/rules/no-extra-keys.test.jsrename to packages/tooling/plugins/eslint/rules/no-extra-keys.test.jsdiff --git a/web/plugins/eslint/rules/no-file-wide-disable.js b/packages/tooling/plugins/eslint/rules/no-file-wide-disable.jssimilarity index 93%rename from web/plugins/eslint/rules/no-file-wide-disable.jsrename to packages/tooling/plugins/eslint/rules/no-file-wide-disable.jsindex 2c68f8d244f..28dd670d809 100644--- a/web/plugins/eslint/rules/no-file-wide-disable.js+++ b/packages/tooling/plugins/eslint/rules/no-file-wide-disable.js@@ -5,7 +5,7 @@ export default {schema: [],messages: {fileWideDisable:- 'File-wide disables are forbidden. Use a matching enable, or baseline existing errors with `vp run -w lint:oxlint <path> --suppress-all`. For intentional file exclusions, configure lint.config.ts with a reason.',+ 'File-wide disables are forbidden. Use a matching enable, or baseline existing errors with `vp run -w lint:oxlint <path> --suppress-all`. For intentional file exclusions, configure packages/tooling/lint.config.ts with a reason.',},},create(context) {diff --git a/web/plugins/eslint/rules/prefer-tailwind-icons.js b/packages/tooling/plugins/eslint/rules/prefer-tailwind-icons.jssimilarity index 100%rename from web/plugins/eslint/rules/prefer-tailwind-icons.jsrename to packages/tooling/plugins/eslint/rules/prefer-tailwind-icons.jsdiff --git a/web/plugins/eslint/rules/require-disable-directive-description.js b/packages/tooling/plugins/eslint/rules/require-disable-directive-description.jssimilarity index 100%rename from web/plugins/eslint/rules/require-disable-directive-description.jsrename to packages/tooling/plugins/eslint/rules/require-disable-directive-description.jsdiff --git a/web/plugins/eslint/rules/require-disable-directive-description.test.js b/packages/tooling/plugins/eslint/rules/require-disable-directive-description.test.jssimilarity index 100%rename from web/plugins/eslint/rules/require-disable-directive-description.test.jsrename to packages/tooling/plugins/eslint/rules/require-disable-directive-description.test.jsdiff --git a/web/plugins/eslint/rules/require-i18n-namespace.js b/packages/tooling/plugins/eslint/rules/require-i18n-namespace.jssimilarity index 100%rename from web/plugins/eslint/rules/require-i18n-namespace.jsrename to packages/tooling/plugins/eslint/rules/require-i18n-namespace.jsdiff --git a/web/plugins/eslint/rules/require-i18n-namespace.test.js b/packages/tooling/plugins/eslint/rules/require-i18n-namespace.test.jssimilarity index 100%rename from web/plugins/eslint/rules/require-i18n-namespace.test.jsrename to packages/tooling/plugins/eslint/rules/require-i18n-namespace.test.jsdiff --git a/web/plugins/eslint/rules/require-t-function-namespace.js b/packages/tooling/plugins/eslint/rules/require-t-function-namespace.jssimilarity index 100%rename from web/plugins/eslint/rules/require-t-function-namespace.jsrename to packages/tooling/plugins/eslint/rules/require-t-function-namespace.jsdiff --git a/web/plugins/eslint/rules/require-t-function-namespace.test.js b/packages/tooling/plugins/eslint/rules/require-t-function-namespace.test.jssimilarity index 100%rename from web/plugins/eslint/rules/require-t-function-namespace.test.jsrename to packages/tooling/plugins/eslint/rules/require-t-function-namespace.test.jsdiff --git a/web/plugins/eslint/rules/require-title-for-truncated-text.js b/packages/tooling/plugins/eslint/rules/require-title-for-truncated-text.jssimilarity index 100%rename from web/plugins/eslint/rules/require-title-for-truncated-text.jsrename to packages/tooling/plugins/eslint/rules/require-title-for-truncated-text.jsdiff --git a/web/plugins/eslint/rules/require-title-for-truncated-text.test.js b/packages/tooling/plugins/eslint/rules/require-title-for-truncated-text.test.jssimilarity index 97%rename from web/plugins/eslint/rules/require-title-for-truncated-text.test.jsrename to packages/tooling/plugins/eslint/rules/require-title-for-truncated-text.test.jsindex f5906d1db0b..e62b2c5fb2e 100644--- a/web/plugins/eslint/rules/require-title-for-truncated-text.test.js+++ b/packages/tooling/plugins/eslint/rules/require-title-for-truncated-text.test.js@@ -3,6 +3,7 @@ import { resolve } from 'node:path'import tsParser from '@typescript-eslint/parser'import { Linter } from 'eslint'import { it } from 'vite-plus/test'+import { repositoryRoot } from '../../../paths.ts'import rule from './require-title-for-truncated-text.js'import './fixtures/truncation.module.css'@@ -13,7 +14,7 @@ const plugin = {}function verifyAndFix(code, filename = 'test.tsx') {- const linter = new Linter({ cwd: resolve('..') })+ const linter = new Linter({ cwd: repositoryRoot })return linter.verifyAndFix(code,[@@ -172,7 +173,7 @@ it('reports a single nested text child or a text-bearing prop without fixing', (})it('checks Dify UI single text but ignores multiple text children', () => {- const filename = resolve('../packages/dify-ui/src/example.tsx')+ const filename = resolve(repositoryRoot, 'packages/dify-ui/src/example.tsx')const result = verifyAndFix(`export const Example = ({ primary, secondary }) => <>@@ -208,7 +209,7 @@ it('does not count non-text conditional children as additional text', () => {})it('resolves truncation classes imported from CSS modules', () => {- const filename = resolve('plugins/eslint/rules/fixtures/example.tsx')+ const filename = resolve(import.meta.dirname, 'fixtures/example.tsx')const result = verifyAndFix(`import styles from './truncation.module.css'diff --git a/web/plugins/eslint/utils.js b/packages/tooling/plugins/eslint/utils.jssimilarity index 100%rename from web/plugins/eslint/utils.jsrename to packages/tooling/plugins/eslint/utils.jsdiff --git a/web/plugins/tsslint/no-unnecessary-type-assertion.test.ts b/packages/tooling/plugins/tsslint/no-unnecessary-type-assertion.test.tssimilarity index 100%rename from web/plugins/tsslint/no-unnecessary-type-assertion.test.tsrename to packages/tooling/plugins/tsslint/no-unnecessary-type-assertion.test.tsdiff --git a/web/plugins/tsslint/no-unnecessary-type-assertion.ts b/packages/tooling/plugins/tsslint/no-unnecessary-type-assertion.tssimilarity index 100%rename from web/plugins/tsslint/no-unnecessary-type-assertion.tsrename to packages/tooling/plugins/tsslint/no-unnecessary-type-assertion.tsdiff --git a/web/plugins/tsslint/test-utils.ts b/packages/tooling/plugins/tsslint/test-utils.tssimilarity index 100%rename from web/plugins/tsslint/test-utils.tsrename to packages/tooling/plugins/tsslint/test-utils.tsdiff --git a/packages/tooling/repository.config.ts b/packages/tooling/repository.config.tsnew file mode 100644index 00000000000..3d2693ac14c--- /dev/null+++ b/packages/tooling/repository.config.ts@@ -0,0 +1,103 @@+import { defineConfig } from 'vite-plus'+import { lintConfig } from './lint.config.ts'++const lintFiles = '*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'+const eslintFiles = '*.{json,jsonc,json5,md,yml,yaml}'+const formatOnlyFiles = '*.{mdx,css,scss,less,html,vue,svelte,gql,graphql,hbs,handlebars}'+const checkFix = 'vp check --fix --no-error-on-unmatched-pattern'+const formatFix = 'vp fmt --no-error-on-unmatched-pattern'+const eslintFix =+ 'eslint --fix --pass-on-unpruned-suppressions --no-error-on-unmatched-pattern --no-warn-ignored'++const nonFrontendIgnores = [+ '.agents/**',+ '.devcontainer/**',+ '/*.md',+ 'api/**',+ 'codecov.yml',+ 'depot.json',+ 'dify-agent/**',+ 'docker/**',+ 'docs/**',+ 'scripts/**/*',+ 'sdks/php-client/**',+ 'sdks/python-client/**',+]++const generatedIgnores = [+ '**/.next/**',+ '**/.vinext/**',+ '**/coverage/**',+ '**/dist/**',+ '**/storybook-static/**',+ 'e2e/.auth/**',+ 'e2e/cucumber-report/**',+ 'eslint-suppressions.json',+ 'oxlint-suppressions.json',+ 'web/next/**',+ 'web/next-env.d.ts',+ 'web/public/embed.min.js',+ 'web/public/pdf.worker.min.mjs',+ 'web/public/vs/**',+ // Vendored Emojibase JSON is served verbatim.+ 'web/public/emoji/emojibase-*/**',+]++const formatterUnstableInputs = ['web/app/components/develop/template/*.mdx']++export default defineConfig({+ lint: lintConfig,+ run: {+ tasks: {+ 'check:cached': {+ command: ['vp check', 'eslint --concurrency=auto'],+ cache: {+ env: ['CI', 'NODE_ENV', 'TAILWIND_CANONICAL_CLASSES'],+ // Static checks have no artifacts to restore into the working tree.+ output: [],+ },+ },+ },+ },+ staged: {+ [lintFiles]: checkFix,+ [eslintFiles]: [eslintFix, formatFix],+ [formatOnlyFiles]: formatFix,+ '.vite-hooks/*': 'sh -n',+ 'api/**/*.{py,pyi}': [+ // Format first so fixable long lines do not fail the API's E501 check.+ 'uv run --locked --project api --dev ruff format --force-exclude',+ 'uv run --locked --project api --dev ruff check --fix --force-exclude',+ 'uv run --locked --project api --dev ruff format --force-exclude',+ ],+ 'dify-agent/{src,examples,tests,docs}/**/*.py': [+ 'uv run --locked --project dify-agent --dev ruff check --fix --force-exclude',+ 'uv run --locked --project dify-agent --dev ruff format --force-exclude',+ ],+ },+ fmt: {+ ignorePatterns: [...nonFrontendIgnores, ...generatedIgnores, ...formatterUnstableInputs],+ singleQuote: true,+ semi: false,+ sortImports: {+ groups: [+ 'type-import',+ ['type-parent', 'type-sibling', 'type-index', 'type-internal', 'type-subpath'],+ 'value-builtin',+ 'value-external',+ ['value-internal', 'value-subpath'],+ ['value-parent', 'value-sibling', 'value-index'],+ ['side_effect_style', 'side_effect'],+ 'unknown',+ ],+ newlinesBetween: false,+ sortSideEffects: false,+ },+ sortPackageJson: true,+ sortTailwindcss: {+ functions: ['cn', 'clsx', 'cva', 'tw', 'twMerge'],+ preserveDuplicates: false,+ stylesheet: 'web/app/styles/globals.css',+ },+ },+})diff --git a/scripts/check-web-production-unused-after-knip-fix.mjs b/packages/tooling/scripts/check-web-production-unused-after-knip-fix.mjssimilarity index 87%rename from scripts/check-web-production-unused-after-knip-fix.mjsrename to packages/tooling/scripts/check-web-production-unused-after-knip-fix.mjsindex 5be4d63746d..ec53f523ccc 100644--- a/scripts/check-web-production-unused-after-knip-fix.mjs+++ b/packages/tooling/scripts/check-web-production-unused-after-knip-fix.mjs@@ -3,11 +3,12 @@ import { realpathSync } from 'node:fs'import { createRequire } from 'node:module'import path from 'node:path'import { fileURLToPath } from 'node:url'+import unusedConfig from '../oxlint.unused.config.json' with { type: 'json' }const scriptDir = path.dirname(fileURLToPath(import.meta.url))-const repoRoot = path.resolve(scriptDir, '..')+const repoRoot = path.resolve(scriptDir, '../../..')const webDir = path.join(repoRoot, 'web')-const unusedLintConfig = path.join(webDir, 'oxlint.unused.config.json')+const unusedLintConfig = path.resolve(scriptDir, '../oxlint.unused.config.json')const require = createRequire(import.meta.url)const vitePlusEntry = realpathSync(require.resolve('vite-plus'))const vitePlusRequire = createRequire(vitePlusEntry)@@ -19,10 +20,6 @@ const oxlintBin =if (!oxlintBin) throw new Error('Unable to resolve the bundled Oxlint executable.')const oxlint = path.resolve(path.dirname(oxlintPackagePath), oxlintBin)-function commandName(name) {- return process.platform === 'win32' ? `${name}.cmd` : name-}-function run(command, args, options = {}) {return new Promise((resolve, reject) => {const child = spawn(command, args, {@@ -96,7 +93,7 @@ async function restoreWorktree() {}}-const knip = path.join(repoRoot, 'node_modules', '.bin', commandName('knip'))+const knip = fileURLToPath(new URL('../bin/knip.js', import.meta.resolve('knip')))let shouldRestore = falselet hasUnusedMessages = false@@ -105,9 +102,13 @@ try {shouldRestore = trueconsole.log('Running knip --production --fix...')- const knipResult = await run(knip, ['--workspace', 'web', '--production', '--fix'], {- cwd: repoRoot,- })+ const knipResult = await run(+ process.execPath,+ [knip, '--workspace', 'web', '--production', '--fix'],+ {+ cwd: repoRoot,+ },+ )if (knipResult.status !== 0) {process.stdout.write(knipResult.stdout)process.stderr.write(knipResult.stderr)@@ -117,7 +118,16 @@ try {console.log('Running isolated Oxlint unused checks after knip --fix...')const lintResult = await run(process.execPath,- [oxlint, '--config', unusedLintConfig, '--format', 'json', '.'],+ [+ oxlint,+ '--config',+ unusedLintConfig,+ // CLI ignore patterns are relative to Web's cwd, not the shared config directory.+ ...unusedConfig.ignorePatterns.flatMap((pattern) => ['--ignore-pattern', pattern]),+ '--format',+ 'json',+ '.',+ ],{ cwd: webDir },)diff --git a/web/scripts/lint-a11y.mjs b/packages/tooling/scripts/lint-a11y.mjssimilarity index 97%rename from web/scripts/lint-a11y.mjsrename to packages/tooling/scripts/lint-a11y.mjsindex 5044ef1527d..43ee48bf762 100644--- a/web/scripts/lint-a11y.mjs+++ b/packages/tooling/scripts/lint-a11y.mjs@@ -5,9 +5,9 @@ import path from 'node:path'import process from 'node:process'import ts from 'typescript'-const webRoot = path.resolve(import.meta.dirname, '..')+const webRoot = path.resolve(import.meta.dirname, '../../../web')const repositoryRoot = path.resolve(webRoot, '..')-const configPath = path.resolve(import.meta.dirname, 'a11y', 'oxlint.config.ts')+const configPath = path.resolve(import.meta.dirname, '../a11y.config.ts')const require = createRequire(import.meta.url)const vitePlusRequire = createRequire(require.resolve('vite-plus/package.json'))const oxlintPackageDirectory = path.dirname(vitePlusRequire.resolve('oxlint/package.json'))diff --git a/packages/tooling/tsconfig.json b/packages/tooling/tsconfig.jsonnew file mode 100644index 00000000000..2b8337e5ff9--- /dev/null+++ b/packages/tooling/tsconfig.json@@ -0,0 +1,7 @@+{+ "extends": "@dify/tsconfig/node.json",+ "compilerOptions": {+ "allowImportingTsExtensions": true+ },+ "include": ["**/*.ts", "**/*.js", "**/*.mjs"]+}diff --git a/packages/tooling/tsslint.config.ts b/packages/tooling/tsslint.config.tsnew file mode 100644index 00000000000..94f4c45190f--- /dev/null+++ b/packages/tooling/tsslint.config.ts@@ -0,0 +1,18 @@+import { defineConfig, importESLintRules } from '@tsslint/config'+import noUnnecessaryTypeAssertion from './plugins/tsslint/no-unnecessary-type-assertion.ts'++// Migration-only rules stay out of the regular `lint:tss` run; see `migrate:type-assertions`.+const enableTypeAssertionMigration = process.env.TSSLINT_TYPE_ASSERTION_MIGRATION === 'true'++// Run `npx tsslint-docgen` to generate documentation for the configured rules.++export default defineConfig({+ rules: {+ ...(await importESLintRules({+ 'react-x/no-leaked-conditional-rendering': 'error',+ })),+ ...(enableTypeAssertionMigration+ ? { dify: { 'no-unnecessary-type-assertion': noUnnecessaryTypeAssertion } }+ : {}),+ },+})diff --git a/packages/tooling/vite.config.ts b/packages/tooling/vite.config.tsnew file mode 100644index 00000000000..0766d7e9fe2--- /dev/null+++ b/packages/tooling/vite.config.ts@@ -0,0 +1,8 @@+import { defineConfig } from 'vite-plus'++export default defineConfig({+ test: {+ environment: 'node',+ restoreMocks: true,+ },+})diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3f9d00b1710..d226e57078f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -796,30 +796,18 @@ importers:.:devDependencies:- '@eslint-react/eslint-plugin':- specifier: 'catalog:'- version: 5.28.1(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])- '@eslint/markdown':- specifier: 'catalog:'- version: 8.0.3([email protected])+ '@dify/tooling':+ specifier: workspace:*+ version: link:packages/tooling'@iconify-json/heroicons':specifier: 'catalog:'version: 1.2.3'@iconify-json/ri':specifier: 'catalog:'version: 1.2.10- '@shadcn/lint':- specifier: 'catalog:'- version: 0.2.1(@typescript-eslint/[email protected](@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected]))([email protected]([email protected])([email protected]))- '@tanstack/eslint-plugin-query':- specifier: 'catalog:'- version: 5.104.4(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])'@types/node':specifier: 'catalog:'version: 25.9.9- '@typescript-eslint/parser':- specifier: 'catalog:'- version: 8.71.2(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])'@typescript/native':specifier: 'catalog:'version: [email protected]@@ -829,48 +817,6 @@ importers:eslint:specifier: 'catalog:'version: 10.13.0([email protected])([email protected])- eslint-config-flat-gitignore:- specifier: 'catalog:'- eslint-markdown:- specifier: 'catalog:'- version: 0.19.0(@eslint/[email protected]([email protected]))([email protected]([email protected])([email protected]))- eslint-plugin-antfu:- specifier: 'catalog:'- eslint-plugin-better-tailwindcss:- specifier: 'catalog:'- version: 4.9.1(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected]([email protected])([email protected](@types/[email protected])(@typescript/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@volar/[email protected](@typescript/[email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected])- eslint-plugin-jsdoc:- specifier: 'catalog:'- version: 65.3.12(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])- eslint-plugin-jsonc:- specifier: 'catalog:'- eslint-plugin-markdown-preferences:- specifier: 'catalog:'- version: 0.42.0(@eslint/[email protected]([email protected]))([email protected]([email protected])([email protected]))([email protected])- eslint-plugin-n:- specifier: 'catalog:'- version: 18.5.0(@typescript/[email protected])([email protected]([email protected])([email protected]))- eslint-plugin-no-barrel-files:- specifier: 'catalog:'- version: 2.2.0(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])- eslint-plugin-perfectionist:- specifier: 'catalog:'- version: 5.12.1(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])- eslint-plugin-pnpm:- specifier: 'catalog:'- eslint-plugin-regexp:- specifier: 'catalog:'- eslint-plugin-storybook:- specifier: 'catalog:'- version: 10.6.2(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])- eslint-plugin-yml:- specifier: 'catalog:'knip:specifier: 'catalog:'version: 6.42.0@@ -1331,6 +1277,88 @@ importers:specifier: 'catalog:'version: 1.3.0(@types/[email protected])(@typescript/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@volar/[email protected](@typescript/[email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ packages/tooling:+ dependencies:+ '@eslint-react/eslint-plugin':+ specifier: 'catalog:'+ version: 5.28.1(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])+ '@eslint/markdown':+ specifier: 'catalog:'+ version: 8.0.3([email protected])+ '@shadcn/lint':+ specifier: 'catalog:'+ version: 0.2.1(@typescript-eslint/[email protected](@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected]))([email protected]([email protected])([email protected]))+ '@tanstack/eslint-plugin-query':+ specifier: 'catalog:'+ version: 5.104.4(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])+ '@tsslint/compat-eslint':+ specifier: 'catalog:'+ version: 3.1.4(@typescript/[email protected])+ '@tsslint/config':+ specifier: 'catalog:'+ version: 3.1.4(@tsslint/[email protected](@typescript/[email protected]))+ '@typescript-eslint/parser':+ specifier: 'catalog:'+ version: 8.71.2(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])+ eslint-config-flat-gitignore:+ specifier: 'catalog:'+ eslint-markdown:+ specifier: 'catalog:'+ version: 0.19.0(@eslint/[email protected]([email protected]))([email protected]([email protected])([email protected]))+ eslint-plugin-antfu:+ specifier: 'catalog:'+ eslint-plugin-better-tailwindcss:+ specifier: 'catalog:'+ version: 4.9.1(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected]([email protected])([email protected](@types/[email protected])(@typescript/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@volar/[email protected](@typescript/[email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected])+ eslint-plugin-jsdoc:+ specifier: 'catalog:'+ version: 65.3.12(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])+ eslint-plugin-jsonc:+ specifier: 'catalog:'+ eslint-plugin-markdown-preferences:+ specifier: 'catalog:'+ version: 0.42.0(@eslint/[email protected]([email protected]))([email protected]([email protected])([email protected]))([email protected])+ eslint-plugin-n:+ specifier: 'catalog:'+ version: 18.5.0(@typescript/[email protected])([email protected]([email protected])([email protected]))+ eslint-plugin-no-barrel-files:+ specifier: 'catalog:'+ version: 2.2.0(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])+ eslint-plugin-perfectionist:+ specifier: 'catalog:'+ version: 5.12.1(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])+ eslint-plugin-pnpm:+ specifier: 'catalog:'+ eslint-plugin-regexp:+ specifier: 'catalog:'+ eslint-plugin-storybook:+ specifier: 'catalog:'+ version: 10.6.2(@typescript/[email protected])([email protected]([email protected])([email protected]))([email protected])+ eslint-plugin-yml:+ specifier: 'catalog:'+ typescript:+ specifier: 'catalog:'+ version: '@typescript/[email protected]'+ vite-plus:+ specifier: 'catalog:'+ version: 1.3.0(@types/[email protected])(@typescript/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@vitest/[email protected])(@volar/[email protected](@typescript/[email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ devDependencies:+ '@dify/tsconfig':+ specifier: workspace:*+ version: link:../tsconfig+ '@types/node':+ specifier: 'catalog:'+ version: 25.9.9+ vite:+ specifier: 'catalog:'+ version: '@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])(@volar/[email protected](@typescript/[email protected]))([email protected])([email protected])([email protected])([email protected])'+packages/tsconfig: {}sdks/nodejs-client:@@ -1681,6 +1709,9 @@ importers:'@dify/iconify-collections':specifier: workspace:*version: link:../packages/iconify-collections+ '@dify/tooling':+ specifier: workspace:*+ version: link:../packages/tooling'@dify/tsconfig':specifier: workspace:*version: link:../packages/tsconfig@@ -1738,12 +1769,6 @@ importers:'@tsslint/cli':specifier: 'catalog:'version: 3.1.4(@tsslint/[email protected](@typescript/[email protected]))(@typescript/[email protected])- '@tsslint/compat-eslint':- specifier: 'catalog:'- version: 3.1.4(@typescript/[email protected])- '@tsslint/config':- specifier: 'catalog:'- version: 3.1.4(@tsslint/[email protected](@typescript/[email protected]))'@types/js-cookie':specifier: 'catalog:'version: 3.0.6diff --git a/vite.config.ts b/vite.config.tsindex 82343d3205b..ef4f551745f 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -1,104 +1 @@-import { defineConfig } from 'vite-plus'-import { lintConfig } from './lint.config'--const lintFiles = '*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'-const eslintFiles = '*.{json,jsonc,json5,md,yml,yaml}'-const formatOnlyFiles = '*.{mdx,css,scss,less,html,vue,svelte,gql,graphql,hbs,handlebars}'-const checkFix = 'vp check --fix --no-error-on-unmatched-pattern'-const formatFix = 'vp fmt --no-error-on-unmatched-pattern'-const eslintFix =- 'eslint --fix --pass-on-unpruned-suppressions --no-error-on-unmatched-pattern --no-warn-ignored'--const nonFrontendIgnores = [- '.agents/**',- '.devcontainer/**',- '/*.md',- 'api/**',- 'codecov.yml',- 'depot.json',- 'dify-agent/**',- 'docker/**',- 'docs/**',- 'scripts/**/*',- '!scripts/check-web-production-unused-after-knip-fix.mjs',- 'sdks/php-client/**',- 'sdks/python-client/**',-]--const generatedIgnores = [- '**/.next/**',- '**/.vinext/**',- '**/coverage/**',- '**/dist/**',- '**/storybook-static/**',- 'e2e/.auth/**',- 'e2e/cucumber-report/**',- 'eslint-suppressions.json',- 'oxlint-suppressions.json',- 'web/next/**',- 'web/next-env.d.ts',- 'web/public/embed.min.js',- 'web/public/pdf.worker.min.mjs',- 'web/public/vs/**',- // Vendored Emojibase JSON is served verbatim.- 'web/public/emoji/emojibase-*/**',-]--const formatterUnstableInputs = ['web/app/components/develop/template/*.mdx']--export default defineConfig({- lint: lintConfig,- run: {- tasks: {- 'check:cached': {- command: ['vp check', 'eslint --concurrency=auto'],- cache: {- env: ['CI', 'NODE_ENV', 'TAILWIND_CANONICAL_CLASSES'],- // Static checks have no artifacts to restore into the working tree.- output: [],- },- },- },- },- staged: {- [lintFiles]: checkFix,- [eslintFiles]: [eslintFix, formatFix],- [formatOnlyFiles]: formatFix,- '.vite-hooks/*': 'sh -n',- 'api/**/*.{py,pyi}': [- // Format first so fixable long lines do not fail the API's E501 check.- 'uv run --locked --project api --dev ruff format --force-exclude',- 'uv run --locked --project api --dev ruff check --fix --force-exclude',- 'uv run --locked --project api --dev ruff format --force-exclude',- ],- 'dify-agent/{src,examples,tests,docs}/**/*.py': [- 'uv run --locked --project dify-agent --dev ruff check --fix --force-exclude',- 'uv run --locked --project dify-agent --dev ruff format --force-exclude',- ],- },- fmt: {- ignorePatterns: [...nonFrontendIgnores, ...generatedIgnores, ...formatterUnstableInputs],- singleQuote: true,- semi: false,- sortImports: {- groups: [- 'type-import',- ['type-parent', 'type-sibling', 'type-index', 'type-internal', 'type-subpath'],- 'value-builtin',- 'value-external',- ['value-internal', 'value-subpath'],- ['value-parent', 'value-sibling', 'value-index'],- ['side_effect_style', 'side_effect'],- 'unknown',- ],- newlinesBetween: false,- sortSideEffects: false,- },- sortPackageJson: true,- sortTailwindcss: {- functions: ['cn', 'clsx', 'cva', 'tw', 'twMerge'],- preserveDuplicates: false,- stylesheet: 'web/app/styles/globals.css',- },- },-})+export { default } from '@dify/tooling/repository'diff --git a/web/docs/lint.md b/web/docs/lint.mdindex 143019f7556..45b81af6af1 100644--- a/web/docs/lint.md+++ b/web/docs/lint.md@@ -1,161 +1,5 @@# Static Check Guide-Vite+ provides the primary static check through `vp check`, which combines Oxfmt formatting, Oxlint code-quality rules, and TypeScript diagnostics. The root command also runs ESLint for non-code file types that Oxlint cannot parse.+See the [repository tooling guide] for linting, formatting, static checks, and custom rule maintenance.-## Check--Run the complete repository check from the root before committing or pushing:--```sh-vp run -w check-```--Apply safe fixes before running the same checks:--```sh-vp run -w check:fix-```--CI and local development use the same root `vite.config.ts` configuration.--The root `check` script delegates to the `check:cached` Vite Task. Formatting, linting,-and type checking reuse successful results when their tracked inputs are unchanged.-`CI`, `NODE_ENV`, and `TAILWIND_CANONICAL_CLASSES` are included in the cache key;-check results never restore files into the working tree. Fix commands remain uncached.-To force a fresh check, run `vp run -w --no-cache check`.--The TS Common CI job restores the task cache after dependency installation and saves-it after a successful check. This is separate from the package-manager cache in-`setup-web`. When evaluating CI performance, compare cache transfer time with the-time saved in the Vite Task summary.--Reuse successful checks for the same final changes. Repeat or expand checks only when subsequent edits, failures, or unresolved concerns require it.--To narrow formatting and linting, pass paths directly to Vite+. Type checking remains repository-wide:--```sh-vp check web/app/components packages/dify-ui/src/button-vp check --fix web/app/components packages/dify-ui/src/button-```--Run only the Web JSX accessibility rules for selected files or directories with-`lint:a11y`. Quote paths that contain shell metacharacters such as parentheses:--```sh-vp run dify-web#lint:a11y 'app/(commonLayout)/app/(appDetailLayout)/layout.tsx'-```--Use dependency mode to resolve an entry file's transitive local imports, including path aliases,-re-exports, and dynamic imports, and then lint the resulting JSX and TSX files:--```sh-vp run dify-web#lint:a11y --deps 'app/(commonLayout)/app/(appDetailLayout)/layout.tsx'-```--This is a local page-scoped diagnostic. The repository-wide accessibility rule baseline remains-owned by `lint.config.ts` and is also enforced by the normal `vp check` path.--Run the ESLint fallback separately when targeting JSON, JSONC, JSON5, YAML, or Markdown:--```sh-vp run -w lint:eslint package.json pnpm-workspace.yaml web/docs-vp run -w lint:eslint:fix package.json pnpm-workspace.yaml web/docs-```--Oxlint and Vite+ type-check scope is defined by `lint.config.ts` `ignorePatterns`, and ESLint's scope is defined by `eslint.config.mjs` global ignores.--The primary rule baseline lives in `lint.config.ts` and is connected through the root `vite.config.ts` `lint` block. Oxlint-native rules are preferred, and compatible ESLint rules can run through Oxlint's `jsPlugins` support. The rules are explicit snapshots of the ESLint configurations that were active at migration time. Do not import an upstream preset wholesale: enable a new rule intentionally and review its existing violations first.--Tailwind canonical class cleanup is optional because loading the JavaScript plugin adds noticeable lint startup time. The default `vp run -w check` command does not load it. Run `vp run -w lint:tailwind` to inspect `web/` and `packages/dify-ui/`, or `vp run -w lint:tailwind:fix` to apply safe replacements. Both commands run the complete lint configuration with the additional `better-tailwindcss/enforce-canonical-classes` rule, using `web/app/styles/globals.css` and a 16px root font size.--The non-code baseline and its repository-wide file scope live in `eslint.config.mjs`. ESLint checks JSON, JSONC, JSON5, YAML, and Markdown only. The configuration globally ignores JavaScript, JSX, TypeScript, TSX, and declaration files; a comment-only inventory records the removed code checks as a migration tradeoff. It does not import or depend on the Antfu ESLint config.--### Type-aware Linting--The root configuration enables both `typeAware` and `typeCheck`, so `vp check` runs type-aware rules and full diagnostics through the repository's `@typescript/native` compiler.--The shared `packages/tsconfig/base.json` enforces erasable TypeScript syntax through-`erasableSyntaxOnly`. Root tooling and TypeScript packages inherit this contract; enum-declarations, runtime namespaces, parameter properties, and import assignments are checked-by the compiler without a separate lint plugin.--The web package still runs its existing TSSLint rule separately:--```sh-vp run dify-web#lint:tss-```--### Bulk Suppressions--Existing Oxlint error diagnostics are tracked in the root `oxlint-suppressions.json` baseline. Oxlint reports newly added errors beyond that per-file rule baseline. ESLint has no bulk-suppression baseline. Warnings remain visible and do not fail the normal lint command.--The bulk-suppression flags are available in the bundled Oxlint version but are currently hidden from `vp lint --help`. Run them from the repository root so every package uses the same baseline:--```sh-vp run -w lint:oxlint --suppress-all-vp run -w lint:oxlint --prune-suppressions-```--The Oxc editor extension does not yet apply the bulk-suppression baseline, so the editor may still display findings that the CLI suppresses.--### Known Migration Gaps--ESLint is intentionally limited to non-code files. The remaining limitations and accepted migration tradeoffs are:--| Area | Current status |-| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| Code-only fallback rules | ESLint globally ignores all code files. Six core fallback rules, JS `dot-notation`, and other code-only ESLint checks are listed only in comments rather than executable configuration. |-| Declaration files | Oxlint excludes declaration files and ESLint no longer processes code. The former 223-rule declaration snapshot and CLI declaration import restriction are not enforced. |-| Generated contracts | Both linters and Vite+ type checking ignore `packages/contracts/**`; Oxfmt remains the only staged quality step for the contracts package. |-| Non-JavaScript formats | Oxlint plugins cannot provide custom parsers or file languages. ESLint covers JSON, JSONC, YAML, and Markdown semantic rules, while Oxfmt remains responsible for their formatting. |-| Markdown code blocks | ESLint validates the Markdown document, but fenced JavaScript and TypeScript blocks are not passed through the former overlapping preset. This remains deferred rather than duplicating the Oxlint rule set. |-| Override-scoped settings | The three Dify UI Tailwind rules are disabled with the rest of ESLint's code path. Oxlint still applies the web `react-x.additionalStateHooks` setting globally because it cannot scope settings to an override. |--Suppression comments belong to exactly one linter. Use `oxlint-disable` for code rules from `lint.config.ts`, and use `eslint-disable` only for non-code rules from `eslint.config.mjs`. Oxlint deliberately sets `respectEslintDisableDirectives` to `false`, so an ESLint comment cannot hide an Oxlint finding.--### Inline Disable Comments--Prefer fixing the finding. When an exception is necessary, name the specific rule and use `oxlint-disable-next-line` at the affected statement. For a shared exception spanning several statements, use a bounded disable/enable pair. File-wide disable comments are forbidden, including in tests. `dify/no-file-wide-disable` reports an error when a block disable has any rules left disabled at the end of the file; a matching enable must restore every disabled rule. The native `unicorn/no-abusive-eslint-disable` rule also rejects disables without rule names, which would otherwise suppress the custom check itself.--For existing violations that cannot be fixed in the current change, remove the file-wide comment and record a scoped bulk-suppression baseline instead of turning the rule off for the file:--```sh-vp run -w lint:oxlint path/to/file.spec.tsx --suppress-all-```--Review the `oxlint-suppressions.json` diff and retain only the intended file/rule counts. The rule remains active and findings beyond the recorded count are reported; this is a count baseline, not a list of specific suppressed lines. Avoid repository-wide `--suppress-all` for a scoped cleanup. After fixing violations, use `--prune-suppressions` as described above.--Use `lint.config.ts` overrides only when a rule is intentionally inapplicable to a file, and `ignorePatterns` only when the entire file must be excluded, such as generated output. Explain the reason next to the configuration. Do not migrate existing violations to a blanket rule-off override or broaden exceptions to future files with a directory glob.--Explain the concrete reason after `--`: which external contract, lifecycle, or rule limitation makes the exception necessary. A description that merely repeats the rule or says "fix lint" is insufficient. New or modified disables must include this explanation; existing test typing exceptions can be addressed incrementally.--`dify/require-disable-directive-description` uses Oxlint's parsed directives to report missing explanations, including JSX comments. It runs at `error`; existing undescribed exceptions are tracked in the bulk-suppression baseline for incremental cleanup. Enable comments do not need a repeated explanation. This rule does not assess whether a reason is valid and does not replace review. Do not add generic descriptions just to silence it.--`reportUnusedDisableDirectives` runs at `error` repository-wide. Remove an exception when the finding no longer exists. Keep both checks active: a described disable may still be unused, and a used disable may still lack a reason.--### Translation Function Types--`dify/require-i18n-namespace` requires translation hook calls to use non-empty-inline namespace arrays, including single namespaces: `useTranslation(['common'])`.-Strings and indirect arguments are rejected; only calls reading the `i18n`-instance alone may omit namespaces. Both `react-i18next` and `#i18n` are checked.-The shared client/server adapter accepts typed non-empty tuples and forwards them-through one documented lint exception in its client implementation.--`dify/require-t-function-namespace` requires i18next `TFunction` types to declare a-non-empty inline tuple of namespace string literals. Use `TFunction<['common']>`-or `TFunction<['common', 'workflow']>`; readonly tuples are also supported.-Omitted arguments, single strings, broad namespace types, tuple aliases, and-unions or rest elements inside the tuple are rejected. Named import aliases,-namespace imports, and inline `import('i18next').TFunction` types are checked.--Declare the namespaces the helper or component actually uses. TypeScript checks-translation keys and compatibility with callers; the lint rule does not infer-transitive dependencies or detect unused namespaces. Keep the first namespace-compatible with the caller because it defines the default translation namespace.-The rule has no automatic fix because choosing the dependencies requires reading-the translation calls.--### Introducing New Plugins or Rules--Prefer a native Oxlint rule. If none exists, verify that the rule works through an Oxlint JS plugin on representative files. Record unsupported code rules as migration gaps instead of adding them to ESLint; reserve the ESLint configuration for non-code languages that Oxlint cannot parse. Do not add the Antfu ESLint config as a dependency or enable rules already covered by Oxlint.+[repository tooling guide]: ../../packages/tooling/README.mddiff --git a/web/package.json b/web/package.jsonindex e265710b38d..2b747dbabea 100644--- a/web/package.json+++ b/web/package.json@@ -25,7 +25,7 @@"i18n:check-types": "node ./scripts/generate-i18n-types.ts --check","i18n:generate-types": "node ./scripts/generate-i18n-types.ts","i18n:migrate-selectors": "node ./scripts/migrate-i18n-selectors.ts",- "lint:a11y": "node ./scripts/lint-a11y.mjs",+ "lint:a11y": "node ../packages/tooling/scripts/lint-a11y.mjs","lint:tss": "tsslint --project tsconfig.json","migrate:type-assertions": "TSSLINT_TYPE_ASSERTION_MIGRATION=true tsslint --project tsconfig.json --force --fix","preinstall": "npx only-allow pnpm",@@ -146,6 +146,7 @@"@chromatic-com/storybook": "catalog:","@dify/contracts": "workspace:*","@dify/iconify-collections": "workspace:*",+ "@dify/tooling": "workspace:*","@dify/tsconfig": "workspace:*","@egoist/tailwindcss-icons": "catalog:","@iconify-json/heroicons": "catalog:",@@ -165,8 +166,6 @@"@testing-library/react": "catalog:","@testing-library/user-event": "catalog:","@tsslint/cli": "catalog:",- "@tsslint/compat-eslint": "catalog:",- "@tsslint/config": "catalog:","@types/js-cookie": "catalog:","@types/negotiator": "catalog:","@types/node": "catalog:",diff --git a/web/scripts/__tests__/check-i18n-plurals.spec.ts b/web/scripts/__tests__/check-i18n-plurals.spec.tsindex a4a555131fb..39f524b05ea 100644--- a/web/scripts/__tests__/check-i18n-plurals.spec.ts+++ b/web/scripts/__tests__/check-i18n-plurals.spec.ts@@ -1,11 +1,11 @@// @vitest-environment nodeimport { execFileSync } from 'node:child_process'-import { copyFile, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'+import { copyFile, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises'import { tmpdir } from 'node:os'import path from 'node:path'+import { getTranslationSourceKey } from '@dify/tooling/i18n-plurals'import { describe, expect, it } from 'vite-plus/test'-import { getTranslationSourceKey } from '../check-i18n-plurals'describe('locale-specific plural keys', () => {const sourceKeys = new Set(['skill.references_one', 'skill.references_other', 'skill.title'])@@ -49,7 +49,12 @@ describe('locale-specific plural keys', () => {const directory = await mkdtemp(path.join(tmpdir(), 'dify-i18n-plurals-'))try {await mkdir(path.join(directory, 'scripts'))- for (const file of ['check-i18n.js', 'check-i18n-plurals.ts', 'check-i18n-values.ts']) {+ await symlink(+ new URL('../../../node_modules', import.meta.url),+ path.join(directory, 'node_modules'),+ 'junction',+ )+ for (const file of ['check-i18n.js', 'check-i18n-values.ts']) {await copyFile(new URL(`../${file}`, import.meta.url),path.join(directory, 'scripts', file),diff --git a/web/scripts/check-i18n-values.ts b/web/scripts/check-i18n-values.tsindex 559f267d4b5..ecd140a6f51 100644--- a/web/scripts/check-i18n-values.ts+++ b/web/scripts/check-i18n-values.ts@@ -1,4 +1,4 @@-import { getTranslationSourceKey } from './check-i18n-plurals.ts'+import { getTranslationSourceKey } from '@dify/tooling/i18n-plurals'/*** Value-level checks for locale files.diff --git a/web/scripts/check-i18n.js b/web/scripts/check-i18n.jsindex 7769fefcd9c..697bf8efb00 100644--- a/web/scripts/check-i18n.js+++ b/web/scripts/check-i18n.js@@ -1,8 +1,8 @@import fs from 'node:fs'import path from 'node:path'import { fileURLToPath } from 'node:url'+import { getTranslationSourceKey } from '@dify/tooling/i18n-plurals'import data from '../i18n/languages.ts'-import { getTranslationSourceKey } from './check-i18n-plurals.ts'import { findValueIssues, formatValueIssue } from './check-i18n-values.ts'const __filename = fileURLToPath(import.meta.url)diff --git a/web/tsslint.config.ts b/web/tsslint.config.tsindex 94f4c45190f..2ad60634425 100644--- a/web/tsslint.config.ts+++ b/web/tsslint.config.ts@@ -1,18 +1,2 @@-import { defineConfig, importESLintRules } from '@tsslint/config'-import noUnnecessaryTypeAssertion from './plugins/tsslint/no-unnecessary-type-assertion.ts'--// Migration-only rules stay out of the regular `lint:tss` run; see `migrate:type-assertions`.-const enableTypeAssertionMigration = process.env.TSSLINT_TYPE_ASSERTION_MIGRATION === 'true'--// Run `npx tsslint-docgen` to generate documentation for the configured rules.--export default defineConfig({- rules: {- ...(await importESLintRules({- 'react-x/no-leaked-conditional-rendering': 'error',- })),- ...(enableTypeAssertionMigration- ? { dify: { 'no-unnecessary-type-assertion': noUnnecessaryTypeAssertion } }- : {}),- },-})+// oxlint-disable-next-line no-barrel-files/no-barrel-files -- TSSLint discovers this project entry point; the rules are owned by the tooling package.+export { default } from '@dify/tooling/tsslint'diff --git a/web/vite.config.ts b/web/vite.config.tsindex e97f1f4c8c9..33f53888a2f 100644--- a/web/vite.config.ts+++ b/web/vite.config.ts@@ -106,13 +106,11 @@ export default defineConfig(({ command, mode, isPreview }) => {'**/*.{spec,test,stories}.*','test/**','vitest*.setup.ts',- 'plugins/tsslint/test-utils.ts',// Declarations, generated sources, tool configuration, and build output.'**/*.d.{ts,mts,cts}','**/*.{generated,gen}.*','types/doc-paths.ts','*.config.*',- 'scripts/a11y/oxlint.config.ts','.*/**','**/dist/**','{coverage,build,out,storybook-static}/**',