Skip to content

Commit 03f6c2b

Browse files
committed
fix cognitive complexity
1 parent 1865abf commit 03f6c2b

File tree

1 file changed

+7
-6
lines changed
  • lib/esbuild-plugin-react18-css/src

1 file changed

+7
-6
lines changed

lib/esbuild-plugin-react18-css/src/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,18 @@ function handleModules(build: PluginBuild, { generateScopedName }: CSSPluginOpti
121121
}));
122122
}
123123

124+
function resolveScopedName(options: CSSPluginOptions) {
125+
const globalPrefix = options.globalPrefix ?? "";
126+
options.generateScopedName = (name, filename) =>
127+
(globalPrefix ? `${globalPrefix}__` : "") + `${path.basename(filename).split(".")[0]}__${name}`;
128+
}
129+
124130
const cssPlugin: (options?: CSSPluginOptions) => Plugin = (options = {}) => ({
125131
name: "esbuild-plugin-react18-css-" + uuid(),
126132
setup(build): void {
127133
const write = build.initialOptions.write;
128134
build.initialOptions.write = false;
129-
if (!options.generateScopedName) {
130-
const globalPrefix = options.globalPrefix ?? "";
131-
options.generateScopedName = (name, filename) =>
132-
(globalPrefix ? `${globalPrefix}__` : "") +
133-
`${path.basename(filename).split(".")[0]}__${name}`;
134-
}
135+
if (!options.generateScopedName) resolveScopedName(options);
135136
handleModules(build, options);
136137
handleScss(build);
137138
applyAutoPrefixer(build, options, write);

0 commit comments

Comments
 (0)