chore: lint

This commit is contained in:
sadeghbarati 2024-06-09 08:53:55 +03:30
parent 2516bd2b05
commit 15079bad87
7 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ function getHeadingsWithHierarchy(divId: string) {
const level = Number.parseInt(heading.tagName.charAt(1)) const level = Number.parseInt(heading.tagName.charAt(1))
if (!heading.id) { if (!heading.id) {
const newId = heading.textContent const newId = heading.textContent
.replaceAll(/[^a-zA-Z0-9 ]/g, '') .replaceAll(/[^a-z0-9 ]/gi, '')
.replaceAll(' ', '-') .replaceAll(' ', '-')
.toLowerCase() .toLowerCase()
heading.id = `${newId}` heading.id = `${newId}`

View File

@ -282,7 +282,7 @@ for (const baseColor of ['slate', 'gray', 'zinc', 'neutral', 'stone', 'lime']) {
for (const [key, value] of Object.entries(values)) { for (const [key, value] of Object.entries(values)) {
if (typeof value === 'string') { if (typeof value === 'string') {
const resolvedColor = value.replace( const resolvedColor = value.replace(
/{{base}}-/g, /\{\{base\}\}-/g,
`${baseColor}-`, `${baseColor}-`,
) )
base.inlineColors[mode][key] = resolvedColor base.inlineColors[mode][key] = resolvedColor

View File

@ -122,7 +122,7 @@ type NestedRecord = Record<string, unknown> | { [k: string]: NestedRecord }
* Checks if the path opted out of nested fields using `[fieldName]` syntax * Checks if the path opted out of nested fields using `[fieldName]` syntax
*/ */
export function isNotNestedPath(path: string) { export function isNotNestedPath(path: string) {
return /^\[.+\]$/i.test(path) return /^\[.+\]$/.test(path)
} }
function isObject(obj: unknown): obj is Record<string, unknown> { function isObject(obj: unknown): obj is Record<string, unknown> {
return obj !== null && !!obj && typeof obj === 'object' && !Array.isArray(obj) return obj !== null && !!obj && typeof obj === 'object' && !Array.isArray(obj)
@ -132,7 +132,7 @@ function isContainerValue(value: unknown): value is Record<string, unknown> {
} }
function cleanupNonNestedPath(path: string) { function cleanupNonNestedPath(path: string) {
if (isNotNestedPath(path)) if (isNotNestedPath(path))
return path.replace(/\[|\]/gi, '') return path.replace(/\[|\]/g, '')
return path return path
} }

View File

@ -122,7 +122,7 @@ type NestedRecord = Record<string, unknown> | { [k: string]: NestedRecord }
* Checks if the path opted out of nested fields using `[fieldName]` syntax * Checks if the path opted out of nested fields using `[fieldName]` syntax
*/ */
export function isNotNestedPath(path: string) { export function isNotNestedPath(path: string) {
return /^\[.+\]$/i.test(path) return /^\[.+\]$/.test(path)
} }
function isObject(obj: unknown): obj is Record<string, unknown> { function isObject(obj: unknown): obj is Record<string, unknown> {
return obj !== null && !!obj && typeof obj === 'object' && !Array.isArray(obj) return obj !== null && !!obj && typeof obj === 'object' && !Array.isArray(obj)
@ -132,7 +132,7 @@ function isContainerValue(value: unknown): value is Record<string, unknown> {
} }
function cleanupNonNestedPath(path: string) { function cleanupNonNestedPath(path: string) {
if (isNotNestedPath(path)) if (isNotNestedPath(path))
return path.replace(/\[|\]/gi, '') return path.replace(/\[|\]/g, '')
return path return path
} }

View File

@ -1,7 +1,7 @@
export function transformCJSToESM(filename: string, code: string) { export function transformCJSToESM(filename: string, code: string) {
if (filename.endsWith('.mjs')) { if (filename.endsWith('.mjs')) {
return code return code
.replace(/const\s([\w\d_]+)\s*=\s*require\((.*)\);?/g, 'import $1 from $2') .replace(/const\s(\w+)\s*=\s*require\((.*)\);?/g, 'import $1 from $2')
.replace(/module\.exports = /g, 'export default ') .replace(/module\.exports = /g, 'export default ')
} }
return code return code

View File

@ -40,7 +40,7 @@ export const transformCssVars: Transformer = async ({
else { else {
const s = new MagicString(value) const s = new MagicString(value)
s.replace(/'(.*?)'/g, (substring) => { s.replace(/'(.*?)'/g, (substring) => {
return `'${applyColorMapping(substring.replace(/\'/g, ''), baseColor.inlineColors)}'` return `'${applyColorMapping(substring.replace(/'/g, ''), baseColor.inlineColors)}'`
}) })
node.replaceWithText(s.toString()) node.replaceWithText(s.toString())
} }

View File

@ -39,7 +39,7 @@ export const transformTwPrefixes: Transformer = async ({
else { else {
const s = new MagicString(value) const s = new MagicString(value)
s.replace(/'(.*?)'/g, (substring) => { s.replace(/'(.*?)'/g, (substring) => {
return `'${applyPrefix(substring.replace(/\'/g, ''), config.tailwind.prefix)}'` return `'${applyPrefix(substring.replace(/'/g, ''), config.tailwind.prefix)}'`
}) })
node.replaceWithText(s.toString()) node.replaceWithText(s.toString())
} }