Skip to content

Commit

Permalink
chore: fix lint-staged prettier (#5935)
Browse files Browse the repository at this point in the history
* fix version

* fix
  • Loading branch information
ahabhgk authored Mar 13, 2024
1 parent 9ab165b commit 769ca8e
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 80 deletions.
4 changes: 1 addition & 3 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export default {
"*.rs": "rustfmt --edition 2021",
"packages/**/*.{ts,js}": "prettier --write",
"x.mjs": "prettier --write",
"crates/rspack_plugin_runtime/**/*.{ts,js}": "prettier --write",
"*.{ts,js}": "pnpm run format:js",
"*.toml": "npx @taplo/cli format",
"*.{ts,js,mjs}": () => "pnpm run lint:js"
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build:viewer": "pnpm --filter \"@rspack/*\" build:viewer",
"test:js": "pnpm -r run test",
"format:rs": "pnpm --filter @rspack/core... build",
"format:js": "npx prettier 'packages/**/src/**/*.{ts,js}' 'crates/rspack_plugin_runtime/**/*.{ts,js}' --check --write",
"format:js": "./node_modules/prettier/bin/prettier.cjs 'packages/**/src/**/*.{ts,js}' 'crates/rspack_plugin_runtime/**/*.{ts,js}' 'x.mjs' --check --write",
"format-ci:toml": "npx @taplo/cli format --check '.cargo/*.toml' './crates/**/Cargo.toml' './Cargo.toml'",
"format:toml": "npx @taplo/cli format '.cargo/*.toml' './crates/**/Cargo.toml' './Cargo.toml'",
"lint:js": "oxlint --deny-warnings -c .eslintrc.json",
Expand Down Expand Up @@ -60,8 +60,8 @@
"lint-staged": "^15.0.0",
"npm-run-all": "4.1.5",
"oxlint": "0.2.10",
"prettier": "3.2",
"prettier-2": "npm:prettier@^2",
"prettier": "3.2.5",
"prettier-2": "npm:prettier@2.8.8",
"rimraf": "3.0.2",
"ts-jest": "29.1.2",
"typescript": "5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-plugin-minify/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = class RspackMinifyPlugin {
sourceAsString,
map,
true
)
)
: new RawSource(result.code),
{
...asset.info,
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/src/case/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ const creator = new WatchCaseCreator({
stepName: run.name,
tempDir: temp!,
runable: true
})
})
: new RspackWatchStepProcessor({
name,
stepName: run.name,
tempDir: temp!,
runable: true
})
})
);
}
});
Expand Down
6 changes: 3 additions & 3 deletions packages/rspack-test-tools/src/processor/multi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export class MultiTaskProcessor<T extends ECompilerType = ECompilerType.Rspack>
const bundles = Array.isArray(curBundles)
? curBundles
: curBundles
? [curBundles]
: [];
? [curBundles]
: [];

const multiFileIndexMap: Record<string, number[]> =
context.getValue(_multiOptions.name, "multiFileIndexMap") || {};
Expand Down Expand Up @@ -91,7 +91,7 @@ export class MultiTaskProcessor<T extends ECompilerType = ECompilerType.Rspack>
)
? readConfigFile(
this._multiOptions.configFiles!.map(i => context.getSource(i))
)
)
: [{}];

for (let [index, options] of caseOptions.entries()) {
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/src/processor/normal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class RspackNormalProcessor extends BasicTaskProcessor<ECompilerType.Rspa
// emitOnErrors: true,
minimizer: [terserForTesting],
...testConfig.optimization
}
}
: {
removeAvailableModules: true,
removeEmptyChunks: true,
Expand All @@ -87,7 +87,7 @@ export class RspackNormalProcessor extends BasicTaskProcessor<ECompilerType.Rspa
chunkIds: "named",
minimizer: [terserForTesting],
...compilerOptions?.optimization
},
},
// CHANGE: rspack does not support `performance` yet.
// performance: {
// hints: false
Expand Down
5 changes: 4 additions & 1 deletion packages/rspack-test-tools/src/runner/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { EsmRunner } from "./runner/esm";
export class BasicRunnerFactory<T extends ECompilerType>
implements TRunnerFactory<T>
{
constructor(protected name: string, protected context: ITestContext) {}
constructor(
protected name: string,
protected context: ITestContext
) {}

create(
file: string,
Expand Down
8 changes: 5 additions & 3 deletions packages/rspack-test-tools/src/runner/runner/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ export class BasicRunner<T extends ECompilerType = ECompilerType.Rspack>
if (modules && modulePathStr in modules) {
return modules[modulePathStr];
} else {
return require(modulePathStr.startsWith("node:")
? modulePathStr.slice(5)
: modulePathStr);
return require(
modulePathStr.startsWith("node:")
? modulePathStr.slice(5)
: modulePathStr
);
}
};
}
Expand Down
6 changes: 3 additions & 3 deletions packages/rspack/src/builtin-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function resolveTreeShaking(
return treeShaking !== undefined
? treeShaking.toString()
: production
? "true"
: "false";
? "true"
: "false";
}

