Skip to content

Commit

Permalink
package updates, use eslint 9
Browse files Browse the repository at this point in the history
  • Loading branch information
heidkaemper committed Apr 28, 2024
1 parent c37d5c9 commit b1a163c
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 202 deletions.
153 changes: 0 additions & 153 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion dist/toolbar.js

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import js from '@eslint/js'
import globals from 'globals'
import eslintPluginSvelte from 'eslint-plugin-svelte'

export default [
js.configs.recommended,
...eslintPluginSvelte.configs['flat/recommended'],
{
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
},
},
rules: {
'comma-spacing': ['error', { 'before': false, 'after': true }],
'comma-style': ['error', 'last'],
'func-call-spacing': ['error', 'never'],
'key-spacing': ['error', { 'mode': 'minimum', 'beforeColon': false, 'afterColon': true }],
'keyword-spacing': ['error', { 'before': true, 'after': true }],
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': ['error', 'always'],
'no-console': ['warn', { 'allow': ['warn'] }],
'no-empty-function': 'error',
'no-multiple-empty-lines': ['error', { 'max': 2 }],
'no-var': 'error',
'quotes': ['error', 'single'],
'semi': ['error', 'never'],
'svelte/no-at-html-tags': 'off',
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': ['error', { 'named': 'never', 'anonymous': 'always', 'asyncArrow': 'always' }],
},
}
]
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
"lint:fix": "npx eslint resources/js/**/*.{js,svelte} --fix"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"eslint": "^8.56.0",
"eslint-plugin-svelte": "^2.35.1",
"sass": "^1.70.0",
"svelte": "^4.2.9",
"svelte-preprocess": "^5.1.3",
"vite": "^5.0.12"
"@eslint/js": "^9.1.1",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"eslint": "^9.1.1",
"eslint-plugin-svelte": "^2.38.0",
"sass": "^1.75.0",
"svelte": "^4.2.15",
"svelte-preprocess": "^5.1.4",
"vite": "^5.2.10"
}
}
34 changes: 17 additions & 17 deletions resources/js/components/Breakpoints.svelte
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
<svelte:window bind:innerWidth={windowWidth} />

<script>
import Storage from './../helper/Storage';
import Storage from './../helper/Storage'
export let breakpoints;
export let breakpoints
let windowWidth = 0;
let isButton = Object.keys(breakpoints).length >= 1;
let type = 'width';
let windowWidth = 0
let isButton = Object.keys(breakpoints).length >= 1
let type = 'width'
if (isButton) {
type = Storage.get('statamic.toolbar.breakpoints.type') ?? 'labels';
type = Storage.get('statamic.toolbar.breakpoints.type') ?? 'labels'
}
function handleClick() {
if (! isButton) {
return;
return
}
switch (type) {
case 'labels':
type = 'both';
break;
type = 'both'
break
case 'both':
type = 'width';
break;
type = 'width'
break
default:
type = 'labels';
type = 'labels'
}
Storage.set('statamic.toolbar.breakpoints.type', type);
Storage.set('statamic.toolbar.breakpoints.type', type)
}
function getMediaQueryStyles() {
let styles = '.breakpoints::before { content: "\\2014" }';
let styles = '.breakpoints::before { content: "\\2014" }'
Object.entries(breakpoints).forEach(function (breakpoint) {
styles += `@media (${breakpoint[1]}) { .breakpoints::before { content: "${breakpoint[0]}" } }`;
});
styles += `@media (${breakpoint[1]}) { .breakpoints::before { content: "${breakpoint[0]}" } }`
})
// https://github.com/sveltejs/svelte/issues/5292
return `<${''}style>${styles}</${''}style>`;
return `<${''}style>${styles}</${''}style>`
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/CpLink.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let cp_link;
export let cp_link
</script>

<a href={cp_link} target="_blank" rel="noreferrer" title="Edit this page" class="cell">
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/Site.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let site;
export let site
</script>

<div title="Site: {site}" class="cell">
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/Template.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let template;
export let template
</script>

<div title="Template: {template}" class="cell">
Expand Down
20 changes: 10 additions & 10 deletions resources/js/components/Visibility.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<script>
import { onMount } from 'svelte';
import Storage from './../helper/Storage';
import { onMount } from 'svelte'
import Storage from './../helper/Storage'
export let callback;
export let callback
let isHidden = false;
let isHidden = false
onMount(() => {
if (Storage.has('statamic.toolbar.hidden')) {
isHidden = Storage.get('statamic.toolbar.hidden');
isHidden = Storage.get('statamic.toolbar.hidden')
setTimeout(() => callback(isHidden), 500);
setTimeout(() => callback(isHidden), 500)
}
});
})
function handleClick() {
isHidden = ! isHidden;
isHidden = ! isHidden
Storage.set('statamic.toolbar.hidden', isHidden);
Storage.set('statamic.toolbar.hidden', isHidden)
callback(isHidden);
callback(isHidden)
}
</script>

Expand Down
14 changes: 7 additions & 7 deletions resources/js/helper/DebugbarObserver.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export default class {
constructor(debugbar, callback) {
this.callback = callback;
this.callback = callback

new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.attributeName === 'class') {
this.setStatus(mutation.target);
this.setStatus(mutation.target)
}
});
}).observe(debugbar, { attributes: true });
})
}).observe(debugbar, { attributes: true })

this.setStatus(debugbar);
this.setStatus(debugbar)
}

setStatus(debugbar) {
if (debugbar.classList.contains('phpdebugbar-closed')) {
return this.callback('closed');
return this.callback('closed')
}

return this.callback('minimized');
return this.callback('minimized')
}
}
8 changes: 4 additions & 4 deletions resources/js/helper/Storage.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export default {
get(key) {
return JSON.parse(localStorage.getItem(key));
return JSON.parse(localStorage.getItem(key))
},

set(key, value) {
localStorage.setItem(key, JSON.stringify(value));
localStorage.setItem(key, JSON.stringify(value))
},

has(key) {
return localStorage.getItem(key) !== null;
return localStorage.getItem(key) !== null
},
};
}

0 comments on commit b1a163c

Please sign in to comment.