Skip to content

Commit e75bc16

Browse files
authored
Merge pull request #368 from Flo0807/format-js-files
Format JS files
2 parents 3dfe255 + 86cb40e commit e75bc16

File tree

7 files changed

+4112
-243
lines changed

7 files changed

+4112
-243
lines changed

.github/workflows/ci.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ jobs:
3333
version-file: .tool-versions
3434
version-type: strict
3535

36+
- uses: actions/setup-node@v4
37+
with:
38+
cache: 'npm'
39+
cache-dependency-path: './assets/package-lock.json'
40+
node-version: 20
41+
42+
- name: Install npm dependencies
43+
run: npm ci
44+
working-directory: ./assets
45+
3646
- name: Restore the deps and _build cache
3747
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
3848
id: restore-cache
@@ -57,9 +67,13 @@ jobs:
5767
- name: Compile
5868
run: mix compile --warnings-as-errors --force
5969

60-
- name: Check Formatting
70+
- name: Check Formatting (Elixir)
6171
run: mix format --check-formatted
6272

73+
- name: Check Formatting (JS)
74+
run: npm run lint:standard
75+
working-directory: ./assets
76+
6377
- name: Gettext
6478
run: mix gettext.extract --check-up-to-date
6579

assets/js/app.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616
//
1717

1818
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
19-
import "phoenix_html"
19+
import 'phoenix_html'
2020
// Establish Phoenix Socket and LiveView configuration.
21-
import { Socket } from "phoenix"
22-
import { LiveSocket } from "phoenix_live_view"
23-
import topbar from "topbar"
21+
import { Socket } from 'phoenix'
22+
import { LiveSocket } from 'phoenix_live_view'
23+
import topbar from 'topbar'
2424
import Alpine from 'alpinejs'
2525
import { themeChange } from 'theme-change'
26-
import * as Hooks from "./hooks/index"
26+
import * as Hooks from './hooks/index'
2727

2828
window.Alpine = Alpine
2929
Alpine.start()
3030

3131
themeChange()
3232

33-
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
34-
let liveSocket = new LiveSocket("/live", Socket, {
33+
const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute('content')
34+
const liveSocket = new LiveSocket('/live', Socket, {
3535
longPollFallbackMs: 2500,
3636
params: { _csrf_token: csrfToken },
3737
dom: {
38-
onBeforeElUpdated(from, to) {
38+
onBeforeElUpdated (from, to) {
3939
if (from._x_dataStack) {
4040
window.Alpine.clone(from, to)
4141
}
@@ -45,9 +45,9 @@ let liveSocket = new LiveSocket("/live", Socket, {
4545
})
4646

4747
// Show progress bar on live navigation and form submits
48-
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" })
49-
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
50-
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
48+
topbar.config({ barColors: { 0: '#29d' }, shadowColor: 'rgba(0, 0, 0, .3)' })
49+
window.addEventListener('phx:page-loading-start', _info => topbar.show(300))
50+
window.addEventListener('phx:page-loading-stop', _info => topbar.hide())
5151

5252
// Fix for mobile devices app height
5353
const appHeight = () => {
@@ -65,4 +65,3 @@ liveSocket.connect()
6565
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
6666
// >> liveSocket.disableLatencySim()
6767
window.liveSocket = liveSocket
68-

assets/js/hooks/dynamicTextArea.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
export default {
2-
mounted() {
3-
this.resize();
2+
mounted () {
3+
this.resize()
44

5-
this.el.addEventListener('input', this.resize.bind(this));
6-
this.el.addEventListener('change', this.resize.bind(this));
5+
this.el.addEventListener('input', this.resize.bind(this))
6+
this.el.addEventListener('change', this.resize.bind(this))
77
},
8-
updated() {
9-
this.resize();
8+
updated () {
9+
this.resize()
1010
},
11-
beforeDestroy() {
12-
this.el.removeEventListener('input', this.resize.bind(this));
13-
this.el.removeEventListener('change', this.resize.bind(this));
11+
beforeDestroy () {
12+
this.el.removeEventListener('input', this.resize.bind(this))
13+
this.el.removeEventListener('change', this.resize.bind(this))
1414
},
15-
resize() {
16-
this.el.style.height = '0';
15+
resize () {
16+
this.el.style.height = '0'
1717

1818
// Add 2px to prevent scrollbar
19-
const contentHeight = this.el.scrollHeight + 2;
19+
const contentHeight = this.el.scrollHeight + 2
2020

21-
const minHeight = parseInt(this.el.dataset.minHeight || 40, 10);
22-
const finalHeight = Math.max(contentHeight, minHeight);
21+
const minHeight = parseInt(this.el.dataset.minHeight || 40, 10)
22+
const finalHeight = Math.max(contentHeight, minHeight)
2323

24-
this.el.style.height = `${finalHeight}px`;
24+
this.el.style.height = `${finalHeight}px`
2525
}
26-
};
26+
}

assets/js/hooks/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as DynamicTextArea } from './dynamicTextArea';
1+
export { default as DynamicTextArea } from './dynamicTextArea'

0 commit comments

Comments
 (0)