Skip to content

Commit

Permalink
chore: enable TS no unused check (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Nov 19, 2023
1 parent 9e959d0 commit 141e500
Show file tree
Hide file tree
Showing 20 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ModuleScopePlugin {
this;
resolver.hooks.file.tapAsync(
'ModuleScopePlugin',
(request: any, contextResolver: any, callback: any) => {
(request: any, _context: unknown, callback: any) => {
const { issuer } = request.context;

// Unknown issuer, probably webpack internals
Expand Down
3 changes: 0 additions & 3 deletions packages/compat/webpack/src/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export async function applyBaseCSSRule({

// 1. Check user config
const enableExtractCSS = isUseCssExtract(config, target);
const enableCssMinify = !enableExtractCSS && isProd;

const enableSourceMap = isUseCssSourceMap(config);
const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);

Expand Down Expand Up @@ -122,7 +120,6 @@ export async function applyBaseCSSRule({
enableSourceMap,
browserslist,
config,
enableCssMinify,
});

rule
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/webpack/src/plugins/progress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TARGET_ID_MAP, isProd } from '@rsbuild/shared';
import { TARGET_ID_MAP } from '@rsbuild/shared';
import type { RsbuildPlugin } from '../types';

export const pluginProgress = (): RsbuildPlugin => ({
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/rspack-provider/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export async function applyBaseCSSRule({
importLoaders?: number;
}) {
// 1. Check user config
const enableExtractCSS = isUseCssExtract(config, target);
const enableSourceMap = isUseCssSourceMap(config);
const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);

Expand All @@ -48,8 +47,6 @@ export async function applyBaseCSSRule({
target,
);

const enableCssMinify = !enableExtractCSS && isProd;

// when disableExtractCSS, use css-loader + style-loader
if (!enableNativeCss(config)) {
const localIdentName = getCssModuleLocalIdentName(config, isProd);
Expand Down Expand Up @@ -130,7 +127,6 @@ export async function applyBaseCSSRule({
enableSourceMap,
browserslist,
config,
enableCssMinify,
});

rule
Expand Down
2 changes: 1 addition & 1 deletion packages/doctor-core/src/inner-plugins/utils/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function reportPluginData(
tapName: string,
start: number,
type: SDK.PluginHookData['type'],
res: unknown,
_res: unknown,
err?: Error,
) {
const end = Date.now();
Expand Down
2 changes: 1 addition & 1 deletion packages/doctor-sdk/src/sdk/sdk/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export abstract class SDKCore<T extends DoctorSDKOptions>
/** Upload analysis data pieces */
protected async writePieces(
storeData: Common.PlainObject,
options?: SDK.WriteStoreOptionsType,
_options?: SDK.WriteStoreOptionsType,
) {
const { outputDir } = this;
const manifest = path.resolve(outputDir, Constants.DoctorOutputManifest);
Expand Down
2 changes: 1 addition & 1 deletion packages/doctor-sdk/src/sdk/sdk/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export class DoctorWebpackSDK<
}

public getRuleContext(
options: SDK.RuntimeContextOptions,
_options: SDK.RuntimeContextOptions,
): SDK.RuntimeContext {
this.createPackageGraph();

Expand Down
2 changes: 1 addition & 1 deletion packages/doctor-sdk/src/sdk/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Server } from '@rsbuild/doctor-utils/build';
import { Bundle } from '@rsbuild/doctor-utils/common';
import assert from 'assert';
import bodyParser from 'body-parser';
import open from 'open';
// import open from 'open';
import ip from 'ip';
import cors from 'cors';
import { PassThrough } from 'stream';
Expand Down
3 changes: 1 addition & 2 deletions packages/doctor-utils/src/common/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export class APIDataLoader {
]).then((res) => {
const { moduleId } =
body as SDK.ServerAPI.InferRequestBodyType<SDK.ServerAPI.API.GetModuleDetails>;
const { chunks = [] } = res[0] || {};
const { modules = [], dependencies = [] } = res[1] || {};
return Graph.getModuleDetails(moduleId, modules, dependencies) as R;
});
Expand Down Expand Up @@ -297,7 +296,7 @@ export class APIDataLoader {
this.loader.loadData('configs'),
]).then(
([
manifest,
_manifest,
root = '',
hash = '',
errors = {},
Expand Down
1 change: 1 addition & 0 deletions packages/doctor-webpack-plugin/src/multiple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let globalController: DoctorSDKController | undefined;
export class RsbuildDoctorWebpackMultiplePlugin<
Rules extends Linter.ExtendRuleData[],
> extends RsbuildDoctorWebpackPlugin<Rules> {
// @ts-expect-error
private controller: DoctorSDKController;

constructor(options: DoctorWebpackMultiplePluginOptions<Rules> = {}) {
Expand Down
2 changes: 1 addition & 1 deletion packages/doctor-webpack-plugin/src/plugins/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class DoctorResolverPlugin implements ResolvePluginInstance {
}
});

resolver.hooks.resolveStep.tap(this.tapOptions, (hook, request) => {
resolver.hooks.resolveStep.tap(this.tapOptions, (_, request) => {
const { context } = request as unknown as ResolveRequestWithContext;
if (context.issuer && !this.contextMap.has(context.issuer)) {
this.contextMap.set(context.issuer, [Date.now(), process.hrtime()]);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-babel/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChainedConfig, ChainedConfigWithUtils } from '@rsbuild/shared';
import type { ChainedConfigWithUtils } from '@rsbuild/shared';
import type {
PluginItem as BabelPlugin,
PluginOptions as BabelPluginOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/apply/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '../types';

export function applyResolvePlugin(api: SharedRsbuildPluginAPI) {
api.modifyBundlerChain((chain, { target, CHAIN_ID }) => {
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
const config = api.getNormalizedConfig();
const isTsProject = Boolean(api.context.tsconfigPath);
applyExtensions({
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
DEFAULT_ASSET_PREFIX,
} from './constants';
import type {
RsbuildTarget,
BundlerChainRule,
RsbuildConfig,
InspectConfigOptions,
Expand Down
3 changes: 0 additions & 3 deletions packages/shared/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import deepmerge from '../compiled/deepmerge';
import { getSharedPkgCompiledPath as getCompiledPath } from './utils';
import { mergeChainedOptions } from './mergeChainedOptions';
import type {
CssModules,
RsbuildTarget,
CSSLoaderOptions,
NormalizedConfig,
Expand Down Expand Up @@ -70,12 +69,10 @@ export const getCssnanoDefaultOptions = (): CssNanoOptions => ({
});

export const getPostcssConfig = ({
enableCssMinify,
enableSourceMap,
browserslist,
config,
}: {
enableCssMinify: boolean;
enableSourceMap: boolean;
browserslist: string[];
config: NormalizedConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/types/config/source.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RsbuildEntry, RsbuildTarget } from '../rsbuild';
import type { RsbuildEntry } from '../rsbuild';
import type { ChainedConfig } from '../utils';

export type Alias = Record<string, string | false | (string | false)[]>;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/types/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { NodeEnv, PromiseOrNot } from './utils';
import { RsbuildTarget } from './rsbuild';
import { BundlerChain } from './bundlerConfig';
import { mergeRsbuildConfig } from '../mergeRsbuildConfig';
import type { RspackPluginInstance } from '@rspack/core';

export type OnBeforeBuildFn<BundlerConfig = unknown> = (params: {
bundlerConfigs?: BundlerConfig[];
Expand Down
2 changes: 1 addition & 1 deletion packages/test-helper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function createSnapshotSerializer(options?: SnapshotSerializerOptions) {
{ mark: 'root', match: cwd },
{ mark: 'workspace', match: workspace },
...customMatchers,
...createDefaultPathMatchers(workspace),
...createDefaultPathMatchers(),
];

pathMatchers
Expand Down
2 changes: 1 addition & 1 deletion packages/test-helper/src/pathSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function applyMatcherReplacement(
}, str);
}

export const createDefaultPathMatchers = (root: string) => {
export const createDefaultPathMatchers = () => {
const ret: PathMatcher[] = [
{
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
Expand Down
2 changes: 2 additions & 0 deletions scripts/tsconfig/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"isolatedModules": true,
"esModuleInterop": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"jsx": "preserve",
"resolveJsonModule": true,
"moduleResolution": "Bundler"
Expand Down

0 comments on commit 141e500

Please sign in to comment.