Skip to content

Commit da3ae3b

Browse files
committed
ESLINT: Addressed remaining detected issues
1 parent 0519e58 commit da3ae3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+524
-453
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@codemirror/state": "^6.2.0",
4343
"@codemirror/theme-one-dark": "^6.1.1",
4444
"@codemirror/view": "^6.9.4",
45+
"@lezer/highlight": "^1.1.4",
4546
"@ssddanbrown/codemirror-lang-smarty": "^1.0.0",
4647
"@ssddanbrown/codemirror-lang-twig": "^1.0.0",
4748
"codemirror": "^6.0.1",
@@ -58,48 +59,77 @@
5859
"es2021": true
5960
},
6061
"extends": "airbnb-base",
61-
"ignorePatterns": ["resources/**/*-stub.js"],
62-
"overrides": [
62+
"ignorePatterns": [
63+
"resources/**/*-stub.js"
6364
],
65+
"overrides": [],
6466
"parserOptions": {
6567
"ecmaVersion": "latest",
6668
"sourceType": "module"
6769
},
6870
"rules": {
69-
"indent": ["error", 4],
70-
"arrow-parens": ["error", "as-needed"],
71-
"padded-blocks": ["error", {
71+
"indent": [
72+
"error",
73+
4
74+
],
75+
"arrow-parens": [
76+
"error",
77+
"as-needed"
78+
],
79+
"padded-blocks": [
80+
"error",
81+
{
7282
"blocks": "never",
7383
"classes": "always"
74-
}],
75-
"object-curly-spacing": ["error", "never"],
76-
"space-before-function-paren": ["error", {
77-
"anonymous": "never",
78-
"named": "never",
79-
"asyncArrow": "always"
80-
}],
84+
}
85+
],
86+
"object-curly-spacing": [
87+
"error",
88+
"never"
89+
],
90+
"space-before-function-paren": [
91+
"error",
92+
{
93+
"anonymous": "never",
94+
"named": "never",
95+
"asyncArrow": "always"
96+
}
97+
],
8198
"import/prefer-default-export": "off",
82-
"no-plusplus": ["error", {
83-
"allowForLoopAfterthoughts": true
84-
}],
99+
"no-plusplus": [
100+
"error",
101+
{
102+
"allowForLoopAfterthoughts": true
103+
}
104+
],
85105
"arrow-body-style": "off",
86106
"no-restricted-syntax": "off",
87107
"no-continue": "off",
88-
"no-console": ["warn", {
89-
"allow": ["error"]
90-
}],
91-
"max-len": ["error", {
92-
"code": 110,
93-
"tabWidth": 4,
94-
"ignoreUrls": true,
95-
"ignoreComments": false,
96-
"ignoreRegExpLiterals": true,
97-
"ignoreStrings": true,
98-
"ignoreTemplateLiterals": true
99-
}],
100-
"no-param-reassign": ["error", {
101-
"props": false
102-
}]
108+
"prefer-destructuring": "off",
109+
"class-methods-use-this": "off",
110+
"no-param-reassign": "off",
111+
"no-console": [
112+
"warn",
113+
{
114+
"allow": [
115+
"error",
116+
"warn"
117+
]
118+
}
119+
],
120+
"no-new": "off",
121+
"max-len": [
122+
"error",
123+
{
124+
"code": 110,
125+
"tabWidth": 4,
126+
"ignoreUrls": true,
127+
"ignoreComments": false,
128+
"ignoreRegExpLiterals": true,
129+
"ignoreStrings": true,
130+
"ignoreTemplateLiterals": true
131+
}
132+
]
103133
}
104134
}
105135
}

resources/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import events from './services/events';
1+
import * as events from './services/events';
22
import * as httpInstance from './services/http';
33
import Translations from './services/translations';
44

resources/js/code/index.mjs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,36 @@ import {createView} from './views';
66
import {SimpleEditorInterface} from './simple-editor-interface';
77

