Skip to content

Commit

Permalink
style: update coding style to align with source code conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
dungjk committed May 27, 2024
1 parent 6abbf37 commit 1a065ee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export type SassPluginOptions = StringOptions<'sync'|'async'> & {
/**
* Use named exports alongside default export.
*/
namedExports?: NamedExport;
namedExports?: NamedExport
}

export default sassPlugin
Expand Down
8 changes: 4 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ export function sassPlugin(options: SassPluginOptions = {}): Plugin {

let exportConstants = "";
if (options.namedExports && pluginData.exports) {
const json = JSON.parse(pluginData.exports);
const json = JSON.parse(pluginData.exports)
const getClassName =
typeof options.namedExports === "function"
? options.namedExports
: ensureClassName;
: ensureClassName
Object.keys(json).forEach((name) => {
const newName = getClassName(name);
exportConstants += `export const ${newName} = ${JSON.stringify(
json[name]
)};\n`;
});
)};\n`
})
}

return {
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ export function createResolver(options: SassPluginOptions = {}, loadPaths: strin
}

const escapeClassNameDashes = (name: string) =>
name.replace(/-+/g, (match) => `$${match.replace(/-/g, "_")}$`);
name.replace(/-+/g, (match) => `$${match.replace(/-/g, "_")}$`)
export const ensureClassName = (name: string) => {
const escaped = escapeClassNameDashes(name);
return identifier(escaped);
const escaped = escapeClassNameDashes(name)
return identifier(escaped)
};
2 changes: 1 addition & 1 deletion test/fixture/named-exports/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ esbuild.build({
localsConvention: 'camelCaseOnly'
}),
namedExports: (name) => {
return `${name.replace(/-/g, "_")}`;
return `${name.replace(/-/g, "_")}`
},
})
]
Expand Down

0 comments on commit 1a065ee

Please sign in to comment.