Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"organizeImports": {
"enabled": true,
"include": [
"./**/*.js",
"./**/*.jsx",
"./**/*.ts",
"./**/*.tsx",
"./**/*.mjs",
"./**/*.mjsx",
"./**/*.cjs",
"./**/*.cjsx",
"./**/*.mts",
"./**/*.mtsx",
"./**/*.cts",
"./**/*.ctsx"
]
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"vcs": {
"enabled": true,
Expand All @@ -27,7 +17,12 @@
"ignoreUnknown": true
},
"formatter": {
"ignore": ["**/.rslib/*", "./tests/e2e/react-component/public/umd/*"],
"includes": [
"**",
"!**/*.vue",
"!**/.rslib/**/*",
"!tests/e2e/react-component/public/umd/**/*"
],
"indentStyle": "space"
},
"javascript": {
Expand All @@ -48,10 +43,12 @@
},
"linter": {
"enabled": true,
"ignore": [
"**/.rslib/*",
"./tests/integration/**/*/src/*",
"./tests/e2e/react-component/public/umd/*"
"includes": [
"**",
"!**/*.vue",
"!**/.rslib/**/*",
"!tests/integration/**/*/src/**/*",
"!tests/e2e/react-component/public/umd/**/*"
],
"rules": {
"recommended": true,
Expand All @@ -62,14 +59,30 @@
"options": {
"filenameCases": ["camelCase", "PascalCase", "export"]
}
}
},
"noParameterAssign": "error",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"noUselessElse": "error"
},
"suspicious": {
"noExplicitAny": "off",
"noConfusingVoidType": "off"
},
"performance": {
"noDelete": "off"
},
"correctness": {
"useHookAtTopLevel": "off"
},
"nursery": {
"useUniqueElementIds": "off"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/express-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { RequestHandler } from 'express';
import { logRequest } from './logger';
import { type LoggerOptions, defaultOptions } from './types';
import { defaultOptions, type LoggerOptions } from './types';

export function expressLogger(
options: Partial<LoggerOptions> = {},
): RequestHandler {
const mergedOptions = { ...defaultOptions, ...options };
return (req, res, next) => {
return (req, _res, next) => {
logRequest(req, mergedOptions);
next();
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import type { StorybookConfig } from 'storybook-react-rsbuild';

const require = createRequire(import.meta.url);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { init, loadRemote } from '@module-federation/enhanced/runtime';
import { Suspense, createElement, lazy } from 'react';
import { createElement, lazy, Suspense } from 'react';
import { CounterButton } from './CounterButton';
import { useCounter } from './useCounter';

Expand Down
1 change: 1 addition & 0 deletions examples/vue-component-bundleless/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import type { StorybookConfig } from 'storybook-vue3-rsbuild';

const require = createRequire(import.meta.url);

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"pnpm-lock.yaml": "pnpm dedupe --check"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@biomejs/biome": "^2.0.0",
"@changesets/cli": "^2.29.4",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.31",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/cli/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type RsbuildInstance, createRsbuild } from '@rsbuild/core';
import { createRsbuild, type RsbuildInstance } from '@rsbuild/core';
import { composeRsbuildEnvironments, pruneEnvironments } from '../config';
import type { RslibConfig } from '../types/config';
import type { BuildOptions } from './commands';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/cli/inspect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type RsbuildInstance, createRsbuild } from '@rsbuild/core';
import { createRsbuild, type RsbuildInstance } from '@rsbuild/core';
import { composeRsbuildEnvironments, pruneEnvironments } from '../config';
import type { RslibConfig } from '../types/config';
import type { InspectOptions } from './commands';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/cli/mf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createRsbuild } from '@rsbuild/core';
import type { RsbuildInstance } from '@rsbuild/core';
import { createRsbuild } from '@rsbuild/core';
import { composeRsbuildEnvironments, pruneEnvironments } from '../config';
import type { RslibConfig } from '../types';
import type { CommonOptions } from './commands';
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import fs from 'node:fs';
import path, { dirname, extname, isAbsolute, join } from 'node:path';
import {
defineConfig as defineRsbuildConfig,
type EnvironmentConfig,
loadConfig as loadRsbuildConfig,
mergeRsbuildConfig,
type RsbuildConfig,
type RsbuildEntry,
type RsbuildPlugin,
type RsbuildPlugins,
type Rspack,
type ToolsConfig,
defineConfig as defineRsbuildConfig,
loadConfig as loadRsbuildConfig,
mergeRsbuildConfig,
rspack,
type ToolsConfig,
} from '@rsbuild/core';
import { glob } from 'tinyglobby';
import { composeAssetConfig } from './asset/assetConfig';
Expand All @@ -23,9 +23,9 @@ import {
SWC_HELPERS,
} from './constant';
import {
RSLIB_CSS_ENTRY_FLAG,
composeCssConfig,
cssExternalHandler,
RSLIB_CSS_ENTRY_FLAG,
} from './css/cssConfig';
import { type CssLoaderOptionsAuto, isCssGlobalFile } from './css/utils';
import { composeEntryChunkConfig } from './plugins/EntryChunkPlugin';
Expand Down Expand Up @@ -254,7 +254,7 @@ const composeExternalsWarnConfig = (
}
// object
else if (typeof externals === 'object') {
if (Object.prototype.hasOwnProperty.call(externals, request)) {
if (Object.hasOwn(externals, request)) {
if (handleMatchedExternal(externals[request]!, request)) {
callback(true, true);
} else {
Expand Down Expand Up @@ -1277,7 +1277,7 @@ const composeBundlelessExternalConfig = (
// NOTE: If request is a phantom dependency, which means it can be resolved but not specified in dependencies or peerDependencies in package.json, the output will be incorrect to use when the package is published
// return the original request instead of the resolved request
return undefined;
} catch (e) {
} catch (_e) {
// catch error when request can not be resolved by resolver
// e.g. A react component library importing and using 'react' but while not defining
// it in devDependencies and peerDependencies. Preserve 'react' as-is if so.
Expand Down Expand Up @@ -1637,11 +1637,11 @@ export async function composeCreateRsbuildConfig(
const constantRsbuildConfig = await createConstantRsbuildConfig();
const {
lib: libConfigsArray,
mode,
mode: _mode,
root,
plugins: sharedPlugins,
dev,
server,
dev: _dev,
server: _server,
...sharedRsbuildConfig
} = rslibConfig;

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/css/cssConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
isCssFile,
isCssModulesFile,
} from './utils';

const require = createRequire(import.meta.url);

export const RSLIB_CSS_ENTRY_FLAG = '__rslib_css__';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/css/libCssExtractLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from './const';

import { type CssLoaderOptionsAuto, isCssModulesFile } from './utils';

interface DependencyDescription {
identifier: string;
content: string;
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export { prepareCli } from './cli/prepare';
export { runCli } from './cli/commands';
export { build } from './cli/build';
export { runCli } from './cli/commands';
export { inspect } from './cli/inspect';
export { startMFDevServer } from './cli/mf';
export { prepareCli } from './cli/prepare';
export {
composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig,
defineConfig,
loadConfig,
composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig,
} from './config';
export { logger } from './utils/logger';
export type * from './types';
export { logger } from './utils/logger';

export const version: string = RSLIB_VERSION;

export { rspack, type Rspack } from '@rsbuild/core';
export * as rsbuild from '@rsbuild/core';
export { type Rspack, rspack } from '@rsbuild/core';
1 change: 1 addition & 0 deletions packages/core/src/plugins/EntryChunkPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
SHEBANG_PREFIX,
SHEBANG_REGEX,
} from '../constant';

const require = createRequire(import.meta.url);

const PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const readPackageJson = (rootPath: string): undefined | PkgJson => {

try {
return JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
} catch (err) {
} catch (_err) {
logger.warn(`Failed to parse ${pkgJsonPath}, it might not be valid JSON`);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/fixtures/config/cjs/rslib.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { defineConfig } = require('../../../../../core/src/config');

module.exports = defineConfig((args) => ({
module.exports = defineConfig((_args) => ({
lib: [],
source: {
entry: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/fixtures/config/esm/rslib.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from '../../../../../core/src/config';

export default defineConfig((args) => ({
export default defineConfig((_args) => ({
lib: [],
source: {
entry: {
Expand Down
1 change: 1 addition & 0 deletions packages/create-rslib/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { pluginPublint } from 'rsbuild-plugin-publint';
import { defineConfig } from 'rslib';

const { execSync } = require('node:child_process');

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rslib/src/genTemplates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TEMPLATES, genTemplate } from './helpers';
import { genTemplate, TEMPLATES } from './helpers';

function main() {
for (const template of TEMPLATES) {
Expand Down
12 changes: 10 additions & 2 deletions packages/create-rslib/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,23 @@ export const composeTemplateName = ({
template,
tools,
lang,
}: { template: string; tools?: Record<string, string>; lang: Lang }) => {
}: {
template: string;
tools?: Record<string, string>;
lang: Lang;
}) => {
return `[${template}]-[${(tools ? Object.keys(tools) : []).sort()}]-${lang}`;
};

export function genTemplate({
template,
lang,
tools,
}: { template: string; lang: Lang; tools?: Record<string, string> }): void {
}: {
template: string;
lang: Lang;
tools?: Record<string, string>;
}): void {
const toolKeys = tools ? Object.keys(tools) : [];
const target = path.resolve(
__dirname,
Expand Down
4 changes: 2 additions & 2 deletions packages/create-rslib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import {
type Argv,
type ESLintTemplateName,
checkCancel,
create,
type ESLintTemplateName,
multiselect,
select,
} from 'create-rstack';
import { type Lang, TEMPLATES, composeTemplateName } from './helpers';
import { composeTemplateName, type Lang, TEMPLATES } from './helpers';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
2 changes: 1 addition & 1 deletion packages/create-rslib/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import { describe, expect, test } from 'vitest';
import { TEMPLATES, composeTemplateName } from '../src/helpers';
import { composeTemplateName, TEMPLATES } from '../src/helpers';
import { createAndValidate } from './helper';

const CASES_NODE_DUAL = [
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dts/src/apiExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type BundleOptions = {
};

export async function bundleDts(options: BundleOptions): Promise<void> {
let apiExtractor: typeof ApiExtractor | undefined = undefined;
let apiExtractor: typeof ApiExtractor | undefined;
try {
apiExtractor = await import('@microsoft/api-extractor');
} catch {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dts/src/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const calcBundledPackages = (options: {
try {
const content = fs.readFileSync(join(cwd, 'package.json'), 'utf-8');
pkgJson = JSON.parse(content);
} catch (err) {
} catch (_err) {
logger.warn(
'The type of third-party packages will not be bundled due to read package.json failed',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type ChildProcess, fork } from 'node:child_process';
import { dirname, extname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { type RsbuildConfig, type RsbuildPlugin, logger } from '@rsbuild/core';
import { logger, type RsbuildConfig, type RsbuildPlugin } from '@rsbuild/core';
import color from 'picocolors';
import ts from 'typescript';
import {
Expand Down
Loading
Loading