Skip to content

Commit

Permalink
run prettier again locallay, and add it to pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 25, 2024
1 parent 941a730 commit 7c8e182
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/husky.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ jobs:
node-version: 16
- name: install dependencies
run: pnpm install
- run: pnpm exec prettier --write .
- run: pnpm exec prettier -c .
- run: pnpm exec eslint .
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
node_modules
coverage
pnpm-lock.yaml
nuxt.config.js
14 changes: 7 additions & 7 deletions components/FeedbackBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ export default {
email: "",
emailRules: [
(v) => !!v || this.$t("email"),
(v) => /.+@.+\..+/.test(v) || this.$t("email")
(v) => /.+@.+\..+/.test(v) || this.$t("email"),
],
text: "",
starValue: 0,
starRules: [(v) => !!v || this.$t("rating")],
select: null,
dialog: false,
message: null
message: null,
};
},
Expand All @@ -144,10 +144,10 @@ export default {
text: this.text,
rating: this.starValue,
locale: this.$i18n.locale,
email: this.email
email: this.email,
},
created: this.$fireModule.firestore.FieldValue.serverTimestamp()
}
created: this.$fireModule.firestore.FieldValue.serverTimestamp(),
},
};
this.$fire.firestore
.collection("mail")
Expand All @@ -157,8 +157,8 @@ export default {
this.message = this.$t("messageReceived");
});
}
}
}
},
},
};
</script>
<style scoped>
Expand Down
62 changes: 31 additions & 31 deletions components/charts/WordCloud.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
<template>
<div>
<div ref="chartdiv"></div>
<v-row data-html2canvas-ignore
remove-height-in-html2-canvas>
<v-row data-html2canvas-ignore remove-height-in-html2-canvas>
<v-text-field
v-model="additionalExcludes"
:label='$t("excludeWords")'
:hint='$t("excludeWordsHint")'
:label="$t('excludeWords')"
:hint="$t('excludeWordsHint')"
clearable
@keydown.enter.prevent="updateGraph"
@click:clear="updateGraph"
></v-text-field>
<v-btn class="btn-color"
dark
@click="updateGraph">
<v-btn class="btn-color" dark @click="updateGraph">
<v-icon>mdi-arrow-right</v-icon>
</v-btn>
</v-row>

</div>
</template>

Expand All @@ -32,35 +28,35 @@ export default {
chartdata: new Chat(),
minWordLength: {
type: Number,
default: 3
default: 3,
},
minFontSize: {
type: Number,
default: 6
default: 6,
},
randomness: {
type: Number,
default: 0.1
default: 0.1,
},
stopWords: {
type: Array,
default: () => stopwords
}
default: () => stopwords,
},
},
data() {
return {
chart: null,
series: null,
additionalExcludes: ""
additionalExcludes: "",
};
},
watch: {
chartdata: {
handler() {
this.updateGraph();
},
deep: true
}
deep: true,
},
},
mounted() {
let { am4core, am4themes_animated, am4plugins_wordCloud } = this.$am4core();
Expand All @@ -80,57 +76,61 @@ export default {
this.series.accuracy = 5;
this.updateGraph();
},
beforeDestroy: function() {
beforeDestroy: function () {
this.chart.dispose();
},
methods: {
async updateGraph() {
// this is a list of [{word: String, freq: String}, ...]
const allWords = await this.chartdata.getAllWords();
if(!this.additionalExcludes){
this.series.data = allWords
return
if (!this.additionalExcludes) {
this.series.data = allWords;
return;
}
const regex = this.buildRegex()
const regex = this.buildRegex();
//remove everything from all words, that matches
this.series.data = allWords.filter(item => !regex.test(item.word));
this.series.data = allWords.filter((item) => !regex.test(item.word));
},
buildRegex() {
// Regex to detect if a string contains regex metacharacters
const regexMetaChars = /[.*+?^${}()|[\]\\]/;
function isValidRegex(pattern) {
if( regexMetaChars.test(pattern)) {
if (regexMetaChars.test(pattern)) {
try {
new RegExp(pattern);
return true;
} catch (e) {
return false;
}
}
else{
return false
} else {
return false;
}
}
// Function to escape regex special characters if the string is intended to be a literal
function escapeRegexCharacters(string) {
// Escape only if the string does not contain regex metacharacters
// otherwise it needs to be an exact match
return isValidRegex(string) ? string : `^${string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`;
return isValidRegex(string)
? string
: `^${string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`;
}
// Filter out empty strings and escape regex special characters if needed
const regexParts = this.additionalExcludes.split(" ").filter(s => s !== '').map(escapeRegexCharacters);
const regexParts = this.additionalExcludes
.split(" ")
.filter((s) => s !== "")
.map(escapeRegexCharacters);
// Join the parts to create a single regex pattern
const regexPattern = regexParts.join('|');
const regexPattern = regexParts.join("|");
return new RegExp(regexPattern);
}
}
},
},
};
</script>

Expand Down
3 changes: 2 additions & 1 deletion utils/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ export const messages = {
lookingFor: "Looking for",
pdfDownload: "PDF download",
excludeWords: "Exclude Words",
excludeWordsHint: "Should be space separated list. RegEx is also supported."
excludeWordsHint:
"Should be space separated list. RegEx is also supported.",
},
de: {
titleGoogle: "WhatsAnalyze - The WhatsApp Chat Analyzer",
Expand Down

0 comments on commit 7c8e182

Please sign in to comment.