Skip to content

Commit

Permalink
chore: Fix eslint failures in CI (meltano#6815)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillDaSilva committed Oct 4, 2022
1 parent 640634b commit d121d7f
Show file tree
Hide file tree
Showing 84 changed files with 2,212 additions and 1,548 deletions.
22 changes: 13 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ repos:
- id: debug-statements

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.14.0
rev: v8.24.0 # Keep this in sync with the eslint "additional_dependency" below!
hooks:
- id: eslint
files: ".(js|vue)"
files: \.([jt]sx?|vue)$
entry: bash -c 'cd src/webapp && ARGS=("$@") && eslint --fix --config=.eslintrc.js "../../$0" "${ARGS[@]/#/../../}"'
types: [file]
require_serial: true
additional_dependencies:
- "@vue/eslint-config-prettier@^4.0.1"
- babel-eslint@^10.0.1
- eslint-config-prettier@^3.3.0
- eslint-plugin-prettier@^3.1.0
- eslint-plugin-vue@^5.0.0
- eslint@^5.16.0
- prettier@^1.15.2
- "@vue/eslint-config-prettier@7.0.0"
- "@vue/babel-preset-app@5.0.8"
- "@babel/eslint-parser@7.19.1"
- "eslint@8.24.0" # Keep this in sync with the rev above!
- "eslint-config-prettier@8.5.0"
- "eslint-plugin-prettier@4.2.1"
- "eslint-plugin-vue@9.5.1"
- "prettier@2.7.1"

- repo: https://github.com/psf/black
rev: 22.6.0
Expand Down
57 changes: 31 additions & 26 deletions docs/js/tabs.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
const removeActiveClasses = function (ulElement) {
const lis = ulElement.querySelectorAll('li');
Array.prototype.forEach.call(lis, function(li) {
li.classList.remove('active');
});
}

const getChildPosition = function (element) {
var parent = element.parentNode;
var i = 0;
for (var i = 0; i < parent.children.length; i++) {
if (parent.children[i] === element) {
return i;
}
}
const lis = ulElement.querySelectorAll('li');
Array.prototype.forEach.call(lis, function (li) {
li.classList.remove('active');
});
};

throw new Error('No parent found');
const getChildPosition = function (element) {
let parent = element.parentNode;
for (let i = 0; i < parent.children.length; i++) {
if (parent.children[i] === element) {
return i;
}
}

throw new Error('No parent found');
};

window.addEventListener('load', function () {
const tabLinks = document.querySelectorAll('ul.tab li a');
const tabLinks = document.querySelectorAll('ul.tab li a');

Array.prototype.forEach.call(tabLinks, function(link) {
link.addEventListener('click', function (event) {
Array.prototype.forEach.call(tabLinks, function (link) {
link.addEventListener(
'click',
function (event) {
event.preventDefault();

liTab = link.parentNode;
ulTab = liTab.parentNode;
position = getChildPosition(liTab);
let liTab = link.parentNode;
let ulTab = liTab.parentNode;
let position = getChildPosition(liTab);
if (liTab.className.includes('active')) {
return;
}

removeActiveClasses(ulTab);
tabContentId = ulTab.getAttribute('data-tab');
tabContentElement = document.getElementById(tabContentId);
let tabContentId = ulTab.getAttribute('data-tab');
let tabContentElement = document.getElementById(tabContentId);
removeActiveClasses(tabContentElement);

tabContentElement.querySelectorAll('li')[position].classList.add('active');
tabContentElement
.querySelectorAll('li')
[position].classList.add('active');
liTab.classList.add('active');
}, false);
});
},
false
);
});
});
216 changes: 107 additions & 109 deletions docs/js/termy_custom.js
Original file line number Diff line number Diff line change
@@ -1,121 +1,119 @@
document.querySelectorAll(".use-termynal").forEach(node => {
node.style.display = "block";
new Termynal(node, {
lineDelay: 500
});
document.querySelectorAll('.use-termynal').forEach((node) => {
node.style.display = 'block';
// eslint-disable-next-line no-undef
new Termynal(node, {
lineDelay: 500,
});
});
const progressLiteralStart = "---> 100%";
const promptLiteralStart = "$ ";
const customPromptLiteralStart = "# ";
const termynalActivateClass = "termy";
const codeThingy = "```"
const waitStart = "<---"
const progressLiteralStart = '---> 100%';
const promptLiteralStart = '$ ';
const customPromptLiteralStart = '# ';
const termynalActivateClass = 'termy';
const codeThingy = '```';
const waitStart = '<---';

let termynals = [];

function createTermynals() {
document
.querySelectorAll(`.${termynalActivateClass}`)
.forEach(node => {
const text = node.textContent;
const lines = text.split("\n");
const useLines = [];
let buffer = [];
function saveBuffer() {
if (buffer.length) {
let isBlankSpace = true;
buffer.forEach(line => {
if (line) {
isBlankSpace = false;
}
});
dataValue = {};
if (isBlankSpace) {
dataValue["delay"] = 0;
}
if (buffer[buffer.length - 1] === "") {
// A last single <br> won't have effect
// so put an additional one
buffer.push("");
}
const bufferValue = buffer.join("<br>");
dataValue["value"] = bufferValue;
useLines.push(dataValue);
buffer = [];
}
}
for (let line of lines) {
if (line === progressLiteralStart) {
saveBuffer();
useLines.push({
type: "progress"
});
} else if (line.startsWith(promptLiteralStart)) {
saveBuffer();
const value = line.replace(promptLiteralStart, "").trimEnd();
useLines.push({
type: "input",
value: value
});
} else if (line.startsWith("// ")) {
saveBuffer();
const value = "💬 " + line.replace("// ", "").trimEnd();
useLines.push({
value: value,
class: "termynal-comment",
delay: 0
});

} else if (line == waitStart) {
saveBuffer();
useLines.push({
type: "wait",
delay: 1,
value: "<br />"

});

} else if (line.startsWith(customPromptLiteralStart)) {
saveBuffer();
const promptStart = line.indexOf(promptLiteralStart);
if (promptStart === -1) {
console.error("Custom prompt found but no end delimiter", line)
}
const prompt = line.slice(0, promptStart).replace(customPromptLiteralStart, "")
let value = line.slice(promptStart + promptLiteralStart.length);
useLines.push({
type: "input",
value: value,
prompt: prompt
});
} else if (line.startsWith(codeThingy)) {
saveBuffer();
}
else {
buffer.push(line);
}
}
saveBuffer();
const div = document.createElement("div");
node.replaceWith(div);
const termynal = new Termynal(div, {
lineData: useLines,
noInit: true,
lineDelay: 500
});
termynals.push(termynal);
document.querySelectorAll(`.${termynalActivateClass}`).forEach((node) => {
const text = node.textContent;
const lines = text.split('\n');
const useLines = [];
let buffer = [];
function saveBuffer() {
if (buffer.length) {
let isBlankSpace = true;
buffer.forEach((line) => {
if (line) {
isBlankSpace = false;
}
});
let dataValue = {};
if (isBlankSpace) {
dataValue['delay'] = 0;
}
if (buffer[buffer.length - 1] === '') {
// A last single <br> won't have effect
// so put an additional one
buffer.push('');
}
const bufferValue = buffer.join('<br>');
dataValue['value'] = bufferValue;
useLines.push(dataValue);
buffer = [];
}
}
for (let line of lines) {
if (line === progressLiteralStart) {
saveBuffer();
useLines.push({
type: 'progress',
});
} else if (line.startsWith(promptLiteralStart)) {
saveBuffer();
const value = line.replace(promptLiteralStart, '').trimEnd();
useLines.push({
type: 'input',
value: value,
});
} else if (line.startsWith('// ')) {
saveBuffer();
const value = '💬 ' + line.replace('// ', '').trimEnd();
useLines.push({
value: value,
class: 'termynal-comment',
delay: 0,
});
} else if (line == waitStart) {
saveBuffer();
useLines.push({
type: 'wait',
delay: 1,
value: '<br />',
});
} else if (line.startsWith(customPromptLiteralStart)) {
saveBuffer();
const promptStart = line.indexOf(promptLiteralStart);
if (promptStart === -1) {
console.error('Custom prompt found but no end delimiter', line);
}
const prompt = line
.slice(0, promptStart)
.replace(customPromptLiteralStart, '');
let value = line.slice(promptStart + promptLiteralStart.length);
useLines.push({
type: 'input',
value: value,
prompt: prompt,
});
} else if (line.startsWith(codeThingy)) {
saveBuffer();
} else {
buffer.push(line);
}
}
saveBuffer();
const div = document.createElement('div');
node.replaceWith(div);
// eslint-disable-next-line no-undef
const termynal = new Termynal(div, {
lineData: useLines,
noInit: true,
lineDelay: 500,
});
termynals.push(termynal);
});
}

function loadVisibleTermynals() {
termynals = termynals.filter(termynal => {
if (termynal.container.getBoundingClientRect().top - innerHeight <= 0) {
termynal.init();
return false;
}
return true;
});
termynals = termynals.filter((termynal) => {
if (termynal.container.getBoundingClientRect().top - innerHeight <= 0) {
termynal.init();
return false;
}
return true;
});
}
window.addEventListener("scroll", loadVisibleTermynals);
window.addEventListener('scroll', loadVisibleTermynals);
createTermynals();
loadVisibleTermynals();

0 comments on commit d121d7f

Please sign in to comment.