From 0414a1300b2f7cf72db48d4d04bf8400b62a9b07 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 10 Mar 2025 16:24:48 +0800 Subject: [PATCH] workspace: fix eslint --- build/prepare.js | 12 ++++++------ framework/eslint-config/build.ts | 8 +++----- framework/eslint-config/package.json | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build/prepare.js b/build/prepare.js index 8320f06ed..608527eb3 100644 --- a/build/prepare.js +++ b/build/prepare.js @@ -150,18 +150,18 @@ const pluginsConfig = { }; fs.writeFileSync(path.resolve(process.cwd(), 'plugins', 'tsconfig.json'), JSON.stringify(pluginsConfig)); -for (const package of modules) { - const basedir = path.resolve(process.cwd(), package); +for (const pkg of modules) { + const basedir = path.resolve(process.cwd(), pkg); const files = fs.readdirSync(basedir); try { // eslint-disable-next-line import/no-dynamic-require const name = require(path.join(basedir, 'package.json')).name; fs.symlinkSync(basedir, path.join(nm, name), 'dir'); } catch (e) { } - if (!files.includes('src') && !files.filter((i) => i.endsWith('.ts')).length && package !== 'packages/utils') continue; - config.references.push({ path: package }); - const origConfig = (files.includes('src') ? configSrc : configFlat)(package); - const expectedConfig = JSON.stringify(package.startsWith('modules/') ? withoutTypes(origConfig) : origConfig); + if (!files.includes('src') && !files.filter((i) => i.endsWith('.ts')).length && pkg !== 'packages/utils') continue; + config.references.push({ path: pkg }); + const origConfig = (files.includes('src') ? configSrc : configFlat)(pkg); + const expectedConfig = JSON.stringify(pkg.startsWith('modules/') ? withoutTypes(origConfig) : origConfig); const configPath = path.resolve(basedir, 'tsconfig.json'); const currentConfig = fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf-8') : ''; if (expectedConfig !== currentConfig) fs.writeFileSync(configPath, expectedConfig); diff --git a/framework/eslint-config/build.ts b/framework/eslint-config/build.ts index 006632ee2..2e9121f6f 100644 --- a/framework/eslint-config/build.ts +++ b/framework/eslint-config/build.ts @@ -10,14 +10,12 @@ const base = yaml.load(fs.readFileSync('base.yaml', 'utf8')) as any; const react = yaml.load(fs.readFileSync('react.yaml', 'utf8')) as any; function sort(obj: Record): Record { - const clone = { ...obj }; - Object.keys(clone).sort().reduce( + return Object.keys(obj).sort().reduce( (acc, key) => { - acc[key] = clone[key]; + acc[key] = obj[key]; return acc; }, - ); - return clone; + ) as any; } // NOTE: oxlint doesn't support most stylistic rules diff --git a/framework/eslint-config/package.json b/framework/eslint-config/package.json index df913600e..fc3925b61 100644 --- a/framework/eslint-config/package.json +++ b/framework/eslint-config/package.json @@ -4,7 +4,7 @@ "license": "MIT", "main": "react.yaml", "dependencies": { - "@stylistic/eslint-plugin": "^4.2.0", + "@stylistic/eslint-plugin": "^3.1.0", "@typescript-eslint/eslint-plugin": "^8.26.0", "@typescript-eslint/parser": "^8.26.0", "eslint-config-airbnb": "^19.0.4",