chore: introduce bulk-suppressions and multithread linting (#31157)

This commit is contained in:
Stephen Zhou
2026-01-17 19:51:56 +08:00
committed by GitHub
parent 77366f33a4
commit 7b66bbc35a
6 changed files with 5177 additions and 65 deletions

View File

@ -106,8 +106,9 @@ jobs:
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
working-directory: ./web working-directory: ./web
run: | run: |
pnpm run lint:report pnpm run lint:ci
continue-on-error: true # pnpm run lint:report
# continue-on-error: true
# - name: Annotate Code # - name: Annotate Code
# if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'pull_request' # if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'pull_request'
@ -126,11 +127,6 @@ jobs:
working-directory: ./web working-directory: ./web
run: pnpm run knip run: pnpm run knip
- name: Web build check
if: steps.changed-files.outputs.any_changed == 'true'
working-directory: ./web
run: pnpm run build
superlinter: superlinter:
name: SuperLinter name: SuperLinter
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -366,3 +366,48 @@ jobs:
path: web/coverage path: web/coverage
retention-days: 30 retention-days: 30
if-no-files-found: error if-no-files-found: error
web-build:
name: Web Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./web
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Check changed files
id: changed-files
uses: tj-actions/changed-files@v47
with:
files: |
web/**
.github/workflows/web-tests.yml
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
package_json_file: web/package.json
run_install: false
- name: Setup NodeJS
uses: actions/setup-node@v6
if: steps.changed-files.outputs.any_changed == 'true'
with:
node-version: 24
cache: pnpm
cache-dependency-path: ./web/pnpm-lock.yaml
- name: Web dependencies
if: steps.changed-files.outputs.any_changed == 'true'
working-directory: ./web
run: pnpm install --frozen-lockfile
- name: Web build check
if: steps.changed-files.outputs.any_changed == 'true'
working-directory: ./web
run: pnpm run build

View File

@ -221,7 +221,6 @@ describe('useReadmePanelStore', () => {
// ReadmeEntrance Component Tests // ReadmeEntrance Component Tests
// ================================ // ================================
describe('ReadmeEntrance', () => { describe('ReadmeEntrance', () => {
// ================================ // ================================
// Rendering Tests // Rendering Tests
// ================================ // ================================

5107
web/eslint-suppressions.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,30 +9,15 @@ import difyI18n from './eslint-rules/index.js'
export default antfu( export default antfu(
{ {
react: { react: {
reactCompiler: true,
overrides: { overrides: {
'react/no-context-provider': 'off', 'react/no-context-provider': 'off',
'react/no-forward-ref': 'off', 'react/no-forward-ref': 'off',
'react/no-use-context': 'off', 'react/no-use-context': 'off',
'react/prefer-namespace-import': 'error',
// React Compiler rules
// Set to warn for gradual adoption
'react-hooks/config': 'warn',
'react-hooks/error-boundaries': 'warn',
'react-hooks/component-hook-factories': 'warn',
'react-hooks/gating': 'warn',
'react-hooks/globals': 'warn',
'react-hooks/immutability': 'warn',
'react-hooks/preserve-manual-memoization': 'warn',
'react-hooks/purity': 'warn',
'react-hooks/refs': 'warn',
// prefer react-hooks-extra/no-direct-set-state-in-use-effect // prefer react-hooks-extra/no-direct-set-state-in-use-effect
'react-hooks/set-state-in-effect': 'off', 'react-hooks/set-state-in-effect': 'off',
'react-hooks/set-state-in-render': 'warn', 'react-hooks-extra/no-direct-set-state-in-use-effect': 'error',
'react-hooks/static-components': 'warn',
'react-hooks/unsupported-syntax': 'warn',
'react-hooks/use-memo': 'warn',
'react-hooks/incompatible-library': 'warn',
}, },
}, },
nextjs: true, nextjs: true,
@ -40,7 +25,7 @@ export default antfu(
typescript: { typescript: {
overrides: { overrides: {
'ts/consistent-type-definitions': ['error', 'type'], 'ts/consistent-type-definitions': ['error', 'type'],
'ts/no-explicit-any': 'warn', 'ts/no-explicit-any': 'error',
}, },
}, },
test: { test: {
@ -54,6 +39,11 @@ export default antfu(
}, },
}, },
}, },
{
rules: {
'node/prefer-global/process': 'off',
},
},
{ {
files: ['**/*.ts', '**/*.tsx'], files: ['**/*.ts', '**/*.tsx'],
settings: { settings: {
@ -62,32 +52,6 @@ export default antfu(
}, },
}, },
}, },
// downgrade some rules from error to warn for gradual adoption
// we should fix these in following pull requests
{
// @keep-sorted
rules: {
'next/inline-script-id': 'warn',
'no-console': 'warn',
'no-irregular-whitespace': 'warn',
'node/prefer-global/buffer': 'warn',
'node/prefer-global/process': 'warn',
'react/no-create-ref': 'warn',
'react/no-missing-key': 'warn',
'react/no-nested-component-definitions': 'warn',
'regexp/no-dupe-disjunctions': 'warn',
'regexp/no-super-linear-backtracking': 'warn',
'regexp/no-unused-capturing-group': 'warn',
'regexp/no-useless-assertions': 'warn',
'regexp/no-useless-quantifier': 'warn',
'style/multiline-ternary': 'warn',
'test/no-identical-title': 'warn',
'test/prefer-hooks-in-order': 'warn',
'ts/no-empty-object-type': 'warn',
'unicorn/prefer-number-properties': 'warn',
'unused-imports/no-unused-vars': 'warn',
},
},
storybook.configs['flat/recommended'], storybook.configs['flat/recommended'],
...pluginQuery.configs['flat/recommended'], ...pluginQuery.configs['flat/recommended'],
// sonar // sonar
@ -178,19 +142,19 @@ export default antfu(
}, },
}, },
// dify i18n namespace migration // dify i18n namespace migration
{ // {
files: ['**/*.ts', '**/*.tsx'], // files: ['**/*.ts', '**/*.tsx'],
ignores: ['eslint-rules/**', 'i18n/**', 'i18n-config/**'], // ignores: ['eslint-rules/**', 'i18n/**', 'i18n-config/**'],
plugins: { // plugins: {
'dify-i18n': difyI18n, // 'dify-i18n': difyI18n,
}, // },
rules: { // rules: {
// 'dify-i18n/no-as-any-in-t': ['error', { mode: 'all' }], // // 'dify-i18n/no-as-any-in-t': ['error', { mode: 'all' }],
'dify-i18n/no-as-any-in-t': 'error', // 'dify-i18n/no-as-any-in-t': 'error',
// 'dify-i18n/no-legacy-namespace-prefix': 'error', // // 'dify-i18n/no-legacy-namespace-prefix': 'error',
// 'dify-i18n/require-ns-option': 'error', // // 'dify-i18n/require-ns-option': 'error',
}, // },
}, // },
// i18n JSON validation rules // i18n JSON validation rules
{ {
files: ['i18n/**/*.json'], files: ['i18n/**/*.json'],

View File

@ -28,6 +28,7 @@
"build:docker": "next build && node scripts/optimize-standalone.js", "build:docker": "next build && node scripts/optimize-standalone.js",
"start": "node ./scripts/copy-and-start.mjs", "start": "node ./scripts/copy-and-start.mjs",
"lint": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache", "lint": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache",
"lint:ci": "pnpm lint --concurrency 3",
"lint:fix": "pnpm lint --fix", "lint:fix": "pnpm lint --fix",
"lint:quiet": "pnpm lint --quiet", "lint:quiet": "pnpm lint --quiet",
"lint:complexity": "pnpm lint --rule 'complexity: [error, {max: 15}]' --quiet", "lint:complexity": "pnpm lint --rule 'complexity: [error, {max: 15}]' --quiet",