export interface Builtins {
Expand All @@ -97,7 +97,7 @@ export function deprecated_resolveBuiltins(
...builtins.css?.modules
},
namedExports: builtins.css?.namedExports
}
}
: undefined,
treeShaking: resolveTreeShaking(builtins.treeShaking, production)
};
Expand Down
53 changes: 28 additions & 25 deletions packages/rspack/src/config/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function getRawResolve(resolve: Resolve): RawOptions["resolve"] {
referencesType:
references == "auto" ? "auto" : references ? "manual" : "disabled",
references: references == "auto" ? undefined : references
}
}
: undefined,
byDependency: getRawResolveByDependency(resolve.byDependency)
};
Expand Down Expand Up @@ -255,7 +255,7 @@ export function getRawLibrary(library: LibraryOptions): RawLibraryOptions {
commonjs2: auxiliaryComment,
amd: auxiliaryComment,
root: auxiliaryComment
}
}
: auxiliaryComment,
libraryType: type,
name: isNil(name) ? name : getRawLibraryName(name),
Expand Down Expand Up @@ -398,7 +398,7 @@ const getRawModuleRule = (
k,
getRawRuleSetCondition(v)
])
)
)
: undefined,
resource: rule.resource ? getRawRuleSetCondition(rule.resource) : undefined,
resourceQuery: rule.resourceQuery
Expand All @@ -420,7 +420,7 @@ const getRawModuleRule = (
`${path}.use`,
options
)
},
},
type: rule.type,
parser: rule.parser
? getRawParserOptions(rule.parser, rule.type ?? "javascript/auto")
Expand All @@ -432,12 +432,12 @@ const getRawModuleRule = (
oneOf: rule.oneOf
? rule.oneOf.map((rule, index) =>
getRawModuleRule(rule, `${path}.oneOf[${index}]`, options)
)
)
: undefined,
rules: rule.rules
? rule.rules.map((rule, index) =>
getRawModuleRule(rule, `${path}.rules[${index}]`, options)
)
)
: undefined,
enforce: rule.enforce
};
Expand All @@ -456,27 +456,30 @@ const getRawModuleRule = (
delete rawModuleRule.resourceQuery;
delete rawModuleRule.resourceFragment;

rawModuleRule.rspackResource = getRawRuleSetCondition(function (
resourceQueryFragment
) {
const { path, query, fragment } = parseResource(resourceQueryFragment);
rawModuleRule.rspackResource = getRawRuleSetCondition(
function (resourceQueryFragment) {
const { path, query, fragment } = parseResource(resourceQueryFragment);

if (rule.test && !tryMatch(path, rule.test)) {
return false;
} else if (rule.resource && !tryMatch(path, rule.resource)) {
return false;
}
if (rule.test && !tryMatch(path, rule.test)) {
return false;
} else if (rule.resource && !tryMatch(path, rule.resource)) {
return false;
}

if (rule.resourceQuery && !tryMatch(query, rule.resourceQuery)) {
return false;
}
if (rule.resourceQuery && !tryMatch(query, rule.resourceQuery)) {
return false;
}

if (rule.resourceFragment && !tryMatch(fragment, rule.resourceFragment)) {
return false;
}
if (
rule.resourceFragment &&
!tryMatch(fragment, rule.resourceFragment)
) {
return false;
}

return true;
});
return true;
}
);
}
return rawModuleRule;
};
Expand Down Expand Up @@ -579,8 +582,8 @@ function getRawJavascriptParserOptions(parser: JavascriptParserOptions) {
parser.url === false
? "false"
: parser.url === "relative"
? parser.url
: "true"
? parser.url
: "true"
};
}

Expand Down
8 changes: 4 additions & 4 deletions packages/rspack/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export const applyRspackOptionsDefaults = (
target === false
? false
: typeof target === "string"
? getTargetProperties(target, options.context!)
: getTargetsProperties(target, options.context!);
? getTargetProperties(target, options.context!)
: getTargetsProperties(target, options.context!);

const development = mode === "development";
const production = mode === "production" || !mode;
Expand Down Expand Up @@ -114,8 +114,8 @@ export const applyRspackOptionsDefaults = (
return options.output.library
? options.output.library.type
: options.output.module
? "module"
: "var";
? "module"
: "var";
});