88
/**
9-
* Highlight pre elements on a page
9+
* Add a button to a CodeMirror instance which copies the contents to the clipboard upon click.
10+
* @param {EditorView} editorView
1011
*/
11-
export function highlight() {
12-
const codeBlocks = document.querySelectorAll('.page-content pre, .comment-box .content pre');
13-
for (const codeBlock of codeBlocks) {
14-
highlightElem(codeBlock);
15-
}
16-
}
12+
function addCopyIcon(editorView) {
13+
const copyIcon = '<svg viewBox="0 0 24 24" width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>';
14+
const checkIcon = '<svg viewBox="0 0 24 24" width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>';
15+
const copyButton = document.createElement('button');
16+
copyButton.setAttribute('type', 'button');
17+
copyButton.classList.add('cm-copy-button');
18+
copyButton.innerHTML = copyIcon;
19+
editorView.dom.appendChild(copyButton);
1720

18-
/**
19-
* Highlight all code blocks within the given parent element
20-
* @param {HTMLElement} parent
21-
*/
22-
export function highlightWithin(parent) {
23-
const codeBlocks = parent.querySelectorAll('pre');
24-
for (const codeBlock of codeBlocks) {
25-
highlightElem(codeBlock);
26-
}
21+
const notifyTime = 620;
22+
const transitionTime = 60;
23+
copyButton.addEventListener('click', () => {
24+
copyTextToClipboard(editorView.state.doc.toString());
25+
copyButton.classList.add('success');
26+
27+
setTimeout(() => {
28+
copyButton.innerHTML = checkIcon;
29+
}, transitionTime / 2);
30+
31+
setTimeout(() => {
32+
copyButton.classList.remove('success');
33+
}, notifyTime);
34+
35+
setTimeout(() => {
36+
copyButton.innerHTML = copyIcon;
37+
}, notifyTime + (transitionTime / 2));
38+
});
2739
}
2840

2941
/**
@@ -32,7 +44,7 @@ export function highlightWithin(parent) {
3244
*/
3345
function highlightElem(elem) {
3446
const innerCodeElem = elem.querySelector('code[class^=language-]');
35-
elem.innerHTML = elem.innerHTML.replace(/<br\s*[\/]?>/gi, '\n');
47+
elem.innerHTML = elem.innerHTML.replace(/<br\s*\/?>/gi, '\n');
3648
const content = elem.textContent.trimEnd();
3749

3850
let langName = '';
@@ -57,36 +69,24 @@ function highlightElem(elem) {
5769
}
5870

5971
/**
60-
* Add a button to a CodeMirror instance which copies the contents to the clipboard upon click.
61-
* @param {EditorView} editorView
72+
* Highlight all code blocks within the given parent element
73+
* @param {HTMLElement} parent
6274
*/
63-
function addCopyIcon(editorView) {
64-
const copyIcon = '<svg viewBox="0 0 24 24" width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>';
65-
const checkIcon = '<svg viewBox="0 0 24 24" width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>';
66-
const copyButton = document.createElement('button');
67-
copyButton.setAttribute('type', 'button');
68-
copyButton.classList.add('cm-copy-button');
69-
copyButton.innerHTML = copyIcon;
70-
editorView.dom.appendChild(copyButton);
71-
72-
const notifyTime = 620;
73-
const transitionTime = 60;
74-
copyButton.addEventListener('click', event => {
75-
copyTextToClipboard(editorView.state.doc.toString());
76-
copyButton.classList.add('success');
77-
78-
setTimeout(() => {
79-
copyButton.innerHTML = checkIcon;
80-
}, transitionTime / 2);
81-
82-
setTimeout(() => {
83-
copyButton.classList.remove('success');
84-
}, notifyTime);
75+
export function highlightWithin(parent) {
76+
const codeBlocks = parent.querySelectorAll('pre');
77+
for (const codeBlock of codeBlocks) {
78+
highlightElem(codeBlock);
79+
}
80+
}
8581

86-
setTimeout(() => {
87-
copyButton.innerHTML = copyIcon;
88-
}, notifyTime + (transitionTime / 2));
89-
});
82+
/**
83+
* Highlight pre elements on a page
84+
*/
85+
export function highlight() {
86+
const codeBlocks = document.querySelectorAll('.page-content pre, .comment-box .content pre');
87+
for (const codeBlock of codeBlocks) {
88+
highlightElem(codeBlock);
89+
}
9090
}
9191

9292
/**

resources/js/components/ajax-delete-row.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class AjaxDeleteRow extends Component {
2020
window.$events.emit('success', resp.data.message);
2121
}
2222
this.row.remove();
23-
}).catch(err => {
23+
}).catch(() => {
2424
this.row.style.opacity = null;
2525
this.row.style.pointerEvents = null;
2626
});

resources/js/components/attachments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Attachments extends Component {
2727
this.startEdit(event.detail.id);
2828
});
2929

30-
this.container.addEventListener('event-emit-select-edit-back', event => {
30+
this.container.addEventListener('event-emit-select-edit-back', () => {
3131
this.stopEdit();
3232
});
3333

resources/js/components/auto-suggest.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class AutoSuggest extends Component {
2525
setupListeners() {
2626
const navHandler = new KeyboardNavigationHandler(
2727
this.list,
28-
event => {
28+
() => {
2929
this.input.focus();
3030
setTimeout(() => this.hideSuggestions(), 1);
3131
},
@@ -104,7 +104,8 @@ export class AutoSuggest extends Component {
104104
*/
105105
displaySuggestions(suggestions) {
106106
if (suggestions.length === 0) {
107-
return this.hideSuggestions();
107+
this.hideSuggestions();
108+
return;
108109
}
109110

110111
// This used to use <button>s but was changed to div elements since Safari would not focus on buttons

0 commit comments

Comments
 (0)