diff --git a/dist/biscuitman.js b/dist/biscuitman.js
index 67bdff3..b5763b6 100644
--- a/dist/biscuitman.js
+++ b/dist/biscuitman.js
@@ -171,7 +171,7 @@
function clearStorages() {
const localStores = Object1.fromEntries(Object1.entries(localStorage));
const cookies = Object1.fromEntries(d.cookie.split('; ').map((cookie)=>cookie.split('=')));
- // eslint-disable-next-line no-unused-vars
+
const { consentTime, ...consents } = loadConsents() || options.sections.slice(1).reduce((consents, section)=>{
consents[section] = false;
return {
diff --git a/dist/biscuitman.withcss.js b/dist/biscuitman.withcss.js
index a132a9c..eddb2dd 100644
--- a/dist/biscuitman.withcss.js
+++ b/dist/biscuitman.withcss.js
@@ -171,7 +171,7 @@
function clearStorages() {
const localStores = Object1.fromEntries(Object1.entries(localStorage));
const cookies = Object1.fromEntries(d.cookie.split('; ').map((cookie)=>cookie.split('=')));
- // eslint-disable-next-line no-unused-vars
+
const { consentTime, ...consents } = loadConsents() || options.sections.slice(1).reduce((consents, section)=>{
consents[section] = false;
return {
diff --git a/eslint.config.js b/eslint.config.js
index 27fc283..e191df1 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -15,7 +15,8 @@ export default [
rules: {
...pluginJs.configs.recommended.rules,
semi: [2,'never'],
- quotes: [2,'single']
+ quotes: [2,'single'],
+ 'object-curly-spacing': [2, 'always']
},
},
{
diff --git a/run.js b/run.js
index c9a810b..ae3cbd8 100644
--- a/run.js
+++ b/run.js
@@ -1,6 +1,6 @@
import fs from 'fs'
import swc from '@swc/core'
-import { transform as transformCss, browserslistToTargets, Features} from 'lightningcss'
+import { transform as transformCss, browserslistToTargets, Features } from 'lightningcss'
import browserslist from 'browserslist'
import browserSync from 'browser-sync'
import { Readable } from 'stream'
@@ -58,6 +58,7 @@ export async function scripts(skipFileSave) {
minify: false
})
.then(async ({ code }) => {
+ code = code.replace(/(\/\* eslint-disable.*?\*\/)|(\/\/ eslint-disable-.*?$)/gm,'') // strip eslint comments
if (!skipFileSave) await writeFile(`dist/${filenames.js}`, `${comment}\n` + code)
log('js',`Saved dist/${filenames.js}`)
return code
@@ -99,6 +100,7 @@ ${js[0]};
css.textContent=\`${css[0]}\`;
d.head.appendChild(css)
})(document);`
+ jsCss = jsCss.replace(/(\/\* eslint-disable.*?\*\/)|(\/\/ eslint-disable-.*?$)/gm,'') // strip eslint comments
let jsCssMin = `${comment}${js[1].replace(/[\n\t]/g, '')};((d)=>{let c=d.createElement('style');c.textContent=\`${css[1]}\`;d.head.appendChild(c)})(document);`
await Promise.all([
@@ -165,7 +167,7 @@ export async function report() {
cssReportData.push(usageInfo)
})
.on('end', async () => {
- await writeFile('cssreport.json', JSON.stringify({report: cssReportData}))
+ await writeFile('cssreport.json', JSON.stringify({ report: cssReportData }))
log('report: css','Saved cssreport.json (see compatibility table on index.html')
})
}
diff --git a/src/biscuitman.js b/src/biscuitman.js
index 1e8580c..cbd89f9 100644
--- a/src/biscuitman.js
+++ b/src/biscuitman.js
@@ -40,7 +40,7 @@
// uncategorizedTitle: 'Uncategorized',
// uncategorizedMessage: 'Uncategorized cookies are those currently under analysis and have not yet been assigned to a specific category',
}
- const options = {...defaults, ...w.biscuitman}
+ const options = { ...defaults, ...w.biscuitman }
// UI & Events:
@@ -134,7 +134,7 @@
function buttonHandler(e) {
let id = e.target.dataset.id
- dispatch('button', {id})
+ dispatch('button', { id })
switch (id) {
case 'accept': saveConsents(true); break
case 'close': dialog.close(); break
@@ -179,7 +179,7 @@
function checkConsents(oldConsents, newConsents) {
for (const sectionName in oldConsents)
if (oldConsents[sectionName] && newConsents[sectionName] === false)
- dispatch('revoke', {section: sectionName})
+ dispatch('revoke', { section: sectionName })
}
function loadConsents() {
@@ -210,7 +210,7 @@
sectionCookieNames
.filter(name => name.endsWith('*'))
.map(wildcardName => {
- Object.keys({...cookies, ...localStores}).map(name => {
+ Object.keys({ ...cookies, ...localStores }).map(name => {
if (name.startsWith(wildcardName.slice(0, -1))) sectionCookieNames.push(name)
})
})
@@ -221,11 +221,11 @@
d.cookie = expiredCookie
d.cookie = `${expiredCookie}domain=${location.hostname};` // Safari iOS
d.cookie = `${expiredCookie}domain=.${location.hostname};` // Safari iOS
- dispatch('delete',{cookie : name})
+ dispatch('delete',{ cookie : name })
}
if (localStores[name]) {
localStorage.removeItem(name)
- dispatch('delete',{localStorage : name})
+ dispatch('delete',{ localStorage : name })
}
}
}
@@ -248,7 +248,7 @@
checkConsents(getConsents(),consents)
setConsents(consents)
localStorage.setItem(options.key, JSON.stringify(consents))
- dispatch('save', {data: consents})
+ dispatch('save', { data: consents })
clearStorages()
insertScripts()
dialog.close()
@@ -268,7 +268,7 @@
newScript.setAttribute('type', script.dataset.type || 'text/javascript')
if (!script.src) newScript.textContent = script.textContent
script.parentNode.replaceChild(newScript, script)
- dispatch('inject', {el: script, ...(script.id && {id: script.id})})
+ dispatch('inject', { el: script, ...(script.id && { id: script.id }) })
// If tag has src AND tag content, inject new tag adjacent to parent after load
if (script.src && script.textContent.trim() !== '') newScript.addEventListener('load', () => {
@@ -276,7 +276,7 @@
afterScript.textContent = script.textContent
if (script.id) afterScript.id = script.id + '-after'
newScript.insertAdjacentElement('afterend', afterScript)
- dispatch('inject', {el: afterScript, parent: script, ...(afterScript.id && {id: afterScript.id})})
+ dispatch('inject', { el: afterScript, parent: script, ...(afterScript.id && { id: afterScript.id }) })
})
})
}
@@ -308,7 +308,7 @@
// Helper methods
// Delete Consent Preferences
w.bmInvalidate = () => {
- dispatch('invalidate', {data: getConsents()})
+ dispatch('invalidate', { data: getConsents() })
checkConsents({})
saveConsents(false)
setConsents({})
@@ -317,7 +317,7 @@
}
// Update Consent Preferences
w.bmUpdate = () => {
- dispatch('update', {data: getConsents()})
+ dispatch('update', { data: getConsents() })
openModal()
}
})(document, window, Object, document.documentElement, 'biscuitman')