applyNodeDefaults(options.node, { targetProperties });
Expand Down
12 changes: 6 additions & 6 deletions packages/rspack/src/config/normalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const getNormalizedRspackOptions = (
return ignore.test(warning.message);
};
}
})
})
: undefined,
name: config.name,
dependencies: config.dependencies,
Expand All @@ -115,10 +115,10 @@ export const getNormalizedRspackOptions = (
"type" in library
? library
: libraryAsName || output.libraryTarget
? ({
name: libraryAsName
} as LibraryOptions)
: undefined;
? ({
name: libraryAsName
} as LibraryOptions)
: undefined;
return {
path: output.path,
publicPath: output.publicPath,
Expand Down Expand Up @@ -396,7 +396,7 @@ const keyedNestedConfig = <T, R>(
obj
),
{} as Record<string, R>
);
);
if (customKeys) {
for (const key of Object.keys(customKeys)) {
if (!(key in result)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/src/lite-tapable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type FixedSizeArray<T extends number, U> = T extends 0
: ReadonlyArray<U> & {
0: U;
length: T;
};
};
type Measure<T extends number> = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
? T
: never;
Expand Down
6 changes: 4 additions & 2 deletions packages/rspack/src/rspack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ function rspack(
} else {
const { compiler, watch } = create();
if (watch) {
util.deprecate(() => {},
"A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
util.deprecate(
() => {},
"A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback."
)();
}
return compiler;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/rspack/src/sharing/ConsumeSharedPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ConsumeSharedPlugin extends RspackBuiltinPlugin {
let result =
item === key || !isRequiredVersion(item)
? // item is a request/key
{
{
import: key,
shareScope: options.shareScope || "default",
shareKey: key,
Expand All @@ -57,10 +57,10 @@ export class ConsumeSharedPlugin extends RspackBuiltinPlugin {
strictVersion: false,
singleton: false,
eager: false
}
}
: // key is a request/key
// item is a version
{
// item is a version
{
import: key,
shareScope: options.shareScope || "default",
shareKey: key,
Expand All @@ -69,7 +69,7 @@ export class ConsumeSharedPlugin extends RspackBuiltinPlugin {
packageName: undefined,
singleton: false,
eager: false
};
};
return result;
},
(item, key) => ({
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack/src/stats/DefaultStatsFactoryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ const ASSETS_GROUPERS: Record<
[name]: !!key,
filteredChildren: assets.length,
...assetGroup(children)
}
}
: {
type: "assets by status",
[name]: !!key,
children,
...assetGroup(children)
};
};
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack/src/stats/statsFactoryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ const getItemSize = (item: Child) => {
return !item.children
? 1
: item.filteredChildren
? 2 + getTotalSize(item.children)
: 1 + getTotalSize(item.children);
? 2 + getTotalSize(item.children)
: 1 + getTotalSize(item.children);
};

export const spaceLimited = (
Expand Down
Loading

2 comments on commit 769ca8e

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-03-13 f3dc1fd) Current Change
10000_development-mode + exec 1.7 s ± 16 ms 1.74 s ± 20 ms +2.10 %
10000_development-mode_hmr + exec 715 ms ± 4.2 ms 725 ms ± 4.9 ms +1.46 %
10000_production-mode + exec 2.77 s ± 36 ms 2.68 s ± 44 ms -3.16 %
arco-pro_development-mode + exec 2.45 s ± 18 ms 3 s ± 40 ms +22.55 %
arco-pro_development-mode_hmr + exec 507 ms ± 1.6 ms 511 ms ± 4.4 ms +0.77 %
arco-pro_development-mode_hmr_intercept-plugin + exec 523 ms ± 5.8 ms 527 ms ± 7.9 ms +0.73 %
arco-pro_development-mode_intercept-plugin + exec 3.31 s ± 34 ms 3.27 s ± 77 ms -1.39 %
arco-pro_production-mode + exec 4.12 s ± 43 ms 4.7 s ± 71 ms +14.05 %
arco-pro_production-mode_intercept-plugin + exec 5.05 s ± 53 ms 4.9 s ± 28 ms -2.87 %
threejs_development-mode_10x + exec 1.95 s ± 19 ms 1.82 s ± 26 ms -6.65 %
threejs_development-mode_10x_hmr + exec 726 ms ± 3.9 ms 727 ms ± 3.3 ms +0.08 %
threejs_production-mode_10x + exec 5.77 s ± 131 ms 5.69 s ± 108 ms -1.33 %

Threshold exceeded: ["arco-pro_development-mode + exec","arco-pro_production-mode + exec"]

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ✅ success
nx ❌ failure
rspress ✅ success
rsbuild ✅ success
compat ✅ success
examples ✅ success

Please sign in to comment.